/*
 * Copyright 2020-2025 VMware, Inc. All rights reserved. VMware Confidential
 */
import { Observable } from "rxjs";
import { CREATE_IP_BINDINGS_TYPE } from "../create-ip-bindings/create-ip-bindings.extension-point";
import { CREATE_ORG_TYPE } from "../create-org/create-org.extension-point";
import {
    CREATE_VAPP_OVF_TYPE,
    CREATE_VAPP_TEMPLATE_TYPE,
    CREATE_VAPP_TYPE,
} from "../create-vapp/create-vapp.extension-point";
import { CREATE_VM_TYPE } from "../create-vm/create-vm.extension-point";

export type INTERENAL_EXTENSION_POINT_TYPE =
    | CREATE_VM_TYPE
    | CREATE_VAPP_TYPE
    | CREATE_VAPP_OVF_TYPE
    | CREATE_VAPP_TEMPLATE_TYPE
    | CREATE_ORG_TYPE
    | CREATE_IP_BINDINGS_TYPE;

export interface ExtensibilityEvent<Payload, ReturnType> {
    extensionPointType: INTERENAL_EXTENSION_POINT_TYPE;
    payload: Payload;
    returnValue: Observable<ReturnType> | Promise<ReturnType> | ReturnType;
}

export class FakeCreateVMOrVappEvent implements ExtensibilityEvent<{ value: any; }, Observable<any>> {
    extensionPointType: CREATE_VAPP_TYPE;
    payload: {
        value: any;
    };
    returnValue: Observable<any>;

    constructor(payload, returnValue) {
        this.extensionPointType = CREATE_VAPP_TYPE;
        this.payload = payload;
        this.returnValue = returnValue;
    }
}

export class CreateIpBindingsEvent implements ExtensibilityEvent<{ value: any; }, Observable<any>> {
    id: string;
    extensionPointType: CREATE_IP_BINDINGS_TYPE;
    payload: {
        value: any;
    };
    returnValue: Observable<any>;

    constructor(id: string, payload, returnValue) {
        this.id = id;
        this.extensionPointType = CREATE_IP_BINDINGS_TYPE;
        this.payload = payload;
        this.returnValue = returnValue;
    }
}
