Skip to content

Commit

Permalink
Merge pull request #683 from rithujohn191/add-version-endpoint
Browse files Browse the repository at this point in the history
api: add gRPC definition for version endpoint.
  • Loading branch information
ericchiang authored Nov 14, 2016
2 parents 36ade89 + de4e23a commit e1f6679
Show file tree
Hide file tree
Showing 3 changed files with 141 additions and 49 deletions.
154 changes: 110 additions & 44 deletions api/api.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 19 additions & 5 deletions api/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,30 @@ message DeletePasswordResp {
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.
service Dex {
// CreateClient attempts to create the client.
// CreateClient creates a client.
rpc CreateClient(CreateClientReq) returns (CreateClientResp) {};
// DeleteClient attempts to delete the provided client.
// DeleteClient deletes the provided client.
rpc DeleteClient(DeleteClientReq) returns (DeleteClientResp) {};
// CreatePassword attempts to create the password.
// CreatePassword creates a password.
rpc CreatePassword(CreatePasswordReq) returns (CreatePasswordResp) {};
// UpdatePassword attempts to modify existing password.
// UpdatePassword modifies existing password.
rpc UpdatePassword(UpdatePasswordReq) returns (UpdatePasswordResp) {};
// DeletePassword attempts to delete the password.
// DeletePassword deletes the password.
rpc DeletePassword(DeletePasswordReq) returns (DeletePasswordResp) {};
// GetVersion returns version information of the server.
rpc GetVersion(VersionReq) returns (VersionResp) {};
}
12 changes: 12 additions & 0 deletions server/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ import (

"github.com/coreos/dex/api"
"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.
func NewAPI(s storage.Storage) api.DexServer {
return dexAPI{s: s}
Expand Down Expand Up @@ -159,3 +164,10 @@ func (d dexAPI) DeletePassword(ctx context.Context, req *api.DeletePasswordReq)
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
}

0 comments on commit e1f6679

Please sign in to comment.