Convert Idp API spec to GVK style

This commit is contained in:
Akshay Gaikwad
2022-01-19 12:38:09 +05:30
parent c1ba133383
commit ad3cbc10d3
3 changed files with 710 additions and 229 deletions

View File

@@ -16,10 +16,12 @@
"https"
],
"consumes": [
"application/json"
"application/json",
"application/yaml"
],
"produces": [
"application/json"
"application/json",
"application/yaml"
],
"paths": {
"/auth/v3/sso/idp": {
@@ -29,7 +31,7 @@
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/v3ListIdpsResponse"
"$ref": "#/definitions/v3IdpList"
}
},
"403": {
@@ -50,15 +52,6 @@
}
}
},
"parameters": [
{
"name": "limit",
"in": "query",
"required": false,
"type": "integer",
"format": "int32"
}
],
"tags": [
"Idp"
]
@@ -100,7 +93,7 @@
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/v3NewIdp"
"$ref": "#/definitions/v3Idp"
}
}
],
@@ -109,9 +102,219 @@
]
}
},
"/auth/v3/sso/idp/{id}": {
"/auth/v3/sso/idp/{metadata.id}": {
"get": {
"operationId": "Idp_GetIdp",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/v3Idp"
}
},
"403": {
"description": "Returned when the user does not have permission to access the resource.",
"schema": {}
},
"404": {
"description": "Returned when the resource does not exist.",
"schema": {
"type": "string",
"format": "string"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/googlerpcStatus"
}
}
},
"parameters": [
{
"name": "metadata.id",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "apiVersion",
"description": "API Version. API Version of the idp resource",
"in": "query",
"required": false,
"type": "string",
"default": "usermgmt.k8smgmt.io/v3"
},
{
"name": "kind",
"description": "Kind. Kind of the idp resource",
"in": "query",
"required": false,
"type": "string",
"default": "Idp"
},
{
"name": "metadata.name",
"description": "Name. name of the resource",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "metadata.description",
"description": "Description. description of the resource",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "metadata.project",
"description": "Project. Project of the resource",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "metadata.organization",
"description": "Organization. Organization to which the resource belongs",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "metadata.partner",
"description": "Partner. Partner to which the resource belongs",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "metadata.modifiedAt",
"in": "query",
"required": false,
"type": "string",
"format": "date-time"
},
{
"name": "spec.idpName",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.domain",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.acsUrl",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.ssoUrl",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.idpCert",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.spCert",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.metadataUrl",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.metadataFilename",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.saeEnabled",
"in": "query",
"required": false,
"type": "boolean"
},
{
"name": "spec.groupAttributeName",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.nameIdFormat",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.consumerBinding",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.spEntityId",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "status.conditionType",
"description": "Condition Type. type of the status condition",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "status.conditionStatus",
"description": "Condition Status. status of the condition",
"in": "query",
"required": false,
"type": "string",
"enum": [
"StatusNotSet",
"StatusSubmitted",
"StatusOK",
"StatusFailed"
],
"default": "StatusNotSet"
},
{
"name": "status.lastUpdated",
"description": "Last Updated. when the condition status is last updated",
"in": "query",
"required": false,
"type": "string",
"format": "date-time"
},
{
"name": "status.reason",
"description": "Reason. reason of the last condition status",
"in": "query",
"required": false,
"type": "string"
}
],
"tags": [
"Idp"
]
},
"delete": {
"summary": "DELETE /auth/v1/sso/idp/{id}/",
"operationId": "Idp_DeleteIdp",
"responses": {
"200": {
@@ -144,10 +347,182 @@
},
"parameters": [
{
"name": "id",
"name": "metadata.id",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "apiVersion",
"description": "API Version. API Version of the idp resource",
"in": "query",
"required": false,
"type": "string",
"default": "usermgmt.k8smgmt.io/v3"
},
{
"name": "kind",
"description": "Kind. Kind of the idp resource",
"in": "query",
"required": false,
"type": "string",
"default": "Idp"
},
{
"name": "metadata.name",
"description": "Name. name of the resource",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "metadata.description",
"description": "Description. description of the resource",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "metadata.project",
"description": "Project. Project of the resource",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "metadata.organization",
"description": "Organization. Organization to which the resource belongs",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "metadata.partner",
"description": "Partner. Partner to which the resource belongs",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "metadata.modifiedAt",
"in": "query",
"required": false,
"type": "string",
"format": "date-time"
},
{
"name": "spec.idpName",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.domain",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.acsUrl",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.ssoUrl",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.idpCert",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.spCert",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.metadataUrl",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.metadataFilename",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.saeEnabled",
"in": "query",
"required": false,
"type": "boolean"
},
{
"name": "spec.groupAttributeName",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.nameIdFormat",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.consumerBinding",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.spEntityId",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "status.conditionType",
"description": "Condition Type. type of the status condition",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "status.conditionStatus",
"description": "Condition Status. status of the condition",
"in": "query",
"required": false,
"type": "string",
"enum": [
"StatusNotSet",
"StatusSubmitted",
"StatusOK",
"StatusFailed"
],
"default": "StatusNotSet"
},
{
"name": "status.lastUpdated",
"description": "Last Updated. when the condition status is last updated",
"in": "query",
"required": false,
"type": "string",
"format": "date-time"
},
{
"name": "status.reason",
"description": "Reason. reason of the last condition status",
"in": "query",
"required": false,
"type": "string"
}
],
"tags": [
@@ -183,7 +558,7 @@
},
"parameters": [
{
"name": "id",
"name": "metadata.id",
"in": "path",
"required": true,
"type": "string"
@@ -193,30 +568,7 @@
"in": "body",
"required": true,
"schema": {
"type": "object",
"properties": {
"acsUrl": {
"type": "string"
},
"domain": {
"type": "string"
},
"groupAttributeName": {
"type": "string"
},
"idpName": {
"type": "string"
},
"isSaeEnabled": {
"type": "boolean"
},
"metadataUrl": {
"type": "string"
},
"name": {
"type": "string"
}
}
"$ref": "#/definitions/v3Idp"
}
}
],
@@ -224,50 +576,48 @@
"Idp"
]
}
},
"/auth/v3/sso/idp/{id}/spconfig": {
"get": {
"operationId": "Idp_GetSpConfigById",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/v3SpConfig"
}
},
"403": {
"description": "Returned when the user does not have permission to access the resource.",
"schema": {}
},
"404": {
"description": "Returned when the resource does not exist.",
"schema": {
"type": "string",
"format": "string"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/googlerpcStatus"
}
}
},
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"type": "string"
}
],
"tags": [
"Idp"
]
}
}
},
"definitions": {
"commonv3Status": {
"type": "object",
"properties": {
"conditionType": {
"type": "string",
"description": "type of the status condition",
"title": "Condition Type",
"readOnly": true
},
"conditionStatus": {
"$ref": "#/definitions/v3ConditionStatus",
"enum": [
"StatusNotSet",
"StatusSubmitted",
"StatusOK",
"StatusFailed"
],
"description": "status of the condition",
"title": "Condition Status",
"readOnly": true
},
"lastUpdated": {
"type": "string",
"format": "date-time",
"description": "when the condition status is last updated",
"title": "Last Updated",
"readOnly": true
},
"reason": {
"type": "string",
"description": "reason of the last condition status",
"title": "Reason",
"readOnly": true
}
},
"description": "status of a resource",
"title": "Status",
"readOnly": true
},
"googlerpcStatus": {
"type": "object",
"properties": {
@@ -295,15 +645,98 @@
},
"additionalProperties": {}
},
"v3ConditionStatus": {
"type": "string",
"enum": [
"StatusNotSet",
"StatusSubmitted",
"StatusOK",
"StatusFailed"
],
"default": "StatusNotSet",
"title": "$title: ConditionStatus\n$description: status of a condition for a resource"
},
"v3Idp": {
"type": "object",
"properties": {
"id": {
"type": "string"
"apiVersion": {
"type": "string",
"default": "usermgmt.k8smgmt.io/v3",
"description": "API Version of the idp resource",
"title": "API Version"
},
"name": {
"type": "string"
"kind": {
"type": "string",
"default": "Idp",
"description": "Kind of the idp resource",
"title": "Kind"
},
"metadata": {
"$ref": "#/definitions/v3Metadata",
"description": "Metadata of the idp resource",
"title": "Metadata"
},
"spec": {
"$ref": "#/definitions/v3IdpSpec",
"description": "Spec of the idp resource",
"title": "Spec"
},
"status": {
"$ref": "#/definitions/commonv3Status",
"description": "Status of the resource",
"title": "Status",
"readOnly": true
}
},
"description": "Idp",
"title": "Idp",
"required": [
"apiVersion",
"kind",
"metadata",
"spec"
]
},
"v3IdpList": {
"type": "object",
"properties": {
"apiVersion": {
"type": "string",
"default": "usermgmt.k8smgmt.io/v3",
"description": "API Version of the idp list resource",
"title": "API Version",
"readOnly": true
},
"kind": {
"type": "string",
"default": "IdpList",
"description": "Kind of the idp list resource",
"title": "Kind",
"readOnly": true
},
"metadata": {
"$ref": "#/definitions/v3ListMetadata",
"description": "Metadata of the idp list resource",
"title": "Metadata",
"readOnly": true
},
"items": {
"type": "array",
"items": {
"$ref": "#/definitions/v3Idp"
},
"description": "List of the idp resources",
"title": "Items",
"readOnly": true
}
},
"description": "idp list",
"title": "IdpList",
"readOnly": true
},
"v3IdpSpec": {
"type": "object",
"properties": {
"idpName": {
"type": "string"
},
@@ -328,91 +761,105 @@
"metadataFilename": {
"type": "string"
},
"isSaeEnabled": {
"saeEnabled": {
"type": "boolean"
},
"groupAttributeName": {
"type": "string"
},
"organizationId": {
"type": "string"
},
"partnerId": {
"type": "string"
},
"createdAt": {
"type": "string"
},
"modifiedAt": {
"type": "string"
}
}
},
"v3ListIdpsResponse": {
"type": "object",
"properties": {
"count": {
"type": "integer",
"format": "int32"
},
"next": {
"type": "integer",
"format": "int32"
},
"previous": {
"type": "integer",
"format": "int32"
},
"result": {
"type": "array",
"items": {
"$ref": "#/definitions/v3Idp"
}
}
}
},
"v3NewIdp": {
"type": "object",
"properties": {
"domain": {
"type": "string"
},
"groupAttributeName": {
"type": "string"
},
"idpName": {
"type": "string"
},
"isSaeEnabled": {
"type": "boolean"
},
"name": {
"type": "string"
}
}
},
"v3SpConfig": {
"type": "object",
"properties": {
"nameidFormat": {
"nameIdFormat": {
"type": "string"
},
"consumerBinding": {
"type": "string"
},
"acsUrl": {
"type": "string"
},
"entityId": {
"type": "string"
},
"groupAttributeName": {
"type": "string"
},
"spCert": {
"spEntityId": {
"type": "string"
}
}
},
"v3ListMetadata": {
"type": "object",
"properties": {
"count": {
"type": "string",
"format": "int64"
},
"offset": {
"type": "string",
"format": "int64"
},
"limt": {
"type": "string",
"format": "int64"
}
},
"title": "$title: ListMetadata\n$description: metadata for a list of resources\n$required: enabled"
},
"v3Metadata": {
"type": "object",
"example": {
"name": "some-name",
"project": "defaultproject"
},
"properties": {
"name": {
"type": "string",
"description": "name of the resource",
"title": "Name"
},
"description": {
"type": "string",
"description": "description of the resource",
"title": "Description"
},
"labels": {
"type": "object",
"additionalProperties": {
"type": "string"
},
"description": "labels of the resource",
"title": "Lables"
},
"annotations": {
"type": "object",
"additionalProperties": {
"type": "string"
},
"description": "annotations of the resource",
"title": "Annotations"
},
"project": {
"type": "string",
"description": "Project of the resource",
"title": "Project"
},
"organization": {
"type": "string",
"description": "Organization to which the resource belongs",
"title": "Organization"
},
"partner": {
"type": "string",
"description": "Partner to which the resource belongs",
"title": "Partner"
},
"id": {
"type": "string",
"readOnly": true
},
"modifiedAt": {
"type": "string",
"format": "date-time",
"readOnly": true
}
},
"description": "metadata of the resource",
"title": "Metadata",
"required": [
"name",
"project"
]
}
},
"securityDefinitions": {

View File

@@ -14,7 +14,9 @@ option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
}
schemes : HTTPS
consumes : "application/json"
consumes : "application/yaml"
produces : "application/json"
produces : "application/yaml"
security_definitions : {
security : {
key : "BasicAuth"
@@ -53,7 +55,7 @@ option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
service Idp {
rpc CreateIdp(rafay.dev.types.user.v3.NewIdp) returns (rafay.dev.types.user.v3.Idp) {
rpc CreateIdp(rafay.dev.types.user.v3.Idp) returns (rafay.dev.types.user.v3.Idp) {
option (google.api.http) = {
post : "/auth/v3/sso/idp"
body : "*"
@@ -67,29 +69,28 @@ service Idp {
};
};
rpc UpdateIdp(rafay.dev.types.user.v3.UpdateIdp) returns (rafay.dev.types.user.v3.Idp) {
rpc GetIdp(rafay.dev.types.user.v3.Idp) returns (rafay.dev.types.user.v3.Idp) {
option (google.api.http) = {
put : "/auth/v3/sso/idp/{id}"
body : "*"
get : "/auth/v3/sso/idp/{metadata.id}"
};
};
rpc GetSpConfigById(rafay.dev.types.user.v3.IdpID) returns (rafay.dev.types.user.v3.SpConfig) {
option (google.api.http) = {
get : "/auth/v3/sso/idp/{id}/spconfig"
};
};
rpc ListIdps(rafay.dev.types.user.v3.ListIdpsRequest) returns (rafay.dev.types.user.v3.ListIdpsResponse) {
rpc ListIdps(google.protobuf.Empty) returns (rafay.dev.types.user.v3.IdpList) {
option (google.api.http) = {
get : "/auth/v3/sso/idp"
};
};
// DELETE /auth/v1/sso/idp/{id}/
rpc DeleteIdp(rafay.dev.types.user.v3.IdpID) returns (google.protobuf.Empty) {
rpc UpdateIdp(rafay.dev.types.user.v3.Idp) returns (rafay.dev.types.user.v3.Idp) {
option (google.api.http) = {
delete : "/auth/v3/sso/idp/{id}"
put : "/auth/v3/sso/idp/{metadata.id}"
body : "*"
};
};
rpc DeleteIdp(rafay.dev.types.user.v3.Idp) returns (google.protobuf.Empty) {
option (google.api.http) = {
delete : "/auth/v3/sso/idp/{metadata.id}"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
@@ -101,8 +102,8 @@ service Idp {
}
};
};
// endpooint /auth/v1/sso/idp/{id}/upload_metadata/
// TODO: endpooint /auth/v1/sso/idp/{id}/upload_metadata/
// file content as request payload and response is Idp
}

View File

@@ -1,64 +1,97 @@
syntax = "proto3";
package rafay.dev.types.user.v3;
import "proto/types/commonpb/v3/common.proto";
import "protoc-gen-openapiv2/options/annotations.proto";
message Idp {
string id = 1;
string name = 2;
string idp_name = 3;
string domain = 4;
string acs_url = 5;
string sso_url = 6;
string idp_cert = 7;
string sp_cert = 8;
string metadata_url = 9;
string metadata_filename = 10;
bool is_sae_enabled = 11;
string group_attribute_name = 12;
string organization_id = 13;
string partner_id = 14;
string created_at = 15;
string modified_at = 16;
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = {
json_schema : {
title : "Idp"
description : "Idp"
required : [ "apiVersion", "kind", "metadata", "spec" ]
}
};
string apiVersion = 1
[ (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
title : "API Version",
description : "API Version of the idp resource"
default : "usermgmt.k8smgmt.io/v3"
} ];
string kind = 2
[ (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
title : "Kind",
description : "Kind of the idp resource"
default : "Idp"
} ];
rafay.dev.types.common.v3.Metadata metadata = 3
[ (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
title : "Metadata",
description : "Metadata of the idp resource"
} ];
IdpSpec spec = 4
[ (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
title : "Spec",
description : "Spec of the idp resource"
} ];
rafay.dev.types.common.v3.Status status = 5
[ (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
title : "Status",
description : "Status of the resource"
read_only : true
} ];
}
message NewIdp {
string domain = 1;
string group_attribute_name = 2;
string idp_name = 3;
bool is_sae_enabled = 4;
string name = 5;
message IdpSpec {
string idpName = 1;
string domain = 2;
string acsUrl = 3;
string ssoUrl = 4;
string idpCert = 5;
string spCert = 6;
string metadataUrl = 7;
string metadataFilename = 8;
bool saeEnabled = 9;
string groupAttributeName = 10;
string nameIdFormat = 11;
string consumerBinding = 12;
string spEntityId = 13;
}
message UpdateIdp {
string id = 1;
string acs_url = 2;
string domain = 3;
string group_attribute_name = 4;
string idp_name = 5;
bool is_sae_enabled = 6;
string metadata_url = 7;
string name = 8;
}
message IdpID {
string id = 1;
}
message SpConfig {
string nameid_format = 1;
string consumer_binding = 2;
string acs_url = 3;
string entity_id = 4;
string group_attribute_name = 5;
string sp_cert = 6;
}
message ListIdpsResponse {
int32 count = 1;
int32 next = 2;
int32 previous = 3;
repeated Idp result = 4;
}
message ListIdpsRequest {
int32 limit = 1;
message IdpList {
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = {
json_schema : {
title : "IdpList"
description : "idp list"
read_only : true
}
};
string apiVersion = 1
[ (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
title : "API Version",
description : "API Version of the idp list resource"
default : "usermgmt.k8smgmt.io/v3"
read_only : true
} ];
string kind = 2
[ (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
title : "Kind",
description : "Kind of the idp list resource"
default : "IdpList"
read_only : true
} ];
rafay.dev.types.common.v3.ListMetadata metadata = 3
[ (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
title : "Metadata",
description : "Metadata of the idp list resource"
read_only : true
} ];
repeated Idp items = 4
[ (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
title : "Items",
description : "List of the idp resources"
read_only : true
} ];
}