feat: Add UpdateInstance endpoint (#9452)

This commit is contained in:
Marco Ardizzone
2025-04-24 18:05:11 +02:00
parent da11910ba9
commit a9258b92e4
2 changed files with 61 additions and 1 deletions

View File

@@ -25,3 +25,19 @@ func (s *Server) DeleteInstance(ctx context.Context, request *instance.DeleteIns
}, nil }, nil
} }
func (s *Server) UpdateInstance(ctx context.Context, request *instance.UpdateInstanceRequest) (*instance.UpdateInstanceResponse, error) {
instanceName := strings.TrimSpace(request.GetInstanceName())
if instanceName == "" {
return nil, zerrors.ThrowInvalidArgument(nil, "instance_name", "instance name must not be empty")
}
obj, err := s.command.UpdateInstance(ctx, instanceName)
if err != nil {
return nil, err
}
return &instance.UpdateInstanceResponse{
Details: object.DomainToDetailsPb(obj),
}, nil
}

View File

@@ -121,6 +121,22 @@ message GetInstanceResponse {
zitadel.instance.v2.Instance instance = 1; zitadel.instance.v2.Instance instance = 1;
} }
message UpdateInstanceRequest {
string instance_name = 1 [
(validate.rules).string = {min_len: 1, max_len: 200},
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
min_length: 1;
max_length: 200;
description: "\"name of the instance to update\"";
example: "\"my instance\"";
}
];
}
message UpdateInstanceResponse {
zitadel.object.v2.Details details = 1;
}
service InstanceService { service InstanceService {
// DeleteInstance deletes an instance with the given ID. // DeleteInstance deletes an instance with the given ID.
@@ -184,11 +200,39 @@ service InstanceService {
}; };
} }
// UpdateInstance updates the current instance with the given name.
rpc UpdateInstance(UpdateInstanceRequest) returns (UpdateInstanceResponse) {
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
description: "Updates the current instance with the given name.";
tags: "Instance";
responses: {
key: "200";
value: {
description: "The updated instance.";
schema: {
json_schema: {
ref: "#/definitions/UpdateInstanceResponse";
}
};
}
};
};
option (google.api.http) = {
put: "/v2/instances/current"
body: "*"
};
option (zitadel.protoc_gen_zitadel.v2.options) = {
auth_option: {
permission: "instance.update"
}
};
}
} }
// UpdateInstance // UpdateInstance
// ListInstances // ListInstances
// DeleteInstance
// Add Custom Domain // Add Custom Domain
// Remove Custom Domain // Remove Custom Domain