feat(delivery): refine base service integrations
This commit is contained in:
@@ -14,6 +14,11 @@ export interface WayneNamespace {
|
||||
kubeNamespace: string
|
||||
}
|
||||
|
||||
export interface SinaOrganization {
|
||||
id: string
|
||||
name: string
|
||||
}
|
||||
|
||||
export const businessLineApi = {
|
||||
async listMine(): Promise<BusinessLine[]> {
|
||||
const token = getToken()
|
||||
@@ -87,6 +92,28 @@ export const businessLineApi = {
|
||||
body: JSON.stringify({ namespaces }),
|
||||
})
|
||||
},
|
||||
|
||||
async listSinaOrganizations(businessLineId: number, keyword = ''): Promise<SinaOrganization[]> {
|
||||
const params = new URLSearchParams()
|
||||
if (keyword.trim()) {
|
||||
params.set('keyword', keyword.trim())
|
||||
}
|
||||
const suffix = params.toString() ? `?${params.toString()}` : ''
|
||||
const data = await request(`/auth/api/v1/business-lines/${businessLineId}/sina-organizations${suffix}`)
|
||||
return Array.isArray(data.items) ? data.items : []
|
||||
},
|
||||
|
||||
async listMappedSinaOrganizations(businessLineId: number): Promise<SinaOrganization[]> {
|
||||
const data = await request(`/auth/api/v1/business-lines/${businessLineId}/sina-organization-mappings`)
|
||||
return Array.isArray(data.items) ? data.items : []
|
||||
},
|
||||
|
||||
async replaceMappedSinaOrganizations(businessLineId: number, organizations: SinaOrganization[]): Promise<void> {
|
||||
await request(`/auth/api/v1/business-lines/${businessLineId}/sina-organization-mappings`, {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify({ organizations }),
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
async function request(path: string, init: RequestInit = {}) {
|
||||
|
||||
@@ -66,6 +66,7 @@ export interface DeliveryTask {
|
||||
updated_at: string
|
||||
started_at?: string
|
||||
finished_at?: string
|
||||
credential_available?: boolean
|
||||
}
|
||||
|
||||
export interface TaskEvent {
|
||||
@@ -85,8 +86,12 @@ export interface DeliveryTaskSnapshot {
|
||||
}
|
||||
|
||||
export interface DeploymentCredential {
|
||||
username: string
|
||||
service: string
|
||||
instance_name: string
|
||||
host: string
|
||||
port: number
|
||||
username: string
|
||||
account_host: string
|
||||
password: string
|
||||
}
|
||||
|
||||
@@ -109,8 +114,13 @@ export const deliveryApi = {
|
||||
return Array.isArray(data.items) ? data.items : []
|
||||
},
|
||||
|
||||
async listTargetMountPaths(targetId: number, host: string): Promise<DeliveryMountPath[]> {
|
||||
const data = await authRequest(`/auth/api/v1/delivery/targets/${targetId}/hosts/${encodeURIComponent(host)}/mount-paths`)
|
||||
async listTargetMountPaths(targetId: number, host: string, prefix = ''): Promise<DeliveryMountPath[]> {
|
||||
const search = new URLSearchParams()
|
||||
if (prefix) search.set('prefix', prefix)
|
||||
const query = search.toString()
|
||||
const data = await authRequest(
|
||||
`/auth/api/v1/delivery/targets/${targetId}/hosts/${encodeURIComponent(host)}/mount-paths${query ? `?${query}` : ''}`,
|
||||
)
|
||||
return Array.isArray(data.items) ? data.items : []
|
||||
},
|
||||
|
||||
|
||||
@@ -46,13 +46,13 @@ export interface MachineResourceList {
|
||||
export interface MachineResourceQuery {
|
||||
page: number
|
||||
size: number
|
||||
businessLineId?: number
|
||||
hostname?: string
|
||||
assetNumber?: string
|
||||
type?: string
|
||||
location?: string
|
||||
ip?: string
|
||||
spec?: string
|
||||
businessLine?: string
|
||||
source?: string
|
||||
status?: string
|
||||
}
|
||||
@@ -83,21 +83,24 @@ export const emptyMachineOverview: MachineOverview = {
|
||||
}
|
||||
|
||||
export const machineApi = {
|
||||
async getOverview(): Promise<MachineOverview> {
|
||||
return authRequest('/auth/api/v1/machines/overview')
|
||||
async getOverview(businessLineId?: number): Promise<MachineOverview> {
|
||||
const params = new URLSearchParams()
|
||||
if (businessLineId) params.set('business_line_id', String(businessLineId))
|
||||
const suffix = params.toString() ? `?${params.toString()}` : ''
|
||||
return authRequest(`/auth/api/v1/machines/overview${suffix}`)
|
||||
},
|
||||
|
||||
async listResources(query: MachineResourceQuery): Promise<MachineResourceList> {
|
||||
const params = new URLSearchParams()
|
||||
params.set('page', String(query.page))
|
||||
params.set('size', String(query.size))
|
||||
if (query.businessLineId) params.set('business_line_id', String(query.businessLineId))
|
||||
if (query.hostname) params.set('hostname', query.hostname)
|
||||
if (query.assetNumber) params.set('assetNumber', query.assetNumber)
|
||||
if (query.type) params.set('type', query.type)
|
||||
if (query.location) params.set('location', query.location)
|
||||
if (query.ip) params.set('ip', query.ip)
|
||||
if (query.spec) params.set('spec', query.spec)
|
||||
if (query.businessLine) params.set('businessLine', query.businessLine)
|
||||
if (query.source) params.set('source', query.source)
|
||||
if (query.status) params.set('status', query.status)
|
||||
const data = await authRequest(`/auth/api/v1/machines/resources?${params.toString()}`)
|
||||
|
||||
Reference in New Issue
Block a user