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:Add plan_type property to OpenAPI specification for GitHub Copilot access #46

Merged
merged 1 commit into from
Oct 8, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ public sealed partial class CopilotOrganizationDetails
[global::System.Text.Json.Serialization.JsonRequired]
public required global::GitHub.CopilotOrganizationDetailsSeatManagementSetting SeatManagementSetting { get; set; }

/// <summary>
/// The Copilot plan of the organization, or the parent enterprise, when applicable.
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("plan_type")]
[global::System.Text.Json.Serialization.JsonConverter(typeof(global::OpenApiGenerator.JsonConverters.CopilotOrganizationDetailsPlanTypeJsonConverter))]
public global::GitHub.CopilotOrganizationDetailsPlanType? PlanType { get; set; }

/// <summary>
/// Additional properties that are not explicitly defined in the schema
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@

#nullable enable

namespace GitHub
{
/// <summary>
/// The Copilot plan of the organization, or the parent enterprise, when applicable.
/// </summary>
public enum CopilotOrganizationDetailsPlanType
{
/// <summary>
///
/// </summary>
Business,
/// <summary>
///
/// </summary>
Enterprise,
/// <summary>
///
/// </summary>
Unknown,
}

/// <summary>
/// Enum extensions to do fast conversions without the reflection.
/// </summary>
public static class CopilotOrganizationDetailsPlanTypeExtensions
{
/// <summary>
/// Converts an enum to a string.
/// </summary>
public static string ToValueString(this CopilotOrganizationDetailsPlanType value)
{
return value switch
{
CopilotOrganizationDetailsPlanType.Business => "business",
CopilotOrganizationDetailsPlanType.Enterprise => "enterprise",
CopilotOrganizationDetailsPlanType.Unknown => "unknown",
_ => throw new global::System.ArgumentOutOfRangeException(nameof(value), value, null),
};
}
/// <summary>
/// Converts an string to a enum.
/// </summary>
public static CopilotOrganizationDetailsPlanType? ToEnum(string value)
{
return value switch
{
"business" => CopilotOrganizationDetailsPlanType.Business,
"enterprise" => CopilotOrganizationDetailsPlanType.Enterprise,
"unknown" => CopilotOrganizationDetailsPlanType.Unknown,
_ => null,
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ public sealed partial class CopilotSeatDetails
[global::System.Text.Json.Serialization.JsonPropertyName("updated_at")]
public global::System.DateTime UpdatedAt { get; set; }

/// <summary>
/// The Copilot plan of the organization, or the parent enterprise, when applicable.
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("plan_type")]
[global::System.Text.Json.Serialization.JsonConverter(typeof(global::OpenApiGenerator.JsonConverters.CopilotSeatDetailsPlanTypeJsonConverter))]
public global::GitHub.CopilotSeatDetailsPlanType? PlanType { get; set; }

/// <summary>
/// Additional properties that are not explicitly defined in the schema
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@

#nullable enable

namespace GitHub
{
/// <summary>
/// The Copilot plan of the organization, or the parent enterprise, when applicable.
/// </summary>
public enum CopilotSeatDetailsPlanType
{
/// <summary>
///
/// </summary>
Business,
/// <summary>
///
/// </summary>
Enterprise,
/// <summary>
///
/// </summary>
Unknown,
}

/// <summary>
/// Enum extensions to do fast conversions without the reflection.
/// </summary>
public static class CopilotSeatDetailsPlanTypeExtensions
{
/// <summary>
/// Converts an enum to a string.
/// </summary>
public static string ToValueString(this CopilotSeatDetailsPlanType value)
{
return value switch
{
CopilotSeatDetailsPlanType.Business => "business",
CopilotSeatDetailsPlanType.Enterprise => "enterprise",
CopilotSeatDetailsPlanType.Unknown => "unknown",
_ => throw new global::System.ArgumentOutOfRangeException(nameof(value), value, null),
};
}
/// <summary>
/// Converts an string to a enum.
/// </summary>
public static CopilotSeatDetailsPlanType? ToEnum(string value)
{
return value switch
{
"business" => CopilotSeatDetailsPlanType.Business,
"enterprise" => CopilotSeatDetailsPlanType.Enterprise,
"unknown" => CopilotSeatDetailsPlanType.Unknown,
_ => null,
};
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#nullable enable

namespace OpenApiGenerator.JsonConverters
{
/// <inheritdoc />
public sealed class CopilotOrganizationDetailsPlanTypeJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::GitHub.CopilotOrganizationDetailsPlanType>
{
/// <inheritdoc />
public override global::GitHub.CopilotOrganizationDetailsPlanType Read(
ref global::System.Text.Json.Utf8JsonReader reader,
global::System.Type typeToConvert,
global::System.Text.Json.JsonSerializerOptions options)
{
switch (reader.TokenType)
{
case global::System.Text.Json.JsonTokenType.String:
{
var stringValue = reader.GetString();
if (stringValue != null)
{
return global::GitHub.CopilotOrganizationDetailsPlanTypeExtensions.ToEnum(stringValue) ?? default;
}

break;
}
case global::System.Text.Json.JsonTokenType.Number:
{
var numValue = reader.GetInt32();
return (global::GitHub.CopilotOrganizationDetailsPlanType)numValue;
}
default:
throw new global::System.ArgumentOutOfRangeException(nameof(reader));
}

return default;
}

/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::GitHub.CopilotOrganizationDetailsPlanType value,
global::System.Text.Json.JsonSerializerOptions options)
{
writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer));

writer.WriteStringValue(global::GitHub.CopilotOrganizationDetailsPlanTypeExtensions.ToValueString(value));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#nullable enable

namespace OpenApiGenerator.JsonConverters
{
/// <inheritdoc />
public sealed class CopilotOrganizationDetailsPlanTypeNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::GitHub.CopilotOrganizationDetailsPlanType?>
{
/// <inheritdoc />
public override global::GitHub.CopilotOrganizationDetailsPlanType? Read(
ref global::System.Text.Json.Utf8JsonReader reader,
global::System.Type typeToConvert,
global::System.Text.Json.JsonSerializerOptions options)
{
switch (reader.TokenType)
{
case global::System.Text.Json.JsonTokenType.String:
{
var stringValue = reader.GetString();
if (stringValue != null)
{
return global::GitHub.CopilotOrganizationDetailsPlanTypeExtensions.ToEnum(stringValue);
}

break;
}
case global::System.Text.Json.JsonTokenType.Number:
{
var numValue = reader.GetInt32();
return (global::GitHub.CopilotOrganizationDetailsPlanType)numValue;
}
default:
throw new global::System.ArgumentOutOfRangeException(nameof(reader));
}

return default;
}

/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::GitHub.CopilotOrganizationDetailsPlanType? value,
global::System.Text.Json.JsonSerializerOptions options)
{
writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer));

if (value == null)
{
writer.WriteNullValue();
}
else
{
writer.WriteStringValue(global::GitHub.CopilotOrganizationDetailsPlanTypeExtensions.ToValueString(value.Value));
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#nullable enable

namespace OpenApiGenerator.JsonConverters
{
/// <inheritdoc />
public sealed class CopilotSeatDetailsPlanTypeJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::GitHub.CopilotSeatDetailsPlanType>
{
/// <inheritdoc />
public override global::GitHub.CopilotSeatDetailsPlanType Read(
ref global::System.Text.Json.Utf8JsonReader reader,
global::System.Type typeToConvert,
global::System.Text.Json.JsonSerializerOptions options)
{
switch (reader.TokenType)
{
case global::System.Text.Json.JsonTokenType.String:
{
var stringValue = reader.GetString();
if (stringValue != null)
{
return global::GitHub.CopilotSeatDetailsPlanTypeExtensions.ToEnum(stringValue) ?? default;
}

break;
}
case global::System.Text.Json.JsonTokenType.Number:
{
var numValue = reader.GetInt32();
return (global::GitHub.CopilotSeatDetailsPlanType)numValue;
}
default:
throw new global::System.ArgumentOutOfRangeException(nameof(reader));
}

return default;
}

/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::GitHub.CopilotSeatDetailsPlanType value,
global::System.Text.Json.JsonSerializerOptions options)
{
writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer));

writer.WriteStringValue(global::GitHub.CopilotSeatDetailsPlanTypeExtensions.ToValueString(value));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#nullable enable

namespace OpenApiGenerator.JsonConverters
{
/// <inheritdoc />
public sealed class CopilotSeatDetailsPlanTypeNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::GitHub.CopilotSeatDetailsPlanType?>
{
/// <inheritdoc />
public override global::GitHub.CopilotSeatDetailsPlanType? Read(
ref global::System.Text.Json.Utf8JsonReader reader,
global::System.Type typeToConvert,
global::System.Text.Json.JsonSerializerOptions options)
{
switch (reader.TokenType)
{
case global::System.Text.Json.JsonTokenType.String:
{
var stringValue = reader.GetString();
if (stringValue != null)
{
return global::GitHub.CopilotSeatDetailsPlanTypeExtensions.ToEnum(stringValue);
}

break;
}
case global::System.Text.Json.JsonTokenType.Number:
{
var numValue = reader.GetInt32();
return (global::GitHub.CopilotSeatDetailsPlanType)numValue;
}
default:
throw new global::System.ArgumentOutOfRangeException(nameof(reader));
}

return default;
}

/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::GitHub.CopilotSeatDetailsPlanType? value,
global::System.Text.Json.JsonSerializerOptions options)
{
writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer));

if (value == null)
{
writer.WriteNullValue();
}
else
{
writer.WriteStringValue(global::GitHub.CopilotSeatDetailsPlanTypeExtensions.ToValueString(value.Value));
}
}
}
}
4 changes: 4 additions & 0 deletions src/libs/GitHub/Generated/JsonSerializerContext.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ namespace GitHub
typeof(global::OpenApiGenerator.JsonConverters.ClassroomAssignmentTypeNullableJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.SimpleClassroomAssignmentTypeJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.SimpleClassroomAssignmentTypeNullableJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.CopilotSeatDetailsPlanTypeJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.CopilotSeatDetailsPlanTypeNullableJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.DependabotAlertSecurityVulnerabilitySeverityJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.DependabotAlertSecurityVulnerabilitySeverityNullableJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.DependabotAlertSecurityAdvisorySeverityJsonConverter),
Expand Down Expand Up @@ -249,6 +251,8 @@ namespace GitHub
typeof(global::OpenApiGenerator.JsonConverters.CopilotOrganizationDetailsCliNullableJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.CopilotOrganizationDetailsSeatManagementSettingJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.CopilotOrganizationDetailsSeatManagementSettingNullableJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.CopilotOrganizationDetailsPlanTypeJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.CopilotOrganizationDetailsPlanTypeNullableJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.OrganizationDependabotSecretVisibilityJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.OrganizationDependabotSecretVisibilityNullableJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.PackagePackageTypeJsonConverter),
Expand Down
Loading
Loading