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

feature/no cache localhost #3317

Merged
merged 2 commits into from
Sep 19, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Localhost based descriptions are not cached anymore to facilitate development workflows. [#3316](https://github.com/microsoft/kiota/issues/3316)

## [1.6.1] - 2023-09-11

### Changed
Expand Down
13 changes: 9 additions & 4 deletions src/Kiota.Builder/Caching/DocumentCachingProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,17 @@ private async Task<Stream> DownloadDocumentFromSourceAsync(Uri documentUri, stri
responseMessage.EnsureSuccessStatusCode();
content = new MemoryStream();
await responseMessage.Content.CopyToAsync(content, token).ConfigureAwait(false);
if (documentUri.IsLoopback)
Logger.LogInformation("skipping cache write for URI {Uri} as it is a loopback address", documentUri);
else
{
#pragma warning disable CA2007
await using var fileStream = File.Create(target);
await using var fileStream = File.Create(target);
#pragma warning restore CA2007
content.Position = 0;
await content.CopyToAsync(fileStream, token).ConfigureAwait(false);
await fileStream.FlushAsync(token).ConfigureAwait(false);
content.Position = 0;
await content.CopyToAsync(fileStream, token).ConfigureAwait(false);
await fileStream.FlushAsync(token).ConfigureAwait(false);
}
content.Position = 0;
return content;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,55 +1,46 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
// <auto-generated/>
using Kiota.Builder.SearchProviders.GitHub.GitHubClient.Repos;
using Kiota.Builder.SearchProviders.GitHub.GitHubClient.Search;
using Kiota.Builder.SearchProviders.GitHub.GitHubClient.User;
using Microsoft.Kiota.Abstractions;
using Microsoft.Kiota.Abstractions.Extensions;
using Microsoft.Kiota.Abstractions;
using Microsoft.Kiota.Serialization.Form;
using Microsoft.Kiota.Serialization.Json;
using Microsoft.Kiota.Serialization.Text;
namespace Kiota.Builder.SearchProviders.GitHub.GitHubClient
{
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System;
namespace Kiota.Builder.SearchProviders.GitHub.GitHubClient {
/// <summary>
/// The main entry point of the SDK, exposes the configuration and the fluent API.
/// </summary>
public class GitHubClient : BaseRequestBuilder
{
public class GitHubClient : BaseRequestBuilder {
/// <summary>The repos property</summary>
public ReposRequestBuilder Repos
{
get =>
public ReposRequestBuilder Repos { get =>
new ReposRequestBuilder(PathParameters, RequestAdapter);
}
/// <summary>The search property</summary>
public SearchRequestBuilder Search
{
get =>
public SearchRequestBuilder Search { get =>
new SearchRequestBuilder(PathParameters, RequestAdapter);
}
/// <summary>The user property</summary>
public UserRequestBuilder User
{
get =>
public UserRequestBuilder User { get =>
new UserRequestBuilder(PathParameters, RequestAdapter);
}
/// <summary>
/// Instantiates a new GitHubClient and sets the default values.
/// </summary>
/// <param name="requestAdapter">The request adapter to use to execute the requests.</param>
public GitHubClient(IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}", new Dictionary<string, object>())
{
public GitHubClient(IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}", new Dictionary<string, object>()) {
ApiClientBuilder.RegisterDefaultSerializer<JsonSerializationWriterFactory>();
ApiClientBuilder.RegisterDefaultSerializer<TextSerializationWriterFactory>();
ApiClientBuilder.RegisterDefaultSerializer<FormSerializationWriterFactory>();
ApiClientBuilder.RegisterDefaultDeserializer<JsonParseNodeFactory>();
ApiClientBuilder.RegisterDefaultDeserializer<TextParseNodeFactory>();
ApiClientBuilder.RegisterDefaultDeserializer<FormParseNodeFactory>();
if (string.IsNullOrEmpty(RequestAdapter.BaseUrl))
{
if (string.IsNullOrEmpty(RequestAdapter.BaseUrl)) {
RequestAdapter.BaseUrl = "https://api.github.com";
}
PathParameters.TryAdd("baseurl", RequestAdapter.BaseUrl);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,211 +1,102 @@
using System;
// <auto-generated/>
using Microsoft.Kiota.Abstractions.Serialization;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.Kiota.Abstractions.Serialization;
namespace Kiota.Builder.SearchProviders.GitHub.GitHubClient.Models
{
using System;
namespace Kiota.Builder.SearchProviders.GitHub.GitHubClient.Models {
/// <summary>
/// The permissions granted to the user access token.
/// </summary>
public class AppPermissions : IAdditionalDataHolder, IParsable
{
public class AppPermissions : IAdditionalDataHolder, IParsable {
/// <summary>The level of permission to grant the access token for GitHub Actions workflows, workflow runs, and artifacts.</summary>
public AppPermissions_actions? Actions
{
get; set;
}
public AppPermissions_actions? Actions { get; set; }
/// <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;
}
public IDictionary<string, object> AdditionalData { get; set; }
/// <summary>The level of permission to grant the access token for repository creation, deletion, settings, teams, and collaborators creation.</summary>
public AppPermissions_administration? Administration
{
get; set;
}
public AppPermissions_administration? Administration { get; set; }
/// <summary>The level of permission to grant the access token for checks on code.</summary>
public AppPermissions_checks? Checks
{
get; set;
}
public AppPermissions_checks? Checks { get; set; }
/// <summary>The level of permission to grant the access token for repository contents, commits, branches, downloads, releases, and merges.</summary>
public AppPermissions_contents? Contents
{
get; set;
}
public AppPermissions_contents? Contents { get; set; }
/// <summary>The level of permission to grant the access token for deployments and deployment statuses.</summary>
public AppPermissions_deployments? Deployments
{
get; set;
}
public AppPermissions_deployments? Deployments { get; set; }
/// <summary>The level of permission to grant the access token for managing repository environments.</summary>
public AppPermissions_environments? Environments
{
get; set;
}
public AppPermissions_environments? Environments { get; set; }
/// <summary>The level of permission to grant the access token for issues and related comments, assignees, labels, and milestones.</summary>
public AppPermissions_issues? Issues
{
get; set;
}
public AppPermissions_issues? Issues { get; set; }
/// <summary>The level of permission to grant the access token for organization teams and members.</summary>
public AppPermissions_members? Members
{
get; set;
}
public AppPermissions_members? Members { get; set; }
/// <summary>The level of permission to grant the access token to search repositories, list collaborators, and access repository metadata.</summary>
public AppPermissions_metadata? Metadata
{
get; set;
}
public AppPermissions_metadata? Metadata { get; set; }
/// <summary>The level of permission to grant the access token to manage access to an organization.</summary>
public AppPermissions_organization_administration? OrganizationAdministration
{
get; set;
}
public AppPermissions_organization_administration? OrganizationAdministration { get; set; }
/// <summary>The level of permission to grant the access token to view and manage announcement banners for an organization.</summary>
public AppPermissions_organization_announcement_banners? OrganizationAnnouncementBanners
{
get; set;
}
public AppPermissions_organization_announcement_banners? OrganizationAnnouncementBanners { get; set; }
/// <summary>The level of permission to grant the access token for custom repository roles management. This property is in beta and is subject to change.</summary>
public AppPermissions_organization_custom_roles? OrganizationCustomRoles
{
get; set;
}
public AppPermissions_organization_custom_roles? OrganizationCustomRoles { get; set; }
/// <summary>The level of permission to grant the access token to manage the post-receive hooks for an organization.</summary>
public AppPermissions_organization_hooks? OrganizationHooks
{
get; set;
}
public AppPermissions_organization_hooks? OrganizationHooks { get; set; }
/// <summary>The level of permission to grant the access token for organization packages published to GitHub Packages.</summary>
public AppPermissions_organization_packages? OrganizationPackages
{
get; set;
}
public AppPermissions_organization_packages? OrganizationPackages { get; set; }
/// <summary>The level of permission to grant the access token for viewing and managing fine-grained personal access tokens that have been approved by an organization.</summary>
public AppPermissions_organization_personal_access_token_requests? OrganizationPersonalAccessTokenRequests
{
get; set;
}
public AppPermissions_organization_personal_access_token_requests? OrganizationPersonalAccessTokenRequests { get; set; }
/// <summary>The level of permission to grant the access token for viewing and managing fine-grained personal access token requests to an organization.</summary>
public AppPermissions_organization_personal_access_tokens? OrganizationPersonalAccessTokens
{
get; set;
}
public AppPermissions_organization_personal_access_tokens? OrganizationPersonalAccessTokens { get; set; }
/// <summary>The level of permission to grant the access token for viewing an organization&apos;s plan.</summary>
public AppPermissions_organization_plan? OrganizationPlan
{
get; set;
}
public AppPermissions_organization_plan? OrganizationPlan { get; set; }
/// <summary>The level of permission to grant the access token to manage organization projects and projects beta (where available).</summary>
public AppPermissions_organization_projects? OrganizationProjects
{
get; set;
}
public AppPermissions_organization_projects? OrganizationProjects { get; set; }
/// <summary>The level of permission to grant the access token to manage organization secrets.</summary>
public AppPermissions_organization_secrets? OrganizationSecrets
{
get; set;
}
public AppPermissions_organization_secrets? OrganizationSecrets { get; 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 AppPermissions_organization_self_hosted_runners? OrganizationSelfHostedRunners
{
get; set;
}
public AppPermissions_organization_self_hosted_runners? OrganizationSelfHostedRunners { get; set; }
/// <summary>The level of permission to grant the access token to view and manage users blocked by the organization.</summary>
public AppPermissions_organization_user_blocking? OrganizationUserBlocking
{
get; set;
}
public AppPermissions_organization_user_blocking? OrganizationUserBlocking { get; set; }
/// <summary>The level of permission to grant the access token for packages published to GitHub Packages.</summary>
public AppPermissions_packages? Packages
{
get; set;
}
public AppPermissions_packages? Packages { get; 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 AppPermissions_pages? Pages
{
get; set;
}
public AppPermissions_pages? Pages { get; set; }
/// <summary>The level of permission to grant the access token for pull requests and related comments, assignees, labels, milestones, and merges.</summary>
public AppPermissions_pull_requests? PullRequests
{
get; set;
}
public AppPermissions_pull_requests? PullRequests { get; set; }
/// <summary>The level of permission to grant the access token to manage the post-receive hooks for a repository.</summary>
public AppPermissions_repository_hooks? RepositoryHooks
{
get; set;
}
public AppPermissions_repository_hooks? RepositoryHooks { get; set; }
/// <summary>The level of permission to grant the access token to manage repository projects, columns, and cards.</summary>
public AppPermissions_repository_projects? RepositoryProjects
{
get; set;
}
public AppPermissions_repository_projects? RepositoryProjects { get; set; }
/// <summary>The level of permission to grant the access token to manage repository secrets.</summary>
public AppPermissions_secrets? Secrets
{
get; set;
}
public AppPermissions_secrets? Secrets { get; set; }
/// <summary>The level of permission to grant the access token to view and manage secret scanning alerts.</summary>
public AppPermissions_secret_scanning_alerts? SecretScanningAlerts
{
get; set;
}
public AppPermissions_secret_scanning_alerts? SecretScanningAlerts { get; set; }
/// <summary>The level of permission to grant the access token to view and manage security events like code scanning alerts.</summary>
public AppPermissions_security_events? SecurityEvents
{
get; set;
}
public AppPermissions_security_events? SecurityEvents { get; set; }
/// <summary>The level of permission to grant the access token to manage just a single file.</summary>
public AppPermissions_single_file? SingleFile
{
get; set;
}
public AppPermissions_single_file? SingleFile { get; set; }
/// <summary>The level of permission to grant the access token for commit statuses.</summary>
public AppPermissions_statuses? Statuses
{
get; set;
}
public AppPermissions_statuses? Statuses { get; set; }
/// <summary>The level of permission to grant the access token to manage team discussions and related comments.</summary>
public AppPermissions_team_discussions? TeamDiscussions
{
get; set;
}
public AppPermissions_team_discussions? TeamDiscussions { get; set; }
/// <summary>The level of permission to grant the access token to manage Dependabot alerts.</summary>
public AppPermissions_vulnerability_alerts? VulnerabilityAlerts
{
get; set;
}
public AppPermissions_vulnerability_alerts? VulnerabilityAlerts { get; set; }
/// <summary>The level of permission to grant the access token to update GitHub Actions workflow files.</summary>
public AppPermissions_workflows? Workflows
{
get; set;
}
public AppPermissions_workflows? Workflows { get; set; }
/// <summary>
/// Instantiates a new appPermissions and sets the default values.
/// </summary>
public AppPermissions()
{
public AppPermissions() {
AdditionalData = new Dictionary<string, object>();
}
/// <summary>
/// Creates a new instance of the appropriate class based on discriminator value
/// </summary>
/// <param name="parseNode">The parse node to use to read the discriminator value and create the object</param>
public static AppPermissions CreateFromDiscriminatorValue(IParseNode parseNode)
{
public static AppPermissions CreateFromDiscriminatorValue(IParseNode parseNode) {
_ = parseNode ?? throw new ArgumentNullException(nameof(parseNode));
return new AppPermissions();
}
/// <summary>
/// The deserialization information for the current model
/// </summary>
public IDictionary<string, Action<IParseNode>> GetFieldDeserializers()
{
public IDictionary<string, Action<IParseNode>> GetFieldDeserializers() {
return new Dictionary<string, Action<IParseNode>> {
{"actions", n => { Actions = n.GetEnumValue<AppPermissions_actions>(); } },
{"administration", n => { Administration = n.GetEnumValue<AppPermissions_administration>(); } },
Expand Down Expand Up @@ -247,8 +138,7 @@ public IDictionary<string, Action<IParseNode>> GetFieldDeserializers()
/// Serializes information the current object
/// </summary>
/// <param name="writer">Serialization writer to use to serialize this model</param>
public void Serialize(ISerializationWriter writer)
{
public void Serialize(ISerializationWriter writer) {
_ = writer ?? throw new ArgumentNullException(nameof(writer));
writer.WriteEnumValue<AppPermissions_actions>("actions", Actions);
writer.WriteEnumValue<AppPermissions_administration>("administration", Administration);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using System;
// <auto-generated/>
using System.Runtime.Serialization;
namespace Kiota.Builder.SearchProviders.GitHub.GitHubClient.Models
{
using System;
namespace Kiota.Builder.SearchProviders.GitHub.GitHubClient.Models {
/// <summary>The level of permission to grant the access token for GitHub Actions workflows, workflow runs, and artifacts.</summary>
public enum AppPermissions_actions
{
public enum AppPermissions_actions {
[EnumMember(Value = "read")]
Read,
[EnumMember(Value = "write")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using System;
// <auto-generated/>
using System.Runtime.Serialization;
namespace Kiota.Builder.SearchProviders.GitHub.GitHubClient.Models
{
using System;
namespace Kiota.Builder.SearchProviders.GitHub.GitHubClient.Models {
/// <summary>The level of permission to grant the access token for repository creation, deletion, settings, teams, and collaborators creation.</summary>
public enum AppPermissions_administration
{
public enum AppPermissions_administration {
[EnumMember(Value = "read")]
Read,
[EnumMember(Value = "write")]
Expand Down
Loading