pterowraptyl
    Preparing search index...

    Class NodesModule

    Module for accessing Pterodactyl nodes endpoints. This module provides methods to access node details, create nodes, update nodes, etc.

    Index

    Constructors

    Methods

    • Parameters

      • data: AllocationRequest

        The request object containing the node ID and allocation details to create.

      Returns Promise<boolean>

      • A promise that resolves to true if the allocation was successfully created, otherwise false.
      //creating an allocation on a node
      const isCreated = await ptero.nodes.createAllocation({
      id: 1,
      ip: "127.0.0.1",
      port: ["8080"],
      });
      console.log("Allocation Created:", isCreated);
    • Creates a new node with the specified attributes. This method allows you to create a new node in the Pterodactyl panel

      Parameters

      • data: NodeAttributes

        The attributes of the node to create. This should include all required fields as per the Pterodactyl API documentation.

      Returns Promise<NodeAttributes>

      • A promise that resolves to the attributes of the created node.
      const newNode = await ptero.nodes.createNode({
      name: "New Node",
      location_id: 1,
      fqdn: "node2.example.com",
      scheme: "https",
      memory: 10240,
      memory_overallocate: 0,
      disk: 50000,
      disk_overallocate: 0,
      upload_size: 100,
      daemon_sftp: 2022,
      daemon_listen: 8080,
      });
      console.log("New Node Created:", newNode);
    • Deletes an allocation from a node.

      Parameters

      Returns Promise<boolean>

      • A promise that resolves to true if the allocation was successfully deleted, otherwise false.
      //deleting an allocation from a node
      const isDeleted = await ptero.nodes.deleteAllocation({ id: 1, allocation_id: 123 });
      console.log("Allocation Deleted:", isDeleted);
    • Deletes a node by its ID.

      Parameters

      • data: NodeIdRequest

        The request object containing the node ID to delete.

      Returns Promise<boolean>

      • A promise that resolves to true if the node was successfully deleted, otherwise false.
      //deleting a node by its ID
      const isDeleted = await ptero.nodes.deleteNode({ id: "node-id" });
      console.log("Node Deleted:", isDeleted);
    • Fetches all nodes with optional include parameters and pagination.

      Parameters

      • Optionalinclude: IncludeParameters[]

        Include parameters to specify related resources to include in the response. Allowed values are IncludeParameters.SERVERS, IncludeParameters.ALLOCATIONS, and IncludeParameters.LOCATION. If not provided, no related resources are included.

      • Optionalpagination: PaginationOptions

        Pagination options to control the number of results returned.

      Returns Promise<NodeAttributes[]>

      • A promise that resolves to an array of node attributes.
      //fetching all nodes with all include parameters
      const nodes = await ptero.nodes.fetchAll(["allocations", "servers", "location"]);
      console.log("Nodes:", nodes);
    • Fetches the configuration of a node by its ID.

      Parameters

      Returns Promise<NodeConfig>

      • A promise that resolves to the configuration of the requested node.
      // fetching config of node 1
      const config = await ptero.nodes.fetchConfiguration({id: 1});
      console.log("Node 1 Configuration:", config);
    • Fetches a single node by its ID with optional include parameters.

      Parameters

      • data: NodeIdRequest

        The request object containing the node ID.

      • Optionalinclude: IncludeParameters[]

        Include parameters to specify related resources to include in the response. Allowed values are IncludeParameters.SERVERS, IncludeParameters.ALLOCATIONS, and IncludeParameters.LOCATION. If not provided, no related resources are included.

      Returns Promise<NodeAttributes>

      • A promise that resolves to the attributes of the requested node.
      //fetching a single node by its ID with all include parameters
      const node = await ptero.nodes.fetchOne({ id: "node-id" },
      ["allocations", "servers", "location"]);
      console.log("Node:", node);
    • Updates an existing node with the specified attributes.

      Parameters

      • data: NodeUpdateRequest

        The request object containing the node ID and attributes to update.

      Returns Promise<NodeAttributes>

      • A promise that resolves to the updated attributes of the node.
      const node = await ptero.nodes.updateNode({
      id: 2,
      name: "Updated_Node",
      location_id: 1,
      fqdn: "node2.example.com",
      scheme: "https",
      memory: 10240,
      memory_overallocate: 0,
      disk: 50000,
      disk_overallocate: 0,
      daemon_sftp: 2022,
      daemon_listen: 8080,
      });
      console.log("Update:", node);