import type { Application, InjectedDependenciesParam, BalenaModel, ApplicationMembershipRole } from '..'; import type { ODataOptionsWithoutCount, OptionsToResponse, ResourceAlternateKey } from 'pinejs-client-core'; declare const RESOURCE = "user_application_membership"; type ApplicationMembership = BalenaModel[typeof RESOURCE]; type ResourceKey = number | ResourceAlternateKey>; export interface ApplicationMembershipCreationOptions { application: string | number; username: string; roleName?: ApplicationMembershipRole['Read']['name']; } declare const getApplicationMembershipModel: (deps: InjectedDependenciesParam, getApplication: >(slugOrUuidOrId: string | number, options?: T) => Promise[number]>) => { /** * @summary Get a single application membership * @name get * @public * @function * @memberof balena.models.application.membership * * @description * This method returns a single application membership. * * @param {number|Object} membershipId - the id or an object with the unique `user` & `is_member_of__application` numeric pair of the membership * @param {Object} [options={}] - extra pine options to use * @fulfil {Object} - application membership * @returns {Promise} * * @example * balena.models.application.membership.get(5).then(function(memberships) { * console.log(memberships); * }); */ get>(membershipId: ResourceKey, options?: T): Promise[number]>; /** * @summary Get all memberships by application * @name getAllByApplication * @public * @function * @memberof balena.models.application.membership * * @description * This method returns all application memberships for a specific application. * * @param {String|Number} slugOrUuidOrId - application slug (string), uuid (string) or id (number) * @param {Object} [options={}] - extra pine options to use * @fulfil {Object[]} - application memberships * @returns {Promise} * * @example * balena.models.application.membership.getAllByApplication('myorganization/myapp').then(function(memberships) { * console.log(memberships); * }); * * @example * balena.models.application.membership.getAllByApplication(123).then(function(memberships) { * console.log(memberships); * }); */ getAllByApplication>(slugOrUuidOrId: number | string, options?: T): Promise>; /** * @summary Get all memberships by user * @name getAllByUser * @public * @function * @memberof balena.models.application.membership * * @description * This method returns all application memberships for a specific user. * * @param {String|Number} usernameOrId - the user's username (string) or id (number) * @param {Object} [options={}] - extra pine options to use * @fulfil {Object[]} - application memberships * @returns {Promise} * * @example * balena.models.application.membership.getAllByUser('balena_os').then(function(memberships) { * console.log(memberships); * }); * * @example * balena.models.application.membership.getAllByUser(123).then(function(memberships) { * console.log(memberships); * }); */ getAllByUser>(usernameOrId: number | string, options?: T): Promise>; /** * @summary Creates a new membership for an application * @name create * @public * @function * @memberof balena.models.application.membership * * @description This method adds a user to an application by their username if they are a member of the organization. * * @param {Object} options - membership creation parameters * @param {String|Number} options.application - application handle (string), or id (number) * @param {String} options.username - the username of the balena user that will become a member * @param {String} [options.roleName="member"] - the role name to be granted to the membership * * @fulfil {Object} - application membership * @returns {Promise} * * @example * balena.models.application.membership.create({ application: "myApp", username: "user123", roleName: "member" }).then(function(membership) { * console.log(membership); * }); */ create({ application, username, roleName, }: ApplicationMembershipCreationOptions): Promise>; /** * @summary Changes the role of an application member * @name changeRole * @public * @function * @memberof balena.models.application.membership * * @description This method changes the role of an application member. * * @param {Number|Object} idOrUniqueKey - the id or an object with the unique `user` & `is_member_of__application` numeric pair of the membership that will be changed * @param {String} roleName - the role name to be granted to the membership * * @returns {Promise} * * @example * balena.models.application.membership.changeRole(123, "member").then(function() { * console.log('OK'); * }); * * @example * balena.models.application.membership.changeRole({ * user: 123, * is_member_of__application: 125, * }, "member").then(function() { * console.log('OK'); * }); */ changeRole(idOrUniqueKey: ResourceKey, roleName: ApplicationMembershipRole["Read"]["name"]): Promise; /** * @summary Remove a membership * @name remove * @public * @function * @memberof balena.models.application.membership * * @param {Number|Object} idOrUniqueKey - the id or an object with the unique `user` & `is_member_of__application` numeric pair of the membership that will be removed * @returns {Promise} * * @example * balena.models.application.membership.remove(123); * * @example * balena.models.application.membership.remove({ * user: 123, * is_member_of__application: 125, * }); */ remove(idOrUniqueKey: ResourceKey): Promise; }; export default getApplicationMembershipModel;