Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • SubUserManager

Index

Constructors

Properties

cache: Dict<string, SubUser>
client: PteroClient
serverId: string

Accessors

  • get panelURL(): string

Methods

  • _patch(data: any): any
  • Transforms the raw subuser object(s) into class objects.

    Parameters

    • data: any

      The resolvable subuser object(s).

    Returns any

    The resolved subuser object(s).

  • add(email: string, permissions: string[]): Promise<SubUser>
  • Adds a user as a subuser to the server.

    example
    const perms = new Permissions(...Permissions.CONTROL, ...Permissions.FILES);
    const server = await client.servers.fetch('1c639a86');
    await server.users.add('user@example.com', perms.value)
    .then(console.log)
    .catch(console.error);

    Parameters

    • email: string

      The email of the account to add.

    • permissions: string[]

      Permissions for the account.

    Returns Promise<SubUser>

    The new subuser.

  • Fetches a subuser from the API by its UUID. This will check the cache first unless the force option is specified.

    example
    const server = await client.servers.fetch('1c639a86');
    await server.users.fetch('36de5ed4-8c37-4bde-a1da-4203115a3e9d')
    .then(console.log)
    .catch(console.error);

    Parameters

    • uuid: string

      The UUID of the subuser.

    • Optional options: FetchOptions

    Returns Promise<SubUser>

    The fetched subuser.

  • Fetches a list of subusers from the API with the given options (default is undefined).

    example
    const server = await client.servers.fetch('1c639a86');
    await server.users.fetch({ perPage: 10 })
    .then(console.log)
    .catch(console.error);

    Parameters

    Returns Promise<Dict<number, SubUser>>

    The fetched subusers.

  • remove(id: string): Promise<void>
  • Removes a subuser's access to the server.

    example
    const server = await client.servers.fetch('1c639a86');
    await server.users.remove('9d7b1d20-6e34-4a3a-abcd-c26ae79dc2bd')
    .catch(console.error);

    Parameters

    • id: string

      The UUID of the subuser.

    Returns Promise<void>

  • setPermissions(id: string, permissions: string[]): Promise<SubUser>
  • Updates the permissions of a specified subuser.

    example
    const perms = new Permissions(...Permissions.FILES, ...Permissions.BACKUPS);
    const server = await client.servers.fetch('1c639a86');
    await server.users.setPermissions(
    '36de5ed4-8c37-4bde-a1da-4203115a3e9d',
    perms.value
    )
    .then(console.log)
    .catch(console.error);

    Parameters

    • id: string

      The UUID of the subuser.

    • permissions: string[]

      The permissions to set.

    Returns Promise<SubUser>

    The updated subuser account.

Generated using TypeDoc