@terasky/backstage-plugin-vcf-automation 1.1.1 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"VCFAutomationProjectOverview.esm.js","sources":["../../src/components/VCFAutomationProjectOverview.tsx"],"sourcesContent":["import { Key, JSXElementConstructor, ReactElement, ReactNode, ReactPortal } from 'react';\nimport { useEntity } from '@backstage/plugin-catalog-react';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { vcfAutomationApiRef } from '../api/VcfAutomationClient';\nimport {\n InfoCard,\n Progress,\n ResponseErrorPanel,\n} from '@backstage/core-components';\nimport { Grid, Typography, Chip } from '@material-ui/core';\nimport useAsync from 'react-use/lib/useAsync';\nimport { usePermission } from '@backstage/plugin-permission-react';\nimport { viewProjectDetailsPermission } from '@terasky/backstage-plugin-vcf-automation-common';\n\nexport const VCFAutomationProjectOverview = () => {\n const { entity } = useEntity();\n const api = useApi(vcfAutomationApiRef);\n const projectId = entity.metadata.name;\n const instanceName = entity.metadata.annotations?.['terasky.backstage.io/vcf-automation-instance'];\n\n const { allowed: hasViewPermission, loading: permissionLoading } = usePermission({\n permission: viewProjectDetailsPermission,\n });\n\n const { value: project, loading, error } = useAsync(async () => {\n if (!projectId || !hasViewPermission) return undefined;\n return await api.getProjectDetails(projectId, instanceName);\n }, [projectId, hasViewPermission, instanceName]);\n\n if (!projectId) {\n return (\n <InfoCard title=\"VCF Automation Project\">\n <Typography>No project ID found for this entity.</Typography>\n </InfoCard>\n );\n }\n\n if (loading || permissionLoading) {\n return (\n <InfoCard title=\"VCF Automation Project\">\n <Progress />\n </InfoCard>\n );\n }\n\n if (!hasViewPermission) {\n return (\n <InfoCard title=\"VCF Automation Project\">\n <Typography>You don't have permission to view project details.</Typography>\n </InfoCard>\n );\n }\n\n if (error) {\n return <ResponseErrorPanel error={error} />;\n }\n\n if (!project) {\n return (\n <InfoCard title=\"VCF Automation Project\">\n <Typography>No project details available.</Typography>\n </InfoCard>\n );\n }\n\n return (\n <InfoCard title=\"VCF Automation Project\">\n <Grid container spacing={2}>\n <Grid item xs={6}>\n <Typography variant=\"subtitle2\">Name</Typography>\n <Typography>{project.name}</Typography>\n </Grid>\n <Grid item xs={6}>\n <Typography variant=\"subtitle2\">Description</Typography>\n <Typography>{project.description || 'No description'}</Typography>\n </Grid>\n <Grid item xs={12}>\n <Typography variant=\"subtitle2\">Administrators</Typography>\n <Grid container spacing={1}>\n {project.administrators.map((admin: { email: any; type: any; }) => (\n <Grid item key={`${admin.email}-${admin.type}`}>\n <Chip\n label={`${admin.email} (${admin.type})`}\n size=\"small\"\n />\n </Grid>\n ))}\n </Grid>\n </Grid>\n <Grid item xs={12}>\n <Typography variant=\"subtitle2\">Resource Allocation</Typography>\n {project.zones.map((zone: { id: Key | null | undefined; zoneId: string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | null | undefined; allocatedInstancesCount: string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | null | undefined; maxNumberInstances: any; allocatedMemoryMB: string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | null | undefined; memoryLimitMB: any; allocatedCpu: string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | null | undefined; cpuLimit: any; allocatedStorageGB: string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | null | undefined; storageLimitGB: any; }) => (\n <Grid container spacing={2} key={zone.id}>\n <Grid item xs={12}>\n <Typography variant=\"body2\">Zone: {zone.zoneId}</Typography>\n </Grid>\n <Grid item xs={4}>\n <Typography variant=\"caption\">Instances</Typography>\n <Typography>\n {zone.allocatedInstancesCount} / {zone.maxNumberInstances || 'Unlimited'}\n </Typography>\n </Grid>\n <Grid item xs={4}>\n <Typography variant=\"caption\">Memory (MB)</Typography>\n <Typography>\n {zone.allocatedMemoryMB} / {zone.memoryLimitMB || 'Unlimited'}\n </Typography>\n </Grid>\n <Grid item xs={4}>\n <Typography variant=\"caption\">CPU</Typography>\n <Typography>\n {zone.allocatedCpu} / {zone.cpuLimit || 'Unlimited'}\n </Typography>\n </Grid>\n <Grid item xs={4}>\n <Typography variant=\"caption\">Storage (GB)</Typography>\n <Typography>\n {zone.allocatedStorageGB} / {zone.storageLimitGB || 'Unlimited'}\n </Typography>\n </Grid>\n </Grid>\n ))}\n </Grid>\n <Grid item xs={6}>\n <Typography variant=\"subtitle2\">Shared Resources</Typography>\n <Typography>{project.sharedResources ? 'Yes' : 'No'}</Typography>\n </Grid>\n <Grid item xs={6}>\n <Typography variant=\"subtitle2\">Placement Policy</Typography>\n <Typography>{project.placementPolicy}</Typography>\n </Grid>\n </Grid>\n </InfoCard>\n );\n}; "],"names":[],"mappings":";;;;;;;;;;AAcO,MAAM,+BAA+B,MAAM;AAChD,EAAM,MAAA,EAAE,MAAO,EAAA,GAAI,SAAU,EAAA;AAC7B,EAAM,MAAA,GAAA,GAAM,OAAO,mBAAmB,CAAA;AACtC,EAAM,MAAA,SAAA,GAAY,OAAO,QAAS,CAAA,IAAA;AAClC,EAAA,MAAM,YAAe,GAAA,MAAA,CAAO,QAAS,CAAA,WAAA,GAAc,8CAA8C,CAAA;AAEjG,EAAA,MAAM,EAAE,OAAS,EAAA,iBAAA,EAAmB,OAAS,EAAA,iBAAA,KAAsB,aAAc,CAAA;AAAA,IAC/E,UAAY,EAAA;AAAA,GACb,CAAA;AAED,EAAA,MAAM,EAAE,KAAO,EAAA,OAAA,EAAS,SAAS,KAAM,EAAA,GAAI,SAAS,YAAY;AAC9D,IAAA,IAAI,CAAC,SAAA,IAAa,CAAC,iBAAA,EAA0B,OAAA,KAAA,CAAA;AAC7C,IAAA,OAAO,MAAM,GAAA,CAAI,iBAAkB,CAAA,SAAA,EAAW,YAAY,CAAA;AAAA,GACzD,EAAA,CAAC,SA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B,EAAA;AAAA,KACvC,EAAA;AAAA,GAAA,EACF,CACF,EAAA,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"VCFAutomationProjectOverview.esm.js","sources":["../../src/components/VCFAutomationProjectOverview.tsx"],"sourcesContent":["import { Key, JSXElementConstructor, ReactElement, ReactNode, ReactPortal } from 'react';\nimport { useEntity } from '@backstage/plugin-catalog-react';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { vcfAutomationApiRef } from '../api/VcfAutomationClient';\nimport {\n InfoCard,\n Progress,\n ResponseErrorPanel,\n} from '@backstage/core-components';\nimport { Grid, Typography, Chip } from '@material-ui/core';\nimport useAsync from 'react-use/lib/useAsync';\nimport { usePermission } from '@backstage/plugin-permission-react';\nimport { viewProjectDetailsPermission } from '@terasky/backstage-plugin-vcf-automation-common';\n\nexport const VCFAutomationProjectOverview = () => {\n const { entity } = useEntity();\n const api = useApi(vcfAutomationApiRef);\n const projectId = entity.metadata.name;\n const instanceName = entity.metadata.annotations?.['terasky.backstage.io/vcf-automation-instance'];\n\n const { allowed: hasViewPermission, loading: permissionLoading } = usePermission({\n permission: viewProjectDetailsPermission,\n });\n\n const { value: project, loading, error } = useAsync(async () => {\n if (!projectId || !hasViewPermission) return undefined;\n return await api.getProjectDetails(projectId, instanceName);\n }, [projectId, hasViewPermission, instanceName]);\n\n if (!projectId) {\n return (\n <InfoCard title=\"VCF Automation Project\">\n <Typography>No project ID found for this entity.</Typography>\n </InfoCard>\n );\n }\n\n if (loading || permissionLoading) {\n return (\n <InfoCard title=\"VCF Automation Project\">\n <Progress />\n </InfoCard>\n );\n }\n\n if (!hasViewPermission) {\n return (\n <InfoCard title=\"VCF Automation Project\">\n <Typography>You don't have permission to view project details.</Typography>\n </InfoCard>\n );\n }\n\n if (error) {\n return <ResponseErrorPanel error={error} />;\n }\n\n if (!project) {\n return (\n <InfoCard title=\"VCF Automation Project\">\n <Typography>No project details available.</Typography>\n </InfoCard>\n );\n }\n\n return (\n <InfoCard title=\"VCF Automation Project\">\n <Grid container spacing={2}>\n <Grid item xs={6}>\n <Typography variant=\"subtitle2\">Name</Typography>\n <Typography>{project.name}</Typography>\n </Grid>\n <Grid item xs={6}>\n <Typography variant=\"subtitle2\">Description</Typography>\n <Typography>{project.description || 'No description'}</Typography>\n </Grid>\n <Grid item xs={12}>\n <Typography variant=\"subtitle2\">Administrators</Typography>\n <Grid container spacing={1}>\n {project.administrators && project.administrators.length > 0 ? (\n project.administrators.map((admin: any, index: number) => (\n <Grid item key={admin.email ? `${admin.email}-${admin.type}` : `admin-${index}`}>\n <Chip\n label={admin.email ? `${admin.email} (${admin.type || 'User'})` : admin.toString()}\n size=\"small\"\n />\n </Grid>\n ))\n ) : (\n <Grid item>\n <Typography variant=\"body2\" color=\"textSecondary\">\n No administrators configured\n </Typography>\n </Grid>\n )}\n </Grid>\n </Grid>\n {project.zones && project.zones.length > 0 && (\n <Grid item xs={12}>\n <Typography variant=\"subtitle2\">Resource Allocation</Typography>\n {project.zones.map((zone: { id: Key | null | undefined; zoneId: string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | null | undefined; allocatedInstancesCount: string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | null | undefined; maxNumberInstances: any; allocatedMemoryMB: string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | null | undefined; memoryLimitMB: any; allocatedCpu: string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | null | undefined; cpuLimit: any; allocatedStorageGB: string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | null | undefined; storageLimitGB: any; }) => (\n <Grid container spacing={2} key={zone.id}>\n <Grid item xs={12}>\n <Typography variant=\"body2\">Zone: {zone.zoneId}</Typography>\n </Grid>\n <Grid item xs={4}>\n <Typography variant=\"caption\">Instances</Typography>\n <Typography>\n {zone.allocatedInstancesCount} / {zone.maxNumberInstances || 'Unlimited'}\n </Typography>\n </Grid>\n <Grid item xs={4}>\n <Typography variant=\"caption\">Memory (MB)</Typography>\n <Typography>\n {zone.allocatedMemoryMB} / {zone.memoryLimitMB || 'Unlimited'}\n </Typography>\n </Grid>\n <Grid item xs={4}>\n <Typography variant=\"caption\">CPU</Typography>\n <Typography>\n {zone.allocatedCpu} / {zone.cpuLimit || 'Unlimited'}\n </Typography>\n </Grid>\n <Grid item xs={4}>\n <Typography variant=\"caption\">Storage (GB)</Typography>\n <Typography>\n {zone.allocatedStorageGB} / {zone.storageLimitGB || 'Unlimited'}\n </Typography>\n </Grid>\n </Grid>\n ))}\n </Grid>\n )}\n {project.sharedResources !== undefined && (\n <Grid item xs={6}>\n <Typography variant=\"subtitle2\">Shared Resources</Typography>\n <Typography>{project.sharedResources ? 'Yes' : 'No'}</Typography>\n </Grid>\n )}\n {project.placementPolicy && (\n <Grid item xs={6}>\n <Typography variant=\"subtitle2\">Placement Policy</Typography>\n <Typography>{project.placementPolicy}</Typography>\n </Grid>\n )}\n {project.orgId && (\n <Grid item xs={6}>\n <Typography variant=\"subtitle2\">Organization ID</Typography>\n <Typography>{project.orgId}</Typography>\n </Grid>\n )}\n {project.operationTimeout !== undefined && (\n <Grid item xs={6}>\n <Typography variant=\"subtitle2\">Operation Timeout</Typography>\n <Typography>{project.operationTimeout} minutes</Typography>\n </Grid>\n )}\n </Grid>\n </InfoCard>\n );\n}; "],"names":[],"mappings":";;;;;;;;;;AAcO,MAAM,+BAA+B,MAAM;AAChD,EAAM,MAAA,EAAE,MAAO,EAAA,GAAI,SAAU,EAAA;AAC7B,EAAM,MAAA,GAAA,GAAM,OAAO,mBAAmB,CAAA;AACtC,EAAM,MAAA,SAAA,GAAY,OAAO,QAAS,CAAA,IAAA;AAClC,EAAA,MAAM,YAAe,GAAA,MAAA,CAAO,QAAS,CAAA,WAAA,GAAc,8CAA8C,CAAA;AAEjG,EAAA,MAAM,EAAE,OAA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EAAA,CAAA;AAAA,IAED,OAAA,CAAQ,qBAAqB,KAC5B,CAAA,oBAAA,IAAA,CAAC,QAAK,IAAI,EAAA,IAAA,EAAC,IAAI,CACb,EAAA,QAAA,EAAA;AAAA,sBAAC,GAAA,CAAA,UAAA,EAAA,EAAW,OAAQ,EAAA,WAAA,EAAY,QAAiB,EAAA,mBAAA,EAAA,CAAA;AAAA,2BAChD,UAAY,EAAA,EAAA,QAAA,EAAA;AAAA,QAAQ,OAAA,CAAA,gBAAA;AAAA,QAAiB;AAAA,OAAQ,EAAA;AAAA,KAChD,EAAA;AAAA,GAAA,EAEJ,CACF,EAAA,CAAA;AAEJ;;;;"}
@@ -0,0 +1,262 @@
1
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
2
+ import { useState, useMemo, useCallback } from 'react';
3
+ import { useApi } from '@backstage/core-plugin-api';
4
+ import { vcfAutomationApiRef } from '../api/VcfAutomationClient.esm.js';
5
+ import { Box, CircularProgress, Typography, Button, Chip, Dialog, DialogTitle, DialogContent, DialogActions, Snackbar } from '@material-ui/core';
6
+ import { Alert } from '@material-ui/lab';
7
+ import { makeStyles } from '@material-ui/core/styles';
8
+ import PowerSettingsNewIcon from '@material-ui/icons/PowerSettingsNew';
9
+ import PlayArrowIcon from '@material-ui/icons/PlayArrow';
10
+ import StopIcon from '@material-ui/icons/Stop';
11
+ import useAsync from 'react-use/lib/useAsync';
12
+ import { usePermission } from '@backstage/plugin-permission-react';
13
+ import { vmPowerManagementPermission } from '@terasky/backstage-plugin-vcf-automation-common';
14
+
15
+ const useStyles = makeStyles((theme) => ({
16
+ powerButtons: {
17
+ display: "flex",
18
+ gap: theme.spacing(1),
19
+ alignItems: "center"
20
+ },
21
+ powerOnButton: {
22
+ backgroundColor: theme.palette.success.main,
23
+ color: theme.palette.success.contrastText,
24
+ "&:hover": {
25
+ backgroundColor: theme.palette.success.dark
26
+ },
27
+ "&:disabled": {
28
+ backgroundColor: theme.palette.action.disabled,
29
+ color: theme.palette.action.disabled
30
+ }
31
+ },
32
+ powerOffButton: {
33
+ backgroundColor: theme.palette.error.main,
34
+ color: theme.palette.error.contrastText,
35
+ "&:hover": {
36
+ backgroundColor: theme.palette.error.dark
37
+ },
38
+ "&:disabled": {
39
+ backgroundColor: theme.palette.action.disabled,
40
+ color: theme.palette.action.disabled
41
+ }
42
+ },
43
+ statusChip: {
44
+ marginLeft: theme.spacing(1)
45
+ }
46
+ }));
47
+ const VCFAutomationVMPowerManagement = ({
48
+ entity,
49
+ resourceId,
50
+ instanceName,
51
+ isStandalone,
52
+ vmName,
53
+ namespaceName,
54
+ namespaceUrnId
55
+ }) => {
56
+ const classes = useStyles();
57
+ const api = useApi(vcfAutomationApiRef);
58
+ const [confirmDialog, setConfirmDialog] = useState({
59
+ open: false,
60
+ action: null
61
+ });
62
+ const [executing, setExecuting] = useState(false);
63
+ const [snackbar, setSnackbar] = useState({
64
+ open: false,
65
+ message: "",
66
+ severity: "success"
67
+ });
68
+ const { allowed: hasPermission } = usePermission({
69
+ permission: vmPowerManagementPermission
70
+ });
71
+ const { value: vmData, loading, error } = useAsync(async () => {
72
+ if (isStandalone) {
73
+ if (!vmName || !namespaceName || !namespaceUrnId) {
74
+ throw new Error("Missing required parameters for standalone VM");
75
+ }
76
+ const vmStatus = await api.getStandaloneVmStatus(namespaceUrnId, namespaceName, vmName, instanceName);
77
+ return {
78
+ powerState: vmStatus.spec.powerState,
79
+ isStandalone: true,
80
+ vmData: vmStatus
81
+ };
82
+ } else {
83
+ const [powerOnAction, powerOffAction] = await Promise.all([
84
+ api.checkVmPowerAction(resourceId, "PowerOn", instanceName),
85
+ api.checkVmPowerAction(resourceId, "PowerOff", instanceName)
86
+ ]);
87
+ const powerState = powerOnAction.valid ? "PoweredOff" : "PoweredOn";
88
+ return {
89
+ powerState,
90
+ isStandalone: false,
91
+ availableActions: {
92
+ PowerOn: powerOnAction,
93
+ PowerOff: powerOffAction
94
+ }
95
+ };
96
+ }
97
+ }, [resourceId, instanceName, isStandalone, vmName, namespaceName, namespaceUrnId]);
98
+ const availableAction = useMemo(() => {
99
+ if (!vmData) return null;
100
+ if (isStandalone) {
101
+ return vmData.powerState === "PoweredOff" ? "PowerOn" : "PowerOff";
102
+ } else {
103
+ const powerOnValid = vmData.availableActions?.PowerOn?.valid;
104
+ const powerOffValid = vmData.availableActions?.PowerOff?.valid;
105
+ if (powerOnValid) return "PowerOn";
106
+ if (powerOffValid) return "PowerOff";
107
+ return null;
108
+ }
109
+ }, [vmData, isStandalone]);
110
+ const handleActionClick = useCallback((action) => {
111
+ if (!hasPermission) return;
112
+ const actionDisplayName = action === "PowerOn" ? "Power On" : "Power Off";
113
+ setConfirmDialog({
114
+ open: true,
115
+ action,
116
+ actionDisplayName
117
+ });
118
+ }, [hasPermission]);
119
+ const handleConfirmAction = useCallback(async () => {
120
+ if (!confirmDialog.action || !vmData) return;
121
+ setExecuting(true);
122
+ setConfirmDialog({ open: false, action: null });
123
+ try {
124
+ if (isStandalone) {
125
+ if (!vmName || !namespaceName || !namespaceUrnId) {
126
+ throw new Error("Missing required parameters for standalone VM");
127
+ }
128
+ const newPowerState = confirmDialog.action === "PowerOn" ? "PoweredOn" : "PoweredOff";
129
+ await api.executeStandaloneVmPowerAction(namespaceUrnId, namespaceName, vmName, newPowerState, vmData.vmData, instanceName);
130
+ } else {
131
+ await api.executeVmPowerAction(resourceId, confirmDialog.action, instanceName);
132
+ }
133
+ setSnackbar({
134
+ open: true,
135
+ message: `Successfully executed ${confirmDialog.action} action`,
136
+ severity: "success"
137
+ });
138
+ setTimeout(() => window.location.reload(), 1e3);
139
+ } catch (error2) {
140
+ setSnackbar({
141
+ open: true,
142
+ message: `Failed to execute ${confirmDialog.action} action: ${error2 instanceof Error ? error2.message : "Unknown error"}`,
143
+ severity: "error"
144
+ });
145
+ } finally {
146
+ setExecuting(false);
147
+ }
148
+ }, [confirmDialog.action, vmData, isStandalone, vmName, namespaceName, namespaceUrnId, api, instanceName, resourceId]);
149
+ const handleCancelAction = useCallback(() => {
150
+ setConfirmDialog({ open: false, action: null });
151
+ }, []);
152
+ const handleCloseSnackbar = useCallback(() => {
153
+ setSnackbar((prev) => ({ ...prev, open: false }));
154
+ }, []);
155
+ if (loading) {
156
+ return /* @__PURE__ */ jsxs(Box, { className: classes.powerButtons, children: [
157
+ /* @__PURE__ */ jsx(CircularProgress, { size: 20 }),
158
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", children: "Loading power status..." })
159
+ ] });
160
+ }
161
+ if (error) {
162
+ return /* @__PURE__ */ jsx(Box, { className: classes.powerButtons, children: /* @__PURE__ */ jsx(Typography, { variant: "body2", color: "error", children: "Failed to load power status" }) });
163
+ }
164
+ if (!vmData) {
165
+ return null;
166
+ }
167
+ const canExecuteAction = hasPermission && availableAction && !executing;
168
+ const buttonIcon = availableAction === "PowerOn" ? /* @__PURE__ */ jsx(PlayArrowIcon, {}) : /* @__PURE__ */ jsx(StopIcon, {});
169
+ const buttonClass = availableAction === "PowerOn" ? classes.powerOnButton : classes.powerOffButton;
170
+ const buttonText = availableAction === "PowerOn" ? "Power On" : "Power Off";
171
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
172
+ /* @__PURE__ */ jsxs(Box, { className: classes.powerButtons, children: [
173
+ /* @__PURE__ */ jsx(
174
+ Button,
175
+ {
176
+ variant: "contained",
177
+ size: "small",
178
+ startIcon: buttonIcon,
179
+ className: buttonClass,
180
+ disabled: !canExecuteAction,
181
+ onClick: () => availableAction && handleActionClick(availableAction),
182
+ title: !hasPermission ? "You do not have permission to manage VM power state" : !availableAction ? "No power action available" : `${buttonText} this virtual machine`,
183
+ children: executing ? /* @__PURE__ */ jsx(CircularProgress, { size: 16, color: "inherit" }) : buttonText
184
+ }
185
+ ),
186
+ /* @__PURE__ */ jsx(
187
+ Chip,
188
+ {
189
+ label: vmData.powerState,
190
+ size: "small",
191
+ className: classes.statusChip,
192
+ color: vmData.powerState === "PoweredOn" ? "primary" : "default",
193
+ icon: /* @__PURE__ */ jsx(PowerSettingsNewIcon, {})
194
+ }
195
+ )
196
+ ] }),
197
+ /* @__PURE__ */ jsxs(
198
+ Dialog,
199
+ {
200
+ open: confirmDialog.open,
201
+ onClose: handleCancelAction,
202
+ maxWidth: "sm",
203
+ fullWidth: true,
204
+ children: [
205
+ /* @__PURE__ */ jsxs(DialogTitle, { children: [
206
+ "Confirm ",
207
+ confirmDialog.actionDisplayName
208
+ ] }),
209
+ /* @__PURE__ */ jsxs(DialogContent, { children: [
210
+ /* @__PURE__ */ jsxs(Typography, { children: [
211
+ "Are you sure you want to ",
212
+ confirmDialog.actionDisplayName?.toLowerCase(),
213
+ " this virtual machine?"
214
+ ] }),
215
+ /* @__PURE__ */ jsxs(Typography, { variant: "body2", color: "textSecondary", style: { marginTop: 8 }, children: [
216
+ "VM: ",
217
+ vmName || entity.metadata.name
218
+ ] }),
219
+ isStandalone && /* @__PURE__ */ jsxs(Typography, { variant: "body2", color: "textSecondary", children: [
220
+ "Namespace: ",
221
+ namespaceName
222
+ ] })
223
+ ] }),
224
+ /* @__PURE__ */ jsxs(DialogActions, { children: [
225
+ /* @__PURE__ */ jsx(Button, { onClick: handleCancelAction, color: "primary", children: "Cancel" }),
226
+ /* @__PURE__ */ jsx(
227
+ Button,
228
+ {
229
+ onClick: handleConfirmAction,
230
+ color: "primary",
231
+ variant: "contained",
232
+ autoFocus: true,
233
+ children: confirmDialog.actionDisplayName
234
+ }
235
+ )
236
+ ] })
237
+ ]
238
+ }
239
+ ),
240
+ /* @__PURE__ */ jsx(
241
+ Snackbar,
242
+ {
243
+ open: snackbar.open,
244
+ autoHideDuration: 6e3,
245
+ onClose: handleCloseSnackbar,
246
+ anchorOrigin: { vertical: "bottom", horizontal: "right" },
247
+ children: /* @__PURE__ */ jsx(
248
+ Alert,
249
+ {
250
+ onClose: handleCloseSnackbar,
251
+ severity: snackbar.severity,
252
+ variant: "filled",
253
+ children: snackbar.message
254
+ }
255
+ )
256
+ }
257
+ )
258
+ ] });
259
+ };
260
+
261
+ export { VCFAutomationVMPowerManagement };
262
+ //# sourceMappingURL=VCFAutomationVMPowerManagement.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VCFAutomationVMPowerManagement.esm.js","sources":["../../src/components/VCFAutomationVMPowerManagement.tsx"],"sourcesContent":["import React, { useState, useCallback, useMemo } from 'react';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { vcfAutomationApiRef } from '../api/VcfAutomationClient';\nimport { VmPowerAction, VmPowerActionType, StandaloneVmStatus } from '../types';\nimport {\n Button,\n Dialog,\n DialogTitle,\n DialogContent,\n DialogActions,\n Typography,\n Box,\n CircularProgress,\n Snackbar,\n Chip,\n} from '@material-ui/core';\nimport { Alert } from '@material-ui/lab';\nimport { makeStyles } from '@material-ui/core/styles';\nimport PowerSettingsNewIcon from '@material-ui/icons/PowerSettingsNew';\nimport PlayArrowIcon from '@material-ui/icons/PlayArrow';\nimport StopIcon from '@material-ui/icons/Stop';\nimport useAsync from 'react-use/lib/useAsync';\nimport { usePermission } from '@backstage/plugin-permission-react';\nimport { vmPowerManagementPermission } from '@terasky/backstage-plugin-vcf-automation-common';\n\nconst useStyles = makeStyles(theme => ({\n powerButtons: {\n display: 'flex',\n gap: theme.spacing(1),\n alignItems: 'center',\n },\n powerOnButton: {\n backgroundColor: theme.palette.success.main,\n color: theme.palette.success.contrastText,\n '&:hover': {\n backgroundColor: theme.palette.success.dark,\n },\n '&:disabled': {\n backgroundColor: theme.palette.action.disabled,\n color: theme.palette.action.disabled,\n },\n },\n powerOffButton: {\n backgroundColor: theme.palette.error.main,\n color: theme.palette.error.contrastText,\n '&:hover': {\n backgroundColor: theme.palette.error.dark,\n },\n '&:disabled': {\n backgroundColor: theme.palette.action.disabled,\n color: theme.palette.action.disabled,\n },\n },\n statusChip: {\n marginLeft: theme.spacing(1),\n },\n}));\n\n// Permission is defined in vcf-automation-common plugin\n\ninterface VCFAutomationVMPowerManagementProps {\n entity: any;\n resourceId: string;\n instanceName?: string;\n isStandalone: boolean;\n vmName?: string;\n namespaceName?: string;\n namespaceUrnId?: string;\n}\n\nexport const VCFAutomationVMPowerManagement: React.FC<VCFAutomationVMPowerManagementProps> = ({\n entity,\n resourceId,\n instanceName,\n isStandalone,\n vmName,\n namespaceName,\n namespaceUrnId,\n}) => {\n const classes = useStyles();\n const api = useApi(vcfAutomationApiRef);\n \n const [confirmDialog, setConfirmDialog] = useState<{\n open: boolean;\n action: VmPowerActionType | null;\n actionDisplayName?: string;\n }>({\n open: false,\n action: null,\n });\n \n const [executing, setExecuting] = useState(false);\n const [snackbar, setSnackbar] = useState<{\n open: boolean;\n message: string;\n severity: 'success' | 'error';\n }>({\n open: false,\n message: '',\n severity: 'success',\n });\n\n // Check permissions\n const { allowed: hasPermission } = usePermission({ \n permission: vmPowerManagementPermission,\n });\n\n // Get current power state and available actions\n const { value: vmData, loading, error } = useAsync(async () => {\n if (isStandalone) {\n if (!vmName || !namespaceName || !namespaceUrnId) {\n throw new Error('Missing required parameters for standalone VM');\n }\n \n // Get standalone VM status\n const vmStatus: StandaloneVmStatus = await api.getStandaloneVmStatus(namespaceUrnId, namespaceName, vmName, instanceName);\n return {\n powerState: vmStatus.spec.powerState,\n isStandalone: true,\n vmData: vmStatus,\n };\n } else {\n // For deployment-managed VMs, check both power actions\n const [powerOnAction, powerOffAction] = await Promise.all([\n api.checkVmPowerAction(resourceId, 'PowerOn', instanceName),\n api.checkVmPowerAction(resourceId, 'PowerOff', instanceName),\n ]);\n \n // Determine current power state based on which action is valid\n const powerState = powerOnAction.valid ? 'PoweredOff' : 'PoweredOn';\n \n return {\n powerState,\n isStandalone: false,\n availableActions: {\n PowerOn: powerOnAction as VmPowerAction,\n PowerOff: powerOffAction as VmPowerAction,\n },\n };\n }\n }, [resourceId, instanceName, isStandalone, vmName, namespaceName, namespaceUrnId]);\n\n // Determine which action is available\n const availableAction = useMemo(() => {\n if (!vmData) return null;\n \n if (isStandalone) {\n return vmData.powerState === 'PoweredOff' ? 'PowerOn' : 'PowerOff';\n } else {\n // For deployment-managed VMs, check which action is valid\n const powerOnValid = vmData.availableActions?.PowerOn?.valid;\n const powerOffValid = vmData.availableActions?.PowerOff?.valid;\n \n if (powerOnValid) return 'PowerOn';\n if (powerOffValid) return 'PowerOff';\n return null;\n }\n }, [vmData, isStandalone]);\n\n const handleActionClick = useCallback((action: VmPowerActionType) => {\n if (!hasPermission) return;\n \n const actionDisplayName = action === 'PowerOn' ? 'Power On' : 'Power Off';\n setConfirmDialog({\n open: true,\n action,\n actionDisplayName,\n });\n }, [hasPermission]);\n\n const handleConfirmAction = useCallback(async () => {\n if (!confirmDialog.action || !vmData) return;\n \n setExecuting(true);\n setConfirmDialog({ open: false, action: null });\n \n try {\n if (isStandalone) {\n if (!vmName || !namespaceName || !namespaceUrnId) {\n throw new Error('Missing required parameters for standalone VM');\n }\n \n const newPowerState = confirmDialog.action === 'PowerOn' ? 'PoweredOn' : 'PoweredOff';\n await api.executeStandaloneVmPowerAction(namespaceUrnId, namespaceName, vmName, newPowerState, vmData.vmData, instanceName);\n } else {\n await api.executeVmPowerAction(resourceId, confirmDialog.action, instanceName);\n }\n \n setSnackbar({\n open: true,\n message: `Successfully executed ${confirmDialog.action} action`,\n severity: 'success',\n });\n \n // Refresh the data\n setTimeout(() => window.location.reload(), 1000); // Wait a bit for the action to take effect\n } catch (error) {\n setSnackbar({\n open: true,\n message: `Failed to execute ${confirmDialog.action} action: ${error instanceof Error ? error.message : 'Unknown error'}`,\n severity: 'error',\n });\n } finally {\n setExecuting(false);\n }\n }, [confirmDialog.action, vmData, isStandalone, vmName, namespaceName, namespaceUrnId, api, instanceName, resourceId]);\n\n const handleCancelAction = useCallback(() => {\n setConfirmDialog({ open: false, action: null });\n }, []);\n\n const handleCloseSnackbar = useCallback(() => {\n setSnackbar(prev => ({ ...prev, open: false }));\n }, []);\n\n if (loading) {\n return (\n <Box className={classes.powerButtons}>\n <CircularProgress size={20} />\n <Typography variant=\"body2\">Loading power status...</Typography>\n </Box>\n );\n }\n\n if (error) {\n return (\n <Box className={classes.powerButtons}>\n <Typography variant=\"body2\" color=\"error\">\n Failed to load power status\n </Typography>\n </Box>\n );\n }\n\n if (!vmData) {\n return null;\n }\n\n const canExecuteAction = hasPermission && availableAction && !executing;\n const buttonIcon = availableAction === 'PowerOn' ? <PlayArrowIcon /> : <StopIcon />;\n const buttonClass = availableAction === 'PowerOn' ? classes.powerOnButton : classes.powerOffButton;\n const buttonText = availableAction === 'PowerOn' ? 'Power On' : 'Power Off';\n\n return (\n <>\n <Box className={classes.powerButtons}>\n <Button\n variant=\"contained\"\n size=\"small\"\n startIcon={buttonIcon}\n className={buttonClass}\n disabled={!canExecuteAction}\n onClick={() => availableAction && handleActionClick(availableAction)}\n title={\n !hasPermission \n ? 'You do not have permission to manage VM power state'\n : !availableAction\n ? 'No power action available'\n : `${buttonText} this virtual machine`\n }\n >\n {executing ? <CircularProgress size={16} color=\"inherit\" /> : buttonText}\n </Button>\n \n <Chip\n label={vmData.powerState}\n size=\"small\"\n className={classes.statusChip}\n color={vmData.powerState === 'PoweredOn' ? 'primary' : 'default'}\n icon={<PowerSettingsNewIcon />}\n />\n </Box>\n\n {/* Confirmation Dialog */}\n <Dialog\n open={confirmDialog.open}\n onClose={handleCancelAction}\n maxWidth=\"sm\"\n fullWidth\n >\n <DialogTitle>\n Confirm {confirmDialog.actionDisplayName}\n </DialogTitle>\n <DialogContent>\n <Typography>\n Are you sure you want to {confirmDialog.actionDisplayName?.toLowerCase()} this virtual machine?\n </Typography>\n <Typography variant=\"body2\" color=\"textSecondary\" style={{ marginTop: 8 }}>\n VM: {vmName || entity.metadata.name}\n </Typography>\n {isStandalone && (\n <Typography variant=\"body2\" color=\"textSecondary\">\n Namespace: {namespaceName}\n </Typography>\n )}\n </DialogContent>\n <DialogActions>\n <Button onClick={handleCancelAction} color=\"primary\">\n Cancel\n </Button>\n <Button \n onClick={handleConfirmAction} \n color=\"primary\" \n variant=\"contained\"\n autoFocus\n >\n {confirmDialog.actionDisplayName}\n </Button>\n </DialogActions>\n </Dialog>\n\n {/* Success/Error Snackbar */}\n <Snackbar\n open={snackbar.open}\n autoHideDuration={6000}\n onClose={handleCloseSnackbar}\n anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }}\n >\n <Alert \n onClose={handleCloseSnackbar} \n severity={snackbar.severity}\n variant=\"filled\"\n >\n {snackbar.message}\n </Alert>\n </Snackbar>\n </>\n );\n};"],"names":["error"],"mappings":";;;;;;;;;;;;;;AAyBA,MAAM,SAAA,GAAY,WAAW,CAAU,KAAA,MAAA;AAAA,EACrC,YAAc,EAAA;AAAA,IACZ,OAAS,EAAA,MAAA;AAAA,IACT,GAAA,EAAK,KAAM,CAAA,OAAA,CAAQ,CAAC,CAAA;AAAA,IACpB,UAAY,EAAA;AAAA,GACd;AAAA,EACA,aAAe,EAAA;AAAA,IACb,eAAA,EAAiB,KAAM,CAAA,OAAA,CAAQ,OAAQ,CAAA,IAAA;AAAA,IACvC,KAAA,EAAO,KAAM,CAAA,OAAA,CAAQ,OAAQ,CAAA,YAAA;AAAA,IAC7B,SAAW,EAAA;AAAA,MACT,eAAA,EAAiB,KAAM,CAAA,OAAA,CAAQ,OAAQ,CAAA;AAAA,KACzC;AAAA,IACA,YAAc,EAAA;AAAA,MACZ,eAAA,EAAiB,KAAM,CAAA,OAAA,CAAQ,MAAO,CAAA,QAAA;AAAA,MACtC,KAAA,EAAO,KAAM,CAAA,OAAA,CAAQ,MAAO,CAAA;AAAA;AAC9B,GACF;AAAA,EACA,cAAgB,EAAA;AAAA,IACd,eAAA,EAAiB,KAAM,CAAA,OAAA,CAAQ,KAAM,CAAA,IAAA;AAAA,IACrC,KAAA,EAAO,KAAM,CAAA,OAAA,CAAQ,KAAM,CAAA,YAAA;AAAA,IAC3B,SAAW,EAAA;AAAA,MACT,eAAA,EAAiB,KAAM,CAAA,OAAA,CAAQ,KAAM,CAAA;AAAA,KACvC;AAAA,IACA,YAAc,EAAA;AAAA,MACZ,eAAA,EAAiB,KAAM,CA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AA,QAAA,EAAA;AAAA,cAAA,aAAA;AAAA,cACpC;AAAA,aACd,EAAA;AAAA,WAEJ,EAAA,CAAA;AAAA,+BACC,aACC,EAAA,EAAA,QAAA,EAAA;AAAA,4BAAA,GAAA,CAAC,MAAO,EAAA,EAAA,OAAA,EAAS,kBAAoB,EAAA,KAAA,EAAM,WAAU,QAErD,EAAA,QAAA,EAAA,CAAA;AAAA,4BACA,GAAA;AAAA,cAAC,MAAA;AAAA,cAAA;AAAA,gBACC,OAAS,EAAA,mBAAA;AAAA,gBACT,KAAM,EAAA,SAAA;AAAA,gBACN,OAAQ,EAAA,WAAA;AAAA,gBACR,SAAS,EAAA,IAAA;AAAA,gBAER,QAAc,EAAA,aAAA,CAAA;AAAA;AAAA;AACjB,WACF,EAAA;AAAA;AAAA;AAAA,KACF;AAAA,oBAGA,GAAA;AAAA,MAAC,QAAA;AAAA,MAAA;AAAA,QACC,MAAM,QAAS,CAAA,IAAA;AAAA,QACf,gBAAkB,EAAA,GAAA;AAAA,QAClB,OAAS,EAAA,mBAAA;AAAA,QACT,YAAc,EAAA,EAAE,QAAU,EAAA,QAAA,EAAU,YAAY,OAAQ,EAAA;AAAA,QAExD,QAAA,kBAAA,GAAA;AAAA,UAAC,KAAA;AAAA,UAAA;AAAA,YACC,OAAS,EAAA,mBAAA;AAAA,YACT,UAAU,QAAS,CAAA,QAAA;AAAA,YACnB,OAAQ,EAAA,QAAA;AAAA,YAEP,QAAS,EAAA,QAAA,CAAA;AAAA;AAAA;AACZ;AAAA;AACF,GACF,EAAA,CAAA;AAEJ;;;;"}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as _backstage_core_plugin_api from '@backstage/core-plugin-api';
2
2
  import { DiscoveryApi, IdentityApi } from '@backstage/core-plugin-api';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
+ import React from 'react';
4
5
 
5
6
  declare const vcfAutomationPlugin: _backstage_core_plugin_api.BackstagePlugin<{
6
7
  root: _backstage_core_plugin_api.RouteRef<undefined>;
@@ -24,6 +25,25 @@ declare const VCFAutomationGenericResourceOverview: () => react_jsx_runtime.JSX.
24
25
 
25
26
  declare const VCFAutomationDeploymentOverview: () => react_jsx_runtime.JSX.Element;
26
27
 
28
+ declare const VCFAutomationCCINamespaceOverview: () => react_jsx_runtime.JSX.Element;
29
+
30
+ declare const VCFAutomationCCIResourceOverview: () => react_jsx_runtime.JSX.Element;
31
+
32
+ declare const VCFAutomationCCINamespaceDetails: () => react_jsx_runtime.JSX.Element;
33
+
34
+ declare const VCFAutomationCCIResourceDetails: () => react_jsx_runtime.JSX.Element;
35
+
36
+ interface VCFAutomationVMPowerManagementProps {
37
+ entity: any;
38
+ resourceId: string;
39
+ instanceName?: string;
40
+ isStandalone: boolean;
41
+ vmName?: string;
42
+ namespaceName?: string;
43
+ namespaceUrnId?: string;
44
+ }
45
+ declare const VCFAutomationVMPowerManagement: React.FC<VCFAutomationVMPowerManagementProps>;
46
+
27
47
  interface VcfPageable {
28
48
  pageNumber: number;
29
49
  pageSize: number;
@@ -153,40 +173,162 @@ interface VcfProjectZone {
153
173
  id: string;
154
174
  }
155
175
  interface VcfProject$1 {
156
- machineNamingTemplate: string;
176
+ name: string;
177
+ description: string;
178
+ id: string;
179
+ operationTimeout: number;
157
180
  administrators: Array<{
158
181
  email: string;
159
182
  type: string;
160
- }>;
161
- members: Array<{
183
+ }> | any[];
184
+ machineNamingTemplate?: string;
185
+ members?: Array<{
162
186
  email: string;
163
187
  type: string;
164
188
  }>;
165
- viewers: Array<{
189
+ viewers?: Array<{
166
190
  email: string;
167
191
  type: string;
168
192
  }>;
169
- supervisors: Array<{
193
+ supervisors?: Array<{
170
194
  email: string;
171
195
  type: string;
172
196
  }>;
173
- zones: VcfProjectZone[];
174
- constraints: Record<string, unknown>;
175
- operationTimeout: number;
176
- sharedResources: boolean;
177
- placementPolicy: string;
178
- customProperties: Record<string, unknown>;
179
- name: string;
180
- description: string;
181
- id: string;
182
- organizationId: string;
183
- orgId: string;
184
- _links: {
197
+ zones?: VcfProjectZone[];
198
+ constraints?: Record<string, unknown>;
199
+ sharedResources?: boolean;
200
+ placementPolicy?: string;
201
+ customProperties?: Record<string, unknown>;
202
+ organizationId?: string;
203
+ _links?: {
185
204
  self: {
186
205
  href: string;
187
206
  };
188
207
  };
208
+ orgId?: string;
209
+ users?: any[];
210
+ auditors?: any[];
211
+ advancedUsers?: any[];
212
+ properties?: Record<string, unknown>;
213
+ }
214
+ interface CciSupervisorNamespace {
215
+ id: string;
216
+ name: string;
217
+ type: 'CCI.Supervisor.Namespace';
218
+ properties: {
219
+ metadata: {
220
+ 'infrastructure.cci.vmware.com/id': string;
221
+ 'infrastructure.cci.vmware.com/project-id': string;
222
+ };
223
+ existing: boolean;
224
+ name: string;
225
+ id: string;
226
+ resourceLink: string;
227
+ status: {
228
+ conditions: Array<{
229
+ lastTransitionTime: string;
230
+ status: string;
231
+ type: string;
232
+ }>;
233
+ namespaceEndpointURL: string;
234
+ phase: string;
235
+ storageClasses: Array<{
236
+ limit: string;
237
+ name: string;
238
+ }>;
239
+ vmClasses: Array<{
240
+ name: string;
241
+ }>;
242
+ zones: Array<{
243
+ cpuLimit: string;
244
+ cpuReservation: string;
245
+ memoryLimit: string;
246
+ memoryReservation: string;
247
+ name: string;
248
+ }>;
249
+ };
250
+ };
251
+ createdAt: string;
252
+ syncStatus: string;
253
+ origin: string;
254
+ state: string;
255
+ }
256
+ interface CciSupervisorResource {
257
+ id: string;
258
+ name: string;
259
+ type: 'CCI.Supervisor.Resource';
260
+ properties: {
261
+ wait?: {
262
+ conditions: Array<{
263
+ type: string;
264
+ status: string;
265
+ }>;
266
+ };
267
+ manifest: any;
268
+ count?: number;
269
+ existing: boolean;
270
+ countIndex?: number;
271
+ context: string;
272
+ id: string;
273
+ resourceLink: string;
274
+ object: any;
275
+ };
276
+ createdAt: string;
277
+ syncStatus: string;
278
+ origin: string;
279
+ dependsOn: string[];
280
+ state: string;
281
+ }
282
+ interface VmPowerAction {
283
+ id: string;
284
+ name: string;
285
+ displayName: string;
286
+ description: string;
287
+ dependents: string[];
288
+ valid: boolean;
289
+ actionType: string;
290
+ }
291
+ interface VmPowerActionRequest {
292
+ actionId: string;
293
+ }
294
+ interface StandaloneVmStatus {
295
+ apiVersion: string;
296
+ kind: string;
297
+ metadata: {
298
+ name: string;
299
+ namespace: string;
300
+ annotations?: {
301
+ [key: string]: string;
302
+ };
303
+ labels?: {
304
+ [key: string]: string;
305
+ };
306
+ creationTimestamp: string;
307
+ uid: string;
308
+ resourceVersion: string;
309
+ };
310
+ spec: {
311
+ powerState: 'PoweredOn' | 'PoweredOff';
312
+ className: string;
313
+ imageName: string;
314
+ network?: any;
315
+ bootstrap?: any;
316
+ [key: string]: any;
317
+ };
318
+ status: {
319
+ powerState: 'PoweredOn' | 'PoweredOff';
320
+ conditions: Array<{
321
+ type: string;
322
+ status: string;
323
+ lastTransitionTime: string;
324
+ reason?: string;
325
+ message?: string;
326
+ }>;
327
+ [key: string]: any;
328
+ };
189
329
  }
330
+ type VmPowerState = 'PoweredOn' | 'PoweredOff';
331
+ type VmPowerActionType = 'PowerOn' | 'PowerOff';
190
332
 
191
333
  interface VcfDeploymentEvent {
192
334
  timestamp: string;
@@ -308,6 +450,17 @@ interface VcfAutomationApi {
308
450
  getProjectDetails(projectId: string, instanceName?: string): Promise<VcfProject>;
309
451
  getGenericResourceDetails(deploymentId: string, resourceId: string, instanceName?: string): Promise<any>;
310
452
  getDeploymentDetails(deploymentId: string, instanceName?: string): Promise<any>;
453
+ getProjects(instanceName?: string): Promise<any>;
454
+ getDeployments(instanceName?: string): Promise<any>;
455
+ getDeploymentResources(deploymentId: string, instanceName?: string): Promise<any>;
456
+ getSupervisorResources(instanceName?: string): Promise<any>;
457
+ getSupervisorResource(resourceId: string, instanceName?: string): Promise<any>;
458
+ getSupervisorNamespaces(instanceName?: string): Promise<any>;
459
+ getSupervisorNamespace(namespaceId: string, instanceName?: string): Promise<any>;
460
+ checkVmPowerAction(resourceId: string, action: 'PowerOn' | 'PowerOff', instanceName?: string): Promise<any>;
461
+ executeVmPowerAction(resourceId: string, action: 'PowerOn' | 'PowerOff', instanceName?: string): Promise<any>;
462
+ getStandaloneVmStatus(namespaceUrnId: string, namespaceName: string, vmName: string, instanceName?: string): Promise<any>;
463
+ executeStandaloneVmPowerAction(namespaceUrnId: string, namespaceName: string, vmName: string, powerState: 'PoweredOn' | 'PoweredOff', vmData: any, instanceName?: string): Promise<any>;
311
464
  }
312
465
  declare const vcfAutomationApiRef: _backstage_core_plugin_api.ApiRef<VcfAutomationApi>;
313
466
  declare class VcfAutomationClient implements VcfAutomationApi {
@@ -323,8 +476,19 @@ declare class VcfAutomationClient implements VcfAutomationApi {
323
476
  getGenericResourceDetails(deploymentId: string, resourceId: string, instanceName?: string): Promise<any>;
324
477
  getDeploymentDetails(deploymentId: string, instanceName?: string): Promise<any>;
325
478
  getProjectDetails(projectId: string, instanceName?: string): Promise<VcfProject>;
479
+ getProjects(instanceName?: string): Promise<any>;
480
+ getDeployments(instanceName?: string): Promise<any>;
481
+ getDeploymentResources(deploymentId: string, instanceName?: string): Promise<any>;
482
+ getSupervisorResources(instanceName?: string): Promise<any>;
483
+ getSupervisorResource(resourceId: string, instanceName?: string): Promise<any>;
484
+ getSupervisorNamespaces(instanceName?: string): Promise<any>;
485
+ getSupervisorNamespace(namespaceId: string, instanceName?: string): Promise<any>;
486
+ checkVmPowerAction(resourceId: string, action: 'PowerOn' | 'PowerOff', instanceName?: string): Promise<any>;
487
+ executeVmPowerAction(resourceId: string, action: 'PowerOn' | 'PowerOff', instanceName?: string): Promise<any>;
488
+ getStandaloneVmStatus(namespaceUrnId: string, namespaceName: string, vmName: string, instanceName?: string): Promise<any>;
489
+ executeStandaloneVmPowerAction(namespaceUrnId: string, namespaceName: string, vmName: string, powerState: 'PoweredOn' | 'PoweredOff', vmData: any, instanceName?: string): Promise<any>;
326
490
  }
327
491
 
328
492
  declare const rootRouteRef: _backstage_core_plugin_api.RouteRef<undefined>;
329
493
 
330
- export { VCFAutomationDeploymentDetails, VCFAutomationDeploymentOverview, VCFAutomationGenericResourceDetails, VCFAutomationGenericResourceOverview, VCFAutomationProjectDetails, VCFAutomationProjectOverview, VCFAutomationVSphereVMDetails, VCFAutomationVSphereVMOverview, type VcfAutomationApi, VcfAutomationClient, type VcfDeploymentEvent$1 as VcfDeploymentEvent, type VcfDeploymentHistory, type VcfPageResponse, type VcfPageable, type VcfProject$1 as VcfProject, type VcfProjectZone, type VcfResource, type VcfResourceDisk, type VcfResourceExpense, type VcfResourceNetwork, rootRouteRef, vcfAutomationApiRef, vcfAutomationPlugin };
494
+ export { type CciSupervisorNamespace, type CciSupervisorResource, type StandaloneVmStatus, VCFAutomationCCINamespaceDetails, VCFAutomationCCINamespaceOverview, VCFAutomationCCIResourceDetails, VCFAutomationCCIResourceOverview, VCFAutomationDeploymentDetails, VCFAutomationDeploymentOverview, VCFAutomationGenericResourceDetails, VCFAutomationGenericResourceOverview, VCFAutomationProjectDetails, VCFAutomationProjectOverview, VCFAutomationVMPowerManagement, VCFAutomationVSphereVMDetails, VCFAutomationVSphereVMOverview, type VcfAutomationApi, VcfAutomationClient, type VcfDeploymentEvent$1 as VcfDeploymentEvent, type VcfDeploymentHistory, type VcfPageResponse, type VcfPageable, type VcfProject$1 as VcfProject, type VcfProjectZone, type VcfResource, type VcfResourceDisk, type VcfResourceExpense, type VcfResourceNetwork, type VmPowerAction, type VmPowerActionRequest, type VmPowerActionType, type VmPowerState, rootRouteRef, vcfAutomationApiRef, vcfAutomationPlugin };
package/dist/index.esm.js CHANGED
@@ -7,6 +7,11 @@ export { VCFAutomationVSphereVMDetails } from './components/VCFAutomationVSphere
7
7
  export { VCFAutomationGenericResourceDetails } from './components/VCFAutomationGenericResourceDetails.esm.js';
8
8
  export { VCFAutomationGenericResourceOverview } from './components/VCFAutomationGenericResourceOverview.esm.js';
9
9
  export { VCFAutomationDeploymentOverview } from './components/VCFAutomationDeploymentOverview.esm.js';
10
+ export { VCFAutomationCCINamespaceOverview } from './components/VCFAutomationCCINamespaceOverview.esm.js';
11
+ export { VCFAutomationCCIResourceOverview } from './components/VCFAutomationCCIResourceOverview.esm.js';
12
+ export { VCFAutomationCCINamespaceDetails } from './components/VCFAutomationCCINamespaceDetails.esm.js';
13
+ export { VCFAutomationCCIResourceDetails } from './components/VCFAutomationCCIResourceDetails.esm.js';
14
+ export { VCFAutomationVMPowerManagement } from './components/VCFAutomationVMPowerManagement.esm.js';
10
15
  export { VcfAutomationClient, vcfAutomationApiRef } from './api/VcfAutomationClient.esm.js';
11
16
  export { rootRouteRef } from './routes.esm.js';
12
17
  //# sourceMappingURL=index.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
1
+ {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;"}