This document provides a concise guide to the Switch module, focusing on the Switch model and its usage.
Defines the structure for Switch entities.
type Switch = {
_id?: string;
id: string;
createdAt: Date | string;
updatedAt: Date | string;
deletedAt?: Date;
kind: string;
connectables: Array<string | null>;
switchType: string;
port_labels: Array<string | null>;
shelf?: string | null;
manageable: boolean;
};
Defines the structure for creating a new Switch.
type CreateSwitchDTO = {
kind?: string;
connectables?: Array<string | null>;
switchType?: string;
port_labels?: Array<string | null>;
shelf?: string | null;
manageable?: boolean;
external_id?: any;
};
Defines the structure for updating an existing Switch.
type UpdateSwitchDTO = {
kind?: string;
connectables?: Array<string | null>;
switchType?: string;
port_labels?: Array<string | null>;
shelf?: string | null;
manageable?: boolean;
external_id?: any;
};
import OZMapSDK from 'ozmapsdk';
const sdk = new OZMapSDK('ozmapURL', { apiKey: 'yourApiKey' });
const newSwitchData: CreateSwitchDTO = {
kind: 'SWITCH',
switchType: 'switchTypeId',
port_labels: ['Port 1', 'Port 2'],
manageable: true,
};
sdk.switch.create(newswitchData).then((sw) => {
console.log('switch created:', sw);
});
import OZMapSDK from 'ozmapsdk';
const sdk = new OZMapSDK('ozmapURL', { apiKey: 'yourApiKey' });
const updateSwitchData: UpdateSwitchDTO = {
manageable: false,
};
sdk.switch.updateById('switchId', updateSwitchData).then(() => {
console.log('Switch updated');
});
import OZMapSDK from 'ozmapsdk';
const sdk = new OZMapSDK('ozmapURL', { apiKey: 'yourApiKey' });
sdk.switch.deleteById('switchId').then(() => {
console.log('Switch deleted');
});
import OZMapSDK from 'ozmapsdk';
const sdk = new OZMapSDK('ozmapURL', { apiKey: 'yourApiKey' });
sdk.switch.find({ page: 1, limit: 10 }).then((pagination) => {
console.log('switch:', pagination);
});
import OZMapSDK from 'ozmapsdk';
const sdk = new OZMapSDK('ozmapURL', { apiKey: 'yourApiKey' });
sdk.switch.findById('switchId').then((sw) => {
console.log('switch:', sw);
});