Commit e1f66791 authored by Eric Chiang's avatar Eric Chiang Committed by GitHub

Merge pull request #683 from rithujohn191/add-version-endpoint

api: add gRPC definition for version endpoint.
parents 36ade89e de4e23a2
This diff is collapsed.
...@@ -80,16 +80,30 @@ message DeletePasswordResp { ...@@ -80,16 +80,30 @@ message DeletePasswordResp {
bool not_found = 1; bool not_found = 1;
} }
// VersionReq is a request to fetch version info.
message VersionReq {}
// VersionResp holds the version info of components.
message VersionResp {
// Semantic version of the server.
string server = 1;
// Numeric version of the API. It increases everytime a new call is added to the API.
// Clients should use this info to determine if the server supports specific features.
int32 api = 2;
}
// Dex represents the dex gRPC service. // Dex represents the dex gRPC service.
service Dex { service Dex {
// CreateClient attempts to create the client. // CreateClient creates a client.
rpc CreateClient(CreateClientReq) returns (CreateClientResp) {}; rpc CreateClient(CreateClientReq) returns (CreateClientResp) {};
// DeleteClient attempts to delete the provided client. // DeleteClient deletes the provided client.
rpc DeleteClient(DeleteClientReq) returns (DeleteClientResp) {}; rpc DeleteClient(DeleteClientReq) returns (DeleteClientResp) {};
// CreatePassword attempts to create the password. // CreatePassword creates a password.
rpc CreatePassword(CreatePasswordReq) returns (CreatePasswordResp) {}; rpc CreatePassword(CreatePasswordReq) returns (CreatePasswordResp) {};
// UpdatePassword attempts to modify existing password. // UpdatePassword modifies existing password.
rpc UpdatePassword(UpdatePasswordReq) returns (UpdatePasswordResp) {}; rpc UpdatePassword(UpdatePasswordReq) returns (UpdatePasswordResp) {};
// DeletePassword attempts to delete the password. // DeletePassword deletes the password.
rpc DeletePassword(DeletePasswordReq) returns (DeletePasswordResp) {}; rpc DeletePassword(DeletePasswordReq) returns (DeletePasswordResp) {};
// GetVersion returns version information of the server.
rpc GetVersion(VersionReq) returns (VersionResp) {};
} }
...@@ -10,8 +10,13 @@ import ( ...@@ -10,8 +10,13 @@ import (
"github.com/coreos/dex/api" "github.com/coreos/dex/api"
"github.com/coreos/dex/storage" "github.com/coreos/dex/storage"
"github.com/coreos/dex/version"
) )
// apiVersion increases everytime a new call is added to the API. Clients should use this info
// to determine if the server supports specific features.
const apiVersion = 0
// NewAPI returns a server which implements the gRPC API interface. // NewAPI returns a server which implements the gRPC API interface.
func NewAPI(s storage.Storage) api.DexServer { func NewAPI(s storage.Storage) api.DexServer {
return dexAPI{s: s} return dexAPI{s: s}
...@@ -159,3 +164,10 @@ func (d dexAPI) DeletePassword(ctx context.Context, req *api.DeletePasswordReq) ...@@ -159,3 +164,10 @@ func (d dexAPI) DeletePassword(ctx context.Context, req *api.DeletePasswordReq)
return &api.DeletePasswordResp{}, nil return &api.DeletePasswordResp{}, nil
} }
func (d dexAPI) GetVersion(ctx context.Context, req *api.VersionReq) (*api.VersionResp, error) {
return &api.VersionResp{
Server: version.Version,
Api: apiVersion,
}, nil
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment