mirror of
https://github.com/moghtech/komodo.git
synced 2026-04-29 04:10:01 -05:00
get available accounts
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
use anyhow::Context;
|
||||
use async_trait::async_trait;
|
||||
use monitor_types::{
|
||||
entities::{builder::{Builder, BuilderListItem}, PermissionLevel},
|
||||
entities::{
|
||||
builder::{Builder, BuilderListItem},
|
||||
PermissionLevel,
|
||||
},
|
||||
requests::read::*,
|
||||
};
|
||||
use mungos::mongodb::bson::doc;
|
||||
@@ -60,3 +63,14 @@ impl Resolve<GetBuildersSummary, RequestUser> for State {
|
||||
Ok(res)
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl Resolve<GetBuilderAvailableAccounts, RequestUser> for State {
|
||||
async fn resolve(
|
||||
&self,
|
||||
GetBuilderAvailableAccounts { id }: GetBuilderAvailableAccounts,
|
||||
user: RequestUser,
|
||||
) -> anyhow::Result<GetBuilderAvailableAccountsResponse> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ enum ReadRequest {
|
||||
GetDockerNetworks(GetDockerNetworks),
|
||||
GetServerActionState(GetServerActionState),
|
||||
GetHistoricalServerStats(GetHistoricalServerStats),
|
||||
GetAvailableAccounts(GetAvailableAccounts),
|
||||
GetServerAvailableAccounts(GetServerAvailableAccounts),
|
||||
GetAvailableNetworks(GetAvailableNetworks),
|
||||
|
||||
// ==== DEPLOYMENT ====
|
||||
@@ -83,6 +83,7 @@ enum ReadRequest {
|
||||
GetBuildersSummary(GetBuildersSummary),
|
||||
GetBuilder(GetBuilder),
|
||||
ListBuilders(ListBuilders),
|
||||
GetBuilderAvailableAccounts(GetBuilderAvailableAccounts),
|
||||
|
||||
// ==== ALERTER ====
|
||||
GetAlertersSummary(GetAlertersSummary),
|
||||
|
||||
@@ -405,21 +405,21 @@ impl Resolve<GetDockerContainers, RequestUser> for State {
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl Resolve<GetAvailableAccounts, RequestUser> for State {
|
||||
impl Resolve<GetServerAvailableAccounts, RequestUser> for State {
|
||||
async fn resolve(
|
||||
&self,
|
||||
GetAvailableAccounts { server_id }: GetAvailableAccounts,
|
||||
GetServerAvailableAccounts { id }: GetServerAvailableAccounts,
|
||||
user: RequestUser,
|
||||
) -> anyhow::Result<GetAvailableAccountsResponse> {
|
||||
) -> anyhow::Result<GetServerAvailableAccountsResponse> {
|
||||
let server: Server = self
|
||||
.get_resource_check_permissions(&server_id, &user, PermissionLevel::Read)
|
||||
.get_resource_check_permissions(&id, &user, PermissionLevel::Read)
|
||||
.await?;
|
||||
let GetAccountsResponse { github, docker } = self
|
||||
.periphery_client(&server)
|
||||
.request(requests::GetAccounts {})
|
||||
.await
|
||||
.context("failed to get accounts from periphery")?;
|
||||
let res = GetAvailableAccountsResponse { github, docker };
|
||||
let res = GetServerAvailableAccountsResponse { github, docker };
|
||||
Ok(res)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ export type ReadResponses = {
|
||||
GetDockerNetworks: Types.DockerNetwork[];
|
||||
GetServerActionState: Types.ServerActionState;
|
||||
GetHistoricalServerStats: Types.GetHistoricalServerStatsResponse;
|
||||
GetAvailableAccounts: Types.GetAvailableAccountsResponse;
|
||||
GetServerAvailableAccounts: Types.GetServerAvailableAccountsResponse;
|
||||
GetAvailableNetworks: Types.GetAvailableNetworksResponse;
|
||||
|
||||
// ==== DEPLOYMENT ====
|
||||
@@ -59,6 +59,7 @@ export type ReadResponses = {
|
||||
GetBuildersSummary: Types.GetBuildersSummaryResponse;
|
||||
GetBuilder: Types.Builder;
|
||||
ListBuilders: Types.BuilderListItem[];
|
||||
GetBuilderAvailableAccounts: Types.GetBuilderAvailableAccountsResponse;
|
||||
|
||||
// ==== ALERTER ====
|
||||
GetAlertersSummary: Types.GetAlertersSummaryResponse;
|
||||
|
||||
@@ -847,6 +847,15 @@ export interface GetBuildersSummaryResponse {
|
||||
total: number;
|
||||
}
|
||||
|
||||
export interface GetBuilderAvailableAccounts {
|
||||
id: string;
|
||||
}
|
||||
|
||||
export interface GetBuilderAvailableAccountsResponse {
|
||||
github: string[];
|
||||
docker: string[];
|
||||
}
|
||||
|
||||
export interface GetDeployment {
|
||||
id: string;
|
||||
}
|
||||
@@ -1038,11 +1047,11 @@ export interface GetServersSummaryResponse {
|
||||
disabled: I64;
|
||||
}
|
||||
|
||||
export interface GetAvailableAccounts {
|
||||
server_id: string;
|
||||
export interface GetServerAvailableAccounts {
|
||||
id: string;
|
||||
}
|
||||
|
||||
export interface GetAvailableAccountsResponse {
|
||||
export interface GetServerAvailableAccountsResponse {
|
||||
github: string[];
|
||||
docker: string[];
|
||||
}
|
||||
@@ -1351,7 +1360,7 @@ export type ReadRequest =
|
||||
| { type: "GetDockerNetworks", params: GetDockerNetworks }
|
||||
| { type: "GetServerActionState", params: GetServerActionState }
|
||||
| { type: "GetHistoricalServerStats", params: GetHistoricalServerStats }
|
||||
| { type: "GetAvailableAccounts", params: GetAvailableAccounts }
|
||||
| { type: "GetServerAvailableAccounts", params: GetServerAvailableAccounts }
|
||||
| { type: "GetAvailableNetworks", params: GetAvailableNetworks }
|
||||
| { type: "GetDeploymentsSummary", params: GetDeploymentsSummary }
|
||||
| { type: "GetDeployment", params: GetDeployment }
|
||||
@@ -1374,6 +1383,7 @@ export type ReadRequest =
|
||||
| { type: "GetBuildersSummary", params: GetBuildersSummary }
|
||||
| { type: "GetBuilder", params: GetBuilder }
|
||||
| { type: "ListBuilders", params: ListBuilders }
|
||||
| { type: "GetBuilderAvailableAccounts", params: GetBuilderAvailableAccounts }
|
||||
| { type: "GetAlertersSummary", params: GetAlertersSummary }
|
||||
| { type: "GetAlerter", params: GetAlerter }
|
||||
| { type: "ListAlerters", params: ListAlerters }
|
||||
|
||||
@@ -34,3 +34,19 @@ pub struct GetBuildersSummary {}
|
||||
pub struct GetBuildersSummaryResponse {
|
||||
pub total: u32,
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Request)]
|
||||
#[response(GetBuilderAvailableAccountsResponse)]
|
||||
pub struct GetBuilderAvailableAccounts {
|
||||
pub id: String,
|
||||
}
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
pub struct GetBuilderAvailableAccountsResponse {
|
||||
pub github: Vec<String>,
|
||||
pub docker: Vec<String>,
|
||||
}
|
||||
@@ -214,14 +214,14 @@ pub struct GetServersSummaryResponse {
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Request)]
|
||||
#[response(GetAvailableAccountsResponse)]
|
||||
pub struct GetAvailableAccounts {
|
||||
pub server_id: String,
|
||||
#[response(GetServerAvailableAccountsResponse)]
|
||||
pub struct GetServerAvailableAccounts {
|
||||
pub id: String,
|
||||
}
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
pub struct GetAvailableAccountsResponse {
|
||||
pub struct GetServerAvailableAccountsResponse {
|
||||
pub github: Vec<String>,
|
||||
pub docker: Vec<String>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user