Skip to content

Repository files navigation

metalstack.cloud api

Releasego.dev referenceGitHub go.mod Go versionGitHub release (latest SemVer)Go Report Card

This is the API of metalstack.cloud.

Usage examples

Can be found in the examples folder.

Conventions

Method options provide an intuitve and declarative way of providing annotations to service methods. These are used for scoping api-methods, which are getting utilized for authentication, authorization, auditing and payment (mainly in interceptors).

Motivational Example

serviceIPService {
// Get a iprpcGet(IPServiceGetRequest) returns (IPServiceGetResponse) {
option(project_roles)=PROJECT_ROLE_OWNER;
option(project_roles)=PROJECT_ROLE_EDITOR;
option(project_roles)=PROJECT_ROLE_VIEWER;
option(auditing)=AUDITING_EXCLUDED;
}
// Allocate a iprpcAllocate(IPServiceAllocateRequest) returns (IPServiceAllocateResponse) {
option(project_roles)=PROJECT_ROLE_OWNER;
option(project_roles)=PROJECT_ROLE_EDITOR;
option(chargeable)=CHARGEABLE_TRUE;
}
}
messageIPServiceAllocateRequest {
stringproject=2 [(buf.validate.field).string = {
min_len: 2max_len: 128
}];
stringname=3 [(buf.validate.field).string = {
min_len: 2max_len: 128
}];
stringdescription=4 [(buf.validate.field).string = {max_len: 128}];
repeatedstringtags=8 [(buf.validate.field).repeated.max_items = 100];
boolstatic=9;
}

In this example we can see the motivation behind the method options.

  1. Get: can be issued by project owner, editor, viewer and is excluded from auditing
  2. Allocate: can be used by project owner, editor and is an service-method which requires deposited payment information
  3. Both methods are project-scoped, since they are annotated by a project role -> Request object needs to have the project field in order to specify the target project of the service method

Further explanations are explained in the following:

Auth

These options specify the RBAC of the api-endpoint.

OptionDescriptionValuesExplanation
TENANT_ROLE_Specifies the required tenant roleUNSPECIFIED
OWNERtenant owner
EDITORtenant editor
VIEWERtenant viewer
GUESTtenant guest
PROJECT_ROLE_Specifies the required project roleUNSPECIFIED
OWNERproject owner
EDITORproject editor
VIEWERproject viewer
ADMIN_ROLE_Specifies the required admin roleUNSPECIFIED
EDITORadmin editor
VIEWERadmin viewer
VISIBILITY_Specifies the visibility of the api-endpointUNSPECIFIED
PUBLICapi-method is visible to public, a token is not needed
SELFapi-method is scoped to owner resources

Important

Every operation needs at least an option, which references the scope of the request: ROLE or VISIBILITY

Caution

If we use a Tenant or Project role, the request will be respectively scoped as Tenant or Project request. Tenant-Requests must have the field login, which is the tenant id and specifies the tenant on which the service-method is scoped. Project-Requests must have the field project, which is the project id and specifies the project on which the service-method is scoped.

Payment

Some api-methods are associated with payment and will result in costs. In order to use these kind of operations the user must have deposited its payment information. If the payment information are not deposited the user is not allowed to issue these actions.

OptionDescriptionValuesExplanation
CHARGEABLE_Specifies if the api-endpoint is chargeableUNSPECIFIED
TRUEapi-method is associated with payment and requires deposited payment infos
FALSEapi-method is not associated with payment

Auditing

For traceability we require to store audit-logs.

OptionDescriptionValuesExplanation
AUDITING_Specifies if the api-endpoint is auditedUNSPECIFIEDDEFAULT: included
INCLUDEDoperation is audited
EXCLUDEDoperation is not audited

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

5 watching

Forks

Releases

Packages

Used by

Contributors

Languages