发布 0.1.0:通知渠道、告警规则与多项体验修复
This commit is contained in:
+61
-48
@@ -14,6 +14,7 @@ import { mockOn, mocked, request } from './request'
|
||||
import type {
|
||||
AuditEventsResult,
|
||||
IamUser,
|
||||
IdentityDomain,
|
||||
IamUserDetail,
|
||||
IdentityProvider,
|
||||
IdentitySetting,
|
||||
@@ -83,14 +84,25 @@ export function getSubscription(id: number, subscriptionId: string): Promise<Sub
|
||||
return request(`/oci-configs/${id}/subscriptions/${subscriptionId}`)
|
||||
}
|
||||
|
||||
// ---- 身份域 ----
|
||||
/** 租户 ACTIVE 身份域列表;空数组表示无域老租户(隐藏选择器走经典路径) */
|
||||
export function listIdentityDomains(id: number): Promise<IdentityDomain[]> {
|
||||
if (mockOn)
|
||||
return mocked([
|
||||
{ id: 'ocid1.domain.default', displayName: 'Default', homeRegion: 'us-phoenix-1', type: 'DEFAULT', licenseType: 'free' },
|
||||
{ id: 'ocid1.domain.idcs', displayName: 'OracleIdentityCloudService', homeRegion: 'us-phoenix-1', type: 'SECONDARY', licenseType: 'idcs-foundation' },
|
||||
])
|
||||
return request(`/oci-configs/${id}/domains`)
|
||||
}
|
||||
|
||||
// ---- 用户 ----
|
||||
export function listUsers(id: number): Promise<IamUser[]> {
|
||||
export function listUsers(id: number, domainId?: string): Promise<IamUser[]> {
|
||||
if (mockOn) return mocked(mockUsers)
|
||||
return request(`/oci-configs/${id}/users`)
|
||||
return request(`/oci-configs/${id}/users`, { query: { domainId } })
|
||||
}
|
||||
|
||||
// 编辑表单预填充用;不在身份域的经典用户返回 inDomain: false
|
||||
export function getUserDetail(id: number, userId: string): Promise<IamUserDetail> {
|
||||
export function getUserDetail(id: number, userId: string, domainId?: string): Promise<IamUserDetail> {
|
||||
if (mockOn)
|
||||
return mocked(
|
||||
mockUserDetails[userId] ?? {
|
||||
@@ -101,7 +113,7 @@ export function getUserDetail(id: number, userId: string): Promise<IamUserDetail
|
||||
inAdminGroup: false,
|
||||
},
|
||||
)
|
||||
return request(`/oci-configs/${id}/users/${userId}`)
|
||||
return request(`/oci-configs/${id}/users/${userId}`, { query: { domainId } })
|
||||
}
|
||||
|
||||
export interface CreateUserBody {
|
||||
@@ -115,10 +127,10 @@ export interface CreateUserBody {
|
||||
addToAdminGroup?: boolean
|
||||
}
|
||||
|
||||
export function createUser(id: number, body: CreateUserBody): Promise<IamUser> {
|
||||
export function createUser(id: number, body: CreateUserBody, domainId?: string): Promise<IamUser> {
|
||||
if (mockOn)
|
||||
return mocked({ ...mockUsers[2], id: 'ocid1.user..new', name: body.name, email: body.email ?? '' })
|
||||
return request(`/oci-configs/${id}/users`, { method: 'POST', body })
|
||||
return request(`/oci-configs/${id}/users`, { method: 'POST', body, query: { domainId } })
|
||||
}
|
||||
|
||||
export interface UpdateUserBody {
|
||||
@@ -131,29 +143,29 @@ export interface UpdateUserBody {
|
||||
addToAdminGroup?: boolean
|
||||
}
|
||||
|
||||
export function updateUser(id: number, userId: string, body: UpdateUserBody): Promise<IamUser> {
|
||||
export function updateUser(id: number, userId: string, body: UpdateUserBody, domainId?: string): Promise<IamUser> {
|
||||
if (mockOn) {
|
||||
const u = mockUsers.find((x) => x.id === userId) ?? mockUsers[2]
|
||||
if (body.description !== undefined) u.description = body.description
|
||||
if (body.email !== undefined) u.email = body.email
|
||||
return mocked({ ...u })
|
||||
}
|
||||
return request(`/oci-configs/${id}/users/${userId}`, { method: 'PUT', body })
|
||||
return request(`/oci-configs/${id}/users/${userId}`, { method: 'PUT', body, query: { domainId } })
|
||||
}
|
||||
|
||||
export function deleteUser(id: number, userId: string): Promise<void> {
|
||||
export function deleteUser(id: number, userId: string, domainId?: string): Promise<void> {
|
||||
if (mockOn) return mocked(undefined)
|
||||
return request(`/oci-configs/${id}/users/${userId}`, { method: 'DELETE' })
|
||||
return request(`/oci-configs/${id}/users/${userId}`, { method: 'DELETE', query: { domainId } })
|
||||
}
|
||||
|
||||
export function resetUserPassword(id: number, userId: string): Promise<{ password: string }> {
|
||||
export function resetUserPassword(id: number, userId: string, domainId?: string): Promise<{ password: string }> {
|
||||
if (mockOn) return mocked({ password: 'Xy9#kQ2m$Lp8' })
|
||||
return request(`/oci-configs/${id}/users/${userId}/reset-password`, { method: 'POST' })
|
||||
return request(`/oci-configs/${id}/users/${userId}/reset-password`, { method: 'POST', query: { domainId } })
|
||||
}
|
||||
|
||||
export function clearUserMfa(id: number, userId: string): Promise<{ deletedTotpDevices: number }> {
|
||||
export function clearUserMfa(id: number, userId: string, domainId?: string): Promise<{ deletedTotpDevices: number }> {
|
||||
if (mockOn) return mocked({ deletedTotpDevices: 1 })
|
||||
return request(`/oci-configs/${id}/users/${userId}/mfa-devices`, { method: 'DELETE' })
|
||||
return request(`/oci-configs/${id}/users/${userId}/mfa-devices`, { method: 'DELETE', query: { domainId } })
|
||||
}
|
||||
|
||||
export function deleteUserApiKeys(
|
||||
@@ -169,26 +181,19 @@ export function deleteUserApiKeys(
|
||||
}
|
||||
|
||||
// ---- 审计日志 ----
|
||||
/** 实时查询租户 OCI 审计事件:hours ∈ [1,72] 首查;
|
||||
* 截断续查传上次响应的 start/end 与 nextPage(绝对窗+游标断点续翻) */
|
||||
/** 批式懒加载查询审计事件:cursor 空自当前时刻首查,
|
||||
* 非空从上次响应游标向更早续取一批(~100 条,服务端分窗回溯) */
|
||||
export function listAuditEvents(
|
||||
id: number,
|
||||
opts: { hours?: number; region?: string; start?: string; end?: string; page?: string } = {},
|
||||
opts: { region?: string; cursor?: string; limit?: number } = {},
|
||||
): Promise<AuditEventsResult> {
|
||||
// mock 下选 1 小时窗演示截断提示
|
||||
// mock:首批带游标,续查一批后到尽头,演示懒加载链路
|
||||
if (mockOn)
|
||||
return mocked(
|
||||
{
|
||||
items: mockAuditEvents,
|
||||
truncated: opts.hours === 1,
|
||||
start: '2026-07-06T10:00:00Z',
|
||||
end: '2026-07-07T10:00:00Z',
|
||||
},
|
||||
{ items: mockAuditEvents, cursor: opts.cursor ? undefined : 'mock-cursor', exhausted: !!opts.cursor },
|
||||
300,
|
||||
)
|
||||
const { hours = 24, region, start, end, page } = opts
|
||||
const query = start && end ? { region, start, end, page } : { hours, region }
|
||||
return request(`/oci-configs/${id}/audit-events`, { query })
|
||||
return request(`/oci-configs/${id}/audit-events`, { query: { ...opts } })
|
||||
}
|
||||
|
||||
/** 取回单条审计事件的原始 JSON;404 表示缓存过期且重查未找回(前端降级展示精简字段) */
|
||||
@@ -201,45 +206,49 @@ export function getAuditEventDetail(
|
||||
}
|
||||
|
||||
// ---- 域设置 ----
|
||||
export function getNotificationRecipients(id: number): Promise<NotificationRecipients> {
|
||||
export function getNotificationRecipients(id: number, domainId?: string): Promise<NotificationRecipients> {
|
||||
if (mockOn) return mocked(mockRecipients)
|
||||
return request(`/oci-configs/${id}/notification-recipients`)
|
||||
return request(`/oci-configs/${id}/notification-recipients`, { query: { domainId } })
|
||||
}
|
||||
|
||||
export function updateNotificationRecipients(
|
||||
id: number,
|
||||
recipients: string[],
|
||||
domainId?: string,
|
||||
): Promise<NotificationRecipients> {
|
||||
if (mockOn) return mocked({ recipients, testModeEnabled: recipients.length > 0 })
|
||||
return request(`/oci-configs/${id}/notification-recipients`, {
|
||||
method: 'PUT',
|
||||
body: { recipients },
|
||||
query: { domainId },
|
||||
})
|
||||
}
|
||||
|
||||
export function listPasswordPolicies(id: number): Promise<PasswordPolicy[]> {
|
||||
export function listPasswordPolicies(id: number, domainId?: string): Promise<PasswordPolicy[]> {
|
||||
if (mockOn) return mocked(mockPolicies)
|
||||
return request(`/oci-configs/${id}/password-policies`)
|
||||
return request(`/oci-configs/${id}/password-policies`, { query: { domainId } })
|
||||
}
|
||||
|
||||
export function updatePasswordPolicy(
|
||||
id: number,
|
||||
policyId: string,
|
||||
body: { passwordExpiresAfter?: number; minLength?: number; numPasswordsInHistory?: number },
|
||||
domainId?: string,
|
||||
): Promise<PasswordPolicy> {
|
||||
if (mockOn) return mocked({ ...mockPolicies[0], ...body })
|
||||
return request(`/oci-configs/${id}/password-policies/${policyId}`, { method: 'PUT', body })
|
||||
return request(`/oci-configs/${id}/password-policies/${policyId}`, { method: 'PUT', body, query: { domainId } })
|
||||
}
|
||||
|
||||
// ---- 身份设置 ----
|
||||
export function getIdentitySetting(id: number): Promise<IdentitySetting> {
|
||||
export function getIdentitySetting(id: number, domainId?: string): Promise<IdentitySetting> {
|
||||
if (mockOn) return mocked({ ...mockIdentitySetting })
|
||||
return request(`/oci-configs/${id}/identity-settings`)
|
||||
return request(`/oci-configs/${id}/identity-settings`, { query: { domainId } })
|
||||
}
|
||||
|
||||
export function updateIdentitySetting(
|
||||
id: number,
|
||||
primaryEmailRequired: boolean,
|
||||
domainId?: string,
|
||||
): Promise<IdentitySetting> {
|
||||
if (mockOn) {
|
||||
mockIdentitySetting.primaryEmailRequired = primaryEmailRequired
|
||||
@@ -248,10 +257,11 @@ export function updateIdentitySetting(
|
||||
return request(`/oci-configs/${id}/identity-settings`, {
|
||||
method: 'PUT',
|
||||
body: { primaryEmailRequired },
|
||||
query: { domainId },
|
||||
})
|
||||
}
|
||||
|
||||
export async function downloadSamlMetadata(id: number): Promise<void> {
|
||||
export async function downloadSamlMetadata(id: number, domainId?: string): Promise<void> {
|
||||
if (mockOn) {
|
||||
const blob = new Blob(['<mock-saml-metadata/>'], { type: 'application/xml' })
|
||||
triggerDownload(blob, 'oci-domain-saml-metadata.xml')
|
||||
@@ -259,7 +269,8 @@ export async function downloadSamlMetadata(id: number): Promise<void> {
|
||||
}
|
||||
const { useAuthStore } = await import('@/stores/auth')
|
||||
const auth = useAuthStore()
|
||||
const resp = await fetch(`/api/v1/oci-configs/${id}/saml-metadata`, {
|
||||
const qs = domainId ? `?domainId=${encodeURIComponent(domainId)}` : ''
|
||||
const resp = await fetch(`/api/v1/oci-configs/${id}/saml-metadata${qs}`, {
|
||||
headers: auth.token ? { Authorization: `Bearer ${auth.token}` } : {},
|
||||
})
|
||||
if (!resp.ok) throw new Error(`下载失败(${resp.status})`)
|
||||
@@ -293,7 +304,7 @@ export interface CreateIdpBody {
|
||||
jitMapEmail?: boolean
|
||||
}
|
||||
|
||||
export function createIdp(id: number, body: CreateIdpBody): Promise<IdentityProvider> {
|
||||
export function createIdp(id: number, body: CreateIdpBody, domainId?: string): Promise<IdentityProvider> {
|
||||
if (mockOn) {
|
||||
const created = {
|
||||
...mockIdps[1],
|
||||
@@ -304,41 +315,43 @@ export function createIdp(id: number, body: CreateIdpBody): Promise<IdentityProv
|
||||
mockIdps.push(created)
|
||||
return mocked(created, 900)
|
||||
}
|
||||
return request(`/oci-configs/${id}/identity-providers`, { method: 'POST', body })
|
||||
return request(`/oci-configs/${id}/identity-providers`, { method: 'POST', body, query: { domainId } })
|
||||
}
|
||||
|
||||
export function listIdps(id: number): Promise<IdentityProvider[]> {
|
||||
export function listIdps(id: number, domainId?: string): Promise<IdentityProvider[]> {
|
||||
if (mockOn) return mocked(mockIdps)
|
||||
return request(`/oci-configs/${id}/identity-providers`)
|
||||
return request(`/oci-configs/${id}/identity-providers`, { query: { domainId } })
|
||||
}
|
||||
|
||||
export function activateIdp(id: number, idpId: string, enabled: boolean): Promise<IdentityProvider> {
|
||||
export function activateIdp(id: number, idpId: string, enabled: boolean, domainId?: string): Promise<IdentityProvider> {
|
||||
if (mockOn) return mocked({ ...mockIdps[0], enabled })
|
||||
return request(`/oci-configs/${id}/identity-providers/${idpId}/activate`, {
|
||||
method: 'POST',
|
||||
body: { enabled },
|
||||
query: { domainId },
|
||||
})
|
||||
}
|
||||
|
||||
export function deleteIdp(id: number, idpId: string): Promise<void> {
|
||||
export function deleteIdp(id: number, idpId: string, domainId?: string): Promise<void> {
|
||||
if (mockOn) return mocked(undefined)
|
||||
return request(`/oci-configs/${id}/identity-providers/${idpId}`, { method: 'DELETE' })
|
||||
return request(`/oci-configs/${id}/identity-providers/${idpId}`, { method: 'DELETE', query: { domainId } })
|
||||
}
|
||||
|
||||
export function listSignOnRules(id: number): Promise<SignOnRule[]> {
|
||||
export function listSignOnRules(id: number, domainId?: string): Promise<SignOnRule[]> {
|
||||
if (mockOn) return mocked(mockSignOnRules)
|
||||
return request(`/oci-configs/${id}/sign-on-rules`)
|
||||
return request(`/oci-configs/${id}/sign-on-rules`, { query: { domainId } })
|
||||
}
|
||||
|
||||
export function createSignOnExemption(id: number, identityProviderId: string): Promise<SignOnRule> {
|
||||
export function createSignOnExemption(id: number, identityProviderId: string, domainId?: string): Promise<SignOnRule> {
|
||||
if (mockOn) return mocked(mockSignOnRules[0])
|
||||
return request(`/oci-configs/${id}/sign-on-exemptions`, {
|
||||
method: 'POST',
|
||||
body: { identityProviderId },
|
||||
query: { domainId },
|
||||
})
|
||||
}
|
||||
|
||||
export function deleteSignOnExemption(id: number, ruleId: string): Promise<void> {
|
||||
export function deleteSignOnExemption(id: number, ruleId: string, domainId?: string): Promise<void> {
|
||||
if (mockOn) return mocked(undefined)
|
||||
return request(`/oci-configs/${id}/sign-on-exemptions/${ruleId}`, { method: 'DELETE' })
|
||||
return request(`/oci-configs/${id}/sign-on-exemptions/${ruleId}`, { method: 'DELETE', query: { domainId } })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user