mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-15 16:52:38 +00:00
Update ST V3 to machine identity
This commit is contained in:
@@ -16,9 +16,9 @@ export const eventToNameMap: { [K in EventType]: string } = {
|
||||
[EventType.DELETE_TRUSTED_IP]: "Delete trusted IP",
|
||||
[EventType.CREATE_SERVICE_TOKEN]: "Create service token",
|
||||
[EventType.DELETE_SERVICE_TOKEN]: "Delete service token",
|
||||
[EventType.CREATE_SERVICE_TOKEN_V3]: "Create (new) service token",
|
||||
[EventType.UPDATE_SERVICE_TOKEN_V3]: "Update (new) service token",
|
||||
[EventType.DELETE_SERVICE_TOKEN_V3]: "Delete (new) service token",
|
||||
[EventType.CREATE_MACHINE_IDENTITY]: "Create machine identity",
|
||||
[EventType.UPDATE_MACHINE_IDENTITY]: "Update machine identity",
|
||||
[EventType.DELETE_MACHINE_IDENTITY]: "Delete machine identity",
|
||||
[EventType.CREATE_ENVIRONMENT]: "Create environment",
|
||||
[EventType.UPDATE_ENVIRONMENT]: "Update environment",
|
||||
[EventType.DELETE_ENVIRONMENT]: "Delete environment",
|
||||
|
||||
@@ -27,9 +27,9 @@ export enum EventType {
|
||||
DELETE_TRUSTED_IP = "delete-trusted-ip",
|
||||
CREATE_SERVICE_TOKEN = "create-service-token", // v2
|
||||
DELETE_SERVICE_TOKEN = "delete-service-token", // v2
|
||||
CREATE_SERVICE_TOKEN_V3 = "create-service-token-v3", // v3
|
||||
UPDATE_SERVICE_TOKEN_V3 = "update-service-token-v3", // v3
|
||||
DELETE_SERVICE_TOKEN_V3 = "delete-service-token-v3", // v3
|
||||
CREATE_MACHINE_IDENTITY = "create-machine-identity",
|
||||
UPDATE_MACHINE_IDENTITY = "update-machine-identity",
|
||||
DELETE_MACHINE_IDENTITY = "delete-machine-identity",
|
||||
CREATE_ENVIRONMENT = "create-environment",
|
||||
UPDATE_ENVIRONMENT = "update-environment",
|
||||
DELETE_ENVIRONMENT = "delete-environment",
|
||||
|
||||
@@ -188,8 +188,8 @@ interface DeleteServiceTokenEvent {
|
||||
};
|
||||
}
|
||||
|
||||
interface CreateServiceTokenV3Event {
|
||||
type: EventType.CREATE_SERVICE_TOKEN_V3;
|
||||
interface CreateMachineIdentityEvent {
|
||||
type: EventType.CREATE_MACHINE_IDENTITY;
|
||||
metadata: {
|
||||
name: string;
|
||||
isActive: boolean;
|
||||
@@ -198,8 +198,8 @@ interface CreateServiceTokenV3Event {
|
||||
}
|
||||
}
|
||||
|
||||
interface UpdateServiceTokenV3Event {
|
||||
type: EventType.UPDATE_SERVICE_TOKEN_V3;
|
||||
interface UpdateMachineIdentityEvent {
|
||||
type: EventType.UPDATE_MACHINE_IDENTITY;
|
||||
metadata: {
|
||||
name?: string;
|
||||
isActive?: boolean;
|
||||
@@ -208,8 +208,8 @@ interface UpdateServiceTokenV3Event {
|
||||
}
|
||||
}
|
||||
|
||||
interface DeleteServiceTokenV3Event {
|
||||
type: EventType.DELETE_SERVICE_TOKEN_V3;
|
||||
interface DeleteMachineIdentityEvent {
|
||||
type: EventType.DELETE_MACHINE_IDENTITY;
|
||||
metadata: {
|
||||
name: string;
|
||||
isActive: boolean;
|
||||
@@ -414,9 +414,9 @@ export type Event =
|
||||
| DeleteTrustedIPEvent
|
||||
| CreateServiceTokenEvent
|
||||
| DeleteServiceTokenEvent
|
||||
| CreateServiceTokenV3Event
|
||||
| UpdateServiceTokenV3Event
|
||||
| DeleteServiceTokenV3Event
|
||||
| CreateMachineIdentityEvent
|
||||
| UpdateMachineIdentityEvent
|
||||
| DeleteMachineIdentityEvent
|
||||
| CreateEnvironmentEvent
|
||||
| UpdateEnvironmentEvent
|
||||
| DeleteEnvironmentEvent
|
||||
|
||||
@@ -7,6 +7,7 @@ export * from "./incidentContacts";
|
||||
export * from "./integrationAuth";
|
||||
export * from "./integrations";
|
||||
export * from "./keys";
|
||||
export * from "./machineIdentities";
|
||||
export * from "./organization";
|
||||
export * from "./roles";
|
||||
export * from "./secretApproval";
|
||||
@@ -24,4 +25,4 @@ export * from "./tags";
|
||||
export * from "./trustedIps";
|
||||
export * from "./users";
|
||||
export * from "./webhooks";
|
||||
export * from "./workspace";
|
||||
export * from "./workspace";
|
||||
@@ -0,0 +1,4 @@
|
||||
export {
|
||||
useCreateMachineIdentity,
|
||||
useDeleteMachineIdentity,
|
||||
useUpdateMachineIdentity} from "./mutations";
|
||||
@@ -0,0 +1,71 @@
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
|
||||
import { apiRequest } from "@app/config/request";
|
||||
|
||||
import { organizationKeys } from "../organization/queries";
|
||||
import {
|
||||
CreateMachineIdentityDTO,
|
||||
CreateMachineIdentityRes,
|
||||
DeleteMachineIdentityDTO,
|
||||
MachineIdentity,
|
||||
UpdateMachineIdentityDTO} from "./types";
|
||||
|
||||
export const useCreateMachineIdentity = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<CreateMachineIdentityRes, {}, CreateMachineIdentityDTO>({
|
||||
mutationFn: async (body) => {
|
||||
const { data } = await apiRequest.post("/api/v3/machines/", body);
|
||||
return data;
|
||||
},
|
||||
onSuccess: ({ machineIdentity }) => {
|
||||
queryClient.invalidateQueries(organizationKeys.getOrgServiceMemberships(machineIdentity.organization));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useUpdateMachineIdentity = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<MachineIdentity, {}, UpdateMachineIdentityDTO>({
|
||||
mutationFn: async ({
|
||||
machineId,
|
||||
name,
|
||||
role,
|
||||
isActive,
|
||||
trustedIps,
|
||||
expiresIn,
|
||||
accessTokenTTL,
|
||||
isRefreshTokenRotationEnabled
|
||||
}) => {
|
||||
|
||||
const { data: { machineIdentity } } = await apiRequest.patch(`/api/v3/machines/${machineId}`, {
|
||||
name,
|
||||
role,
|
||||
isActive,
|
||||
trustedIps,
|
||||
expiresIn,
|
||||
accessTokenTTL,
|
||||
isRefreshTokenRotationEnabled
|
||||
});
|
||||
|
||||
return machineIdentity;
|
||||
},
|
||||
onSuccess: ({ organization }) => {
|
||||
queryClient.invalidateQueries(organizationKeys.getOrgServiceMemberships(organization));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useDeleteMachineIdentity = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<MachineIdentity, {}, DeleteMachineIdentityDTO>({
|
||||
mutationFn: async ({
|
||||
machineId
|
||||
}) => {
|
||||
const { data: { machineIdentity } } = await apiRequest.delete(`/api/v3/machines/${machineId}`);
|
||||
return machineIdentity;
|
||||
},
|
||||
onSuccess: ({ organization }) => {
|
||||
queryClient.invalidateQueries(organizationKeys.getOrgServiceMemberships(organization));
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,79 @@
|
||||
import { TRole } from "../roles/types";
|
||||
|
||||
export type MachineTrustedIp = {
|
||||
_id: string;
|
||||
ipAddress: string;
|
||||
type: "ipv4" | "ipv6";
|
||||
prefix?: number;
|
||||
}
|
||||
|
||||
export type MachineIdentity = {
|
||||
_id: string;
|
||||
name: string;
|
||||
organization: string;
|
||||
isActive: boolean;
|
||||
refreshTokenLastUsed?: string;
|
||||
accessTokenLastUsed?: string;
|
||||
refreshTokenUsageCount: number;
|
||||
accessTokenUsageCount: number;
|
||||
trustedIps: MachineTrustedIp[];
|
||||
expiresAt?: string;
|
||||
accessTokenTTL: number;
|
||||
isRefreshTokenRotationEnabled: boolean;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
};
|
||||
|
||||
export type MachineMembershipOrg = {
|
||||
_id: string;
|
||||
machineIdentity: MachineIdentity;
|
||||
organization: string;
|
||||
role: "admin" | "member" | "viewer" | "custom";
|
||||
customRole?: TRole;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export type MachineMembership = {
|
||||
_id: string;
|
||||
machineIdentity: MachineIdentity;
|
||||
organization: string;
|
||||
role: "admin" | "member" | "viewer" | "custom";
|
||||
customRole?: TRole;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export type CreateMachineIdentityDTO = {
|
||||
name: string;
|
||||
organizationId: string;
|
||||
role?: string;
|
||||
trustedIps: {
|
||||
ipAddress: string;
|
||||
}[];
|
||||
expiresIn?: number;
|
||||
accessTokenTTL: number;
|
||||
isRefreshTokenRotationEnabled: boolean;
|
||||
}
|
||||
|
||||
export type CreateMachineIdentityRes = {
|
||||
refreshToken: string;
|
||||
machineIdentity: MachineIdentity;
|
||||
}
|
||||
|
||||
export type UpdateMachineIdentityDTO = {
|
||||
machineId: string;
|
||||
isActive?: boolean;
|
||||
name?: string;
|
||||
role?: string;
|
||||
trustedIps?: {
|
||||
ipAddress: string;
|
||||
}[];
|
||||
expiresIn?: number;
|
||||
accessTokenTTL?: number;
|
||||
isRefreshTokenRotationEnabled?: boolean;
|
||||
}
|
||||
|
||||
export type DeleteMachineIdentityDTO = {
|
||||
machineId: string;
|
||||
}
|
||||
@@ -6,6 +6,7 @@ export {
|
||||
useDeleteOrgById,
|
||||
useDeleteOrgPmtMethod,
|
||||
useDeleteOrgTaxId,
|
||||
useGetMachineMembershipOrgs,
|
||||
useGetOrganizations,
|
||||
useGetOrgBillingDetails,
|
||||
useGetOrgInvoices,
|
||||
@@ -14,7 +15,6 @@ export {
|
||||
useGetOrgPlansTable,
|
||||
useGetOrgPlanTable,
|
||||
useGetOrgPmtMethods,
|
||||
useGetOrgServiceMemberships,
|
||||
useGetOrgTaxIds,
|
||||
useGetOrgTrialUrl,
|
||||
useRenameOrg,
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
|
||||
import { apiRequest } from "@app/config/request";
|
||||
|
||||
import { ServiceMembershipOrg } from "../serviceTokens/types";
|
||||
import { MachineMembershipOrg } from "../machineIdentities/types";
|
||||
import {
|
||||
BillingDetails,
|
||||
Invoice,
|
||||
@@ -351,17 +351,17 @@ export const useGetOrgLicenses = (organizationId: string) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const useGetOrgServiceMemberships = (organizationId: string) => {
|
||||
export const useGetMachineMembershipOrgs = (organizationId: string) => {
|
||||
return useQuery({
|
||||
queryKey: organizationKeys.getOrgServiceMemberships(organizationId),
|
||||
queryFn: async () => {
|
||||
const {
|
||||
data: { serviceMemberships }
|
||||
} = await apiRequest.get<{ serviceMemberships: ServiceMembershipOrg[] }>(
|
||||
`/api/v2/organizations/${organizationId}/service-memberships`
|
||||
data: { machineMemberships }
|
||||
} = await apiRequest.get<{ machineMemberships: MachineMembershipOrg[] }>(
|
||||
`/api/v2/organizations/${organizationId}/machine-memberships`
|
||||
);
|
||||
|
||||
return serviceMemberships;
|
||||
return machineMemberships;
|
||||
},
|
||||
enabled: true
|
||||
});
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
export {
|
||||
useCreateServiceToken,
|
||||
useCreateServiceTokenV3,
|
||||
useDeleteServiceToken,
|
||||
useDeleteServiceTokenV3,
|
||||
useGetUserWsServiceTokens,
|
||||
useUpdateServiceTokenV3
|
||||
} from "./queries";
|
||||
|
||||
@@ -2,17 +2,12 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
|
||||
import { apiRequest } from "@app/config/request";
|
||||
|
||||
import { organizationKeys } from "../organization/queries";
|
||||
import {
|
||||
CreateServiceTokenDataV3DTO,
|
||||
CreateServiceTokenDataV3Res,
|
||||
CreateServiceTokenDTO,
|
||||
CreateServiceTokenRes,
|
||||
DeleteServiceTokenDataV3DTO,
|
||||
DeleteServiceTokenRes,
|
||||
ServiceToken,
|
||||
ServiceTokenDataV3,
|
||||
UpdateServiceTokenDataV3DTO} from "./types";
|
||||
ServiceToken
|
||||
} from "./types";
|
||||
|
||||
const serviceTokenKeys = {
|
||||
getAllWorkspaceServiceToken: (workspaceID: string) => [{ workspaceID }, "service-tokens"] as const
|
||||
@@ -64,63 +59,4 @@ export const useDeleteServiceToken = () => {
|
||||
queryClient.invalidateQueries(serviceTokenKeys.getAllWorkspaceServiceToken(workspace));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useCreateServiceTokenV3 = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<CreateServiceTokenDataV3Res, {}, CreateServiceTokenDataV3DTO>({
|
||||
mutationFn: async (body) => {
|
||||
const { data } = await apiRequest.post("/api/v3/service-token/", body);
|
||||
return data;
|
||||
},
|
||||
onSuccess: ({ serviceTokenData }) => {
|
||||
queryClient.invalidateQueries(organizationKeys.getOrgServiceMemberships(serviceTokenData.organization));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useUpdateServiceTokenV3 = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<ServiceTokenDataV3, {}, UpdateServiceTokenDataV3DTO>({
|
||||
mutationFn: async ({
|
||||
serviceTokenDataId,
|
||||
name,
|
||||
role,
|
||||
isActive,
|
||||
trustedIps,
|
||||
expiresIn,
|
||||
accessTokenTTL,
|
||||
isRefreshTokenRotationEnabled
|
||||
}) => {
|
||||
const { data: { serviceTokenData } } = await apiRequest.patch(`/api/v3/service-token/${serviceTokenDataId}`, {
|
||||
name,
|
||||
role,
|
||||
isActive,
|
||||
trustedIps,
|
||||
expiresIn,
|
||||
accessTokenTTL,
|
||||
isRefreshTokenRotationEnabled
|
||||
});
|
||||
|
||||
return serviceTokenData;
|
||||
},
|
||||
onSuccess: ({ organization }) => {
|
||||
queryClient.invalidateQueries(organizationKeys.getOrgServiceMemberships(organization));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useDeleteServiceTokenV3 = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<ServiceTokenDataV3, {}, DeleteServiceTokenDataV3DTO>({
|
||||
mutationFn: async ({
|
||||
serviceTokenDataId
|
||||
}) => {
|
||||
const { data: { serviceTokenData } } = await apiRequest.delete(`/api/v3/service-token/${serviceTokenDataId}`);
|
||||
return serviceTokenData;
|
||||
},
|
||||
onSuccess: ({ organization }) => {
|
||||
queryClient.invalidateQueries(organizationKeys.getOrgServiceMemberships(organization));
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -1,5 +1,3 @@
|
||||
import { TRole } from "../roles/types";
|
||||
|
||||
export type ServiceTokenScope = {
|
||||
environment: string;
|
||||
secretPath: string;
|
||||
@@ -34,84 +32,4 @@ export type CreateServiceTokenRes = {
|
||||
serviceTokenData: ServiceToken;
|
||||
};
|
||||
|
||||
export type DeleteServiceTokenRes = { serviceTokenData: ServiceToken };
|
||||
|
||||
// --- v3
|
||||
|
||||
export type ServiceTokenV3TrustedIp = {
|
||||
_id: string;
|
||||
ipAddress: string;
|
||||
type: "ipv4" | "ipv6";
|
||||
prefix?: number;
|
||||
}
|
||||
|
||||
export type ServiceTokenDataV3 = {
|
||||
_id: string;
|
||||
name: string;
|
||||
organization: string;
|
||||
isActive: boolean;
|
||||
refreshTokenLastUsed?: string;
|
||||
accessTokenLastUsed?: string;
|
||||
refreshTokenUsageCount: number;
|
||||
accessTokenUsageCount: number;
|
||||
trustedIps: ServiceTokenV3TrustedIp[];
|
||||
expiresAt?: string;
|
||||
accessTokenTTL: number;
|
||||
isRefreshTokenRotationEnabled: boolean;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
};
|
||||
|
||||
export type ServiceMembershipOrg = {
|
||||
_id: string;
|
||||
service: ServiceTokenDataV3;
|
||||
organization: string;
|
||||
role: "admin" | "member" | "viewer" | "custom";
|
||||
customRole?: TRole;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export type ServiceMembership = {
|
||||
_id: string;
|
||||
service: ServiceTokenDataV3;
|
||||
organization: string;
|
||||
role: "admin" | "member" | "viewer" | "custom";
|
||||
customRole?: TRole;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export type CreateServiceTokenDataV3DTO = {
|
||||
name: string;
|
||||
organizationId: string;
|
||||
role?: string;
|
||||
trustedIps: {
|
||||
ipAddress: string;
|
||||
}[];
|
||||
expiresIn?: number;
|
||||
accessTokenTTL: number;
|
||||
isRefreshTokenRotationEnabled: boolean;
|
||||
}
|
||||
|
||||
export type CreateServiceTokenDataV3Res = {
|
||||
refreshToken: string;
|
||||
serviceTokenData: ServiceTokenDataV3;
|
||||
}
|
||||
|
||||
export type UpdateServiceTokenDataV3DTO = {
|
||||
serviceTokenDataId: string;
|
||||
isActive?: boolean;
|
||||
name?: string;
|
||||
role?: string;
|
||||
trustedIps?: {
|
||||
ipAddress: string;
|
||||
}[];
|
||||
expiresIn?: number;
|
||||
accessTokenTTL?: number;
|
||||
isRefreshTokenRotationEnabled?: boolean;
|
||||
}
|
||||
|
||||
export type DeleteServiceTokenDataV3DTO = {
|
||||
serviceTokenDataId: string;
|
||||
}
|
||||
export type DeleteServiceTokenRes = { serviceTokenData: ServiceToken };
|
||||
@@ -1,9 +1,9 @@
|
||||
export {
|
||||
useAddServiceToWorkspace,
|
||||
useAddMachineToWorkspace,
|
||||
useAddUserToWorkspace,
|
||||
useCreateWorkspace,
|
||||
useCreateWsEnvironment,
|
||||
useDeleteServiceFromWorkspace,
|
||||
useDeleteMachineFromWorkspace,
|
||||
useDeleteUserFromWorkspace,
|
||||
useDeleteWorkspace,
|
||||
useDeleteWsEnvironment,
|
||||
@@ -13,8 +13,8 @@ export {
|
||||
useGetWorkspaceById,
|
||||
useGetWorkspaceIndexStatus,
|
||||
useGetWorkspaceIntegrations,
|
||||
useGetWorkspaceMachineMemberships,
|
||||
useGetWorkspaceSecrets,
|
||||
useGetWorkspaceServiceMemberships,
|
||||
useGetWorkspaceUsers,
|
||||
useNameWorkspaceSecrets,
|
||||
useRenameWorkspace,
|
||||
|
||||
@@ -4,8 +4,8 @@ import { apiRequest } from "@app/config/request";
|
||||
|
||||
import { IntegrationAuth } from "../integrationAuth/types";
|
||||
import { TIntegration } from "../integrations/types";
|
||||
import { MachineMembership } from "../machineIdentities/types";
|
||||
import { EncryptedSecret } from "../secrets/types";
|
||||
import { ServiceMembership } from "../serviceTokens/types";
|
||||
import { TWorkspaceUser } from "../users/types";
|
||||
import {
|
||||
CreateEnvironmentDTO,
|
||||
@@ -31,8 +31,6 @@ export const workspaceKeys = {
|
||||
getAllUserWorkspace: ["workspaces"] as const,
|
||||
getWorkspaceAuditLogs: (workspaceId: string) => [{ workspaceId }] as const,
|
||||
getWorkspaceUsers: (workspaceId: string) => [{ workspaceId }] as const,
|
||||
getWorkspaceServiceTokenDataV3: (workspaceId: string) =>
|
||||
[{ workspaceId }, "workspace-service-token-data-v3"] as const,
|
||||
getWorkspaceServiceMemberships: (workspaceId: string) => [{ workspaceId }, "organization-service-memberships"] as const
|
||||
};
|
||||
|
||||
@@ -358,23 +356,22 @@ export const useUpdateUserWorkspaceRole = () => {
|
||||
});
|
||||
};
|
||||
|
||||
export const useAddServiceToWorkspace = () => {
|
||||
export const useAddMachineToWorkspace = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async ({
|
||||
serviceId,
|
||||
machineId,
|
||||
workspaceId,
|
||||
role
|
||||
}: {
|
||||
serviceId: string;
|
||||
machineId: string;
|
||||
workspaceId: string;
|
||||
role?: string;
|
||||
}) => {
|
||||
|
||||
const {
|
||||
data: { serviceMembership }
|
||||
} = await apiRequest.post(`/api/v2/workspace/${workspaceId}/service-memberships`, {
|
||||
serviceId,
|
||||
} = await apiRequest.post(`/api/v2/workspace/${workspaceId}/machine-memberships/${machineId}`, {
|
||||
role
|
||||
});
|
||||
|
||||
@@ -386,22 +383,20 @@ export const useAddServiceToWorkspace = () => {
|
||||
});
|
||||
};
|
||||
|
||||
// TODO: update
|
||||
|
||||
export const useDeleteServiceFromWorkspace = () => {
|
||||
export const useDeleteMachineFromWorkspace = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async ({
|
||||
serviceId,
|
||||
machineId,
|
||||
workspaceId,
|
||||
}: {
|
||||
serviceId: string;
|
||||
machineId: string;
|
||||
workspaceId: string;
|
||||
}) => {
|
||||
|
||||
const {
|
||||
data: { serviceMembership }
|
||||
} = await apiRequest.delete(`/api/v2/workspace/${workspaceId}/service-memberships/${serviceId}`);
|
||||
} = await apiRequest.delete(`/api/v2/workspace/${workspaceId}/machine-memberships/${machineId}`);
|
||||
|
||||
return serviceMembership;
|
||||
},
|
||||
@@ -411,18 +406,19 @@ export const useDeleteServiceFromWorkspace = () => {
|
||||
});
|
||||
};
|
||||
|
||||
export const useGetWorkspaceServiceMemberships = (workspaceId: string) => {
|
||||
|
||||
export const useGetWorkspaceMachineMemberships = (workspaceId: string) => {
|
||||
return useQuery({
|
||||
queryKey: workspaceKeys.getWorkspaceServiceMemberships(workspaceId),
|
||||
queryFn: async () => {
|
||||
|
||||
const {
|
||||
data: { serviceMemberships }
|
||||
} = await apiRequest.get<{ serviceMemberships: ServiceMembership[] }>(
|
||||
`/api/v2/workspace/${workspaceId}/service-memberships`
|
||||
data: { machineMemberships }
|
||||
} = await apiRequest.get<{ machineMemberships: MachineMembership[] }>(
|
||||
`/api/v2/workspace/${workspaceId}/machine-memberships`
|
||||
);
|
||||
|
||||
return serviceMemberships;
|
||||
return machineMemberships;
|
||||
},
|
||||
enabled: true
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user