4.2.4 • Published 10 months ago

@magda/auth-api-client v4.2.4

Weekly downloads
15
License
Apache-2.0
Repository
-
Last release
10 months ago

MAGDA Auth API Client

A client lib used to communicate with Magda's authorisation API. This client lib is designed to be used within the cluster internally.

export default class ApiClient {
    constructor(baseUrl: string, jwtSecret?: string, userId?: string);

    /**
     * Get the data of a user.
     *
     * @param {string} userId
     * @returns {Promise<Maybe<User>>}
     * @memberof ApiClient
     */
    getUser(userId: string): Promise<Maybe<User>>;

    /**
     * Lookup user by source (identity provider) & sourceId (identity ID)
     *
     * @param {string} source
     * @param {string} sourceId
     * @returns {Promise<Maybe<User>>}
     * @memberof ApiClient
     */
    lookupUser(source: string, sourceId: string): Promise<Maybe<User>>;

    /**
     * create a user
     *
     * @param {User} user
     * @returns {Promise<User>}
     * @memberof ApiClient
     */
    createUser(user: User): Promise<User>;

    /**
     * Add Roles to a user.
     * Returns a list of current role ids of the user.
     *
     * @param {string} userId
     * @param {string[]} roleIds
     * @returns {Promise<string[]>}
     * @memberof ApiClient
     */
    addUserRoles(userId: string, roleIds: string[]): Promise<string[]>;

    /**
     * Remove a list roles from a user.
     *
     * @param {string} userId
     * @param {string[]} roleIds
     * @returns {Promise<void>}
     * @memberof ApiClient
     */
    deleteUserRoles(userId: string, roleIds: string[]): Promise<void>;

    /**
     * Get all roles of a user
     *
     * @param {string} userId
     * @returns {Promise<Role[]>}
     * @memberof ApiClient
     */
    getUserRoles(userId: string): Promise<Role[]>;

    /**
     * Get all permissions of a user
     *
     * @param {string} userId
     * @returns {Promise<Permission[]>}
     * @memberof ApiClient
     */
    getUserPermissions(userId: string): Promise<Permission[]>;

    /**
     * Get all permissions of a role
     *
     * @param {string} roleId
     * @returns {Promise<Permission[]>}
     * @memberof ApiClient
     */
    getRolePermissions(roleId: string): Promise<Permission[]>;

    /**
     * List OrgUnits at certain org tree level.
     * Optionally provide a test Org Unit Id that will be used to test the relationship with each of returned orgUnit item.
     * Possible Value: 'ancestor', 'descendant', 'equal', 'unrelated'
     *
     * @param {string} orgLevel The level number (starts from 1) where org Units of the tree are taken horizontally.
     * @param {string} [relationshipOrgUnitId] Optional; The org unit id that is used to test the relationship with each of returned orgUnit item.
     * @returns {Promise<OrgUnit[]>}
     * @memberof ApiClient
     */
    getOrgUnitsByLevel(
        orgLevel: string,
        relationshipOrgUnitId?: string
    ): Promise<OrgUnit[]>;

    /**
     * Get orgunits by name
     *
     * @param {string} nodeName
     * @param {boolean} [leafNodesOnly=false] Whether only leaf nodes should be returned
     * @param {string} [relationshipOrgUnitId] Optional; The org unit id that is used to test the relationship with each of returned orgUnit item.
     * @returns {Promise<OrgUnit[]>}
     * @memberof ApiClient
     */
    getOrgUnitsByName(
        nodeName: string,
        leafNodesOnly?: boolean,
        relationshipOrgUnitId?: string
    ): Promise<OrgUnit[]>;

    /**
     * Gets the root organisation unit (top of the tree).
     *
     * @returns {Promise<OrgUnit>}
     * @memberof ApiClient
     */
    getRootOrgUnit(): Promise<OrgUnit>;

    /**
     * Gets the details of the node with its id.
     *
     * @param {string} nodeId
     * @returns {Promise<OrgUnit>}
     * @memberof ApiClient
     */
    getOrgUnitById(nodeId: string): Promise<OrgUnit>;

    /**
     * Gets all the children immediately below the requested node. If the node doesn't exist, returns an empty list.
     *
     * @param {string} nodeId
     * @returns {Promise<OrgUnit[]>}
     * @memberof ApiClient
     */
    getImmediateOrgUnitChildren(nodeId: string): Promise<OrgUnit[]>;

    /**
     * Gets all the children below the requested node recursively. If node doesn't exist, returns an empty list.
     *
     * @param {string} nodeId
     * @returns {Promise<OrgUnit[]>}
     * @memberof ApiClient
     */
    getAllOrgUnitChildren(nodeId: string): Promise<OrgUnit[]>;
}
4.2.4-alpha.1

10 months ago

4.2.4

10 months ago

4.2.4-alpha.0

11 months ago

4.0.0-alpha.5

1 year ago

4.0.0-alpha.4

1 year ago

4.0.1

1 year ago

4.0.0

1 year ago

4.2.2-alpha.0

12 months ago

4.2.3

11 months ago

4.2.2

11 months ago

4.2.1

1 year ago

4.2.0

1 year ago

4.1.0

1 year ago

3.0.4

1 year ago

4.0.0-alpha.3

1 year ago

3.0.3

1 year ago

4.0.0-alpha.2

1 year ago

4.0.0-alpha.1

1 year ago

4.0.0-alpha.0

1 year ago

3.0.2

1 year ago

3.0.2-alpha.1

1 year ago

3.0.2-alpha.0

1 year ago

3.0.1

1 year ago

3.0.1-alpha.0

1 year ago

3.0.0

1 year ago

3.0.0-alpha.2

1 year ago

3.0.0-alpha.1

1 year ago

3.0.0-alpha.0

2 years ago

2.3.0-alpha.0

2 years ago

2.3.0

2 years ago

2.3.2

2 years ago

2.3.1

2 years ago

2.3.3

2 years ago

2.2.5-alpha.1

2 years ago

2.2.5

2 years ago

2.2.6

2 years ago

2.3.2-alpha.1

2 years ago

2.3.2-alpha.0

2 years ago

2.3.2-alpha.2

2 years ago

2.2.5-alpha.0

2 years ago

2.2.4

2 years ago

2.2.4-alpha.0

2 years ago

2.2.4-alpha.1

2 years ago

2.2.3-alpha.3

2 years ago

2.2.3

2 years ago

2.2.3-alpha.1

2 years ago

2.2.3-alpha.0

2 years ago

2.2.3-alpha.2

2 years ago

2.2.2-alpha.1

2 years ago

2.2.2-alpha.0

2 years ago

2.2.2

2 years ago

2.2.2-rc.0

2 years ago

2.2.1

2 years ago

2.2.0

3 years ago

2.2.0-alpha.0

3 years ago

2.2.0-alpha.3

3 years ago

2.2.0-alpha.2

3 years ago

2.2.0-alpha.1

3 years ago

2.1.1-alpha.0

3 years ago

2.1.1

3 years ago

2.1.0

3 years ago

2.1.2-alpha.0

3 years ago

2.0.1

3 years ago

2.1.0-alpha.1

3 years ago

2.1.0-alpha.0

3 years ago

2.0.0-alpha.7

3 years ago

2.0.0-alpha.8

3 years ago

2.0.0-alpha.4

3 years ago

2.0.0-alpha.5

3 years ago

2.0.0-alpha.6

3 years ago

1.3.1-rc.2

3 years ago

1.3.1-rc.1

3 years ago

1.3.1-rc.0

3 years ago

2.0.0

3 years ago

1.3.1

3 years ago

0.0.60-dt.2

3 years ago

2.0.0-alpha.3

3 years ago

2.0.0-alpha.2

3 years ago

1.3.0

3 years ago

1.2.1

3 years ago

2.0.0-alpha.1

3 years ago

1.3.0-rc.0

3 years ago

1.2.2-alpha.0

3 years ago

1.2.1-rc.0

3 years ago

2.0.0-alpha.0

3 years ago

1.2.0

3 years ago

1.2.1-alpha.0

3 years ago

1.2.0-rc.0

3 years ago

1.2.0-alpha.1

3 years ago

1.0.1

4 years ago

1.1.0-arm64.0

4 years ago

1.1.0-rc.1

4 years ago

1.1.0-rc.0

4 years ago

1.1.0

4 years ago

1.2.0-alpha.0

4 years ago

1.1.0-alpha.2

4 years ago

0.0.60-dt.1

4 years ago

1.1.0-alpha.3

4 years ago

0.0.60-dt.0

4 years ago

1.1.0-alpha.4

4 years ago

1.1.0-alpha.1

4 years ago

1.0.0

4 years ago

1.0.0-alpha.5

4 years ago

1.0.0-alpha.4

4 years ago

1.1.0-alpha.0

4 years ago

1.0.0-alpha.3

4 years ago

1.0.0-alpha.2

4 years ago

1.0.0-alpha.1

4 years ago

0.0.60

4 years ago

1.0.0-alpha.0

4 years ago

0.0.60-rc.5

4 years ago

0.0.60-alpha.18

4 years ago

0.0.60-alpha.17

4 years ago

0.0.60-alpha.16

4 years ago

0.0.60-alpha.15

4 years ago

0.0.60-rc.4

4 years ago

0.0.60-alpha.14

4 years ago

0.0.60-alpha.13

4 years ago

0.0.60-rc.3

4 years ago

0.0.60-alpha.12

4 years ago

0.0.60-alpha.11

4 years ago

0.0.60-alpha.10

4 years ago

0.0.60-rc.2

4 years ago

0.0.60-alpha.9

4 years ago

0.0.60-alpha.8

4 years ago

0.0.60-alpha.7

4 years ago

0.0.60-alpha.6

4 years ago

0.0.60-rc.1

4 years ago

0.0.60-alpha.5

4 years ago

0.0.60-rc.0

4 years ago

0.0.60-alpha.4

4 years ago

0.0.60-alpha.3

4 years ago

0.0.60-alpha.2

4 years ago

0.0.60-alpha.1

4 years ago

0.0.60-alpha.0

4 years ago

0.0.59

4 years ago

0.0.59-alpha.3

4 years ago

0.0.59-alpha.2

5 years ago

0.0.59-alpha.1

5 years ago

0.0.59-alpha.0

5 years ago

0.0.58

5 years ago

0.0.58-rc.5

5 years ago

0.0.58-rc.4

5 years ago

0.0.58-alpha.4

5 years ago

0.0.58-alpha.3

5 years ago

0.0.58-alpha.2

5 years ago

0.0.58-alpha.1

5 years ago

0.0.58-alpha.0

5 years ago