/* * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for * license information. * * Code generated by Microsoft (R) AutoRest Code Generator. * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ import * as msRest from "@azure/ms-rest-js"; import * as Models from "../models"; import * as Mappers from "../models/groupsMappers"; import * as Parameters from "../models/parameters"; import { GraphRbacManagementClientContext } from "../graphRbacManagementClientContext"; /** Class representing a Groups. */ export class Groups { private readonly client: GraphRbacManagementClientContext; /** * Create a Groups. * @param {GraphRbacManagementClientContext} client Reference to the service client. */ constructor(client: GraphRbacManagementClientContext) { this.client = client; } /** * Checks whether the specified user, group, contact, or service principal is a direct or * transitive member of the specified group. * @param parameters The check group membership parameters. * @param [options] The optional parameters * @returns Promise */ isMemberOf(parameters: Models.CheckGroupMembershipParameters, options?: msRest.RequestOptionsBase): Promise; /** * @param parameters The check group membership parameters. * @param callback The callback */ isMemberOf(parameters: Models.CheckGroupMembershipParameters, callback: msRest.ServiceCallback): void; /** * @param parameters The check group membership parameters. * @param options The optional parameters * @param callback The callback */ isMemberOf(parameters: Models.CheckGroupMembershipParameters, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; isMemberOf(parameters: Models.CheckGroupMembershipParameters, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { parameters, options }, isMemberOfOperationSpec, callback) as Promise; } /** * Remove a member from a group. * @param groupObjectId The object ID of the group from which to remove the member. * @param memberObjectId Member object id * @param [options] The optional parameters * @returns Promise */ removeMember(groupObjectId: string, memberObjectId: string, options?: msRest.RequestOptionsBase): Promise; /** * @param groupObjectId The object ID of the group from which to remove the member. * @param memberObjectId Member object id * @param callback The callback */ removeMember(groupObjectId: string, memberObjectId: string, callback: msRest.ServiceCallback): void; /** * @param groupObjectId The object ID of the group from which to remove the member. * @param memberObjectId Member object id * @param options The optional parameters * @param callback The callback */ removeMember(groupObjectId: string, memberObjectId: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; removeMember(groupObjectId: string, memberObjectId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { groupObjectId, memberObjectId, options }, removeMemberOperationSpec, callback); } /** * Add a member to a group. * @param groupObjectId The object ID of the group to which to add the member. * @param parameters The URL of the member object, such as * https://graph.windows.net/0b1f9851-1bf0-433f-aec3-cb9272f093dc/directoryObjects/f260bbc4-c254-447b-94cf-293b5ec434dd. * @param [options] The optional parameters * @returns Promise */ addMember(groupObjectId: string, parameters: Models.GroupAddMemberParameters, options?: msRest.RequestOptionsBase): Promise; /** * @param groupObjectId The object ID of the group to which to add the member. * @param parameters The URL of the member object, such as * https://graph.windows.net/0b1f9851-1bf0-433f-aec3-cb9272f093dc/directoryObjects/f260bbc4-c254-447b-94cf-293b5ec434dd. * @param callback The callback */ addMember(groupObjectId: string, parameters: Models.GroupAddMemberParameters, callback: msRest.ServiceCallback): void; /** * @param groupObjectId The object ID of the group to which to add the member. * @param parameters The URL of the member object, such as * https://graph.windows.net/0b1f9851-1bf0-433f-aec3-cb9272f093dc/directoryObjects/f260bbc4-c254-447b-94cf-293b5ec434dd. * @param options The optional parameters * @param callback The callback */ addMember(groupObjectId: string, parameters: Models.GroupAddMemberParameters, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; addMember(groupObjectId: string, parameters: Models.GroupAddMemberParameters, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { groupObjectId, parameters, options }, addMemberOperationSpec, callback); } /** * Create a group in the directory. * @param parameters The parameters for the group to create. * @param [options] The optional parameters * @returns Promise */ create(parameters: Models.GroupCreateParameters, options?: msRest.RequestOptionsBase): Promise; /** * @param parameters The parameters for the group to create. * @param callback The callback */ create(parameters: Models.GroupCreateParameters, callback: msRest.ServiceCallback): void; /** * @param parameters The parameters for the group to create. * @param options The optional parameters * @param callback The callback */ create(parameters: Models.GroupCreateParameters, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; create(parameters: Models.GroupCreateParameters, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { parameters, options }, createOperationSpec, callback) as Promise; } /** * Gets list of groups for the current tenant. * @param [options] The optional parameters * @returns Promise */ list(options?: Models.GroupsListOptionalParams): Promise; /** * @param callback The callback */ list(callback: msRest.ServiceCallback): void; /** * @param options The optional parameters * @param callback The callback */ list(options: Models.GroupsListOptionalParams, callback: msRest.ServiceCallback): void; list(options?: Models.GroupsListOptionalParams | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { options }, listOperationSpec, callback) as Promise; } /** * Gets the members of a group. * @param objectId The object ID of the group whose members should be retrieved. * @param [options] The optional parameters * @returns Promise */ getGroupMembers(objectId: string, options?: msRest.RequestOptionsBase): Promise; /** * @param objectId The object ID of the group whose members should be retrieved. * @param callback The callback */ getGroupMembers(objectId: string, callback: msRest.ServiceCallback): void; /** * @param objectId The object ID of the group whose members should be retrieved. * @param options The optional parameters * @param callback The callback */ getGroupMembers(objectId: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; getGroupMembers(objectId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { objectId, options }, getGroupMembersOperationSpec, callback) as Promise; } /** * Gets group information from the directory. * @param objectId The object ID of the user for which to get group information. * @param [options] The optional parameters * @returns Promise */ get(objectId: string, options?: msRest.RequestOptionsBase): Promise; /** * @param objectId The object ID of the user for which to get group information. * @param callback The callback */ get(objectId: string, callback: msRest.ServiceCallback): void; /** * @param objectId The object ID of the user for which to get group information. * @param options The optional parameters * @param callback The callback */ get(objectId: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; get(objectId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { objectId, options }, getOperationSpec, callback) as Promise; } /** * Delete a group from the directory. * @param objectId The object ID of the group to delete. * @param [options] The optional parameters * @returns Promise */ deleteMethod(objectId: string, options?: msRest.RequestOptionsBase): Promise; /** * @param objectId The object ID of the group to delete. * @param callback The callback */ deleteMethod(objectId: string, callback: msRest.ServiceCallback): void; /** * @param objectId The object ID of the group to delete. * @param options The optional parameters * @param callback The callback */ deleteMethod(objectId: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; deleteMethod(objectId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { objectId, options }, deleteMethodOperationSpec, callback); } /** * Gets a collection of object IDs of groups of which the specified group is a member. * @param objectId The object ID of the group for which to get group membership. * @param parameters Group filtering parameters. * @param [options] The optional parameters * @returns Promise */ getMemberGroups(objectId: string, parameters: Models.GroupGetMemberGroupsParameters, options?: msRest.RequestOptionsBase): Promise; /** * @param objectId The object ID of the group for which to get group membership. * @param parameters Group filtering parameters. * @param callback The callback */ getMemberGroups(objectId: string, parameters: Models.GroupGetMemberGroupsParameters, callback: msRest.ServiceCallback): void; /** * @param objectId The object ID of the group for which to get group membership. * @param parameters Group filtering parameters. * @param options The optional parameters * @param callback The callback */ getMemberGroups(objectId: string, parameters: Models.GroupGetMemberGroupsParameters, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; getMemberGroups(objectId: string, parameters: Models.GroupGetMemberGroupsParameters, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { objectId, parameters, options }, getMemberGroupsOperationSpec, callback) as Promise; } /** * The owners are a set of non-admin users who are allowed to modify this object. * @summary Directory objects that are owners of the group. * @param objectId The object ID of the group for which to get owners. * @param [options] The optional parameters * @returns Promise */ listOwners(objectId: string, options?: msRest.RequestOptionsBase): Promise; /** * @param objectId The object ID of the group for which to get owners. * @param callback The callback */ listOwners(objectId: string, callback: msRest.ServiceCallback): void; /** * @param objectId The object ID of the group for which to get owners. * @param options The optional parameters * @param callback The callback */ listOwners(objectId: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; listOwners(objectId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { objectId, options }, listOwnersOperationSpec, callback) as Promise; } /** * Add an owner to a group. * @param objectId The object ID of the application to which to add the owner. * @param parameters The URL of the owner object, such as * https://graph.windows.net/0b1f9851-1bf0-433f-aec3-cb9272f093dc/directoryObjects/f260bbc4-c254-447b-94cf-293b5ec434dd. * @param [options] The optional parameters * @returns Promise */ addOwner(objectId: string, parameters: Models.AddOwnerParameters, options?: msRest.RequestOptionsBase): Promise; /** * @param objectId The object ID of the application to which to add the owner. * @param parameters The URL of the owner object, such as * https://graph.windows.net/0b1f9851-1bf0-433f-aec3-cb9272f093dc/directoryObjects/f260bbc4-c254-447b-94cf-293b5ec434dd. * @param callback The callback */ addOwner(objectId: string, parameters: Models.AddOwnerParameters, callback: msRest.ServiceCallback): void; /** * @param objectId The object ID of the application to which to add the owner. * @param parameters The URL of the owner object, such as * https://graph.windows.net/0b1f9851-1bf0-433f-aec3-cb9272f093dc/directoryObjects/f260bbc4-c254-447b-94cf-293b5ec434dd. * @param options The optional parameters * @param callback The callback */ addOwner(objectId: string, parameters: Models.AddOwnerParameters, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; addOwner(objectId: string, parameters: Models.AddOwnerParameters, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { objectId, parameters, options }, addOwnerOperationSpec, callback); } /** * Remove a member from owners. * @param objectId The object ID of the group from which to remove the owner. * @param ownerObjectId Owner object id * @param [options] The optional parameters * @returns Promise */ removeOwner(objectId: string, ownerObjectId: string, options?: msRest.RequestOptionsBase): Promise; /** * @param objectId The object ID of the group from which to remove the owner. * @param ownerObjectId Owner object id * @param callback The callback */ removeOwner(objectId: string, ownerObjectId: string, callback: msRest.ServiceCallback): void; /** * @param objectId The object ID of the group from which to remove the owner. * @param ownerObjectId Owner object id * @param options The optional parameters * @param callback The callback */ removeOwner(objectId: string, ownerObjectId: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; removeOwner(objectId: string, ownerObjectId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { objectId, ownerObjectId, options }, removeOwnerOperationSpec, callback); } /** * Gets a list of groups for the current tenant. * @param nextLink Next link for the list operation. * @param [options] The optional parameters * @returns Promise */ listNext(nextLink: string, options?: msRest.RequestOptionsBase): Promise; /** * @param nextLink Next link for the list operation. * @param callback The callback */ listNext(nextLink: string, callback: msRest.ServiceCallback): void; /** * @param nextLink Next link for the list operation. * @param options The optional parameters * @param callback The callback */ listNext(nextLink: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; listNext(nextLink: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { nextLink, options }, listNextOperationSpec, callback) as Promise; } /** * Gets the members of a group. * @param nextLink Next link for the list operation. * @param [options] The optional parameters * @returns Promise */ getGroupMembersNext(nextLink: string, options?: msRest.RequestOptionsBase): Promise; /** * @param nextLink Next link for the list operation. * @param callback The callback */ getGroupMembersNext(nextLink: string, callback: msRest.ServiceCallback): void; /** * @param nextLink Next link for the list operation. * @param options The optional parameters * @param callback The callback */ getGroupMembersNext(nextLink: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; getGroupMembersNext(nextLink: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { nextLink, options }, getGroupMembersNextOperationSpec, callback) as Promise; } /** * The owners are a set of non-admin users who are allowed to modify this object. * @summary Directory objects that are owners of the group. * @param nextPageLink The NextLink from the previous successful call to List operation. * @param [options] The optional parameters * @returns Promise */ listOwnersNext(nextPageLink: string, options?: msRest.RequestOptionsBase): Promise; /** * @param nextPageLink The NextLink from the previous successful call to List operation. * @param callback The callback */ listOwnersNext(nextPageLink: string, callback: msRest.ServiceCallback): void; /** * @param nextPageLink The NextLink from the previous successful call to List operation. * @param options The optional parameters * @param callback The callback */ listOwnersNext(nextPageLink: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; listOwnersNext(nextPageLink: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { nextPageLink, options }, listOwnersNextOperationSpec, callback) as Promise; } } // Operation Specifications const serializer = new msRest.Serializer(Mappers); const isMemberOfOperationSpec: msRest.OperationSpec = { httpMethod: "POST", path: "{tenantID}/isMemberOf", urlParameters: [ Parameters.tenantID ], queryParameters: [ Parameters.apiVersion ], headerParameters: [ Parameters.acceptLanguage ], requestBody: { parameterPath: "parameters", mapper: { ...Mappers.CheckGroupMembershipParameters, required: true } }, responses: { 200: { bodyMapper: Mappers.CheckGroupMembershipResult }, default: { bodyMapper: Mappers.GraphError } }, serializer }; const removeMemberOperationSpec: msRest.OperationSpec = { httpMethod: "DELETE", path: "{tenantID}/groups/{groupObjectId}/$links/members/{memberObjectId}", urlParameters: [ Parameters.groupObjectId, Parameters.memberObjectId, Parameters.tenantID ], queryParameters: [ Parameters.apiVersion ], headerParameters: [ Parameters.acceptLanguage ], responses: { 204: {}, default: { bodyMapper: Mappers.GraphError } }, serializer }; const addMemberOperationSpec: msRest.OperationSpec = { httpMethod: "POST", path: "{tenantID}/groups/{groupObjectId}/$links/members", urlParameters: [ Parameters.groupObjectId, Parameters.tenantID ], queryParameters: [ Parameters.apiVersion ], headerParameters: [ Parameters.acceptLanguage ], requestBody: { parameterPath: "parameters", mapper: { ...Mappers.GroupAddMemberParameters, required: true } }, responses: { 204: {}, default: { bodyMapper: Mappers.GraphError } }, serializer }; const createOperationSpec: msRest.OperationSpec = { httpMethod: "POST", path: "{tenantID}/groups", urlParameters: [ Parameters.tenantID ], queryParameters: [ Parameters.apiVersion ], headerParameters: [ Parameters.acceptLanguage ], requestBody: { parameterPath: "parameters", mapper: { ...Mappers.GroupCreateParameters, required: true } }, responses: { 201: { bodyMapper: Mappers.ADGroup }, default: { bodyMapper: Mappers.GraphError } }, serializer }; const listOperationSpec: msRest.OperationSpec = { httpMethod: "GET", path: "{tenantID}/groups", urlParameters: [ Parameters.tenantID ], queryParameters: [ Parameters.filter, Parameters.apiVersion ], headerParameters: [ Parameters.acceptLanguage ], responses: { 200: { bodyMapper: Mappers.GroupListResult }, default: { bodyMapper: Mappers.GraphError } }, serializer }; const getGroupMembersOperationSpec: msRest.OperationSpec = { httpMethod: "GET", path: "{tenantID}/groups/{objectId}/members", urlParameters: [ Parameters.objectId, Parameters.tenantID ], queryParameters: [ Parameters.apiVersion ], headerParameters: [ Parameters.acceptLanguage ], responses: { 200: { bodyMapper: Mappers.DirectoryObjectListResult }, default: { bodyMapper: Mappers.GraphError } }, serializer }; const getOperationSpec: msRest.OperationSpec = { httpMethod: "GET", path: "{tenantID}/groups/{objectId}", urlParameters: [ Parameters.objectId, Parameters.tenantID ], queryParameters: [ Parameters.apiVersion ], headerParameters: [ Parameters.acceptLanguage ], responses: { 200: { bodyMapper: Mappers.ADGroup }, default: { bodyMapper: Mappers.GraphError } }, serializer }; const deleteMethodOperationSpec: msRest.OperationSpec = { httpMethod: "DELETE", path: "{tenantID}/groups/{objectId}", urlParameters: [ Parameters.objectId, Parameters.tenantID ], queryParameters: [ Parameters.apiVersion ], headerParameters: [ Parameters.acceptLanguage ], responses: { 204: {}, default: { bodyMapper: Mappers.GraphError } }, serializer }; const getMemberGroupsOperationSpec: msRest.OperationSpec = { httpMethod: "POST", path: "{tenantID}/groups/{objectId}/getMemberGroups", urlParameters: [ Parameters.objectId, Parameters.tenantID ], queryParameters: [ Parameters.apiVersion ], headerParameters: [ Parameters.acceptLanguage ], requestBody: { parameterPath: "parameters", mapper: { ...Mappers.GroupGetMemberGroupsParameters, required: true } }, responses: { 200: { bodyMapper: Mappers.GroupGetMemberGroupsResult }, default: { bodyMapper: Mappers.GraphError } }, serializer }; const listOwnersOperationSpec: msRest.OperationSpec = { httpMethod: "GET", path: "{tenantID}/groups/{objectId}/owners", urlParameters: [ Parameters.objectId, Parameters.tenantID ], queryParameters: [ Parameters.apiVersion ], headerParameters: [ Parameters.acceptLanguage ], responses: { 200: { bodyMapper: Mappers.DirectoryObjectListResult }, default: { bodyMapper: Mappers.GraphError } }, serializer }; const addOwnerOperationSpec: msRest.OperationSpec = { httpMethod: "POST", path: "{tenantID}/groups/{objectId}/$links/owners", urlParameters: [ Parameters.objectId, Parameters.tenantID ], queryParameters: [ Parameters.apiVersion ], headerParameters: [ Parameters.acceptLanguage ], requestBody: { parameterPath: "parameters", mapper: { ...Mappers.AddOwnerParameters, required: true } }, responses: { 204: {}, default: { bodyMapper: Mappers.GraphError } }, serializer }; const removeOwnerOperationSpec: msRest.OperationSpec = { httpMethod: "DELETE", path: "{tenantID}/groups/{objectId}/$links/owners/{ownerObjectId}", urlParameters: [ Parameters.objectId, Parameters.ownerObjectId, Parameters.tenantID ], queryParameters: [ Parameters.apiVersion ], headerParameters: [ Parameters.acceptLanguage ], responses: { 204: {}, default: { bodyMapper: Mappers.GraphError } }, serializer }; const listNextOperationSpec: msRest.OperationSpec = { httpMethod: "GET", path: "{tenantID}/{nextLink}", urlParameters: [ Parameters.nextLink, Parameters.tenantID ], queryParameters: [ Parameters.apiVersion ], headerParameters: [ Parameters.acceptLanguage ], responses: { 200: { bodyMapper: Mappers.GroupListResult }, default: { bodyMapper: Mappers.GraphError } }, serializer }; const getGroupMembersNextOperationSpec: msRest.OperationSpec = { httpMethod: "GET", path: "{tenantID}/{nextLink}", urlParameters: [ Parameters.nextLink, Parameters.tenantID ], queryParameters: [ Parameters.apiVersion ], headerParameters: [ Parameters.acceptLanguage ], responses: { 200: { bodyMapper: Mappers.DirectoryObjectListResult }, default: { bodyMapper: Mappers.GraphError } }, serializer }; const listOwnersNextOperationSpec: msRest.OperationSpec = { httpMethod: "GET", baseUrl: "https://graph.windows.net", path: "{nextLink}", urlParameters: [ Parameters.nextPageLink ], headerParameters: [ Parameters.acceptLanguage ], responses: { 200: { bodyMapper: Mappers.DirectoryObjectListResult }, default: { bodyMapper: Mappers.GraphError } }, serializer };