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";
option java_multiple_files = true;
option java_outer_classname = "OrganizationProto";
import "google/api/annotations.proto";
import "google/protobuf/timestamp.proto";
import "google/protobuf/empty.proto";
// OrganizationService is the service managing the organization access.
service OrganizationService {
// Get organization list.
rpc List(ListOrganizationRequest) returns (ListOrganizationResponse) {
option(google.api.http) = {
get: "/api/organizations"
};
}
// Get data for a particular organization.
rpc Get(GetOrganizationRequest) returns (GetOrganizationResponse) {
option(google.api.http) = {
get: "/api/organizations/{id}"
};
}
// Create a new organization.
rpc Create(CreateOrganizationRequest) returns (CreateOrganizationResponse) {
option(google.api.http) = {
post: "/api/organizations"
body: "*"
};
}
// Update an existing organization.
rpc Update(UpdateOrganizationRequest) returns (google.protobuf.Empty) {
option(google.api.http) = {
put: "/api/organizations/{organization.id}"
body: "*"
};
}
// Delete an organization.
rpc Delete(DeleteOrganizationRequest) returns (google.protobuf.Empty) {
option(google.api.http) = {
delete: "/api/organizations/{id}"
};
}
// Get organization's user list.
rpc ListUsers(ListOrganizationUsersRequest) returns (ListOrganizationUsersResponse) {
option(google.api.http) = {
get: "/api/organizations/{organization_id}/users"
};
}
// Get data for a particular organization user.
rpc GetUser(GetOrganizationUserRequest) returns (GetOrganizationUserResponse) {
option(google.api.http) = {
get: "/api/organizations/{organization_id}/users/{user_id}"
};
}
// Add a new user to an organization. The user is matched based on email, not user id.
rpc AddUser(AddOrganizationUserRequest) returns (google.protobuf.Empty) {
option(google.api.http) = {
post: "/api/organizations/{organization_user.organization_id}/users"
body: "*"
};
}
// Update a user in an organization.
rpc UpdateUser(UpdateOrganizationUserRequest) returns (google.protobuf.Empty) {
option(google.api.http) = {
put: "/api/organizations/{organization_user.organization_id}/users/{organization_user.user_id}"
body: "*"
};
}
// Delete a user from an organization.
rpc DeleteUser(DeleteOrganizationUserRequest) returns (google.protobuf.Empty) {
option(google.api.http) = {
delete: "/api/organizations/{organization_id}/users/{user_id}"
};
}
}
message Organization {
// Organization ID.
int64 id = 1;
// Organization name.
string name = 2;
// Organization display name.
string display_name = 3;
// Can the organization create and "own" Gateways?
bool can_have_gateways = 4;
// Max. gateway count for organization.
// When set to 0, the organization can have unlimited gateways.
uint32 max_gateway_count = 5;
// Max. device count for organization.
// When set to 0, the organization can have unlimited devices.
uint32 max_device_count = 6;
}
message OrganizationListItem {
// Organization ID.
int64 id = 1;
// Organization name.
string name = 2;
// Organization display name.
string display_name = 3;
// Can the organization create and "own" Gateways?
bool can_have_gateways = 4;
// Created at timestamp.
google.protobuf.Timestamp created_at = 5;
// Last update timestamp.
google.protobuf.Timestamp updated_at = 6;
}
message GetOrganizationRequest {
// Organization ID.
int64 id = 1;
}
message GetOrganizationResponse {
// Organization object.
Organization organization = 1;
// Created at timestamp.
google.protobuf.Timestamp created_at = 2;
// Last update timestamp.
google.protobuf.Timestamp updated_at = 3;
}
message CreateOrganizationRequest {
// Organization object to create.
Organization organization = 1;
}
message CreateOrganizationResponse {
// Organization ID.
int64 id = 1;
}
message UpdateOrganizationRequest {
// Organization object to update.
Organization organization = 1;
}
message DeleteOrganizationRequest {
// Organization ID.
int64 id = 1;
}
message ListOrganizationRequest {
// Max number of organizations to return in the result-set.
int64 limit = 1;
// Offset in the result-set (for pagination).
int64 offset = 2;
// When provided, the given string will be used to search on
// displayName.
string search = 3;
}
message ListOrganizationResponse {
// Total number of organizations.
int64 total_count = 1;
repeated OrganizationListItem result = 2;
}
message OrganizationUser {
// Organization ID.
int64 organization_id = 1 [json_name = "organizationID"];
// User ID.
int64 user_id = 2 [json_name = "userID"];
// User is admin within the context of the 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 = 5;
// User is able to modify gateways.
bool is_gateway_admin = 6;
// Email (only used on get and when adding a user to an organization).
string email = 4;
}
message OrganizationUserListItem {
// User ID.
// This is not used on create, you must set the user email address
// associated with the user to add an user to an organization.
int64 user_id = 1 [json_name = "userID"];
// Email.
string email = 2;
// User is admin within the context of the 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 AddOrganizationUserRequest {
// Organization-user object to create.
OrganizationUser organization_user = 1;
}
message UpdateOrganizationUserRequest {
// Organization-user object to update.
OrganizationUser organization_user = 1;
}
message DeleteOrganizationUserRequest {
// Organization ID.
int64 organization_id = 1 [json_name = "organizationID"];
// User ID.
int64 user_id = 2 [json_name = "userID"];
}
message ListOrganizationUsersRequest {
// Organization ID.
int64 organization_id = 1 [json_name = "organizationID"];
// Max number of users to return in the result-set.
int32 limit = 2;
// Offset in the result-set (for pagination).
int32 offset = 3;
}
message ListOrganizationUsersResponse {
// The total number of users in the organization.
int64 total_count = 1;
repeated OrganizationUserListItem result = 2;
}
message GetOrganizationUserRequest {
// Organization ID.
int64 organization_id = 1 [json_name = "organizationID"];
// User ID.
int64 user_id = 2 [json_name = "userID"];
}
// Response for a user in the organization
message GetOrganizationUserResponse {
// Organization-user object.
OrganizationUser organization_user = 1;
// Created at timestamp.
google.protobuf.Timestamp created_at = 2;
// Last update timestamp.
google.protobuf.Timestamp updated_at = 3;
}