diff --git a/src/store/deployApi.ts b/src/store/deployApi.ts index b4450b66c7d8fae17e933c7e19a850bfaaca1b72..abcb3b50e84be4192c1c5e51a43d7f3e34545199 100644 --- a/src/store/deployApi.ts +++ b/src/store/deployApi.ts @@ -154,6 +154,9 @@ const injectedRtkApi = api.injectEndpoints({ url: `/api/v1/names/check_naming_uuid/${queryArg.namingUuid}` }) }), + hostDeviance: build.query<HostDevianceApiResponse, HostDevianceApiArg>({ + query: () => ({ url: `/api/v1/migration/deviance` }) + }), getCurrentMode: build.query< GetCurrentModeApiResponse, GetCurrentModeApiArg @@ -367,6 +370,13 @@ const injectedRtkApi = api.injectEndpoints({ getUserRoles: build.query<GetUserRolesApiResponse, GetUserRolesApiArg>({ query: () => ({ url: `/api/v1/authentication/roles` }) }), + removeIocs: build.mutation<RemoveIocsApiResponse, RemoveIocsApiArg>({ + query: (queryArg) => ({ + url: `/api/v1/migration/${queryArg.networkScopeToRemove}/remove_iocs`, + method: "DELETE", + params: { ioc_name_prefix: queryArg.iocNamePrefix } + }) + }), logout: build.mutation<LogoutApiResponse, LogoutApiArg>({ query: () => ({ url: `/api/v1/authentication/logout`, method: "DELETE" }) }) @@ -386,12 +396,12 @@ export type StartJobApiArg = { createJobRequest: CreateJobRequest; }; export type StartBatchUndeploymentApiResponse = - /** status 201 IOC undeployment initiated */ BatchJob; + /** status 201 IOC undeployment initiated */ Job; export type StartBatchUndeploymentApiArg = { batchUndeploymentRequest: BatchUndeploymentRequest; }; export type StartBatchDeploymentApiResponse = - /** status 201 IOC job initiated */ BatchJob; + /** status 201 IOC job initiated */ Job; export type StartBatchDeploymentApiArg = { batchDeploymentRequest: BatchDeploymentRequest; }; @@ -499,6 +509,9 @@ export type CheckNamingUuIdApiArg = { /** Naming UUID */ namingUuid: string; }; +export type HostDevianceApiResponse = + /** status 200 Compares the stored host information about the Jobs against NetBox */ MigrationDeviance; +export type HostDevianceApiArg = void; export type GetCurrentModeApiResponse = /** status 200 Found Mode */ MaintenanceMode; export type GetCurrentModeApiArg = void; @@ -699,6 +712,18 @@ export type GetToolUsersApiArg = { }; export type GetUserRolesApiResponse = /** status 200 Ok */ string[]; export type GetUserRolesApiArg = void; +export type RemoveIocsApiResponse = + /** status 204 Removes all IOCs that has been ever deployed to the network scope */ void; +export type RemoveIocsApiArg = { + /** Removing all IOCs that has even been deployed to this network scope */ + networkScopeToRemove: string; + /** Remove IOCs that's CURRENT name starts like the parameter AND was NEVER deployed + -- leave empty if don't want to delete such IOCs + + This is independent from networkScope parameter! + */ + iocNamePrefix?: string; +}; export type LogoutApiResponse = /** status 200 Ok */ object; export type LogoutApiArg = void; export type MaintenanceMode = { @@ -722,6 +747,14 @@ export type DeploymentHostInfo = { fqdn?: string; netBoxHostFromCache?: boolean; }; +export type JobEntry = { + iocName?: string; + iocId?: number; + deploymentId?: number; + gitProjectId?: number; + gitReference?: string; + host?: DeploymentHostInfo; +}; export type Job = { id?: number; createdBy?: string; @@ -742,6 +775,7 @@ export type Job = { gitProjectId?: number; gitReference?: string; host?: DeploymentHostInfo; + jobs?: JobEntry[]; }; export type CreateJobRequest = { type?: @@ -754,30 +788,6 @@ export type CreateJobRequest = { sourceVersion?: string; hostId?: string; }; -export type JobEntry = { - iocName?: string; - iocId?: number; - deploymentId?: number; - gitProjectId?: number; - gitReference?: string; - host?: DeploymentHostInfo; -}; -export type BatchJob = { - id?: number; - createdBy?: string; - startTime?: string; - createdAt?: string; - finishedAt?: string; - action?: - | "DEPLOY" - | "UNDEPLOY" - | "START" - | "STOP" - | "BATCH_DEPLOY" - | "BATCH_UNDEPLOY"; - status?: "UNKNOWN" | "QUEUED" | "RUNNING" | "FAILED" | "SUCCESSFUL"; - jobs?: JobEntry[]; -}; export type UndeploymentRequest = { iocId?: number; hostId?: string; @@ -939,27 +949,21 @@ export type NameResponse = { export type IdUsedByIoc = { iocId?: number; }; -export type BaseJob = { - id?: number; - createdBy?: string; - startTime?: string; - createdAt?: string; - finishedAt?: string; - action?: - | "DEPLOY" - | "UNDEPLOY" - | "START" - | "STOP" - | "BATCH_DEPLOY" - | "BATCH_UNDEPLOY"; - status?: "UNKNOWN" | "QUEUED" | "RUNNING" | "FAILED" | "SUCCESSFUL"; +export type MigrationDeviance = { + not_found?: number; + network_name_changed?: number; + hostname_changed?: number; + both_changed?: number; + all_jobs?: number; + unresolvable_iocs?: string[]; + network_scopes?: string[]; }; export type PagedJobResponse = { totalCount?: number; listSize?: number; pageNumber?: number; limit?: number; - jobs?: BaseJob[]; + jobs?: Job[]; }; export type HostWithFqdn = { hostId?: string; @@ -971,6 +975,16 @@ export type Alert = { message?: string; link?: string; }; +export type JobDetailsEntry = { + iocName?: string; + iocId?: number; + deploymentId?: number; + gitProjectId?: number; + gitReference?: string; + gitProjectUrl?: string; + gitShortReference?: string; + host?: HostWithFqdn; +}; export type JobDetails = { id?: number; createdBy?: string; @@ -996,6 +1010,7 @@ export type JobDetails = { awxJobId?: number; jobUrl?: string; alerts?: Alert[]; + jobs?: JobDetailsEntry[]; }; export type AwxJobDetails = { id?: number; @@ -1138,6 +1153,8 @@ export const { useLazyFetchIocByNameQuery, useCheckNamingUuIdQuery, useLazyCheckNamingUuIdQuery, + useHostDevianceQuery, + useLazyHostDevianceQuery, useGetCurrentModeQuery, useLazyGetCurrentModeQuery, useEndCurrentMaintenanceModeMutation, @@ -1189,5 +1206,6 @@ export const { useLazyGetToolUsersQuery, useGetUserRolesQuery, useLazyGetUserRolesQuery, + useRemoveIocsMutation, useLogoutMutation } = injectedRtkApi;