feat: provide instance info on admin api and return version on instances responses (admin and system api) (#3802)

* feat: provide instance info on admin api and return version on instances responses (admin and system api)

* fix GetMyInstance
This commit is contained in:
Livio Spring 2022-06-27 11:12:06 +02:00 committed by GitHub
parent 1b4740c78f
commit 30f553dea1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 65 additions and 5 deletions

View File

@ -56,16 +56,28 @@ Set the default language
GET: /languages/default
### GetMyInstance
> **rpc** GetMyInstance([GetMyInstanceRequest](#getmyinstancerequest))
[GetMyInstanceResponse](#getmyinstanceresponse)
Returns the details of the instance
GET: /instances/me
### ListInstanceDomains
> **rpc** ListInstanceDomains([ListInstanceDomainsRequest](#listinstancedomainsrequest))
[ListInstanceDomainsResponse](#listinstancedomainsresponse)
Returns the domains of an instance
Returns the domains of the instance
GET: /domains
POST: /domains/_search
### ListSecretGenerators
@ -2348,6 +2360,23 @@ This is an empty request
### GetMyInstanceRequest
This is an empty request
### GetMyInstanceResponse
| Field | Type | Description | Validation |
| ----- | ---- | ----------- | ----------- |
| instance | zitadel.instance.v1.InstanceDetail | - | |
### GetOIDCSettingsRequest
This is an empty request

View File

@ -8,7 +8,17 @@ import (
admin_pb "github.com/zitadel/zitadel/pkg/grpc/admin"
)
func (s *Server) GetInstanceDomains(ctx context.Context, req *admin_pb.ListInstanceDomainsRequest) (*admin_pb.ListInstanceDomainsResponse, error) {
func (s *Server) GetMyInstance(ctx context.Context, _ *admin_pb.GetMyInstanceRequest) (*admin_pb.GetMyInstanceResponse, error) {
instance, err := s.query.Instance(ctx, true)
if err != nil {
return nil, err
}
return &admin_pb.GetMyInstanceResponse{
Instance: instance_grpc.InstanceDetailToPb(instance),
}, nil
}
func (s *Server) ListInstanceDomains(ctx context.Context, req *admin_pb.ListInstanceDomainsRequest) (*admin_pb.ListInstanceDomainsResponse, error) {
queries, err := ListInstanceDomainsRequestToModel(req)
if err != nil {
return nil, err

View File

@ -1,6 +1,7 @@
package org
import (
"github.com/zitadel/zitadel/cmd/build"
"github.com/zitadel/zitadel/internal/api/grpc/object"
"github.com/zitadel/zitadel/internal/errors"
"github.com/zitadel/zitadel/internal/query"
@ -26,6 +27,7 @@ func InstanceToPb(instance *query.Instance) *instance_pb.Instance {
Id: instance.InstanceID(),
Name: instance.Name,
Domains: DomainsToPb(instance.Domains),
Version: build.Version(),
}
}
@ -40,6 +42,7 @@ func InstanceDetailToPb(instance *query.Instance) *instance_pb.InstanceDetail {
Id: instance.InstanceID(),
Name: instance.Name,
Domains: DomainsToPb(instance.Domains),
Version: build.Version(),
}
}

View File

@ -184,10 +184,21 @@ service AdminService {
};
}
// Returns the domains of an instance
// Returns the details of the instance
rpc GetMyInstance(GetMyInstanceRequest) returns (GetMyInstanceResponse) {
option (google.api.http) = {
get: "/instances/me";
};
option (zitadel.v1.auth_option) = {
permission: "iam.read";
};
}
// Returns the domains of the instance
rpc ListInstanceDomains(ListInstanceDomainsRequest) returns (ListInstanceDomainsResponse) {
option (google.api.http) = {
get: "/domains";
post: "/domains/_search";
};
}
@ -2664,6 +2675,13 @@ message GetDefaultOrgResponse {
zitadel.org.v1.Org org = 1;
}
//This is an empty request
message GetMyInstanceRequest {}
message GetMyInstanceResponse {
zitadel.instance.v1.InstanceDetail instance = 1;
}
message ListInstanceDomainsRequest {
zitadel.v1.ListQuery query = 1;
// the field the result is sorted