diff --git a/lib/services/graphManagement/lib/graphRbacManagementClient.d.ts b/lib/services/graphManagement/lib/graphRbacManagementClient.d.ts index 19513fa457..404e0f87be 100755 --- a/lib/services/graphManagement/lib/graphRbacManagementClient.d.ts +++ b/lib/services/graphManagement/lib/graphRbacManagementClient.d.ts @@ -56,11 +56,13 @@ export default class GraphRbacManagementClient extends AzureServiceClient { generateClientRequestId: boolean; // Operation groups - objects: operations.Objects; + signedInUser: operations.SignedInUser; applications: operations.Applications; + deletedApplications: operations.DeletedApplications; groups: operations.Groups; servicePrincipals: operations.ServicePrincipals; users: operations.Users; + objects: operations.Objects; domains: operations.Domains; oAuth2: operations.OAuth2; } diff --git a/lib/services/graphManagement/lib/graphRbacManagementClient.js b/lib/services/graphManagement/lib/graphRbacManagementClient.js index 33ad279317..c1757ec9e6 100755 --- a/lib/services/graphManagement/lib/graphRbacManagementClient.js +++ b/lib/services/graphManagement/lib/graphRbacManagementClient.js @@ -72,11 +72,13 @@ class GraphRbacManagementClient extends ServiceClient { if(options.generateClientRequestId !== null && options.generateClientRequestId !== undefined) { this.generateClientRequestId = options.generateClientRequestId; } - this.objects = new operations.Objects(this); + this.signedInUser = new operations.SignedInUser(this); this.applications = new operations.Applications(this); + this.deletedApplications = new operations.DeletedApplications(this); this.groups = new operations.Groups(this); this.servicePrincipals = new operations.ServicePrincipals(this); this.users = new operations.Users(this); + this.objects = new operations.Objects(this); this.domains = new operations.Domains(this); this.oAuth2 = new operations.OAuth2(this); this.models = models; diff --git a/lib/services/graphManagement/lib/models/aDGroup.js b/lib/services/graphManagement/lib/models/aDGroup.js index 5cc02740c3..cf18d4c62a 100644 --- a/lib/services/graphManagement/lib/models/aDGroup.js +++ b/lib/services/graphManagement/lib/models/aDGroup.js @@ -21,6 +21,10 @@ class ADGroup extends models['DirectoryObject'] { /** * Create a ADGroup. * @member {string} [displayName] The display name of the group. + * @member {boolean} [mailEnabled] Whether the group is mail-enabled. Must be + * false. This is because only pure security groups can be created using the + * Graph API. + * @member {string} [mailNickname] The mail alias for the group. * @member {boolean} [securityEnabled] Whether the group is security-enable. * @member {string} [mail] The primary email address of the group. */ @@ -78,6 +82,20 @@ class ADGroup extends models['DirectoryObject'] { name: 'String' } }, + mailEnabled: { + required: false, + serializedName: 'mailEnabled', + type: { + name: 'Boolean' + } + }, + mailNickname: { + required: false, + serializedName: 'mailNickname', + type: { + name: 'String' + } + }, securityEnabled: { required: false, serializedName: 'securityEnabled', diff --git a/lib/services/graphManagement/lib/models/addOwnerParameters.js b/lib/services/graphManagement/lib/models/addOwnerParameters.js new file mode 100644 index 0000000000..58e49cb1d4 --- /dev/null +++ b/lib/services/graphManagement/lib/models/addOwnerParameters.js @@ -0,0 +1,68 @@ +/* + * 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. + */ + +'use strict'; + +/** + * Request parameters for adding a owner to an application. + * + */ +class AddOwnerParameters { + /** + * Create a AddOwnerParameters. + * @member {string} url A owner object URL, such as + * "https://graph.windows.net/0b1f9851-1bf0-433f-aec3-cb9272f093dc/directoryObjects/f260bbc4-c254-447b-94cf-293b5ec434dd", + * where "0b1f9851-1bf0-433f-aec3-cb9272f093dc" is the tenantId and + * "f260bbc4-c254-447b-94cf-293b5ec434dd" is the objectId of the owner (user, + * application, servicePrincipal, group) to be added. + */ + constructor() { + } + + /** + * Defines the metadata of AddOwnerParameters + * + * @returns {object} metadata of AddOwnerParameters + * + */ + mapper() { + return { + required: false, + serializedName: 'AddOwnerParameters', + type: { + name: 'Composite', + additionalProperties: { + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'ObjectElementType', + type: { + name: 'Object' + } + } + } + }, + className: 'AddOwnerParameters', + modelProperties: { + url: { + required: true, + serializedName: 'url', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = AddOwnerParameters; diff --git a/lib/services/graphManagement/lib/models/appRole.js b/lib/services/graphManagement/lib/models/appRole.js new file mode 100644 index 0000000000..c440fb20e3 --- /dev/null +++ b/lib/services/graphManagement/lib/models/appRole.js @@ -0,0 +1,108 @@ +/* + * 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. + */ + +'use strict'; + +/** + * Class representing a AppRole. + */ +class AppRole { + /** + * Create a AppRole. + * @member {string} [id] Unique role identifier inside the appRoles + * collection. + * @member {array} [allowedMemberTypes] Specifies whether this app role + * definition can be assigned to users and groups by setting to 'User', or to + * other applications (that are accessing this application in daemon service + * scenarios) by setting to 'Application', or to both. + * @member {string} [description] Permission help text that appears in the + * admin app assignment and consent experiences. + * @member {string} [displayName] Display name for the permission that + * appears in the admin consent and app assignment experiences. + * @member {boolean} [isEnabled] When creating or updating a role definition, + * this must be set to true (which is the default). To delete a role, this + * must first be set to false. At that point, in a subsequent call, this role + * may be removed. + * @member {string} [value] Specifies the value of the roles claim that the + * application should expect in the authentication and access tokens. + */ + constructor() { + } + + /** + * Defines the metadata of AppRole + * + * @returns {object} metadata of AppRole + * + */ + mapper() { + return { + required: false, + serializedName: 'AppRole', + type: { + name: 'Composite', + className: 'AppRole', + modelProperties: { + id: { + required: false, + serializedName: 'id', + type: { + name: 'String' + } + }, + allowedMemberTypes: { + required: false, + serializedName: 'allowedMemberTypes', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + description: { + required: false, + serializedName: 'description', + type: { + name: 'String' + } + }, + displayName: { + required: false, + serializedName: 'displayName', + type: { + name: 'String' + } + }, + isEnabled: { + required: false, + serializedName: 'isEnabled', + type: { + name: 'Boolean' + } + }, + value: { + required: false, + serializedName: 'value', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = AppRole; diff --git a/lib/services/graphManagement/lib/models/application.js b/lib/services/graphManagement/lib/models/application.js index 1c0a6afe81..52acf53ed4 100644 --- a/lib/services/graphManagement/lib/models/application.js +++ b/lib/services/graphManagement/lib/models/application.js @@ -21,6 +21,9 @@ class Application extends models['DirectoryObject'] { /** * Create a Application. * @member {string} [appId] The application ID. + * @member {array} [appRoles] The collection of application roles that an + * application may declare. These roles can be assigned to users, groups or + * service principals. * @member {array} [appPermissions] The application permissions. * @member {boolean} [availableToOtherTenants] Whether the application is be * available to other tenants. @@ -86,6 +89,21 @@ class Application extends models['DirectoryObject'] { name: 'String' } }, + appRoles: { + required: false, + serializedName: 'appRoles', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'AppRoleElementType', + type: { + name: 'Composite', + className: 'AppRole' + } + } + } + }, appPermissions: { required: false, serializedName: 'appPermissions', diff --git a/lib/services/graphManagement/lib/models/applicationAddOwnerParameters.js b/lib/services/graphManagement/lib/models/applicationAddOwnerParameters.js index e0b3216bfd..a2f32b3de0 100644 --- a/lib/services/graphManagement/lib/models/applicationAddOwnerParameters.js +++ b/lib/services/graphManagement/lib/models/applicationAddOwnerParameters.js @@ -10,20 +10,18 @@ 'use strict'; +const models = require('./index'); + /** - * Request parameters for adding a owner to an application. - * + * Class representing a ApplicationAddOwnerParameters. + * @extends models['AddOwnerParameters'] */ -class ApplicationAddOwnerParameters { +class ApplicationAddOwnerParameters extends models['AddOwnerParameters'] { /** * Create a ApplicationAddOwnerParameters. - * @member {string} url A owner object URL, such as - * "https://graph.windows.net/0b1f9851-1bf0-433f-aec3-cb9272f093dc/directoryObjects/f260bbc4-c254-447b-94cf-293b5ec434dd", - * where "0b1f9851-1bf0-433f-aec3-cb9272f093dc" is the tenantId and - * "f260bbc4-c254-447b-94cf-293b5ec434dd" is the objectId of the owner (user, - * application, servicePrincipal, group) to be added. */ constructor() { + super(); } /** @@ -38,18 +36,6 @@ class ApplicationAddOwnerParameters { serializedName: 'ApplicationAddOwnerParameters', type: { name: 'Composite', - additionalProperties: { - type: { - name: 'Dictionary', - value: { - required: false, - serializedName: 'ObjectElementType', - type: { - name: 'Object' - } - } - } - }, className: 'ApplicationAddOwnerParameters', modelProperties: { url: { diff --git a/lib/services/graphManagement/lib/models/applicationCreateParameters.js b/lib/services/graphManagement/lib/models/applicationCreateParameters.js index 93f58b1803..9ad3b2398f 100644 --- a/lib/services/graphManagement/lib/models/applicationCreateParameters.js +++ b/lib/services/graphManagement/lib/models/applicationCreateParameters.js @@ -17,6 +17,9 @@ class ApplicationCreateParameters { /** * Create a ApplicationCreateParameters. + * @member {array} [appRoles] The collection of application roles that an + * application may declare. These roles can be assigned to users, groups or + * service principals. * @member {boolean} availableToOtherTenants Whether the application is * available to other tenants. * @member {string} displayName The display name of the application. @@ -64,6 +67,21 @@ class ApplicationCreateParameters { }, className: 'ApplicationCreateParameters', modelProperties: { + appRoles: { + required: false, + serializedName: 'appRoles', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'AppRoleElementType', + type: { + name: 'Composite', + className: 'AppRole' + } + } + } + }, availableToOtherTenants: { required: true, serializedName: 'availableToOtherTenants', diff --git a/lib/services/graphManagement/lib/models/applicationUpdateParameters.js b/lib/services/graphManagement/lib/models/applicationUpdateParameters.js index 13373b594b..31ac3cb8c4 100644 --- a/lib/services/graphManagement/lib/models/applicationUpdateParameters.js +++ b/lib/services/graphManagement/lib/models/applicationUpdateParameters.js @@ -17,6 +17,9 @@ class ApplicationUpdateParameters { /** * Create a ApplicationUpdateParameters. + * @member {array} [appRoles] The collection of application roles that an + * application may declare. These roles can be assigned to users, groups or + * service principals. * @member {boolean} [availableToOtherTenants] Whether the application is * available to other tenants * @member {string} [displayName] The display name of the application. @@ -64,6 +67,21 @@ class ApplicationUpdateParameters { }, className: 'ApplicationUpdateParameters', modelProperties: { + appRoles: { + required: false, + serializedName: 'appRoles', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'AppRoleElementType', + type: { + name: 'Composite', + className: 'AppRole' + } + } + } + }, availableToOtherTenants: { required: false, serializedName: 'availableToOtherTenants', diff --git a/lib/services/graphManagement/lib/models/directoryObjectListResult.js b/lib/services/graphManagement/lib/models/directoryObjectListResult.js index 3215dcf02a..25d5bfff6e 100644 --- a/lib/services/graphManagement/lib/models/directoryObjectListResult.js +++ b/lib/services/graphManagement/lib/models/directoryObjectListResult.js @@ -16,6 +16,7 @@ class DirectoryObjectListResult extends Array { /** * Create a DirectoryObjectListResult. + * @member {string} [odatanextLink] The URL to get the next set of results. */ constructor() { super(); @@ -66,6 +67,13 @@ class DirectoryObjectListResult extends Array { } } } + }, + odatanextLink: { + required: false, + serializedName: 'odata\\.nextLink', + type: { + name: 'String' + } } } } diff --git a/lib/services/graphManagement/lib/models/getObjectsParameters.js b/lib/services/graphManagement/lib/models/getObjectsParameters.js index 89a166cb69..a05cfd7fed 100644 --- a/lib/services/graphManagement/lib/models/getObjectsParameters.js +++ b/lib/services/graphManagement/lib/models/getObjectsParameters.js @@ -19,8 +19,8 @@ class GetObjectsParameters { * Create a GetObjectsParameters. * @member {array} [objectIds] The requested object IDs. * @member {array} [types] The requested object types. - * @member {boolean} includeDirectoryObjectReferences If true, also searches - * for object IDs in the partner tenant. + * @member {boolean} [includeDirectoryObjectReferences] If true, also + * searches for object IDs in the partner tenant. */ constructor() { } @@ -80,7 +80,7 @@ class GetObjectsParameters { } }, includeDirectoryObjectReferences: { - required: true, + required: false, serializedName: 'includeDirectoryObjectReferences', type: { name: 'Boolean' diff --git a/lib/services/graphManagement/lib/models/index.d.ts b/lib/services/graphManagement/lib/models/index.d.ts index 5c26cb5c46..2a41f6f5ab 100644 --- a/lib/services/graphManagement/lib/models/index.d.ts +++ b/lib/services/graphManagement/lib/models/index.d.ts @@ -155,12 +155,44 @@ export interface RequiredResourceAccess { [property: string]: any; } +/** + * @class + * Initializes a new instance of the AppRole class. + * @constructor + * @member {string} [id] Unique role identifier inside the appRoles collection. + * @member {array} [allowedMemberTypes] Specifies whether this app role + * definition can be assigned to users and groups by setting to 'User', or to + * other applications (that are accessing this application in daemon service + * scenarios) by setting to 'Application', or to both. + * @member {string} [description] Permission help text that appears in the + * admin app assignment and consent experiences. + * @member {string} [displayName] Display name for the permission that appears + * in the admin consent and app assignment experiences. + * @member {boolean} [isEnabled] When creating or updating a role definition, + * this must be set to true (which is the default). To delete a role, this must + * first be set to false. At that point, in a subsequent call, this role may be + * removed. + * @member {string} [value] Specifies the value of the roles claim that the + * application should expect in the authentication and access tokens. + */ +export interface AppRole { + id?: string; + allowedMemberTypes?: string[]; + description?: string; + displayName?: string; + isEnabled?: boolean; + value?: string; +} + /** * @class * Initializes a new instance of the ApplicationCreateParameters class. * @constructor * Request parameters for creating a new application. * + * @member {array} [appRoles] The collection of application roles that an + * application may declare. These roles can be assigned to users, groups or + * service principals. * @member {boolean} availableToOtherTenants Whether the application is * available to other tenants. * @member {string} displayName The display name of the application. @@ -178,6 +210,7 @@ export interface RequiredResourceAccess { * pre-configuration of required resource access drives the consent experience. */ export interface ApplicationCreateParameters { + appRoles?: AppRole[]; availableToOtherTenants: boolean; displayName: string; homepage?: string; @@ -200,6 +233,9 @@ export interface ApplicationCreateParameters { * @constructor * Request parameters for updating an existing application. * + * @member {array} [appRoles] The collection of application roles that an + * application may declare. These roles can be assigned to users, groups or + * service principals. * @member {boolean} [availableToOtherTenants] Whether the application is * available to other tenants * @member {string} [displayName] The display name of the application. @@ -217,6 +253,7 @@ export interface ApplicationCreateParameters { * pre-configuration of required resource access drives the consent experience. */ export interface ApplicationUpdateParameters { + appRoles?: AppRole[]; availableToOtherTenants?: boolean; displayName?: string; homepage?: string; @@ -240,6 +277,9 @@ export interface ApplicationUpdateParameters { * Active Directory application information. * * @member {string} [appId] The application ID. + * @member {array} [appRoles] The collection of application roles that an + * application may declare. These roles can be assigned to users, groups or + * service principals. * @member {array} [appPermissions] The application permissions. * @member {boolean} [availableToOtherTenants] Whether the application is be * available to other tenants. @@ -252,6 +292,7 @@ export interface ApplicationUpdateParameters { */ export interface Application extends DirectoryObject { appId?: string; + appRoles?: AppRole[]; appPermissions?: string[]; availableToOtherTenants?: boolean; displayName?: string; @@ -263,7 +304,7 @@ export interface Application extends DirectoryObject { /** * @class - * Initializes a new instance of the ApplicationAddOwnerParameters class. + * Initializes a new instance of the AddOwnerParameters class. * @constructor * Request parameters for adding a owner to an application. * @@ -273,7 +314,7 @@ export interface Application extends DirectoryObject { * "f260bbc4-c254-447b-94cf-293b5ec434dd" is the objectId of the owner (user, * application, servicePrincipal, group) to be added. */ -export interface ApplicationAddOwnerParameters { +export interface AddOwnerParameters { url: string; /** * @property Describes unknown properties. The value of an unknown property @@ -306,63 +347,6 @@ export interface PasswordCredentialsUpdateParameters { value: PasswordCredential[]; } -/** - * @class - * Initializes a new instance of the AADObject class. - * @constructor - * The properties of an Active Directory object. - * - * @member {string} [objectId] The ID of the object. - * @member {string} [objectType] The type of AAD object. - * @member {string} [displayName] The display name of the object. - * @member {string} [userPrincipalName] The principal name of the object. - * @member {string} [mail] The primary email address of the object. - * @member {boolean} [mailEnabled] Whether the AAD object is mail-enabled. - * @member {string} [mailNickname] The mail alias for the user. - * @member {boolean} [securityEnabled] Whether the AAD object is - * security-enabled. - * @member {string} [signInName] The sign-in name of the object. - * @member {array} [servicePrincipalNames] A collection of service principal - * names associated with the object. - * @member {string} [userType] The user type of the object. - * @member {string} [usageLocation] A two letter country code (ISO standard - * 3166). Required for users that will be assigned licenses due to legal - * requirement to check for availability of services in countries. Examples - * include: "US", "JP", and "GB". - * @member {string} [appId] The application ID. - * @member {array} [appPermissions] The application permissions. - * @member {boolean} [availableToOtherTenants] Whether the application is be - * available to other tenants. - * @member {array} [identifierUris] A collection of URIs for the application. - * @member {array} [replyUrls] A collection of reply URLs for the application. - * @member {string} [homepage] The home page of the application. - */ -export interface AADObject { - objectId?: string; - objectType?: string; - displayName?: string; - userPrincipalName?: string; - mail?: string; - mailEnabled?: boolean; - readonly mailNickname?: string; - securityEnabled?: boolean; - signInName?: string; - servicePrincipalNames?: string[]; - userType?: string; - readonly usageLocation?: string; - readonly appId?: string; - readonly appPermissions?: string[]; - readonly availableToOtherTenants?: boolean; - readonly identifierUris?: string[]; - readonly replyUrls?: string[]; - readonly homepage?: string; - /** - * @property Describes unknown properties. The value of an unknown property - * can be of "any" type. - */ - [property: string]: any; -} - /** * @class * Initializes a new instance of the GroupAddMemberParameters class. @@ -410,11 +394,17 @@ export interface GroupCreateParameters { * Active Directory group information. * * @member {string} [displayName] The display name of the group. + * @member {boolean} [mailEnabled] Whether the group is mail-enabled. Must be + * false. This is because only pure security groups can be created using the + * Graph API. + * @member {string} [mailNickname] The mail alias for the group. * @member {boolean} [securityEnabled] Whether the group is security-enable. * @member {string} [mail] The primary email address of the group. */ export interface ADGroup extends DirectoryObject { displayName?: string; + mailEnabled?: boolean; + mailNickname?: string; securityEnabled?: boolean; mail?: string; } @@ -483,17 +473,89 @@ export interface CheckGroupMembershipResult { * @constructor * Request parameters for creating a new service principal. * + * @member {boolean} [accountEnabled] Whether the account is enabled * @member {string} appId application Id - * @member {boolean} accountEnabled Whether the account is enabled + * @member {boolean} [appRoleAssignmentRequired] Specifies whether an + * AppRoleAssignment to a user or group is required before Azure AD will issue + * a user or access token to the application. + * @member {string} [displayName] The display name for the service principal. + * @member {string} [errorUrl] + * @member {string} [homepage] The URL to the homepage of the associated + * application. * @member {array} [keyCredentials] A collection of KeyCredential objects. * @member {array} [passwordCredentials] A collection of PasswordCredential * objects + * @member {string} [publisherName] The display name of the tenant in which the + * associated application is specified. + * @member {array} [replyUrls] A collection of reply URLs for the service + * principal. + * @member {string} [samlMetadataUrl] + * @member {array} [servicePrincipalNames] A collection of service principal + * names. + * @member {array} [tags] */ export interface ServicePrincipalCreateParameters { + accountEnabled?: boolean; appId: string; - accountEnabled: boolean; + appRoleAssignmentRequired?: boolean; + displayName?: string; + errorUrl?: string; + homepage?: string; keyCredentials?: KeyCredential[]; passwordCredentials?: PasswordCredential[]; + publisherName?: string; + replyUrls?: string[]; + samlMetadataUrl?: string; + servicePrincipalNames?: string[]; + tags?: string[]; + /** + * @property Describes unknown properties. The value of an unknown property + * can be of "any" type. + */ + [property: string]: any; +} + +/** + * @class + * Initializes a new instance of the ServicePrincipalUpdateParameters class. + * @constructor + * Request parameters for creating a new service principal. + * + * @member {boolean} [accountEnabled] Whether the account is enabled + * @member {string} [appId] application Id + * @member {boolean} [appRoleAssignmentRequired] Specifies whether an + * AppRoleAssignment to a user or group is required before Azure AD will issue + * a user or access token to the application. + * @member {string} [displayName] The display name for the service principal. + * @member {string} [errorUrl] + * @member {string} [homepage] The URL to the homepage of the associated + * application. + * @member {array} [keyCredentials] A collection of KeyCredential objects. + * @member {array} [passwordCredentials] A collection of PasswordCredential + * objects + * @member {string} [publisherName] The display name of the tenant in which the + * associated application is specified. + * @member {array} [replyUrls] A collection of reply URLs for the service + * principal. + * @member {string} [samlMetadataUrl] + * @member {array} [servicePrincipalNames] A collection of service principal + * names. + * @member {array} [tags] + */ +export interface ServicePrincipalUpdateParameters { + accountEnabled?: boolean; + appId?: string; + appRoleAssignmentRequired?: boolean; + displayName?: string; + errorUrl?: string; + homepage?: string; + keyCredentials?: KeyCredential[]; + passwordCredentials?: PasswordCredential[]; + publisherName?: string; + replyUrls?: string[]; + samlMetadataUrl?: string; + servicePrincipalNames?: string[]; + tags?: string[]; /** * @property Describes unknown properties. The value of an unknown property * can be of "any" type. @@ -509,12 +571,16 @@ export interface ServicePrincipalCreateParameters { * * @member {string} [displayName] The display name of the service principal. * @member {string} [appId] The application ID. + * @member {array} [appRoles] The collection of application roles that an + * application may declare. These roles can be assigned to users, groups or + * service principals. * @member {array} [servicePrincipalNames] A collection of service principal * names. */ export interface ServicePrincipal extends DirectoryObject { displayName?: string; appId?: string; + appRoles?: AppRole[]; servicePrincipalNames?: string[]; } @@ -710,13 +776,13 @@ export interface UserGetMemberGroupsParameters { * * @member {array} [objectIds] The requested object IDs. * @member {array} [types] The requested object types. - * @member {boolean} includeDirectoryObjectReferences If true, also searches + * @member {boolean} [includeDirectoryObjectReferences] If true, also searches * for object IDs in the partner tenant. */ export interface GetObjectsParameters { objectIds?: string[]; types?: string[]; - includeDirectoryObjectReferences: boolean; + includeDirectoryObjectReferences?: boolean; /** * @property Describes unknown properties. The value of an unknown property * can be of "any" type. @@ -778,13 +844,13 @@ export interface Permissions { /** * @class - * Initializes a new instance of the GetObjectsResult class. + * Initializes a new instance of the DirectoryObjectListResult class. * @constructor - * The response to an Active Directory object inquiry API request. + * DirectoryObject list operation result. * * @member {string} [odatanextLink] The URL to get the next set of results. */ -export interface GetObjectsResult extends Array { +export interface DirectoryObjectListResult extends Array { odatanextLink?: string; } @@ -800,16 +866,6 @@ export interface ApplicationListResult extends Array { odatanextLink?: string; } -/** - * @class - * Initializes a new instance of the DirectoryObjectListResult class. - * @constructor - * DirectoryObject list operation result. - * - */ -export interface DirectoryObjectListResult extends Array { -} - /** * @class * Initializes a new instance of the KeyCredentialListResult class. diff --git a/lib/services/graphManagement/lib/models/index.js b/lib/services/graphManagement/lib/models/index.js index e32659daca..f0927b9540 100644 --- a/lib/services/graphManagement/lib/models/index.js +++ b/lib/services/graphManagement/lib/models/index.js @@ -24,13 +24,13 @@ exports.KeyCredential = require('./keyCredential'); exports.PasswordCredential = require('./passwordCredential'); exports.ResourceAccess = require('./resourceAccess'); exports.RequiredResourceAccess = require('./requiredResourceAccess'); +exports.AppRole = require('./appRole'); exports.ApplicationCreateParameters = require('./applicationCreateParameters'); exports.ApplicationUpdateParameters = require('./applicationUpdateParameters'); exports.Application = require('./application'); -exports.ApplicationAddOwnerParameters = require('./applicationAddOwnerParameters'); +exports.AddOwnerParameters = require('./addOwnerParameters'); exports.KeyCredentialsUpdateParameters = require('./keyCredentialsUpdateParameters'); exports.PasswordCredentialsUpdateParameters = require('./passwordCredentialsUpdateParameters'); -exports.AADObject = require('./aADObject'); exports.GroupAddMemberParameters = require('./groupAddMemberParameters'); exports.GroupCreateParameters = require('./groupCreateParameters'); exports.ADGroup = require('./aDGroup'); @@ -38,6 +38,7 @@ exports.GroupGetMemberGroupsParameters = require('./groupGetMemberGroupsParamete exports.CheckGroupMembershipParameters = require('./checkGroupMembershipParameters'); exports.CheckGroupMembershipResult = require('./checkGroupMembershipResult'); exports.ServicePrincipalCreateParameters = require('./servicePrincipalCreateParameters'); +exports.ServicePrincipalUpdateParameters = require('./servicePrincipalUpdateParameters'); exports.ServicePrincipal = require('./servicePrincipal'); exports.PasswordProfile = require('./passwordProfile'); exports.UserBase = require('./userBase'); @@ -49,9 +50,8 @@ exports.UserGetMemberGroupsParameters = require('./userGetMemberGroupsParameters exports.GetObjectsParameters = require('./getObjectsParameters'); exports.Domain = require('./domain'); exports.Permissions = require('./permissions'); -exports.GetObjectsResult = require('./getObjectsResult'); -exports.ApplicationListResult = require('./applicationListResult'); exports.DirectoryObjectListResult = require('./directoryObjectListResult'); +exports.ApplicationListResult = require('./applicationListResult'); exports.KeyCredentialListResult = require('./keyCredentialListResult'); exports.PasswordCredentialListResult = require('./passwordCredentialListResult'); exports.GroupListResult = require('./groupListResult'); diff --git a/lib/services/graphManagement/lib/models/servicePrincipal.js b/lib/services/graphManagement/lib/models/servicePrincipal.js index 7c00f25054..884bfe3290 100644 --- a/lib/services/graphManagement/lib/models/servicePrincipal.js +++ b/lib/services/graphManagement/lib/models/servicePrincipal.js @@ -22,6 +22,9 @@ class ServicePrincipal extends models['DirectoryObject'] { * Create a ServicePrincipal. * @member {string} [displayName] The display name of the service principal. * @member {string} [appId] The application ID. + * @member {array} [appRoles] The collection of application roles that an + * application may declare. These roles can be assigned to users, groups or + * service principals. * @member {array} [servicePrincipalNames] A collection of service principal * names. */ @@ -86,6 +89,21 @@ class ServicePrincipal extends models['DirectoryObject'] { name: 'String' } }, + appRoles: { + required: false, + serializedName: 'appRoles', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'AppRoleElementType', + type: { + name: 'Composite', + className: 'AppRole' + } + } + } + }, servicePrincipalNames: { required: false, serializedName: 'servicePrincipalNames', diff --git a/lib/services/graphManagement/lib/models/servicePrincipalCreateParameters.js b/lib/services/graphManagement/lib/models/servicePrincipalCreateParameters.js index ef032ece8d..ac86b0b7d6 100644 --- a/lib/services/graphManagement/lib/models/servicePrincipalCreateParameters.js +++ b/lib/services/graphManagement/lib/models/servicePrincipalCreateParameters.js @@ -17,11 +17,26 @@ class ServicePrincipalCreateParameters { /** * Create a ServicePrincipalCreateParameters. + * @member {boolean} [accountEnabled] Whether the account is enabled * @member {string} appId application Id - * @member {boolean} accountEnabled Whether the account is enabled + * @member {boolean} [appRoleAssignmentRequired] Specifies whether an + * AppRoleAssignment to a user or group is required before Azure AD will + * issue a user or access token to the application. + * @member {string} [displayName] The display name for the service principal. + * @member {string} [errorUrl] + * @member {string} [homepage] The URL to the homepage of the associated + * application. * @member {array} [keyCredentials] A collection of KeyCredential objects. * @member {array} [passwordCredentials] A collection of PasswordCredential * objects + * @member {string} [publisherName] The display name of the tenant in which + * the associated application is specified. + * @member {array} [replyUrls] A collection of reply URLs for the service + * principal. + * @member {string} [samlMetadataUrl] + * @member {array} [servicePrincipalNames] A collection of service principal + * names. + * @member {array} [tags] */ constructor() { } @@ -52,6 +67,13 @@ class ServicePrincipalCreateParameters { }, className: 'ServicePrincipalCreateParameters', modelProperties: { + accountEnabled: { + required: false, + serializedName: 'accountEnabled', + type: { + name: 'Boolean' + } + }, appId: { required: true, serializedName: 'appId', @@ -59,13 +81,34 @@ class ServicePrincipalCreateParameters { name: 'String' } }, - accountEnabled: { - required: true, - serializedName: 'accountEnabled', + appRoleAssignmentRequired: { + required: false, + serializedName: 'appRoleAssignmentRequired', type: { name: 'Boolean' } }, + displayName: { + required: false, + serializedName: 'displayName', + type: { + name: 'String' + } + }, + errorUrl: { + required: false, + serializedName: 'errorUrl', + type: { + name: 'String' + } + }, + homepage: { + required: false, + serializedName: 'homepage', + type: { + name: 'String' + } + }, keyCredentials: { required: false, serializedName: 'keyCredentials', @@ -119,6 +162,62 @@ class ServicePrincipalCreateParameters { } } } + }, + publisherName: { + required: false, + serializedName: 'publisherName', + type: { + name: 'String' + } + }, + replyUrls: { + required: false, + serializedName: 'replyUrls', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + samlMetadataUrl: { + required: false, + serializedName: 'samlMetadataUrl', + type: { + name: 'String' + } + }, + servicePrincipalNames: { + required: false, + serializedName: 'servicePrincipalNames', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + tags: { + required: false, + serializedName: 'tags', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } } } } diff --git a/lib/services/graphManagement/lib/models/servicePrincipalUpdateParameters.js b/lib/services/graphManagement/lib/models/servicePrincipalUpdateParameters.js new file mode 100644 index 0000000000..e77c75ca62 --- /dev/null +++ b/lib/services/graphManagement/lib/models/servicePrincipalUpdateParameters.js @@ -0,0 +1,228 @@ +/* + * 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. + */ + +'use strict'; + +/** + * Request parameters for creating a new service principal. + * + */ +class ServicePrincipalUpdateParameters { + /** + * Create a ServicePrincipalUpdateParameters. + * @member {boolean} [accountEnabled] Whether the account is enabled + * @member {string} [appId] application Id + * @member {boolean} [appRoleAssignmentRequired] Specifies whether an + * AppRoleAssignment to a user or group is required before Azure AD will + * issue a user or access token to the application. + * @member {string} [displayName] The display name for the service principal. + * @member {string} [errorUrl] + * @member {string} [homepage] The URL to the homepage of the associated + * application. + * @member {array} [keyCredentials] A collection of KeyCredential objects. + * @member {array} [passwordCredentials] A collection of PasswordCredential + * objects + * @member {string} [publisherName] The display name of the tenant in which + * the associated application is specified. + * @member {array} [replyUrls] A collection of reply URLs for the service + * principal. + * @member {string} [samlMetadataUrl] + * @member {array} [servicePrincipalNames] A collection of service principal + * names. + * @member {array} [tags] + */ + constructor() { + } + + /** + * Defines the metadata of ServicePrincipalUpdateParameters + * + * @returns {object} metadata of ServicePrincipalUpdateParameters + * + */ + mapper() { + return { + required: false, + serializedName: 'ServicePrincipalUpdateParameters', + type: { + name: 'Composite', + additionalProperties: { + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'ObjectElementType', + type: { + name: 'Object' + } + } + } + }, + className: 'ServicePrincipalUpdateParameters', + modelProperties: { + accountEnabled: { + required: false, + serializedName: 'accountEnabled', + type: { + name: 'Boolean' + } + }, + appId: { + required: false, + serializedName: 'appId', + type: { + name: 'String' + } + }, + appRoleAssignmentRequired: { + required: false, + serializedName: 'appRoleAssignmentRequired', + type: { + name: 'Boolean' + } + }, + displayName: { + required: false, + serializedName: 'displayName', + type: { + name: 'String' + } + }, + errorUrl: { + required: false, + serializedName: 'errorUrl', + type: { + name: 'String' + } + }, + homepage: { + required: false, + serializedName: 'homepage', + type: { + name: 'String' + } + }, + keyCredentials: { + required: false, + serializedName: 'keyCredentials', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'KeyCredentialElementType', + type: { + name: 'Composite', + additionalProperties: { + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'ObjectElementType', + type: { + name: 'Object' + } + } + } + }, + className: 'KeyCredential' + } + } + } + }, + passwordCredentials: { + required: false, + serializedName: 'passwordCredentials', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'PasswordCredentialElementType', + type: { + name: 'Composite', + additionalProperties: { + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'ObjectElementType', + type: { + name: 'Object' + } + } + } + }, + className: 'PasswordCredential' + } + } + } + }, + publisherName: { + required: false, + serializedName: 'publisherName', + type: { + name: 'String' + } + }, + replyUrls: { + required: false, + serializedName: 'replyUrls', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + samlMetadataUrl: { + required: false, + serializedName: 'samlMetadataUrl', + type: { + name: 'String' + } + }, + servicePrincipalNames: { + required: false, + serializedName: 'servicePrincipalNames', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + tags: { + required: false, + serializedName: 'tags', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + } + } + } + }; + } +} + +module.exports = ServicePrincipalUpdateParameters; diff --git a/lib/services/graphManagement/lib/operations/applications.js b/lib/services/graphManagement/lib/operations/applications.js index 527c1cfcf6..1f4f3bf4c7 100644 --- a/lib/services/graphManagement/lib/operations/applications.js +++ b/lib/services/graphManagement/lib/operations/applications.js @@ -19,6 +19,10 @@ const WebResource = msRest.WebResource; * * @param {object} parameters The parameters for creating an application. * + * @param {array} [parameters.appRoles] The collection of application roles + * that an application may declare. These roles can be assigned to users, + * groups or service principals. + * * @param {boolean} parameters.availableToOtherTenants Whether the application * is available to other tenants. * @@ -606,6 +610,10 @@ function _get(applicationObjectId, options, callback) { * * @param {object} parameters Parameters to update an existing application. * + * @param {array} [parameters.appRoles] The collection of application roles + * that an application may declare. These roles can be assigned to users, + * groups or service principals. + * * @param {boolean} [parameters.availableToOtherTenants] Whether the * application is available to other tenants * @@ -1012,7 +1020,7 @@ function _addOwner(applicationObjectId, parameters, options, callback) { let requestModel = null; try { if (parameters !== null && parameters !== undefined) { - let requestModelMapper = new client.models['ApplicationAddOwnerParameters']().mapper(); + let requestModelMapper = new client.models['AddOwnerParameters']().mapper(); requestModel = client.serialize(requestModelMapper, parameters, 'parameters'); requestContent = JSON.stringify(requestModel); } @@ -1770,6 +1778,138 @@ function _listNext(nextLink, options, callback) { }); } +/** + * @summary Directory objects that are owners of the application. + * + * The owners are a set of non-admin users who are allowed to modify this + * object. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link DirectoryObjectListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listOwnersNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['GraphError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['DirectoryObjectListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + /** Class representing a Applications. */ class Applications { /** @@ -1790,6 +1930,7 @@ class Applications { this._listPasswordCredentials = _listPasswordCredentials; this._updatePasswordCredentials = _updatePasswordCredentials; this._listNext = _listNext; + this._listOwnersNext = _listOwnersNext; } /** @@ -1797,6 +1938,10 @@ class Applications { * * @param {object} parameters The parameters for creating an application. * + * @param {array} [parameters.appRoles] The collection of application roles + * that an application may declare. These roles can be assigned to users, + * groups or service principals. + * * @param {boolean} parameters.availableToOtherTenants Whether the application * is available to other tenants. * @@ -1854,6 +1999,10 @@ class Applications { * * @param {object} parameters The parameters for creating an application. * + * @param {array} [parameters.appRoles] The collection of application roles + * that an application may declare. These roles can be assigned to users, + * groups or service principals. + * * @param {boolean} parameters.availableToOtherTenants Whether the application * is available to other tenants. * @@ -2180,6 +2329,10 @@ class Applications { * * @param {object} parameters Parameters to update an existing application. * + * @param {array} [parameters.appRoles] The collection of application roles + * that an application may declare. These roles can be assigned to users, + * groups or service principals. + * * @param {boolean} [parameters.availableToOtherTenants] Whether the * application is available to other tenants * @@ -2240,6 +2393,10 @@ class Applications { * * @param {object} parameters Parameters to update an existing application. * + * @param {array} [parameters.appRoles] The collection of application roles + * that an application may declare. These roles can be assigned to users, + * groups or service principals. + * * @param {boolean} [parameters.availableToOtherTenants] Whether the * application is available to other tenants * @@ -2924,6 +3081,97 @@ class Applications { } } + /** + * @summary Directory objects that are owners of the application. + * + * The owners are a set of non-admin users who are allowed to modify this + * object. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listOwnersNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listOwnersNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * @summary Directory objects that are owners of the application. + * + * The owners are a set of non-admin users who are allowed to modify this + * object. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {DirectoryObjectListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link DirectoryObjectListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listOwnersNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listOwnersNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listOwnersNext(nextPageLink, options, optionalCallback); + } + } + } module.exports = Applications; diff --git a/lib/services/graphManagement/lib/operations/deletedApplications.js b/lib/services/graphManagement/lib/operations/deletedApplications.js new file mode 100644 index 0000000000..75543e71c3 --- /dev/null +++ b/lib/services/graphManagement/lib/operations/deletedApplications.js @@ -0,0 +1,905 @@ +/* + * 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. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Restores the deleted application in the directory. + * + * @param {string} objectId Application object ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link Application} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _restore(objectId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (objectId === null || objectId === undefined || typeof objectId.valueOf() !== 'string') { + throw new Error('objectId cannot be null or undefined and it must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.tenantID === null || this.client.tenantID === undefined || typeof this.client.tenantID.valueOf() !== 'string') { + throw new Error('this.client.tenantID cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + '{tenantID}/deletedApplications/{objectId}/restore'; + requestUrl = requestUrl.replace('{objectId}', encodeURIComponent(objectId)); + requestUrl = requestUrl.replace('{tenantID}', encodeURIComponent(this.client.tenantID)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'POST'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['GraphError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['Application']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Gets a list of deleted applications in the directory. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] The filter to apply to the operation. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ApplicationListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _list(options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let filter = (options && options.filter !== undefined) ? options.filter : undefined; + // Validate + try { + if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { + throw new Error('filter must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.tenantID === null || this.client.tenantID === undefined || typeof this.client.tenantID.valueOf() !== 'string') { + throw new Error('this.client.tenantID cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + '{tenantID}/deletedApplications'; + requestUrl = requestUrl.replace('{tenantID}', encodeURIComponent(this.client.tenantID)); + let queryParameters = []; + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['GraphError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['ApplicationListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Hard-delete an application. + * + * @param {string} applicationObjectId Application object ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _hardDelete(applicationObjectId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (applicationObjectId === null || applicationObjectId === undefined || typeof applicationObjectId.valueOf() !== 'string') { + throw new Error('applicationObjectId cannot be null or undefined and it must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.tenantID === null || this.client.tenantID === undefined || typeof this.client.tenantID.valueOf() !== 'string') { + throw new Error('this.client.tenantID cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + '{tenantID}/deletedApplications/{applicationObjectId}'; + requestUrl = requestUrl.replace('{applicationObjectId}', encodeURIComponent(applicationObjectId)); + requestUrl = requestUrl.replace('{tenantID}', encodeURIComponent(this.client.tenantID)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'DELETE'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 204) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['GraphError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Gets a list of deleted applications in the directory. + * + * @param {string} nextLink Next link for the list operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ApplicationListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listNext(nextLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextLink === null || nextLink === undefined || typeof nextLink.valueOf() !== 'string') { + throw new Error('nextLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.tenantID === null || this.client.tenantID === undefined || typeof this.client.tenantID.valueOf() !== 'string') { + throw new Error('this.client.tenantID cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + '{tenantID}/{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextLink); + requestUrl = requestUrl.replace('{tenantID}', encodeURIComponent(this.client.tenantID)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += (requestUrl.indexOf('?') !== -1 ? '&' : '?') + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['GraphError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['ApplicationListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a DeletedApplications. */ +class DeletedApplications { + /** + * Create a DeletedApplications. + * @param {GraphRbacManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._restore = _restore; + this._list = _list; + this._hardDelete = _hardDelete; + this._listNext = _listNext; + } + + /** + * Restores the deleted application in the directory. + * + * @param {string} objectId Application object ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + restoreWithHttpOperationResponse(objectId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._restore(objectId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Restores the deleted application in the directory. + * + * @param {string} objectId Application object ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {Application} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link Application} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + restore(objectId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._restore(objectId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._restore(objectId, options, optionalCallback); + } + } + + /** + * Gets a list of deleted applications in the directory. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] The filter to apply to the operation. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listWithHttpOperationResponse(options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets a list of deleted applications in the directory. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] The filter to apply to the operation. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {ApplicationListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ApplicationListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + list(options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(options, optionalCallback); + } + } + + /** + * Hard-delete an application. + * + * @param {string} applicationObjectId Application object ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + hardDeleteWithHttpOperationResponse(applicationObjectId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._hardDelete(applicationObjectId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Hard-delete an application. + * + * @param {string} applicationObjectId Application object ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + hardDelete(applicationObjectId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._hardDelete(applicationObjectId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._hardDelete(applicationObjectId, options, optionalCallback); + } + } + + /** + * Gets a list of deleted applications in the directory. + * + * @param {string} nextLink Next link for the list operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listNextWithHttpOperationResponse(nextLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listNext(nextLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets a list of deleted applications in the directory. + * + * @param {string} nextLink Next link for the list operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {ApplicationListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ApplicationListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listNext(nextLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listNext(nextLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listNext(nextLink, options, optionalCallback); + } + } + +} + +module.exports = DeletedApplications; diff --git a/lib/services/graphManagement/lib/operations/groups.js b/lib/services/graphManagement/lib/operations/groups.js index 092f7efe24..72975bf399 100644 --- a/lib/services/graphManagement/lib/operations/groups.js +++ b/lib/services/graphManagement/lib/operations/groups.js @@ -774,7 +774,8 @@ function _list(options, callback) { * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. - * See {@link GetObjectsResult} for more information. + * See {@link DirectoryObjectListResult} for more + * information. * * {object} [request] - The HTTP Request object if an error did not occur. * @@ -882,7 +883,7 @@ function _getGroupMembers(objectId, options, callback) { parsedResponse = JSON.parse(responseBody); result = JSON.parse(responseBody); if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = new client.models['GetObjectsResult']().mapper(); + let resultMapper = new client.models['DirectoryObjectListResult']().mapper(); result = client.deserialize(resultMapper, parsedResponse, 'result'); } } catch (error) { @@ -1326,6 +1327,299 @@ function _getMemberGroups(objectId, parameters, options, callback) { }); } +/** + * @summary Directory objects that are owners of the group. + * + * The owners are a set of non-admin users who are allowed to modify this + * object. + * + * @param {string} objectId The object ID of the group for which to get owners. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link DirectoryObjectListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listOwners(objectId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (objectId === null || objectId === undefined || typeof objectId.valueOf() !== 'string') { + throw new Error('objectId cannot be null or undefined and it must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.tenantID === null || this.client.tenantID === undefined || typeof this.client.tenantID.valueOf() !== 'string') { + throw new Error('this.client.tenantID cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + '{tenantID}/groups/{objectId}/owners'; + requestUrl = requestUrl.replace('{objectId}', encodeURIComponent(objectId)); + requestUrl = requestUrl.replace('{tenantID}', encodeURIComponent(this.client.tenantID)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['GraphError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['DirectoryObjectListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Add an owner to a group. + * + * @param {string} objectId The object ID of the application to which to add + * the owner. + * + * @param {object} 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 {string} parameters.url A owner object URL, such as + * "https://graph.windows.net/0b1f9851-1bf0-433f-aec3-cb9272f093dc/directoryObjects/f260bbc4-c254-447b-94cf-293b5ec434dd", + * where "0b1f9851-1bf0-433f-aec3-cb9272f093dc" is the tenantId and + * "f260bbc4-c254-447b-94cf-293b5ec434dd" is the objectId of the owner (user, + * application, servicePrincipal, group) to be added. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _addOwner(objectId, parameters, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (objectId === null || objectId === undefined || typeof objectId.valueOf() !== 'string') { + throw new Error('objectId cannot be null or undefined and it must be of type string.'); + } + if (parameters === null || parameters === undefined) { + throw new Error('parameters cannot be null or undefined.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.tenantID === null || this.client.tenantID === undefined || typeof this.client.tenantID.valueOf() !== 'string') { + throw new Error('this.client.tenantID cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + '{tenantID}/groups/{objectId}/$links/owners'; + requestUrl = requestUrl.replace('{objectId}', encodeURIComponent(objectId)); + requestUrl = requestUrl.replace('{tenantID}', encodeURIComponent(this.client.tenantID)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'POST'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (parameters !== null && parameters !== undefined) { + let requestModelMapper = new client.models['AddOwnerParameters']().mapper(); + requestModel = client.serialize(requestModelMapper, parameters, 'parameters'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(parameters, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 204) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['GraphError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + + return callback(null, result, httpRequest, response); + }); +} + /** * Gets a list of groups for the current tenant. * @@ -1451,7 +1745,148 @@ function _listNext(nextLink, options, callback) { parsedResponse = JSON.parse(responseBody); result = JSON.parse(responseBody); if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = new client.models['GroupListResult']().mapper(); + let resultMapper = new client.models['GroupListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Gets the members of a group. + * + * @param {string} nextLink Next link for the list operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link DirectoryObjectListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _getGroupMembersNext(nextLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextLink === null || nextLink === undefined || typeof nextLink.valueOf() !== 'string') { + throw new Error('nextLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.tenantID === null || this.client.tenantID === undefined || typeof this.client.tenantID.valueOf() !== 'string') { + throw new Error('this.client.tenantID cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + '{tenantID}/{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextLink); + requestUrl = requestUrl.replace('{tenantID}', encodeURIComponent(this.client.tenantID)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += (requestUrl.indexOf('?') !== -1 ? '&' : '?') + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['GraphError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['DirectoryObjectListResult']().mapper(); result = client.deserialize(resultMapper, parsedResponse, 'result'); } } catch (error) { @@ -1467,9 +1902,13 @@ function _listNext(nextLink, options, callback) { } /** - * Gets the members of a group. + * @summary Directory objects that are owners of the group. * - * @param {string} nextLink Next link for the list operation. + * The owners are a set of non-admin users who are allowed to modify this + * object. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. * * @param {object} [options] Optional Parameters. * @@ -1483,13 +1922,14 @@ function _listNext(nextLink, options, callback) { * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. - * See {@link GetObjectsResult} for more information. + * See {@link DirectoryObjectListResult} for more + * information. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ -function _getGroupMembersNext(nextLink, options, callback) { +function _listOwnersNext(nextPageLink, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { @@ -1501,14 +1941,8 @@ function _getGroupMembersNext(nextLink, options, callback) { } // Validate try { - if (nextLink === null || nextLink === undefined || typeof nextLink.valueOf() !== 'string') { - throw new Error('nextLink cannot be null or undefined and it must be of type string.'); - } - if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { - throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); - } - if (this.client.tenantID === null || this.client.tenantID === undefined || typeof this.client.tenantID.valueOf() !== 'string') { - throw new Error('this.client.tenantID cannot be null or undefined and it must be of type string.'); + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); } if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { throw new Error('this.client.acceptLanguage must be of type string.'); @@ -1518,15 +1952,8 @@ function _getGroupMembersNext(nextLink, options, callback) { } // Construct URL - let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + '{tenantID}/{nextLink}'; - requestUrl = requestUrl.replace('{nextLink}', nextLink); - requestUrl = requestUrl.replace('{tenantID}', encodeURIComponent(this.client.tenantID)); - let queryParameters = []; - queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); - if (queryParameters.length > 0) { - requestUrl += (requestUrl.indexOf('?') !== -1 ? '&' : '?') + queryParameters.join('&'); - } + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); // Create HTTP transport objects let httpRequest = new WebResource(); @@ -1591,7 +2018,7 @@ function _getGroupMembersNext(nextLink, options, callback) { parsedResponse = JSON.parse(responseBody); result = JSON.parse(responseBody); if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = new client.models['GetObjectsResult']().mapper(); + let resultMapper = new client.models['DirectoryObjectListResult']().mapper(); result = client.deserialize(resultMapper, parsedResponse, 'result'); } } catch (error) { @@ -1623,8 +2050,11 @@ class Groups { this._get = _get; this._deleteMethod = _deleteMethod; this._getMemberGroups = _getMemberGroups; + this._listOwners = _listOwners; + this._addOwner = _addOwner; this._listNext = _listNext; this._getGroupMembersNext = _getGroupMembersNext; + this._listOwnersNext = _listOwnersNext; } /** @@ -2095,7 +2525,7 @@ class Groups { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error} - The error object. */ @@ -2131,7 +2561,7 @@ class Groups { * * {Promise} A promise is returned * - * @resolve {GetObjectsResult} - The deserialized result object. + * @resolve {DirectoryObjectListResult} - The deserialized result object. * * @reject {Error} - The error object. * @@ -2140,7 +2570,8 @@ class Groups { * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. - * See {@link GetObjectsResult} for more information. + * See {@link DirectoryObjectListResult} for more + * information. * * {object} [request] - The HTTP Request object if an error did not occur. * @@ -2430,6 +2861,196 @@ class Groups { } } + /** + * @summary Directory objects that are owners of the group. + * + * The owners are a set of non-admin users who are allowed to modify this + * object. + * + * @param {string} objectId The object ID of the group for which to get owners. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listOwnersWithHttpOperationResponse(objectId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listOwners(objectId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * @summary Directory objects that are owners of the group. + * + * The owners are a set of non-admin users who are allowed to modify this + * object. + * + * @param {string} objectId The object ID of the group for which to get owners. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {DirectoryObjectListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link DirectoryObjectListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listOwners(objectId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listOwners(objectId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listOwners(objectId, options, optionalCallback); + } + } + + /** + * Add an owner to a group. + * + * @param {string} objectId The object ID of the application to which to add + * the owner. + * + * @param {object} 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 {string} parameters.url A owner object URL, such as + * "https://graph.windows.net/0b1f9851-1bf0-433f-aec3-cb9272f093dc/directoryObjects/f260bbc4-c254-447b-94cf-293b5ec434dd", + * where "0b1f9851-1bf0-433f-aec3-cb9272f093dc" is the tenantId and + * "f260bbc4-c254-447b-94cf-293b5ec434dd" is the objectId of the owner (user, + * application, servicePrincipal, group) to be added. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + addOwnerWithHttpOperationResponse(objectId, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._addOwner(objectId, parameters, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Add an owner to a group. + * + * @param {string} objectId The object ID of the application to which to add + * the owner. + * + * @param {object} 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 {string} parameters.url A owner object URL, such as + * "https://graph.windows.net/0b1f9851-1bf0-433f-aec3-cb9272f093dc/directoryObjects/f260bbc4-c254-447b-94cf-293b5ec434dd", + * where "0b1f9851-1bf0-433f-aec3-cb9272f093dc" is the tenantId and + * "f260bbc4-c254-447b-94cf-293b5ec434dd" is the objectId of the owner (user, + * application, servicePrincipal, group) to be added. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + addOwner(objectId, parameters, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._addOwner(objectId, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._addOwner(objectId, parameters, options, optionalCallback); + } + } + /** * Gets a list of groups for the current tenant. * @@ -2524,7 +3145,7 @@ class Groups { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error} - The error object. */ @@ -2559,7 +3180,7 @@ class Groups { * * {Promise} A promise is returned * - * @resolve {GetObjectsResult} - The deserialized result object. + * @resolve {DirectoryObjectListResult} - The deserialized result object. * * @reject {Error} - The error object. * @@ -2568,7 +3189,8 @@ class Groups { * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. - * See {@link GetObjectsResult} for more information. + * See {@link DirectoryObjectListResult} for more + * information. * * {object} [request] - The HTTP Request object if an error did not occur. * @@ -2594,6 +3216,97 @@ class Groups { } } + /** + * @summary Directory objects that are owners of the group. + * + * The owners are a set of non-admin users who are allowed to modify this + * object. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listOwnersNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listOwnersNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * @summary Directory objects that are owners of the group. + * + * The owners are a set of non-admin users who are allowed to modify this + * object. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {DirectoryObjectListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link DirectoryObjectListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listOwnersNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listOwnersNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listOwnersNext(nextPageLink, options, optionalCallback); + } + } + } module.exports = Groups; diff --git a/lib/services/graphManagement/lib/operations/index.d.ts b/lib/services/graphManagement/lib/operations/index.d.ts index b95b53cbdb..de61175228 100644 --- a/lib/services/graphManagement/lib/operations/index.d.ts +++ b/lib/services/graphManagement/lib/operations/index.d.ts @@ -14,11 +14,11 @@ import * as models from '../models'; /** * @class - * Objects + * SignedInUser * __NOTE__: An instance of this class is automatically created for an * instance of the GraphRbacManagementClient. */ -export interface Objects { +export interface SignedInUser { /** @@ -31,11 +31,11 @@ export interface Objects { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - getCurrentUserWithHttpOperationResponse(options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + getWithHttpOperationResponse(options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** * Gets the details for the currently logged-in user. @@ -52,7 +52,7 @@ export interface Objects { * * {Promise} A promise is returned. * - * @resolve {AADObject} - The deserialized result object. + * @resolve {User} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -60,29 +60,20 @@ export interface Objects { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {AADObject} [result] - The deserialized result object if an error did not occur. - * See {@link AADObject} for more information. + * {User} [result] - The deserialized result object if an error did not occur. + * See {@link User} for more information. * * {WebResource} [request] - The HTTP Request object if an error did not occur. * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - getCurrentUser(options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - getCurrentUser(callback: ServiceCallback): void; - getCurrentUser(options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + get(options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(callback: ServiceCallback): void; + get(options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Gets AD group membership for the specified AD object IDs. - * - * @param {object} parameters Objects filtering parameters. - * - * @param {array} [parameters.objectIds] The requested object IDs. - * - * @param {array} [parameters.types] The requested object types. - * - * @param {boolean} parameters.includeDirectoryObjectReferences If true, also - * searches for object IDs in the partner tenant. + * Get the list of directory objects that are owned by the user. * * @param {object} [options] Optional Parameters. * @@ -91,23 +82,14 @@ export interface Objects { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - getObjectsByObjectIdsWithHttpOperationResponse(parameters: models.GetObjectsParameters, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + listOwnedObjectsWithHttpOperationResponse(options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Gets AD group membership for the specified AD object IDs. - * - * @param {object} parameters Objects filtering parameters. - * - * @param {array} [parameters.objectIds] The requested object IDs. - * - * @param {array} [parameters.types] The requested object types. - * - * @param {boolean} parameters.includeDirectoryObjectReferences If true, also - * searches for object IDs in the partner tenant. + * Get the list of directory objects that are owned by the user. * * @param {object} [options] Optional Parameters. * @@ -121,7 +103,7 @@ export interface Objects { * * {Promise} A promise is returned. * - * @resolve {GetObjectsResult} - The deserialized result object. + * @resolve {DirectoryObjectListResult} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -129,20 +111,21 @@ export interface Objects { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {GetObjectsResult} [result] - The deserialized result object if an error did not occur. - * See {@link GetObjectsResult} for more information. + * {DirectoryObjectListResult} [result] - The deserialized result object if an error did not occur. + * See {@link DirectoryObjectListResult} for more + * information. * * {WebResource} [request] - The HTTP Request object if an error did not occur. * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - getObjectsByObjectIds(parameters: models.GetObjectsParameters, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - getObjectsByObjectIds(parameters: models.GetObjectsParameters, callback: ServiceCallback): void; - getObjectsByObjectIds(parameters: models.GetObjectsParameters, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + listOwnedObjects(options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listOwnedObjects(callback: ServiceCallback): void; + listOwnedObjects(options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Gets AD group membership for the specified AD object IDs. + * Get the list of directory objects that are owned by the user. * * @param {string} nextLink Next link for the list operation. * @@ -153,14 +136,14 @@ export interface Objects { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - getObjectsByObjectIdsNextWithHttpOperationResponse(nextLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + listOwnedObjectsNextWithHttpOperationResponse(nextLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Gets AD group membership for the specified AD object IDs. + * Get the list of directory objects that are owned by the user. * * @param {string} nextLink Next link for the list operation. * @@ -176,7 +159,7 @@ export interface Objects { * * {Promise} A promise is returned. * - * @resolve {GetObjectsResult} - The deserialized result object. + * @resolve {DirectoryObjectListResult} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -184,16 +167,17 @@ export interface Objects { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {GetObjectsResult} [result] - The deserialized result object if an error did not occur. - * See {@link GetObjectsResult} for more information. + * {DirectoryObjectListResult} [result] - The deserialized result object if an error did not occur. + * See {@link DirectoryObjectListResult} for more + * information. * * {WebResource} [request] - The HTTP Request object if an error did not occur. * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - getObjectsByObjectIdsNext(nextLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - getObjectsByObjectIdsNext(nextLink: string, callback: ServiceCallback): void; - getObjectsByObjectIdsNext(nextLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + listOwnedObjectsNext(nextLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listOwnedObjectsNext(nextLink: string, callback: ServiceCallback): void; + listOwnedObjectsNext(nextLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; } /** @@ -210,6 +194,10 @@ export interface Applications { * * @param {object} parameters The parameters for creating an application. * + * @param {array} [parameters.appRoles] The collection of application roles + * that an application may declare. These roles can be assigned to users, + * groups or service principals. + * * @param {boolean} parameters.availableToOtherTenants Whether the application * is available to other tenants. * @@ -255,6 +243,10 @@ export interface Applications { * * @param {object} parameters The parameters for creating an application. * + * @param {array} [parameters.appRoles] The collection of application roles + * that an application may declare. These roles can be assigned to users, + * groups or service principals. + * * @param {boolean} parameters.availableToOtherTenants Whether the application * is available to other tenants. * @@ -485,6 +477,10 @@ export interface Applications { * * @param {object} parameters Parameters to update an existing application. * + * @param {array} [parameters.appRoles] The collection of application roles + * that an application may declare. These roles can be assigned to users, + * groups or service principals. + * * @param {boolean} [parameters.availableToOtherTenants] Whether the * application is available to other tenants * @@ -533,6 +529,10 @@ export interface Applications { * * @param {object} parameters Parameters to update an existing application. * + * @param {array} [parameters.appRoles] The collection of application roles + * that an application may declare. These roles can be assigned to users, + * groups or service principals. + * * @param {boolean} [parameters.availableToOtherTenants] Whether the * application is available to other tenants * @@ -682,7 +682,7 @@ export interface Applications { * * @reject {Error|ServiceError} - The error object. */ - addOwnerWithHttpOperationResponse(applicationObjectId: string, parameters: models.ApplicationAddOwnerParameters, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + addOwnerWithHttpOperationResponse(applicationObjectId: string, parameters: models.AddOwnerParameters, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** * Add an owner to an application. @@ -725,9 +725,9 @@ export interface Applications { * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - addOwner(applicationObjectId: string, parameters: models.ApplicationAddOwnerParameters, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - addOwner(applicationObjectId: string, parameters: models.ApplicationAddOwnerParameters, callback: ServiceCallback): void; - addOwner(applicationObjectId: string, parameters: models.ApplicationAddOwnerParameters, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + addOwner(applicationObjectId: string, parameters: models.AddOwnerParameters, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + addOwner(applicationObjectId: string, parameters: models.AddOwnerParameters, callback: ServiceCallback): void; + addOwner(applicationObjectId: string, parameters: models.AddOwnerParameters, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** @@ -1011,27 +1011,16 @@ export interface Applications { listNext(nextLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; listNext(nextLink: string, callback: ServiceCallback): void; listNext(nextLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; -} - -/** - * @class - * Groups - * __NOTE__: An instance of this class is automatically created for an - * instance of the GraphRbacManagementClient. - */ -export interface Groups { /** - * Checks whether the specified user, group, contact, or service principal is a - * direct or transitive member of the specified group. - * - * @param {object} parameters The check group membership parameters. + * @summary Directory objects that are owners of the application. * - * @param {string} parameters.groupId The object ID of the group to check. + * The owners are a set of non-admin users who are allowed to modify this + * object. * - * @param {string} parameters.memberId The object ID of the contact, group, - * user, or service principal to check for membership in the specified group. + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. * * @param {object} [options] Optional Parameters. * @@ -1040,22 +1029,20 @@ export interface Groups { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - isMemberOfWithHttpOperationResponse(parameters: models.CheckGroupMembershipParameters, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + listOwnersNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Checks whether the specified user, group, contact, or service principal is a - * direct or transitive member of the specified group. - * - * @param {object} parameters The check group membership parameters. + * @summary Directory objects that are owners of the application. * - * @param {string} parameters.groupId The object ID of the group to check. + * The owners are a set of non-admin users who are allowed to modify this + * object. * - * @param {string} parameters.memberId The object ID of the contact, group, - * user, or service principal to check for membership in the specified group. + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. * * @param {object} [options] Optional Parameters. * @@ -1069,7 +1056,7 @@ export interface Groups { * * {Promise} A promise is returned. * - * @resolve {CheckGroupMembershipResult} - The deserialized result object. + * @resolve {DirectoryObjectListResult} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -1077,26 +1064,32 @@ export interface Groups { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {CheckGroupMembershipResult} [result] - The deserialized result object if an error did not occur. - * See {@link CheckGroupMembershipResult} for more + * {DirectoryObjectListResult} [result] - The deserialized result object if an error did not occur. + * See {@link DirectoryObjectListResult} for more * information. * * {WebResource} [request] - The HTTP Request object if an error did not occur. * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - isMemberOf(parameters: models.CheckGroupMembershipParameters, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - isMemberOf(parameters: models.CheckGroupMembershipParameters, callback: ServiceCallback): void; - isMemberOf(parameters: models.CheckGroupMembershipParameters, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + listOwnersNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listOwnersNext(nextPageLink: string, callback: ServiceCallback): void; + listOwnersNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * DeletedApplications + * __NOTE__: An instance of this class is automatically created for an + * instance of the GraphRbacManagementClient. + */ +export interface DeletedApplications { /** - * Remove a member from a group. - * - * @param {string} groupObjectId The object ID of the group from which to - * remove the member. + * Restores the deleted application in the directory. * - * @param {string} memberObjectId Member object id + * @param {string} objectId Application object ID. * * @param {object} [options] Optional Parameters. * @@ -1105,19 +1098,16 @@ export interface Groups { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - removeMemberWithHttpOperationResponse(groupObjectId: string, memberObjectId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + restoreWithHttpOperationResponse(objectId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Remove a member from a group. - * - * @param {string} groupObjectId The object ID of the group from which to - * remove the member. + * Restores the deleted application in the directory. * - * @param {string} memberObjectId Member object id + * @param {string} objectId Application object ID. * * @param {object} [options] Optional Parameters. * @@ -1131,7 +1121,7 @@ export interface Groups { * * {Promise} A promise is returned. * - * @resolve {null} - The deserialized result object. + * @resolve {Application} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -1139,62 +1129,43 @@ export interface Groups { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {null} [result] - The deserialized result object if an error did not occur. + * {Application} [result] - The deserialized result object if an error did not occur. + * See {@link Application} for more information. * * {WebResource} [request] - The HTTP Request object if an error did not occur. * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - removeMember(groupObjectId: string, memberObjectId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - removeMember(groupObjectId: string, memberObjectId: string, callback: ServiceCallback): void; - removeMember(groupObjectId: string, memberObjectId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + restore(objectId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + restore(objectId: string, callback: ServiceCallback): void; + restore(objectId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Add a member to a group. - * - * @param {string} groupObjectId The object ID of the group to which to add the - * member. - * - * @param {object} 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 {string} parameters.url A member object URL, such as - * "https://graph.windows.net/0b1f9851-1bf0-433f-aec3-cb9272f093dc/directoryObjects/f260bbc4-c254-447b-94cf-293b5ec434dd", - * where "0b1f9851-1bf0-433f-aec3-cb9272f093dc" is the tenantId and - * "f260bbc4-c254-447b-94cf-293b5ec434dd" is the objectId of the member (user, - * application, servicePrincipal, group) to be added. + * Gets a list of deleted applications in the directory. * * @param {object} [options] Optional Parameters. * + * @param {string} [options.filter] The filter to apply to the operation. + * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - addMemberWithHttpOperationResponse(groupObjectId: string, parameters: models.GroupAddMemberParameters, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + listWithHttpOperationResponse(options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Add a member to a group. - * - * @param {string} groupObjectId The object ID of the group to which to add the - * member. - * - * @param {object} 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 {string} parameters.url A member object URL, such as - * "https://graph.windows.net/0b1f9851-1bf0-433f-aec3-cb9272f093dc/directoryObjects/f260bbc4-c254-447b-94cf-293b5ec434dd", - * where "0b1f9851-1bf0-433f-aec3-cb9272f093dc" is the tenantId and - * "f260bbc4-c254-447b-94cf-293b5ec434dd" is the objectId of the member (user, - * application, servicePrincipal, group) to be added. + * Gets a list of deleted applications in the directory. * * @param {object} [options] Optional Parameters. * + * @param {string} [options.filter] The filter to apply to the operation. + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -1205,7 +1176,7 @@ export interface Groups { * * {Promise} A promise is returned. * - * @resolve {null} - The deserialized result object. + * @resolve {ApplicationListResult} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -1213,25 +1184,22 @@ export interface Groups { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {null} [result] - The deserialized result object if an error did not occur. + * {ApplicationListResult} [result] - The deserialized result object if an error did not occur. + * See {@link ApplicationListResult} for more information. * * {WebResource} [request] - The HTTP Request object if an error did not occur. * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - addMember(groupObjectId: string, parameters: models.GroupAddMemberParameters, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - addMember(groupObjectId: string, parameters: models.GroupAddMemberParameters, callback: ServiceCallback): void; - addMember(groupObjectId: string, parameters: models.GroupAddMemberParameters, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + list(options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + list(callback: ServiceCallback): void; + list(options: { filter? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Create a group in the directory. - * - * @param {object} parameters The parameters for the group to create. - * - * @param {string} parameters.displayName Group display name + * Hard-delete an application. * - * @param {string} parameters.mailNickname Mail nickname + * @param {string} applicationObjectId Application object ID. * * @param {object} [options] Optional Parameters. * @@ -1240,20 +1208,16 @@ export interface Groups { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - createWithHttpOperationResponse(parameters: models.GroupCreateParameters, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + hardDeleteWithHttpOperationResponse(applicationObjectId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Create a group in the directory. - * - * @param {object} parameters The parameters for the group to create. - * - * @param {string} parameters.displayName Group display name + * Hard-delete an application. * - * @param {string} parameters.mailNickname Mail nickname + * @param {string} applicationObjectId Application object ID. * * @param {object} [options] Optional Parameters. * @@ -1267,7 +1231,7 @@ export interface Groups { * * {Promise} A promise is returned. * - * @resolve {ADGroup} - The deserialized result object. + * @resolve {null} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -1275,42 +1239,41 @@ export interface Groups { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {ADGroup} [result] - The deserialized result object if an error did not occur. - * See {@link ADGroup} for more information. + * {null} [result] - The deserialized result object if an error did not occur. * * {WebResource} [request] - The HTTP Request object if an error did not occur. * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - create(parameters: models.GroupCreateParameters, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - create(parameters: models.GroupCreateParameters, callback: ServiceCallback): void; - create(parameters: models.GroupCreateParameters, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + hardDelete(applicationObjectId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + hardDelete(applicationObjectId: string, callback: ServiceCallback): void; + hardDelete(applicationObjectId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Gets list of groups for the current tenant. + * Gets a list of deleted applications in the directory. * - * @param {object} [options] Optional Parameters. + * @param {string} nextLink Next link for the list operation. * - * @param {string} [options.filter] The filter to apply to the operation. + * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - listWithHttpOperationResponse(options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + listNextWithHttpOperationResponse(nextLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Gets list of groups for the current tenant. + * Gets a list of deleted applications in the directory. * - * @param {object} [options] Optional Parameters. + * @param {string} nextLink Next link for the list operation. * - * @param {string} [options.filter] The filter to apply to the operation. + * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -1322,7 +1285,7 @@ export interface Groups { * * {Promise} A promise is returned. * - * @resolve {GroupListResult} - The deserialized result object. + * @resolve {ApplicationListResult} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -1330,23 +1293,37 @@ export interface Groups { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {GroupListResult} [result] - The deserialized result object if an error did not occur. - * See {@link GroupListResult} for more information. + * {ApplicationListResult} [result] - The deserialized result object if an error did not occur. + * See {@link ApplicationListResult} for more information. * * {WebResource} [request] - The HTTP Request object if an error did not occur. * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - list(options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise; - list(callback: ServiceCallback): void; - list(options: { filter? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + listNext(nextLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listNext(nextLink: string, callback: ServiceCallback): void; + listNext(nextLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * Groups + * __NOTE__: An instance of this class is automatically created for an + * instance of the GraphRbacManagementClient. + */ +export interface Groups { /** - * Gets the members of a group. + * Checks whether the specified user, group, contact, or service principal is a + * direct or transitive member of the specified group. * - * @param {string} objectId The object ID of the group whose members should be - * retrieved. + * @param {object} parameters The check group membership parameters. + * + * @param {string} parameters.groupId The object ID of the group to check. + * + * @param {string} parameters.memberId The object ID of the contact, group, + * user, or service principal to check for membership in the specified group. * * @param {object} [options] Optional Parameters. * @@ -1355,17 +1332,22 @@ export interface Groups { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - getGroupMembersWithHttpOperationResponse(objectId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + isMemberOfWithHttpOperationResponse(parameters: models.CheckGroupMembershipParameters, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Gets the members of a group. + * Checks whether the specified user, group, contact, or service principal is a + * direct or transitive member of the specified group. * - * @param {string} objectId The object ID of the group whose members should be - * retrieved. + * @param {object} parameters The check group membership parameters. + * + * @param {string} parameters.groupId The object ID of the group to check. + * + * @param {string} parameters.memberId The object ID of the contact, group, + * user, or service principal to check for membership in the specified group. * * @param {object} [options] Optional Parameters. * @@ -1379,7 +1361,7 @@ export interface Groups { * * {Promise} A promise is returned. * - * @resolve {GetObjectsResult} - The deserialized result object. + * @resolve {CheckGroupMembershipResult} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -1387,23 +1369,26 @@ export interface Groups { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {GetObjectsResult} [result] - The deserialized result object if an error did not occur. - * See {@link GetObjectsResult} for more information. + * {CheckGroupMembershipResult} [result] - The deserialized result object if an error did not occur. + * See {@link CheckGroupMembershipResult} for more + * information. * * {WebResource} [request] - The HTTP Request object if an error did not occur. * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - getGroupMembers(objectId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - getGroupMembers(objectId: string, callback: ServiceCallback): void; - getGroupMembers(objectId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + isMemberOf(parameters: models.CheckGroupMembershipParameters, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + isMemberOf(parameters: models.CheckGroupMembershipParameters, callback: ServiceCallback): void; + isMemberOf(parameters: models.CheckGroupMembershipParameters, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Gets group information from the directory. + * Remove a member from a group. * - * @param {string} objectId The object ID of the user for which to get group - * information. + * @param {string} groupObjectId The object ID of the group from which to + * remove the member. + * + * @param {string} memberObjectId Member object id * * @param {object} [options] Optional Parameters. * @@ -1412,11 +1397,319 @@ export interface Groups { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - getWithHttpOperationResponse(objectId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + removeMemberWithHttpOperationResponse(groupObjectId: string, memberObjectId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Remove a member from a group. + * + * @param {string} groupObjectId The object ID of the group from which to + * remove the member. + * + * @param {string} memberObjectId Member object id + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + removeMember(groupObjectId: string, memberObjectId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + removeMember(groupObjectId: string, memberObjectId: string, callback: ServiceCallback): void; + removeMember(groupObjectId: string, memberObjectId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Add a member to a group. + * + * @param {string} groupObjectId The object ID of the group to which to add the + * member. + * + * @param {object} 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 {string} parameters.url A member object URL, such as + * "https://graph.windows.net/0b1f9851-1bf0-433f-aec3-cb9272f093dc/directoryObjects/f260bbc4-c254-447b-94cf-293b5ec434dd", + * where "0b1f9851-1bf0-433f-aec3-cb9272f093dc" is the tenantId and + * "f260bbc4-c254-447b-94cf-293b5ec434dd" is the objectId of the member (user, + * application, servicePrincipal, group) to be added. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + addMemberWithHttpOperationResponse(groupObjectId: string, parameters: models.GroupAddMemberParameters, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Add a member to a group. + * + * @param {string} groupObjectId The object ID of the group to which to add the + * member. + * + * @param {object} 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 {string} parameters.url A member object URL, such as + * "https://graph.windows.net/0b1f9851-1bf0-433f-aec3-cb9272f093dc/directoryObjects/f260bbc4-c254-447b-94cf-293b5ec434dd", + * where "0b1f9851-1bf0-433f-aec3-cb9272f093dc" is the tenantId and + * "f260bbc4-c254-447b-94cf-293b5ec434dd" is the objectId of the member (user, + * application, servicePrincipal, group) to be added. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + addMember(groupObjectId: string, parameters: models.GroupAddMemberParameters, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + addMember(groupObjectId: string, parameters: models.GroupAddMemberParameters, callback: ServiceCallback): void; + addMember(groupObjectId: string, parameters: models.GroupAddMemberParameters, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Create a group in the directory. + * + * @param {object} parameters The parameters for the group to create. + * + * @param {string} parameters.displayName Group display name + * + * @param {string} parameters.mailNickname Mail nickname + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + createWithHttpOperationResponse(parameters: models.GroupCreateParameters, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Create a group in the directory. + * + * @param {object} parameters The parameters for the group to create. + * + * @param {string} parameters.displayName Group display name + * + * @param {string} parameters.mailNickname Mail nickname + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ADGroup} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ADGroup} [result] - The deserialized result object if an error did not occur. + * See {@link ADGroup} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + create(parameters: models.GroupCreateParameters, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + create(parameters: models.GroupCreateParameters, callback: ServiceCallback): void; + create(parameters: models.GroupCreateParameters, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Gets list of groups for the current tenant. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] The filter to apply to the operation. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listWithHttpOperationResponse(options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets list of groups for the current tenant. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] The filter to apply to the operation. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {GroupListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {GroupListResult} [result] - The deserialized result object if an error did not occur. + * See {@link GroupListResult} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + list(options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + list(callback: ServiceCallback): void; + list(options: { filter? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Gets the members of a group. + * + * @param {string} objectId The object ID of the group whose members should be + * retrieved. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getGroupMembersWithHttpOperationResponse(objectId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets the members of a group. + * + * @param {string} objectId The object ID of the group whose members should be + * retrieved. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {DirectoryObjectListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {DirectoryObjectListResult} [result] - The deserialized result object if an error did not occur. + * See {@link DirectoryObjectListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + getGroupMembers(objectId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + getGroupMembers(objectId: string, callback: ServiceCallback): void; + getGroupMembers(objectId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Gets group information from the directory. + * + * @param {string} objectId The object ID of the user for which to get group + * information. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(objectId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** * Gets group information from the directory. @@ -1582,6 +1875,142 @@ export interface Groups { getMemberGroups(objectId: string, parameters: models.GroupGetMemberGroupsParameters, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + /** + * @summary Directory objects that are owners of the group. + * + * The owners are a set of non-admin users who are allowed to modify this + * object. + * + * @param {string} objectId The object ID of the group for which to get owners. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listOwnersWithHttpOperationResponse(objectId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * @summary Directory objects that are owners of the group. + * + * The owners are a set of non-admin users who are allowed to modify this + * object. + * + * @param {string} objectId The object ID of the group for which to get owners. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {DirectoryObjectListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {DirectoryObjectListResult} [result] - The deserialized result object if an error did not occur. + * See {@link DirectoryObjectListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listOwners(objectId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listOwners(objectId: string, callback: ServiceCallback): void; + listOwners(objectId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Add an owner to a group. + * + * @param {string} objectId The object ID of the application to which to add + * the owner. + * + * @param {object} 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 {string} parameters.url A owner object URL, such as + * "https://graph.windows.net/0b1f9851-1bf0-433f-aec3-cb9272f093dc/directoryObjects/f260bbc4-c254-447b-94cf-293b5ec434dd", + * where "0b1f9851-1bf0-433f-aec3-cb9272f093dc" is the tenantId and + * "f260bbc4-c254-447b-94cf-293b5ec434dd" is the objectId of the owner (user, + * application, servicePrincipal, group) to be added. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + addOwnerWithHttpOperationResponse(objectId: string, parameters: models.AddOwnerParameters, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Add an owner to a group. + * + * @param {string} objectId The object ID of the application to which to add + * the owner. + * + * @param {object} 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 {string} parameters.url A owner object URL, such as + * "https://graph.windows.net/0b1f9851-1bf0-433f-aec3-cb9272f093dc/directoryObjects/f260bbc4-c254-447b-94cf-293b5ec434dd", + * where "0b1f9851-1bf0-433f-aec3-cb9272f093dc" is the tenantId and + * "f260bbc4-c254-447b-94cf-293b5ec434dd" is the objectId of the owner (user, + * application, servicePrincipal, group) to be added. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + addOwner(objectId: string, parameters: models.AddOwnerParameters, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + addOwner(objectId: string, parameters: models.AddOwnerParameters, callback: ServiceCallback): void; + addOwner(objectId: string, parameters: models.AddOwnerParameters, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + /** * Gets a list of groups for the current tenant. * @@ -1649,11 +2078,11 @@ export interface Groups { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - getGroupMembersNextWithHttpOperationResponse(nextLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + getGroupMembersNextWithHttpOperationResponse(nextLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** * Gets the members of a group. @@ -1672,7 +2101,71 @@ export interface Groups { * * {Promise} A promise is returned. * - * @resolve {GetObjectsResult} - The deserialized result object. + * @resolve {DirectoryObjectListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {DirectoryObjectListResult} [result] - The deserialized result object if an error did not occur. + * See {@link DirectoryObjectListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + getGroupMembersNext(nextLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + getGroupMembersNext(nextLink: string, callback: ServiceCallback): void; + getGroupMembersNext(nextLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * @summary Directory objects that are owners of the group. + * + * The owners are a set of non-admin users who are allowed to modify this + * object. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listOwnersNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * @summary Directory objects that are owners of the group. + * + * The owners are a set of non-admin users who are allowed to modify this + * object. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {DirectoryObjectListResult} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -1680,16 +2173,17 @@ export interface Groups { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {GetObjectsResult} [result] - The deserialized result object if an error did not occur. - * See {@link GetObjectsResult} for more information. + * {DirectoryObjectListResult} [result] - The deserialized result object if an error did not occur. + * See {@link DirectoryObjectListResult} for more + * information. * * {WebResource} [request] - The HTTP Request object if an error did not occur. * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - getGroupMembersNext(nextLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - getGroupMembersNext(nextLink: string, callback: ServiceCallback): void; - getGroupMembersNext(nextLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + listOwnersNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listOwnersNext(nextPageLink: string, callback: ServiceCallback): void; + listOwnersNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; } /** @@ -1706,9 +2200,21 @@ export interface ServicePrincipals { * * @param {object} parameters Parameters to create a service principal. * + * @param {boolean} [parameters.accountEnabled] Whether the account is enabled + * * @param {string} parameters.appId application Id * - * @param {boolean} parameters.accountEnabled Whether the account is enabled + * @param {boolean} [parameters.appRoleAssignmentRequired] Specifies whether an + * AppRoleAssignment to a user or group is required before Azure AD will issue + * a user or access token to the application. + * + * @param {string} [parameters.displayName] The display name for the service + * principal. + * + * @param {string} [parameters.errorUrl] + * + * @param {string} [parameters.homepage] The URL to the homepage of the + * associated application. * * @param {array} [parameters.keyCredentials] A collection of KeyCredential * objects. @@ -1716,6 +2222,19 @@ export interface ServicePrincipals { * @param {array} [parameters.passwordCredentials] A collection of * PasswordCredential objects * + * @param {string} [parameters.publisherName] The display name of the tenant in + * which the associated application is specified. + * + * @param {array} [parameters.replyUrls] A collection of reply URLs for the + * service principal. + * + * @param {string} [parameters.samlMetadataUrl] + * + * @param {array} [parameters.servicePrincipalNames] A collection of service + * principal names. + * + * @param {array} [parameters.tags] + * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the @@ -1734,9 +2253,21 @@ export interface ServicePrincipals { * * @param {object} parameters Parameters to create a service principal. * + * @param {boolean} [parameters.accountEnabled] Whether the account is enabled + * * @param {string} parameters.appId application Id * - * @param {boolean} parameters.accountEnabled Whether the account is enabled + * @param {boolean} [parameters.appRoleAssignmentRequired] Specifies whether an + * AppRoleAssignment to a user or group is required before Azure AD will issue + * a user or access token to the application. + * + * @param {string} [parameters.displayName] The display name for the service + * principal. + * + * @param {string} [parameters.errorUrl] + * + * @param {string} [parameters.homepage] The URL to the homepage of the + * associated application. * * @param {array} [parameters.keyCredentials] A collection of KeyCredential * objects. @@ -1744,8 +2275,76 @@ export interface ServicePrincipals { * @param {array} [parameters.passwordCredentials] A collection of * PasswordCredential objects * + * @param {string} [parameters.publisherName] The display name of the tenant in + * which the associated application is specified. + * + * @param {array} [parameters.replyUrls] A collection of reply URLs for the + * service principal. + * + * @param {string} [parameters.samlMetadataUrl] + * + * @param {array} [parameters.servicePrincipalNames] A collection of service + * principal names. + * + * @param {array} [parameters.tags] + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ServicePrincipal} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ServicePrincipal} [result] - The deserialized result object if an error did not occur. + * See {@link ServicePrincipal} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + create(parameters: models.ServicePrincipalCreateParameters, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + create(parameters: models.ServicePrincipalCreateParameters, callback: ServiceCallback): void; + create(parameters: models.ServicePrincipalCreateParameters, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Gets a list of service principals from the current tenant. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] The filter to apply to the operation. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listWithHttpOperationResponse(options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets a list of service principals from the current tenant. + * * @param {object} [options] Optional Parameters. * + * @param {string} [options.filter] The filter to apply to the operation. + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -1756,7 +2355,7 @@ export interface ServicePrincipals { * * {Promise} A promise is returned. * - * @resolve {ServicePrincipal} - The deserialized result object. + * @resolve {ServicePrincipalListResult} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -1764,42 +2363,117 @@ export interface ServicePrincipals { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {ServicePrincipal} [result] - The deserialized result object if an error did not occur. - * See {@link ServicePrincipal} for more information. + * {ServicePrincipalListResult} [result] - The deserialized result object if an error did not occur. + * See {@link ServicePrincipalListResult} for more + * information. * * {WebResource} [request] - The HTTP Request object if an error did not occur. * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - create(parameters: models.ServicePrincipalCreateParameters, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - create(parameters: models.ServicePrincipalCreateParameters, callback: ServiceCallback): void; - create(parameters: models.ServicePrincipalCreateParameters, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + list(options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + list(callback: ServiceCallback): void; + list(options: { filter? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Gets a list of service principals from the current tenant. + * Updates a service principal in the directory. * - * @param {object} [options] Optional Parameters. + * @param {string} objectId The object ID of the service principal to delete. * - * @param {string} [options.filter] The filter to apply to the operation. + * @param {object} parameters Parameters to update a service principal. + * + * @param {boolean} [parameters.accountEnabled] Whether the account is enabled + * + * @param {string} [parameters.appId] application Id + * + * @param {boolean} [parameters.appRoleAssignmentRequired] Specifies whether an + * AppRoleAssignment to a user or group is required before Azure AD will issue + * a user or access token to the application. + * + * @param {string} [parameters.displayName] The display name for the service + * principal. + * + * @param {string} [parameters.errorUrl] + * + * @param {string} [parameters.homepage] The URL to the homepage of the + * associated application. + * + * @param {array} [parameters.keyCredentials] A collection of KeyCredential + * objects. + * + * @param {array} [parameters.passwordCredentials] A collection of + * PasswordCredential objects + * + * @param {string} [parameters.publisherName] The display name of the tenant in + * which the associated application is specified. + * + * @param {array} [parameters.replyUrls] A collection of reply URLs for the + * service principal. + * + * @param {string} [parameters.samlMetadataUrl] + * + * @param {array} [parameters.servicePrincipalNames] A collection of service + * principal names. + * + * @param {array} [parameters.tags] + * + * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - listWithHttpOperationResponse(options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + updateWithHttpOperationResponse(objectId: string, parameters: models.ServicePrincipalUpdateParameters, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Gets a list of service principals from the current tenant. + * Updates a service principal in the directory. * - * @param {object} [options] Optional Parameters. + * @param {string} objectId The object ID of the service principal to delete. * - * @param {string} [options.filter] The filter to apply to the operation. + * @param {object} parameters Parameters to update a service principal. + * + * @param {boolean} [parameters.accountEnabled] Whether the account is enabled + * + * @param {string} [parameters.appId] application Id + * + * @param {boolean} [parameters.appRoleAssignmentRequired] Specifies whether an + * AppRoleAssignment to a user or group is required before Azure AD will issue + * a user or access token to the application. + * + * @param {string} [parameters.displayName] The display name for the service + * principal. + * + * @param {string} [parameters.errorUrl] + * + * @param {string} [parameters.homepage] The URL to the homepage of the + * associated application. + * + * @param {array} [parameters.keyCredentials] A collection of KeyCredential + * objects. + * + * @param {array} [parameters.passwordCredentials] A collection of + * PasswordCredential objects + * + * @param {string} [parameters.publisherName] The display name of the tenant in + * which the associated application is specified. + * + * @param {array} [parameters.replyUrls] A collection of reply URLs for the + * service principal. + * + * @param {string} [parameters.samlMetadataUrl] + * + * @param {array} [parameters.servicePrincipalNames] A collection of service + * principal names. + * + * @param {array} [parameters.tags] + * + * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -1811,7 +2485,7 @@ export interface ServicePrincipals { * * {Promise} A promise is returned. * - * @resolve {ServicePrincipalListResult} - The deserialized result object. + * @resolve {null} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -1819,17 +2493,15 @@ export interface ServicePrincipals { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {ServicePrincipalListResult} [result] - The deserialized result object if an error did not occur. - * See {@link ServicePrincipalListResult} for more - * information. + * {null} [result] - The deserialized result object if an error did not occur. * * {WebResource} [request] - The HTTP Request object if an error did not occur. * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - list(options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise; - list(callback: ServiceCallback): void; - list(options: { filter? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + update(objectId: string, parameters: models.ServicePrincipalUpdateParameters, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + update(objectId: string, parameters: models.ServicePrincipalUpdateParameters, callback: ServiceCallback): void; + update(objectId: string, parameters: models.ServicePrincipalUpdateParameters, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** @@ -2293,6 +2965,70 @@ export interface ServicePrincipals { listNext(nextLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; listNext(nextLink: string, callback: ServiceCallback): void; listNext(nextLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * @summary Directory objects that are owners of this service principal. + * + * The owners are a set of non-admin users who are allowed to modify this + * object. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listOwnersNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * @summary Directory objects that are owners of this service principal. + * + * The owners are a set of non-admin users who are allowed to modify this + * object. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {DirectoryObjectListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {DirectoryObjectListResult} [result] - The deserialized result object if an error did not occur. + * See {@link DirectoryObjectListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listOwnersNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listOwnersNext(nextPageLink: string, callback: ServiceCallback): void; + listOwnersNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; } /** @@ -2864,6 +3600,145 @@ export interface Users { listNext(nextLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; } +/** + * @class + * Objects + * __NOTE__: An instance of this class is automatically created for an + * instance of the GraphRbacManagementClient. + */ +export interface Objects { + + + /** + * Gets the directory objects specified in a list of object IDs. You can also + * specify which resource collections (users, groups, etc.) should be searched + * by specifying the optional types parameter. + * + * @param {object} parameters Objects filtering parameters. + * + * @param {array} [parameters.objectIds] The requested object IDs. + * + * @param {array} [parameters.types] The requested object types. + * + * @param {boolean} [parameters.includeDirectoryObjectReferences] If true, also + * searches for object IDs in the partner tenant. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getObjectsByObjectIdsWithHttpOperationResponse(parameters: models.GetObjectsParameters, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets the directory objects specified in a list of object IDs. You can also + * specify which resource collections (users, groups, etc.) should be searched + * by specifying the optional types parameter. + * + * @param {object} parameters Objects filtering parameters. + * + * @param {array} [parameters.objectIds] The requested object IDs. + * + * @param {array} [parameters.types] The requested object types. + * + * @param {boolean} [parameters.includeDirectoryObjectReferences] If true, also + * searches for object IDs in the partner tenant. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {DirectoryObjectListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {DirectoryObjectListResult} [result] - The deserialized result object if an error did not occur. + * See {@link DirectoryObjectListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + getObjectsByObjectIds(parameters: models.GetObjectsParameters, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + getObjectsByObjectIds(parameters: models.GetObjectsParameters, callback: ServiceCallback): void; + getObjectsByObjectIds(parameters: models.GetObjectsParameters, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Gets AD group membership for the specified AD object IDs. + * + * @param {string} nextLink Next link for the list operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getObjectsByObjectIdsNextWithHttpOperationResponse(nextLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets AD group membership for the specified AD object IDs. + * + * @param {string} nextLink Next link for the list operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {DirectoryObjectListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {DirectoryObjectListResult} [result] - The deserialized result object if an error did not occur. + * See {@link DirectoryObjectListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + getObjectsByObjectIdsNext(nextLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + getObjectsByObjectIdsNext(nextLink: string, callback: ServiceCallback): void; + getObjectsByObjectIdsNext(nextLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + /** * @class * Domains diff --git a/lib/services/graphManagement/lib/operations/index.js b/lib/services/graphManagement/lib/operations/index.js index 686cb0e4ff..45483f5236 100644 --- a/lib/services/graphManagement/lib/operations/index.js +++ b/lib/services/graphManagement/lib/operations/index.js @@ -14,10 +14,12 @@ 'use strict'; -exports.Objects = require('./objects'); +exports.SignedInUser = require('./signedInUser'); exports.Applications = require('./applications'); +exports.DeletedApplications = require('./deletedApplications'); exports.Groups = require('./groups'); exports.ServicePrincipals = require('./servicePrincipals'); exports.Users = require('./users'); +exports.Objects = require('./objects'); exports.Domains = require('./domains'); exports.OAuth2 = require('./oAuth2'); diff --git a/lib/services/graphManagement/lib/operations/objects.js b/lib/services/graphManagement/lib/operations/objects.js index 6fcf59f58e..9a36e4f0b5 100644 --- a/lib/services/graphManagement/lib/operations/objects.js +++ b/lib/services/graphManagement/lib/operations/objects.js @@ -15,141 +15,9 @@ const msRestAzure = require('ms-rest-azure'); const WebResource = msRest.WebResource; /** - * Gets the details for the currently logged-in user. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} callback - The callback. - * - * @returns {function} callback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {object} [result] - The deserialized result object if an error did not occur. - * See {@link AADObject} for more information. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ -function _getCurrentUser(options, callback) { - /* jshint validthis: true */ - let client = this.client; - if(!callback && typeof options === 'function') { - callback = options; - options = null; - } - if (!callback) { - throw new Error('callback cannot be null.'); - } - // Validate - try { - if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { - throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); - } - if (this.client.tenantID === null || this.client.tenantID === undefined || typeof this.client.tenantID.valueOf() !== 'string') { - throw new Error('this.client.tenantID cannot be null or undefined and it must be of type string.'); - } - if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { - throw new Error('this.client.acceptLanguage must be of type string.'); - } - } catch (error) { - return callback(error); - } - - // Construct URL - let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + '{tenantID}/me'; - requestUrl = requestUrl.replace('{tenantID}', encodeURIComponent(this.client.tenantID)); - let queryParameters = []; - queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); - if (queryParameters.length > 0) { - requestUrl += '?' + queryParameters.join('&'); - } - - // Create HTTP transport objects - let httpRequest = new WebResource(); - httpRequest.method = 'GET'; - httpRequest.url = requestUrl; - httpRequest.headers = {}; - // Set Headers - httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; - if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - } - if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { - httpRequest.headers['accept-language'] = this.client.acceptLanguage; - } - if(options) { - for(let headerName in options['customHeaders']) { - if (options['customHeaders'].hasOwnProperty(headerName)) { - httpRequest.headers[headerName] = options['customHeaders'][headerName]; - } - } - } - httpRequest.body = null; - // Send Request - return client.pipeline(httpRequest, (err, response, responseBody) => { - if (err) { - return callback(err); - } - let statusCode = response.statusCode; - if (statusCode !== 200) { - let error = new Error(responseBody); - error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); - if (responseBody === '') responseBody = null; - let parsedErrorResponse; - try { - parsedErrorResponse = JSON.parse(responseBody); - if (parsedErrorResponse) { - let internalError = null; - if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; - error.code = internalError ? internalError.code : parsedErrorResponse.code; - error.message = internalError ? internalError.message : parsedErrorResponse.message; - } - if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { - let resultMapper = new client.models['GraphError']().mapper(); - error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); - } - } catch (defaultError) { - error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; - return callback(error); - } - return callback(error); - } - // Create Result - let result = null; - if (responseBody === '') responseBody = null; - // Deserialize Response - if (statusCode === 200) { - let parsedResponse = null; - try { - parsedResponse = JSON.parse(responseBody); - result = JSON.parse(responseBody); - if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = new client.models['AADObject']().mapper(); - result = client.deserialize(resultMapper, parsedResponse, 'result'); - } - } catch (error) { - let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); - return callback(deserializationError); - } - } - - return callback(null, result, httpRequest, response); - }); -} - -/** - * Gets AD group membership for the specified AD object IDs. + * Gets the directory objects specified in a list of object IDs. You can also + * specify which resource collections (users, groups, etc.) should be searched + * by specifying the optional types parameter. * * @param {object} parameters Objects filtering parameters. * @@ -157,7 +25,7 @@ function _getCurrentUser(options, callback) { * * @param {array} [parameters.types] The requested object types. * - * @param {boolean} parameters.includeDirectoryObjectReferences If true, also + * @param {boolean} [parameters.includeDirectoryObjectReferences] If true, also * searches for object IDs in the partner tenant. * * @param {object} [options] Optional Parameters. @@ -172,7 +40,8 @@ function _getCurrentUser(options, callback) { * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. - * See {@link GetObjectsResult} for more information. + * See {@link DirectoryObjectListResult} for more + * information. * * {object} [request] - The HTTP Request object if an error did not occur. * @@ -292,7 +161,7 @@ function _getObjectsByObjectIds(parameters, options, callback) { parsedResponse = JSON.parse(responseBody); result = JSON.parse(responseBody); if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = new client.models['GetObjectsResult']().mapper(); + let resultMapper = new client.models['DirectoryObjectListResult']().mapper(); result = client.deserialize(resultMapper, parsedResponse, 'result'); } } catch (error) { @@ -324,7 +193,8 @@ function _getObjectsByObjectIds(parameters, options, callback) { * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. - * See {@link GetObjectsResult} for more information. + * See {@link DirectoryObjectListResult} for more + * information. * * {object} [request] - The HTTP Request object if an error did not occur. * @@ -431,7 +301,7 @@ function _getObjectsByObjectIdsNext(nextLink, options, callback) { parsedResponse = JSON.parse(responseBody); result = JSON.parse(responseBody); if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = new client.models['GetObjectsResult']().mapper(); + let resultMapper = new client.models['DirectoryObjectListResult']().mapper(); result = client.deserialize(resultMapper, parsedResponse, 'result'); } } catch (error) { @@ -454,91 +324,14 @@ class Objects { */ constructor(client) { this.client = client; - this._getCurrentUser = _getCurrentUser; this._getObjectsByObjectIds = _getObjectsByObjectIds; this._getObjectsByObjectIdsNext = _getObjectsByObjectIdsNext; } /** - * Gets the details for the currently logged-in user. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error} - The error object. - */ - getCurrentUserWithHttpOperationResponse(options) { - let client = this.client; - let self = this; - return new Promise((resolve, reject) => { - self._getCurrentUser(options, (err, result, request, response) => { - let httpOperationResponse = new msRest.HttpOperationResponse(request, response); - httpOperationResponse.body = result; - if (err) { reject(err); } - else { resolve(httpOperationResponse); } - return; - }); - }); - } - - /** - * Gets the details for the currently logged-in user. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} [optionalCallback] - The optional callback. - * - * @returns {function|Promise} If a callback was passed as the last parameter - * then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned - * - * @resolve {AADObject} - The deserialized result object. - * - * @reject {Error} - The error object. - * - * {function} optionalCallback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {object} [result] - The deserialized result object if an error did not occur. - * See {@link AADObject} for more information. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ - getCurrentUser(options, optionalCallback) { - let client = this.client; - let self = this; - if (!optionalCallback && typeof options === 'function') { - optionalCallback = options; - options = null; - } - if (!optionalCallback) { - return new Promise((resolve, reject) => { - self._getCurrentUser(options, (err, result, request, response) => { - if (err) { reject(err); } - else { resolve(result); } - return; - }); - }); - } else { - return self._getCurrentUser(options, optionalCallback); - } - } - - /** - * Gets AD group membership for the specified AD object IDs. + * Gets the directory objects specified in a list of object IDs. You can also + * specify which resource collections (users, groups, etc.) should be searched + * by specifying the optional types parameter. * * @param {object} parameters Objects filtering parameters. * @@ -546,7 +339,7 @@ class Objects { * * @param {array} [parameters.types] The requested object types. * - * @param {boolean} parameters.includeDirectoryObjectReferences If true, also + * @param {boolean} [parameters.includeDirectoryObjectReferences] If true, also * searches for object IDs in the partner tenant. * * @param {object} [options] Optional Parameters. @@ -556,7 +349,7 @@ class Objects { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error} - The error object. */ @@ -575,7 +368,9 @@ class Objects { } /** - * Gets AD group membership for the specified AD object IDs. + * Gets the directory objects specified in a list of object IDs. You can also + * specify which resource collections (users, groups, etc.) should be searched + * by specifying the optional types parameter. * * @param {object} parameters Objects filtering parameters. * @@ -583,7 +378,7 @@ class Objects { * * @param {array} [parameters.types] The requested object types. * - * @param {boolean} parameters.includeDirectoryObjectReferences If true, also + * @param {boolean} [parameters.includeDirectoryObjectReferences] If true, also * searches for object IDs in the partner tenant. * * @param {object} [options] Optional Parameters. @@ -598,7 +393,7 @@ class Objects { * * {Promise} A promise is returned * - * @resolve {GetObjectsResult} - The deserialized result object. + * @resolve {DirectoryObjectListResult} - The deserialized result object. * * @reject {Error} - The error object. * @@ -607,7 +402,8 @@ class Objects { * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. - * See {@link GetObjectsResult} for more information. + * See {@link DirectoryObjectListResult} for more + * information. * * {object} [request] - The HTTP Request object if an error did not occur. * @@ -645,7 +441,7 @@ class Objects { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error} - The error object. */ @@ -680,7 +476,7 @@ class Objects { * * {Promise} A promise is returned * - * @resolve {GetObjectsResult} - The deserialized result object. + * @resolve {DirectoryObjectListResult} - The deserialized result object. * * @reject {Error} - The error object. * @@ -689,7 +485,8 @@ class Objects { * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. - * See {@link GetObjectsResult} for more information. + * See {@link DirectoryObjectListResult} for more + * information. * * {object} [request] - The HTTP Request object if an error did not occur. * diff --git a/lib/services/graphManagement/lib/operations/servicePrincipals.js b/lib/services/graphManagement/lib/operations/servicePrincipals.js index 8c587ce02a..e9d1c6e566 100644 --- a/lib/services/graphManagement/lib/operations/servicePrincipals.js +++ b/lib/services/graphManagement/lib/operations/servicePrincipals.js @@ -19,9 +19,21 @@ const WebResource = msRest.WebResource; * * @param {object} parameters Parameters to create a service principal. * + * @param {boolean} [parameters.accountEnabled] Whether the account is enabled + * * @param {string} parameters.appId application Id * - * @param {boolean} parameters.accountEnabled Whether the account is enabled + * @param {boolean} [parameters.appRoleAssignmentRequired] Specifies whether an + * AppRoleAssignment to a user or group is required before Azure AD will issue + * a user or access token to the application. + * + * @param {string} [parameters.displayName] The display name for the service + * principal. + * + * @param {string} [parameters.errorUrl] + * + * @param {string} [parameters.homepage] The URL to the homepage of the + * associated application. * * @param {array} [parameters.keyCredentials] A collection of KeyCredential * objects. @@ -29,6 +41,19 @@ const WebResource = msRest.WebResource; * @param {array} [parameters.passwordCredentials] A collection of * PasswordCredential objects * + * @param {string} [parameters.publisherName] The display name of the tenant in + * which the associated application is specified. + * + * @param {array} [parameters.replyUrls] A collection of reply URLs for the + * service principal. + * + * @param {string} [parameters.samlMetadataUrl] + * + * @param {array} [parameters.servicePrincipalNames] A collection of service + * principal names. + * + * @param {array} [parameters.tags] + * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the @@ -321,6 +346,182 @@ function _list(options, callback) { }); } +/** + * Updates a service principal in the directory. + * + * @param {string} objectId The object ID of the service principal to delete. + * + * @param {object} parameters Parameters to update a service principal. + * + * @param {boolean} [parameters.accountEnabled] Whether the account is enabled + * + * @param {string} [parameters.appId] application Id + * + * @param {boolean} [parameters.appRoleAssignmentRequired] Specifies whether an + * AppRoleAssignment to a user or group is required before Azure AD will issue + * a user or access token to the application. + * + * @param {string} [parameters.displayName] The display name for the service + * principal. + * + * @param {string} [parameters.errorUrl] + * + * @param {string} [parameters.homepage] The URL to the homepage of the + * associated application. + * + * @param {array} [parameters.keyCredentials] A collection of KeyCredential + * objects. + * + * @param {array} [parameters.passwordCredentials] A collection of + * PasswordCredential objects + * + * @param {string} [parameters.publisherName] The display name of the tenant in + * which the associated application is specified. + * + * @param {array} [parameters.replyUrls] A collection of reply URLs for the + * service principal. + * + * @param {string} [parameters.samlMetadataUrl] + * + * @param {array} [parameters.servicePrincipalNames] A collection of service + * principal names. + * + * @param {array} [parameters.tags] + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _update(objectId, parameters, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (objectId === null || objectId === undefined || typeof objectId.valueOf() !== 'string') { + throw new Error('objectId cannot be null or undefined and it must be of type string.'); + } + if (parameters === null || parameters === undefined) { + throw new Error('parameters cannot be null or undefined.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.tenantID === null || this.client.tenantID === undefined || typeof this.client.tenantID.valueOf() !== 'string') { + throw new Error('this.client.tenantID cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + '{tenantID}/servicePrincipals/{objectId}'; + requestUrl = requestUrl.replace('{objectId}', encodeURIComponent(objectId)); + requestUrl = requestUrl.replace('{tenantID}', encodeURIComponent(this.client.tenantID)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'PATCH'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (parameters !== null && parameters !== undefined) { + let requestModelMapper = new client.models['ServicePrincipalUpdateParameters']().mapper(); + requestModel = client.serialize(requestModelMapper, parameters, 'parameters'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(parameters, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 204) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['GraphError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + + return callback(null, result, httpRequest, response); + }); +} + /** * Deletes a service principal from the directory. * @@ -1440,6 +1641,138 @@ function _listNext(nextLink, options, callback) { }); } +/** + * @summary Directory objects that are owners of this service principal. + * + * The owners are a set of non-admin users who are allowed to modify this + * object. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link DirectoryObjectListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listOwnersNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['GraphError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['DirectoryObjectListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + /** Class representing a ServicePrincipals. */ class ServicePrincipals { /** @@ -1450,6 +1783,7 @@ class ServicePrincipals { this.client = client; this._create = _create; this._list = _list; + this._update = _update; this._deleteMethod = _deleteMethod; this._get = _get; this._listOwners = _listOwners; @@ -1458,6 +1792,7 @@ class ServicePrincipals { this._listPasswordCredentials = _listPasswordCredentials; this._updatePasswordCredentials = _updatePasswordCredentials; this._listNext = _listNext; + this._listOwnersNext = _listOwnersNext; } /** @@ -1465,9 +1800,21 @@ class ServicePrincipals { * * @param {object} parameters Parameters to create a service principal. * + * @param {boolean} [parameters.accountEnabled] Whether the account is enabled + * * @param {string} parameters.appId application Id * - * @param {boolean} parameters.accountEnabled Whether the account is enabled + * @param {boolean} [parameters.appRoleAssignmentRequired] Specifies whether an + * AppRoleAssignment to a user or group is required before Azure AD will issue + * a user or access token to the application. + * + * @param {string} [parameters.displayName] The display name for the service + * principal. + * + * @param {string} [parameters.errorUrl] + * + * @param {string} [parameters.homepage] The URL to the homepage of the + * associated application. * * @param {array} [parameters.keyCredentials] A collection of KeyCredential * objects. @@ -1475,6 +1822,19 @@ class ServicePrincipals { * @param {array} [parameters.passwordCredentials] A collection of * PasswordCredential objects * + * @param {string} [parameters.publisherName] The display name of the tenant in + * which the associated application is specified. + * + * @param {array} [parameters.replyUrls] A collection of reply URLs for the + * service principal. + * + * @param {string} [parameters.samlMetadataUrl] + * + * @param {array} [parameters.servicePrincipalNames] A collection of service + * principal names. + * + * @param {array} [parameters.tags] + * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the @@ -1505,9 +1865,21 @@ class ServicePrincipals { * * @param {object} parameters Parameters to create a service principal. * + * @param {boolean} [parameters.accountEnabled] Whether the account is enabled + * * @param {string} parameters.appId application Id * - * @param {boolean} parameters.accountEnabled Whether the account is enabled + * @param {boolean} [parameters.appRoleAssignmentRequired] Specifies whether an + * AppRoleAssignment to a user or group is required before Azure AD will issue + * a user or access token to the application. + * + * @param {string} [parameters.displayName] The display name for the service + * principal. + * + * @param {string} [parameters.errorUrl] + * + * @param {string} [parameters.homepage] The URL to the homepage of the + * associated application. * * @param {array} [parameters.keyCredentials] A collection of KeyCredential * objects. @@ -1515,6 +1887,19 @@ class ServicePrincipals { * @param {array} [parameters.passwordCredentials] A collection of * PasswordCredential objects * + * @param {string} [parameters.publisherName] The display name of the tenant in + * which the associated application is specified. + * + * @param {array} [parameters.replyUrls] A collection of reply URLs for the + * service principal. + * + * @param {string} [parameters.samlMetadataUrl] + * + * @param {array} [parameters.servicePrincipalNames] A collection of service + * principal names. + * + * @param {array} [parameters.tags] + * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the @@ -1645,6 +2030,161 @@ class ServicePrincipals { } } + /** + * Updates a service principal in the directory. + * + * @param {string} objectId The object ID of the service principal to delete. + * + * @param {object} parameters Parameters to update a service principal. + * + * @param {boolean} [parameters.accountEnabled] Whether the account is enabled + * + * @param {string} [parameters.appId] application Id + * + * @param {boolean} [parameters.appRoleAssignmentRequired] Specifies whether an + * AppRoleAssignment to a user or group is required before Azure AD will issue + * a user or access token to the application. + * + * @param {string} [parameters.displayName] The display name for the service + * principal. + * + * @param {string} [parameters.errorUrl] + * + * @param {string} [parameters.homepage] The URL to the homepage of the + * associated application. + * + * @param {array} [parameters.keyCredentials] A collection of KeyCredential + * objects. + * + * @param {array} [parameters.passwordCredentials] A collection of + * PasswordCredential objects + * + * @param {string} [parameters.publisherName] The display name of the tenant in + * which the associated application is specified. + * + * @param {array} [parameters.replyUrls] A collection of reply URLs for the + * service principal. + * + * @param {string} [parameters.samlMetadataUrl] + * + * @param {array} [parameters.servicePrincipalNames] A collection of service + * principal names. + * + * @param {array} [parameters.tags] + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + updateWithHttpOperationResponse(objectId, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._update(objectId, parameters, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Updates a service principal in the directory. + * + * @param {string} objectId The object ID of the service principal to delete. + * + * @param {object} parameters Parameters to update a service principal. + * + * @param {boolean} [parameters.accountEnabled] Whether the account is enabled + * + * @param {string} [parameters.appId] application Id + * + * @param {boolean} [parameters.appRoleAssignmentRequired] Specifies whether an + * AppRoleAssignment to a user or group is required before Azure AD will issue + * a user or access token to the application. + * + * @param {string} [parameters.displayName] The display name for the service + * principal. + * + * @param {string} [parameters.errorUrl] + * + * @param {string} [parameters.homepage] The URL to the homepage of the + * associated application. + * + * @param {array} [parameters.keyCredentials] A collection of KeyCredential + * objects. + * + * @param {array} [parameters.passwordCredentials] A collection of + * PasswordCredential objects + * + * @param {string} [parameters.publisherName] The display name of the tenant in + * which the associated application is specified. + * + * @param {array} [parameters.replyUrls] A collection of reply URLs for the + * service principal. + * + * @param {string} [parameters.samlMetadataUrl] + * + * @param {array} [parameters.servicePrincipalNames] A collection of service + * principal names. + * + * @param {array} [parameters.tags] + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + update(objectId, parameters, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._update(objectId, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._update(objectId, parameters, options, optionalCallback); + } + } + /** * Deletes a service principal from the directory. * @@ -2324,6 +2864,97 @@ class ServicePrincipals { } } + /** + * @summary Directory objects that are owners of this service principal. + * + * The owners are a set of non-admin users who are allowed to modify this + * object. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listOwnersNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listOwnersNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * @summary Directory objects that are owners of this service principal. + * + * The owners are a set of non-admin users who are allowed to modify this + * object. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {DirectoryObjectListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link DirectoryObjectListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listOwnersNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listOwnersNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listOwnersNext(nextPageLink, options, optionalCallback); + } + } + } module.exports = ServicePrincipals; diff --git a/lib/services/graphManagement/lib/operations/signedInUser.js b/lib/services/graphManagement/lib/operations/signedInUser.js new file mode 100644 index 0000000000..773ef87956 --- /dev/null +++ b/lib/services/graphManagement/lib/operations/signedInUser.js @@ -0,0 +1,682 @@ +/* + * 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. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Gets the details for the currently logged-in user. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link User} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _get(options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.tenantID === null || this.client.tenantID === undefined || typeof this.client.tenantID.valueOf() !== 'string') { + throw new Error('this.client.tenantID cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + '{tenantID}/me'; + requestUrl = requestUrl.replace('{tenantID}', encodeURIComponent(this.client.tenantID)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['GraphError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['User']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Get the list of directory objects that are owned by the user. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link DirectoryObjectListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listOwnedObjects(options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.tenantID === null || this.client.tenantID === undefined || typeof this.client.tenantID.valueOf() !== 'string') { + throw new Error('this.client.tenantID cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + '{tenantID}/me/ownedObjects'; + requestUrl = requestUrl.replace('{tenantID}', encodeURIComponent(this.client.tenantID)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['GraphError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['DirectoryObjectListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Get the list of directory objects that are owned by the user. + * + * @param {string} nextLink Next link for the list operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link DirectoryObjectListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listOwnedObjectsNext(nextLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextLink === null || nextLink === undefined || typeof nextLink.valueOf() !== 'string') { + throw new Error('nextLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.tenantID === null || this.client.tenantID === undefined || typeof this.client.tenantID.valueOf() !== 'string') { + throw new Error('this.client.tenantID cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + '{tenantID}/{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextLink); + requestUrl = requestUrl.replace('{tenantID}', encodeURIComponent(this.client.tenantID)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += (requestUrl.indexOf('?') !== -1 ? '&' : '?') + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['GraphError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['DirectoryObjectListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a SignedInUser. */ +class SignedInUser { + /** + * Create a SignedInUser. + * @param {GraphRbacManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._get = _get; + this._listOwnedObjects = _listOwnedObjects; + this._listOwnedObjectsNext = _listOwnedObjectsNext; + } + + /** + * Gets the details for the currently logged-in user. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getWithHttpOperationResponse(options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets the details for the currently logged-in user. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {User} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link User} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + get(options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._get(options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(options, optionalCallback); + } + } + + /** + * Get the list of directory objects that are owned by the user. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listOwnedObjectsWithHttpOperationResponse(options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listOwnedObjects(options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Get the list of directory objects that are owned by the user. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {DirectoryObjectListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link DirectoryObjectListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listOwnedObjects(options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listOwnedObjects(options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listOwnedObjects(options, optionalCallback); + } + } + + /** + * Get the list of directory objects that are owned by the user. + * + * @param {string} nextLink Next link for the list operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listOwnedObjectsNextWithHttpOperationResponse(nextLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listOwnedObjectsNext(nextLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Get the list of directory objects that are owned by the user. + * + * @param {string} nextLink Next link for the list operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {DirectoryObjectListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link DirectoryObjectListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listOwnedObjectsNext(nextLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listOwnedObjectsNext(nextLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listOwnedObjectsNext(nextLink, options, optionalCallback); + } + } + +} + +module.exports = SignedInUser;