4.0.0-alpha.0 • Published 2 days ago

@magda/auth-api-client v4.0.0-alpha.0

Weekly downloads
15
License
Apache-2.0
Repository
-
Last release
2 days 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.0.0-alpha.0

2 days ago

3.0.2

20 days ago

3.0.2-alpha.1

23 days ago

3.0.2-alpha.0

24 days ago

3.0.1

1 month ago

3.0.1-alpha.0

1 month ago

3.0.0

2 months ago

3.0.0-alpha.2

3 months ago

3.0.0-alpha.1

3 months ago

3.0.0-alpha.0

4 months ago

2.3.0-alpha.0

9 months ago

2.3.0

8 months ago

2.3.2

7 months ago

2.3.1

8 months ago

2.3.3

6 months ago

2.2.5-alpha.1

10 months ago

2.2.5

9 months ago

2.2.6

9 months ago

2.3.2-alpha.1

7 months ago

2.3.2-alpha.0

8 months ago

2.3.2-alpha.2

7 months ago

2.2.5-alpha.0

11 months ago

2.2.4

12 months ago

2.2.4-alpha.0

1 year ago

2.2.4-alpha.1

1 year ago

2.2.3-alpha.3

1 year ago

2.2.3

1 year ago

2.2.3-alpha.1

1 year ago

2.2.3-alpha.0

1 year ago

2.2.3-alpha.2

1 year ago

2.2.2-alpha.1

1 year ago

2.2.2-alpha.0

1 year ago

2.2.2

1 year ago

2.2.2-rc.0

1 year ago

2.2.1

1 year ago

2.2.0

1 year ago

2.2.0-alpha.0

2 years ago

2.2.0-alpha.3

1 year ago

2.2.0-alpha.2

1 year ago

2.2.0-alpha.1

1 year ago

2.1.1-alpha.0

2 years ago

2.1.1

2 years ago

2.1.0

2 years ago

2.1.2-alpha.0

2 years ago

2.0.1

2 years ago

2.1.0-alpha.1

2 years ago

2.1.0-alpha.0

2 years ago

2.0.0-alpha.7

2 years ago

2.0.0-alpha.8

2 years ago

2.0.0-alpha.4

2 years ago

2.0.0-alpha.5

2 years ago

2.0.0-alpha.6

2 years ago

1.3.1-rc.2

2 years ago

1.3.1-rc.1

2 years ago

1.3.1-rc.0

2 years ago

2.0.0

2 years ago

1.3.1

2 years ago

0.0.60-dt.2

2 years ago

2.0.0-alpha.3

2 years ago

2.0.0-alpha.2

2 years ago

1.3.0

2 years ago

1.2.1

2 years ago

2.0.0-alpha.1

2 years ago

1.3.0-rc.0

2 years ago

1.2.2-alpha.0

2 years ago

1.2.1-rc.0

2 years ago

2.0.0-alpha.0

2 years ago

1.2.0

2 years ago

1.2.1-alpha.0

2 years ago

1.2.0-rc.0

2 years ago

1.2.0-alpha.1

2 years ago

1.0.1

2 years ago

1.1.0-arm64.0

3 years ago

1.1.0-rc.1

2 years ago

1.1.0-rc.0

2 years ago

1.1.0

2 years ago

1.2.0-alpha.0

2 years ago

1.1.0-alpha.2

2 years ago

0.0.60-dt.1

2 years ago

1.1.0-alpha.3

2 years ago

0.0.60-dt.0

2 years ago

1.1.0-alpha.4

2 years ago

1.1.0-alpha.1

3 years ago

1.0.0

3 years ago

1.0.0-alpha.5

3 years ago

1.0.0-alpha.4

3 years ago

1.1.0-alpha.0

3 years ago

1.0.0-alpha.3

3 years ago

1.0.0-alpha.2

3 years ago

1.0.0-alpha.1

3 years ago

0.0.60

3 years ago

1.0.0-alpha.0

3 years ago

0.0.60-rc.5

3 years ago

0.0.60-alpha.18

3 years ago

0.0.60-alpha.17

3 years ago

0.0.60-alpha.16

3 years ago

0.0.60-alpha.15

3 years ago

0.0.60-rc.4

3 years ago

0.0.60-alpha.14

3 years ago

0.0.60-alpha.13

3 years ago

0.0.60-rc.3

3 years ago

0.0.60-alpha.12

3 years ago

0.0.60-alpha.11

3 years ago

0.0.60-alpha.10

3 years ago

0.0.60-rc.2

3 years ago

0.0.60-alpha.9

3 years ago

0.0.60-alpha.8

3 years ago

0.0.60-alpha.7

3 years ago

0.0.60-alpha.6

3 years ago

0.0.60-rc.1

3 years ago

0.0.60-alpha.5

3 years ago

0.0.60-rc.0

3 years ago

0.0.60-alpha.4

3 years ago

0.0.60-alpha.3

3 years ago

0.0.60-alpha.2

3 years ago

0.0.60-alpha.1

3 years ago

0.0.60-alpha.0

3 years ago

0.0.59

3 years ago

0.0.59-alpha.3

3 years ago

0.0.59-alpha.2

3 years ago

0.0.59-alpha.1

3 years ago

0.0.59-alpha.0

3 years ago

0.0.58

3 years ago

0.0.58-rc.5

3 years ago

0.0.58-rc.4

3 years ago

0.0.58-alpha.4

4 years ago

0.0.58-alpha.3

4 years ago

0.0.58-alpha.2

4 years ago

0.0.58-alpha.1

4 years ago

0.0.58-alpha.0

4 years ago