syntax = "proto3";
package api;
option go_package = "github.com/brocaar/chirpstack-api/go/v3/as/external/api";
option java_package = "io.chirpstack.api.as.external.api";
import "google/api/annotations.proto";
import "google/protobuf/timestamp.proto";
import "google/protobuf/empty.proto";
import "as/external/api/user.proto";
// InternalService is the service providing API endpoints for internal usage.
service InternalService {
// Log in a user
rpc Login(LoginRequest) returns (LoginResponse) {
option(google.api.http) = {
post: "/api/internal/login"
body: "*"
};
}
// Get the current user's profile
rpc Profile(google.protobuf.Empty) returns (ProfileResponse) {
option(google.api.http) = {
get: "/api/internal/profile"
};
}
// Perform a global search.
rpc GlobalSearch(GlobalSearchRequest) returns (GlobalSearchResponse) {
option(google.api.http) = {
get: "/api/internal/search"
};
}
// CreateAPIKey creates the given API key.
rpc CreateAPIKey(CreateAPIKeyRequest) returns (CreateAPIKeyResponse) {
option(google.api.http) = {
post: "/api/internal/api-keys"
body: "*"
};
}
// DeleteAPIKey deletes the API key.
rpc DeleteAPIKey(DeleteAPIKeyRequest) returns (google.protobuf.Empty) {
option(google.api.http) = {
delete: "/api/internal/api-keys/{id}"
};
}
// ListAPIKeys lists the available API keys.
rpc ListAPIKeys(ListAPIKeysRequest) returns (ListAPIKeysResponse) {
option(google.api.http) = {
get: "/api/internal/api-keys"
};
}
// Get the global settings.
rpc Settings(google.protobuf.Empty) returns (SettingsResponse) {
option(google.api.http) = {
get: "/api/internal/settings"
};
}
// OpenID Connect login.
rpc OpenIDConnectLogin(OpenIDConnectLoginRequest) returns (OpenIDConnectLoginResponse) {
option(google.api.http) = {
get: "/api/internal/oidc/login"
};
}
// GetDevicesSummary returns an aggregated summary of the devices.
rpc GetDevicesSummary(GetDevicesSummaryRequest) returns (GetDevicesSummaryResponse) {
option(google.api.http) = {
get: "/api/internal/devices/summary"
};
}
// GetGatewaysSummary returns an aggregated summary of the gateways.
rpc GetGatewaysSummary(GetGatewaysSummaryRequest) returns (GetGatewaysSummaryResponse) {
option(google.api.http) = {
get: "/api/internal/gateways/summary"
};
}
}
message APIKey {
// API key ID.
// This value will be automatically generated on create.
string id = 1;
// Name.
string name = 2;
// Is global admin key.
bool is_admin = 3;
// Organization ID.
// In case this API key is to manage resources within a single organization
// set this to the ID of this organization.
int64 organization_id = 4 [json_name = "organizationID"];
// Application ID.
// In case the API key is to manage resources within an application, set
// this to the ID of this application.message
int64 application_id = 5 [json_name = "applicationID"];
}
message CreateAPIKeyRequest {
// The API key to create.
APIKey api_key = 1;
}
message CreateAPIKeyResponse {
// API key ID.
string id = 1;
// JWT token for this API Key.
string jwt_token = 2;
}
message DeleteAPIKeyRequest {
// API key ID.
string id = 1;
}
message ListAPIKeysRequest {
// Max number of items to return.
int64 limit = 1;
// Offset in the result-set (for pagination).
int64 offset = 2;
// Return only admin keys.
bool is_admin = 3;
// Filter on organization ID.
int64 organization_id = 4 [json_name = "organizationID"];
// Filter on application ID.
int64 application_id = 5 [json_name = "applicationID"];
}
message ListAPIKeysResponse {
// Total number of API keys.
int64 total_count = 1;
repeated APIKey result = 2;
}
// Defines an organization to which an user is associated.
message OrganizationLink {
// Organization ID.
int64 organization_id = 1 [json_name = "organizationID"];
// Organization name.
string organization_name = 2;
// User is admin within the context of this organization.
// There is no need to set the is_device_admin and is_gateway_admin flags.
bool is_admin = 3;
// User is able to modify device related resources (applications,
// device-profiles, devices, multicast-groups).
bool is_device_admin = 6;
// User is able to modify gateways.
bool is_gateway_admin = 7;
// Created at timestamp.
google.protobuf.Timestamp created_at = 4;
// Last update timestamp.
google.protobuf.Timestamp updated_at = 5;
}
message LoginRequest {
// Email of the user.
string email = 1;
// Password of the user.
string password = 2;
}
message LoginResponse {
// The JWT tag to be used to access chirpstack-application-server interfaces.
string jwt = 1;
}
message ProfileResponse {
// User object.
User user = 1;
// Organizations to which the user is associated.
repeated OrganizationLink organizations = 3;
}
message GlobalSearchRequest {
// Search query.
string search = 1;
// Max number of results to return.
int64 limit = 2;
// Offset offset of the result-set (for pagination).
int64 offset = 3;
}
message GlobalSearchResponse {
repeated GlobalSearchResult result = 1;
}
message GlobalSearchResult {
// Record kind.
string kind = 1;
// Search score.
float score = 2;
// Organization id.
int64 organization_id = 3 [json_name = "organizationID"];
// Organization name.
string organization_name = 4;
// Application id.
int64 application_id = 5 [json_name = "applicationID"];
// Application name.
string application_name = 6;
// Device DevEUI (hex encoded).
string device_dev_eui = 7 [json_name = "deviceDevEUI"];
// Device name.
string device_name = 8;
// Gateway MAC (hex encoded).
string gateway_mac = 9 [json_name = "gatewayMAC"];
// Gateway name.
string gateway_name = 10;
}
message SettingsResponse {
// Branding settings.
Branding branding = 2;
// OpenID Connect settings.
OpenIDConnect openid_connect = 3;
}
message Branding {
// Registration html.
string registration = 1;
// Footer html.
string footer = 2;
}
message OpenIDConnect {
// Enable OpenID Connect authentication.
bool enabled = 1;
// Login url.
string login_url = 2 [json_name = "loginURL"];
// Login label.
string login_label = 3;
// Logout url.
string logout_url = 4 [json_name = "logoutURL"];
}
message OpenIDConnectLoginRequest {
// OpenID Connect callback code.
string code = 1;
// OpenID Connect callback state.
string state = 2;
}
message OpenIDConnectLoginResponse {
// JWT token to use for authentication.
string jwt_token = 1;
}
message GetDevicesSummaryRequest {
// Organization ID.
int64 organization_id = 1 [json_name = "organizationID"];
}
message GetDevicesSummaryResponse {
// Active count.
uint32 active_count = 1;
// Inactive count.
uint32 inactive_count = 2;
// per data-rate count.
// Devices that have never been seen are excluded.
map<uint32, uint32> dr_count = 3;
// Never seen count.
uint32 never_seen_count = 4;
}
message GetGatewaysSummaryRequest {
// Organization ID.
int64 organization_id = 1 [json_name = "organizationID"];
}
message GetGatewaysSummaryResponse {
// Active count.
uint32 active_count = 1;
// Inactive count.
uint32 inactive_count = 2;
// Never seen count.
uint32 never_seen_count = 3;
}