Skip to content

Commit

Permalink
Initial import
Browse files Browse the repository at this point in the history
  • Loading branch information
filipnavara committed May 31, 2024
0 parents commit c343511
Show file tree
Hide file tree
Showing 19 changed files with 878 additions and 0 deletions.
489 changes: 489 additions & 0 deletions .gitignore

Large diffs are not rendered by default.

31 changes: 31 additions & 0 deletions error.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
components:
schemas:
SingleError:
type: object
properties:
domain:
type: string
reason:
type: string
message:
type: string
locationType:
type: string
location:
type: string
RequestError:
type: object
properties:
errors:
type: array
items:
$ref: '#/components/schemas/SingleError'
code:
type: integer
message:
type: string
GoogleApiException:
type: object
properties:
error:
$ref: '#/components/schemas/RequestError'
5 changes: 5 additions & 0 deletions generate-calendar.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
yq eval '(del(.components.schemas.[].id) | .openapi = "3.0.0" | del(.. | select(has("annotations")).annotations)) * load("error.yaml") | .paths.[].[]?.["responses"]? += {"4XX":{"description":"Failure response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GoogleApiException"}}}}} | .paths.[].[]?.["responses"]? += {"5XX":{"description":"Failure response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GoogleApiException"}}}}}' google-discovery-to-openapi/openapi/googleapis.com/v00.00.00000/services/calendar/calendar.yaml > src/Google.Apis.Kiota.Calendar/calendar.generated.yaml
kiota generate --openapi src/Google.Apis.Kiota.Calendar/calendar.generated.yaml -o src/Google.Apis.Kiota.Calendar/Generated -l CSharp -n Google.Apis.Kiota.Calendar -c CalendarApiClient -s Microsoft.Kiota.Serialization.Json.JsonSerializationWriterFactory --ds Microsoft.Kiota.Serialization.Json.JsonParseNodeFactory
rm src/Google.Apis.Kiota.Calendar/Generated/Models/GoogleApiException.cs
rm src/Google.Apis.Kiota.Calendar/Generated/Models/RequestError.cs
rm src/Google.Apis.Kiota.Calendar/Generated/Models/SingleError.cs
5 changes: 5 additions & 0 deletions generate-drive.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
yq eval '(del(.components.schemas.[].id) | .openapi = "3.0.0" | del(.. | select(has("annotations")).annotations)) * load("error.yaml") | .paths.[].[]?.["responses"]? += {"4XX":{"description":"Failure response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GoogleApiException"}}}}} | .paths.[].[]?.["responses"]? += {"5XX":{"description":"Failure response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GoogleApiException"}}}}}' google-discovery-to-openapi/openapi/googleapis.com/v00.00.00000/services/drive/drive.yaml > src/Google.Apis.Kiota.Drive/drive.generated.yaml
kiota generate --openapi src/Google.Apis.Kiota.Drive/drive.generated.yaml -o src/Google.Apis.Kiota.Drive/Generated -l CSharp -n Google.Apis.Kiota.Drive -c DriveApiClient -s Microsoft.Kiota.Serialization.Json.JsonSerializationWriterFactory --ds Microsoft.Kiota.Serialization.Json.JsonParseNodeFactory
rm src/Google.Apis.Kiota.Drive/Generated/Models/GoogleApiException.cs
rm src/Google.Apis.Kiota.Drive/Generated/Models/RequestError.cs
rm src/Google.Apis.Kiota.Drive/Generated/Models/SingleError.cs
5 changes: 5 additions & 0 deletions generate-gmail.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
yq eval '(del(.components.schemas.[].id) | .openapi = "3.0.0" | del(.. | select(has("annotations")).annotations) | del(.. | select(has("enumDescriptions")).enumDescriptions)) * load("error.yaml") | .paths.[].[]?.["responses"]? += {"4XX":{"description":"Failure response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GoogleApiException"}}}}} | .paths.[].[]?.["responses"]? += {"5XX":{"description":"Failure response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GoogleApiException"}}}}}' google-discovery-to-openapi/openapi/googleapis.com/v00.00.00000/services/gmail/gmail.yaml > src/Google.Apis.Kiota.Gmail/gmail.generated.yaml
kiota generate --openapi src/Google.Apis.Kiota.Gmail/gmail.generated.yaml -o src/Google.Apis.Kiota.Gmail/Generated -l CSharp -n Google.Apis.Kiota.Gmail -c GmailApiClient -s Microsoft.Kiota.Serialization.Json.JsonSerializationWriterFactory --ds Microsoft.Kiota.Serialization.Json.JsonParseNodeFactory
rm src/Google.Apis.Kiota.Gmail/Generated/Models/GoogleApiException.cs
rm src/Google.Apis.Kiota.Gmail/Generated/Models/RequestError.cs
rm src/Google.Apis.Kiota.Gmail/Generated/Models/SingleError.cs
6 changes: 6 additions & 0 deletions generate-openapi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
git clone https://github.com/stackql/google-discovery-to-openapi.git
pushd google-discovery-to-openapi
npm install
chmod +x ./bin/google-discovery-to-openapi.mjs
./bin/google-discovery-to-openapi.mjs generate googleapis.com
popd
5 changes: 5 additions & 0 deletions generate-people.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
yq eval '(del(.components.schemas.[].id) | .openapi = "3.0.0" | del(.. | select(has("enumDescriptions")).enumDescriptions) | del(.. | select(has("enumDeprecated")).enumDeprecated)) * load("error.yaml") | .paths.[].[]?.["responses"]? += {"4XX":{"description":"Failure response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GoogleApiException"}}}}} | .paths.[].[]?.["responses"]? += {"5XX":{"description":"Failure response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GoogleApiException"}}}}}' google-discovery-to-openapi/openapi/googleapis.com/v00.00.00000/services/people/people.yaml > src/Google.Apis.Kiota.People/people.generated.yaml
kiota generate --openapi src/Google.Apis.Kiota.People/people.generated.yaml -o src/Google.Apis.Kiota.People/Generated -l CSharp -n Google.Apis.Kiota.People -c PeopleApiClient -s Microsoft.Kiota.Serialization.Json.JsonSerializationWriterFactory --ds Microsoft.Kiota.Serialization.Json.JsonParseNodeFactory
rm src/Google.Apis.Kiota.People/Generated/Models/GoogleApiException.cs
rm src/Google.Apis.Kiota.People/Generated/Models/RequestError.cs
rm src/Google.Apis.Kiota.People/Generated/Models/SingleError.cs
5 changes: 5 additions & 0 deletions generate-tasks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
yq eval '(del(.components.schemas.[].id) | .openapi = "3.0.0") * load("error.yaml") | .paths.[].[]?.["responses"]? += {"4XX":{"description":"Failure response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GoogleApiException"}}}}} | .paths.[].[]?.["responses"]? += {"5XX":{"description":"Failure response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GoogleApiException"}}}}}' google-discovery-to-openapi/openapi/googleapis.com/v00.00.00000/services/tasks/tasks.yaml > src/Google.Apis.Kiota.Tasks/tasks.generated.yaml
kiota generate --openapi src/Google.Apis.Kiota.Tasks/tasks.generated.yaml -o src/Google.Apis.Kiota.Tasks/Generated -l CSharp -n Google.Apis.Kiota.Tasks -c TasksApiClient -s Microsoft.Kiota.Serialization.Json.JsonSerializationWriterFactory --ds Microsoft.Kiota.Serialization.Json.JsonParseNodeFactory
rm src/Google.Apis.Kiota.Tasks/Generated/Models/GoogleApiException.cs
rm src/Google.Apis.Kiota.Tasks/Generated/Models/RequestError.cs
rm src/Google.Apis.Kiota.Tasks/Generated/Models/SingleError.cs
8 changes: 8 additions & 0 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project>
<ItemGroup>
<PackageReference Include="Nerdbank.GitVersioning" Version="3.7.62-alpha">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
12 changes: 12 additions & 0 deletions src/Google.Apis.Kiota.Calendar/Google.Apis.Kiota.Calendar.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Using Include="Google.Apis.Kiota.Models" />
<ProjectReference Include="../Google.Apis.Kiota.Core/Google.Apis.Kiota.Core.csproj" />
<PackageReference Include="Microsoft.Kiota.Abstractions" Version="1.9.4" />
<PackageReference Include="Microsoft.Kiota.Serialization.Json" Version="1.3.3" />
</ItemGroup>
</Project>
9 changes: 9 additions & 0 deletions src/Google.Apis.Kiota.Core/Google.Apis.Kiota.Core.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Kiota.Abstractions" Version="1.9.4" />
</ItemGroup>
</Project>
64 changes: 64 additions & 0 deletions src/Google.Apis.Kiota.Core/Models/GoogleApiException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// <auto-generated/>
using Microsoft.Kiota.Abstractions.Serialization;
using Microsoft.Kiota.Abstractions;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System;
namespace Google.Apis.Kiota.Models {
#pragma warning disable CS1591
public class GoogleApiException : ApiException, IAdditionalDataHolder, IParsable
#pragma warning restore CS1591
{
/// <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 error property</summary>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
public RequestError? Error { get; set; }
#nullable restore
#else
public RequestError Error { get; set; }
#endif
/// <summary>The primary error message.</summary>
public override string Message { get => base.Message; }
/// <summary>
/// Instantiates a new <see cref="GoogleApiException"/> and sets the default values.
/// </summary>
public GoogleApiException()
{
AdditionalData = new Dictionary<string, object>();
}
/// <summary>
/// Creates a new instance of the appropriate class based on discriminator value
/// </summary>
/// <returns>A <see cref="GoogleApiException"/></returns>
/// <param name="parseNode">The parse node to use to read the discriminator value and create the object</param>
public static GoogleApiException CreateFromDiscriminatorValue(IParseNode parseNode)
{
_ = parseNode ?? throw new ArgumentNullException(nameof(parseNode));
return new GoogleApiException();
}
/// <summary>
/// The deserialization information for the current model
/// </summary>
/// <returns>A IDictionary&lt;string, Action&lt;IParseNode&gt;&gt;</returns>
public virtual IDictionary<string, Action<IParseNode>> GetFieldDeserializers()
{
return new Dictionary<string, Action<IParseNode>>
{
{"error", n => { Error = n.GetObjectValue<RequestError>(RequestError.CreateFromDiscriminatorValue); } },
};
}
/// <summary>
/// Serializes information the current object
/// </summary>
/// <param name="writer">Serialization writer to use to serialize this model</param>
public virtual void Serialize(ISerializationWriter writer)
{
_ = writer ?? throw new ArgumentNullException(nameof(writer));
writer.WriteObjectValue<RequestError>("error", Error);
writer.WriteAdditionalData(AdditionalData);
}
}
}
75 changes: 75 additions & 0 deletions src/Google.Apis.Kiota.Core/Models/RequestError.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// <auto-generated/>
using Microsoft.Kiota.Abstractions.Serialization;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System;
namespace Google.Apis.Kiota.Models {
#pragma warning disable CS1591
public class RequestError : IAdditionalDataHolder, IParsable
#pragma warning restore CS1591
{
/// <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 code property</summary>
public int? Code { get; set; }
/// <summary>The errors property</summary>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
public List<SingleError>? Errors { get; set; }
#nullable restore
#else
public List<SingleError> Errors { get; set; }
#endif
/// <summary>The message property</summary>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
public string? Message { get; set; }
#nullable restore
#else
public string Message { get; set; }
#endif
/// <summary>
/// Instantiates a new <see cref="RequestError"/> and sets the default values.
/// </summary>
public RequestError()
{
AdditionalData = new Dictionary<string, object>();
}
/// <summary>
/// Creates a new instance of the appropriate class based on discriminator value
/// </summary>
/// <returns>A <see cref="RequestError"/></returns>
/// <param name="parseNode">The parse node to use to read the discriminator value and create the object</param>
public static RequestError CreateFromDiscriminatorValue(IParseNode parseNode)
{
_ = parseNode ?? throw new ArgumentNullException(nameof(parseNode));
return new RequestError();
}
/// <summary>
/// The deserialization information for the current model
/// </summary>
/// <returns>A IDictionary&lt;string, Action&lt;IParseNode&gt;&gt;</returns>
public virtual IDictionary<string, Action<IParseNode>> GetFieldDeserializers()
{
return new Dictionary<string, Action<IParseNode>>
{
{"code", n => { Code = n.GetIntValue(); } },
{"errors", n => { Errors = n.GetCollectionOfObjectValues<SingleError>(SingleError.CreateFromDiscriminatorValue)?.ToList(); } },
{"message", n => { Message = n.GetStringValue(); } },
};
}
/// <summary>
/// Serializes information the current object
/// </summary>
/// <param name="writer">Serialization writer to use to serialize this model</param>
public virtual void Serialize(ISerializationWriter writer)
{
_ = writer ?? throw new ArgumentNullException(nameof(writer));
writer.WriteIntValue("code", Code);
writer.WriteCollectionOfObjectValues<SingleError>("errors", Errors);
writer.WriteStringValue("message", Message);
writer.WriteAdditionalData(AdditionalData);
}
}
}
101 changes: 101 additions & 0 deletions src/Google.Apis.Kiota.Core/Models/SingleError.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
// <auto-generated/>
using Microsoft.Kiota.Abstractions.Serialization;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System;
namespace Google.Apis.Kiota.Models {
#pragma warning disable CS1591
public class SingleError : IAdditionalDataHolder, IParsable
#pragma warning restore CS1591
{
/// <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 domain property</summary>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
public string? Domain { get; set; }
#nullable restore
#else
public string Domain { get; set; }
#endif
/// <summary>The location property</summary>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
public string? Location { get; set; }
#nullable restore
#else
public string Location { get; set; }
#endif
/// <summary>The locationType property</summary>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
public string? LocationType { get; set; }
#nullable restore
#else
public string LocationType { get; set; }
#endif
/// <summary>The message property</summary>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
public string? Message { get; set; }
#nullable restore
#else
public string Message { get; set; }
#endif
/// <summary>The reason property</summary>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
public string? Reason { get; set; }
#nullable restore
#else
public string Reason { get; set; }
#endif
/// <summary>
/// Instantiates a new <see cref="SingleError"/> and sets the default values.
/// </summary>
public SingleError()
{
AdditionalData = new Dictionary<string, object>();
}
/// <summary>
/// Creates a new instance of the appropriate class based on discriminator value
/// </summary>
/// <returns>A <see cref="SingleError"/></returns>
/// <param name="parseNode">The parse node to use to read the discriminator value and create the object</param>
public static SingleError CreateFromDiscriminatorValue(IParseNode parseNode)
{
_ = parseNode ?? throw new ArgumentNullException(nameof(parseNode));
return new SingleError();
}
/// <summary>
/// The deserialization information for the current model
/// </summary>
/// <returns>A IDictionary&lt;string, Action&lt;IParseNode&gt;&gt;</returns>
public virtual IDictionary<string, Action<IParseNode>> GetFieldDeserializers()
{
return new Dictionary<string, Action<IParseNode>>
{
{"domain", n => { Domain = n.GetStringValue(); } },
{"location", n => { Location = n.GetStringValue(); } },
{"locationType", n => { LocationType = n.GetStringValue(); } },
{"message", n => { Message = n.GetStringValue(); } },
{"reason", n => { Reason = n.GetStringValue(); } },
};
}
/// <summary>
/// Serializes information the current object
/// </summary>
/// <param name="writer">Serialization writer to use to serialize this model</param>
public virtual void Serialize(ISerializationWriter writer)
{
_ = writer ?? throw new ArgumentNullException(nameof(writer));
writer.WriteStringValue("domain", Domain);
writer.WriteStringValue("location", Location);
writer.WriteStringValue("locationType", LocationType);
writer.WriteStringValue("message", Message);
writer.WriteStringValue("reason", Reason);
writer.WriteAdditionalData(AdditionalData);
}
}
}
12 changes: 12 additions & 0 deletions src/Google.Apis.Kiota.Drive/Google.Apis.Kiota.Drive.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Using Include="Google.Apis.Kiota.Models" />
<ProjectReference Include="../Google.Apis.Kiota.Core/Google.Apis.Kiota.Core.csproj" />
<PackageReference Include="Microsoft.Kiota.Abstractions" Version="1.9.4" />
<PackageReference Include="Microsoft.Kiota.Serialization.Json" Version="1.3.3" />
</ItemGroup>
</Project>
12 changes: 12 additions & 0 deletions src/Google.Apis.Kiota.Gmail/Google.Apis.Kiota.Gmail.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Using Include="Google.Apis.Kiota.Models" />
<ProjectReference Include="../Google.Apis.Kiota.Core/Google.Apis.Kiota.Core.csproj" />
<PackageReference Include="Microsoft.Kiota.Abstractions" Version="1.9.4" />
<PackageReference Include="Microsoft.Kiota.Serialization.Json" Version="1.3.3" />
</ItemGroup>
</Project>
12 changes: 12 additions & 0 deletions src/Google.Apis.Kiota.People/Google.Apis.Kiota.People.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Using Include="Google.Apis.Kiota.Models" />
<ProjectReference Include="../Google.Apis.Kiota.Core/Google.Apis.Kiota.Core.csproj" />
<PackageReference Include="Microsoft.Kiota.Abstractions" Version="1.9.4" />
<PackageReference Include="Microsoft.Kiota.Serialization.Json" Version="1.3.3" />
</ItemGroup>
</Project>
12 changes: 12 additions & 0 deletions src/Google.Apis.Kiota.Tasks/Google.Apis.Kiota.Tasks.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Using Include="Google.Apis.Kiota.Models" />
<ProjectReference Include="../Google.Apis.Kiota.Core/Google.Apis.Kiota.Core.csproj" />
<PackageReference Include="Microsoft.Kiota.Abstractions" Version="1.9.4" />
<PackageReference Include="Microsoft.Kiota.Serialization.Json" Version="1.3.3" />
</ItemGroup>
</Project>
Loading

0 comments on commit c343511

Please sign in to comment.