/* * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for * license information. * * Code generated by Microsoft (R) AutoRest Code Generator. * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ import * as msRest from "@azure/ms-rest-js"; import * as Models from "../models"; import * as Mappers from "../models/servicePrincipalsMappers"; import * as Parameters from "../models/parameters"; import { GraphRbacManagementClientContext } from "../graphRbacManagementClientContext"; /** Class representing a ServicePrincipals. */ export class ServicePrincipals { private readonly client: GraphRbacManagementClientContext; /** * Create a ServicePrincipals. * @param {GraphRbacManagementClientContext} client Reference to the service client. */ constructor(client: GraphRbacManagementClientContext) { this.client = client; } /** * Creates a service principal in the directory. * @param parameters Parameters to create a service principal. * @param [options] The optional parameters * @returns Promise */ create(parameters: Models.ServicePrincipalCreateParameters, options?: msRest.RequestOptionsBase): Promise; /** * @param parameters Parameters to create a service principal. * @param callback The callback */ create(parameters: Models.ServicePrincipalCreateParameters, callback: msRest.ServiceCallback): void; /** * @param parameters Parameters to create a service principal. * @param options The optional parameters * @param callback The callback */ create(parameters: Models.ServicePrincipalCreateParameters, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; create(parameters: Models.ServicePrincipalCreateParameters, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { parameters, options }, createOperationSpec, callback) as Promise; } /** * Gets a list of service principals from the current tenant. * @param [options] The optional parameters * @returns Promise */ list(options?: Models.ServicePrincipalsListOptionalParams): Promise; /** * @param callback The callback */ list(callback: msRest.ServiceCallback): void; /** * @param options The optional parameters * @param callback The callback */ list(options: Models.ServicePrincipalsListOptionalParams, callback: msRest.ServiceCallback): void; list(options?: Models.ServicePrincipalsListOptionalParams | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { options }, listOperationSpec, callback) as Promise; } /** * Updates a service principal in the directory. * @param objectId The object ID of the service principal to delete. * @param parameters Parameters to update a service principal. * @param [options] The optional parameters * @returns Promise */ update(objectId: string, parameters: Models.ServicePrincipalUpdateParameters, options?: msRest.RequestOptionsBase): Promise; /** * @param objectId The object ID of the service principal to delete. * @param parameters Parameters to update a service principal. * @param callback The callback */ update(objectId: string, parameters: Models.ServicePrincipalUpdateParameters, callback: msRest.ServiceCallback): void; /** * @param objectId The object ID of the service principal to delete. * @param parameters Parameters to update a service principal. * @param options The optional parameters * @param callback The callback */ update(objectId: string, parameters: Models.ServicePrincipalUpdateParameters, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; update(objectId: string, parameters: Models.ServicePrincipalUpdateParameters, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { objectId, parameters, options }, updateOperationSpec, callback); } /** * Deletes a service principal from the directory. * @param objectId The object ID of the service principal to delete. * @param [options] The optional parameters * @returns Promise */ deleteMethod(objectId: string, options?: msRest.RequestOptionsBase): Promise; /** * @param objectId The object ID of the service principal to delete. * @param callback The callback */ deleteMethod(objectId: string, callback: msRest.ServiceCallback): void; /** * @param objectId The object ID of the service principal to delete. * @param options The optional parameters * @param callback The callback */ deleteMethod(objectId: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; deleteMethod(objectId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { objectId, options }, deleteMethodOperationSpec, callback); } /** * Gets service principal information from the directory. Query by objectId or pass a filter to * query by appId * @param objectId The object ID of the service principal to get. * @param [options] The optional parameters * @returns Promise */ get(objectId: string, options?: msRest.RequestOptionsBase): Promise; /** * @param objectId The object ID of the service principal to get. * @param callback The callback */ get(objectId: string, callback: msRest.ServiceCallback): void; /** * @param objectId The object ID of the service principal to get. * @param options The optional parameters * @param callback The callback */ get(objectId: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; get(objectId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { objectId, options }, getOperationSpec, callback) as Promise; } /** * The owners are a set of non-admin users who are allowed to modify this object. * @summary Directory objects that are owners of this service principal. * @param objectId The object ID of the service principal for which to get owners. * @param [options] The optional parameters * @returns Promise */ listOwners(objectId: string, options?: msRest.RequestOptionsBase): Promise; /** * @param objectId The object ID of the service principal for which to get owners. * @param callback The callback */ listOwners(objectId: string, callback: msRest.ServiceCallback): void; /** * @param objectId The object ID of the service principal for which to get owners. * @param options The optional parameters * @param callback The callback */ listOwners(objectId: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; listOwners(objectId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { objectId, options }, listOwnersOperationSpec, callback) as Promise; } /** * Get the keyCredentials associated with the specified service principal. * @param objectId The object ID of the service principal for which to get keyCredentials. * @param [options] The optional parameters * @returns Promise */ listKeyCredentials(objectId: string, options?: msRest.RequestOptionsBase): Promise; /** * @param objectId The object ID of the service principal for which to get keyCredentials. * @param callback The callback */ listKeyCredentials(objectId: string, callback: msRest.ServiceCallback): void; /** * @param objectId The object ID of the service principal for which to get keyCredentials. * @param options The optional parameters * @param callback The callback */ listKeyCredentials(objectId: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; listKeyCredentials(objectId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { objectId, options }, listKeyCredentialsOperationSpec, callback) as Promise; } /** * Update the keyCredentials associated with a service principal. * @param objectId The object ID for which to get service principal information. * @param value A collection of KeyCredentials. * @param [options] The optional parameters * @returns Promise */ updateKeyCredentials(objectId: string, value: Models.KeyCredential[], options?: msRest.RequestOptionsBase): Promise; /** * @param objectId The object ID for which to get service principal information. * @param value A collection of KeyCredentials. * @param callback The callback */ updateKeyCredentials(objectId: string, value: Models.KeyCredential[], callback: msRest.ServiceCallback): void; /** * @param objectId The object ID for which to get service principal information. * @param value A collection of KeyCredentials. * @param options The optional parameters * @param callback The callback */ updateKeyCredentials(objectId: string, value: Models.KeyCredential[], options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; updateKeyCredentials(objectId: string, value: Models.KeyCredential[], options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { objectId, value, options }, updateKeyCredentialsOperationSpec, callback); } /** * Gets the passwordCredentials associated with a service principal. * @param objectId The object ID of the service principal. * @param [options] The optional parameters * @returns Promise */ listPasswordCredentials(objectId: string, options?: msRest.RequestOptionsBase): Promise; /** * @param objectId The object ID of the service principal. * @param callback The callback */ listPasswordCredentials(objectId: string, callback: msRest.ServiceCallback): void; /** * @param objectId The object ID of the service principal. * @param options The optional parameters * @param callback The callback */ listPasswordCredentials(objectId: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; listPasswordCredentials(objectId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { objectId, options }, listPasswordCredentialsOperationSpec, callback) as Promise; } /** * Updates the passwordCredentials associated with a service principal. * @param objectId The object ID of the service principal. * @param value A collection of PasswordCredentials. * @param [options] The optional parameters * @returns Promise */ updatePasswordCredentials(objectId: string, value: Models.PasswordCredential[], options?: msRest.RequestOptionsBase): Promise; /** * @param objectId The object ID of the service principal. * @param value A collection of PasswordCredentials. * @param callback The callback */ updatePasswordCredentials(objectId: string, value: Models.PasswordCredential[], callback: msRest.ServiceCallback): void; /** * @param objectId The object ID of the service principal. * @param value A collection of PasswordCredentials. * @param options The optional parameters * @param callback The callback */ updatePasswordCredentials(objectId: string, value: Models.PasswordCredential[], options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; updatePasswordCredentials(objectId: string, value: Models.PasswordCredential[], options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { objectId, value, options }, updatePasswordCredentialsOperationSpec, callback); } /** * Gets a list of service principals from the current tenant. * @param nextLink Next link for the list operation. * @param [options] The optional parameters * @returns Promise */ listNext(nextLink: string, options?: msRest.RequestOptionsBase): Promise; /** * @param nextLink Next link for the list operation. * @param callback The callback */ listNext(nextLink: string, callback: msRest.ServiceCallback): void; /** * @param nextLink Next link for the list operation. * @param options The optional parameters * @param callback The callback */ listNext(nextLink: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; listNext(nextLink: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { nextLink, options }, listNextOperationSpec, callback) as Promise; } /** * The owners are a set of non-admin users who are allowed to modify this object. * @summary Directory objects that are owners of this service principal. * @param nextPageLink The NextLink from the previous successful call to List operation. * @param [options] The optional parameters * @returns Promise */ listOwnersNext(nextPageLink: string, options?: msRest.RequestOptionsBase): Promise; /** * @param nextPageLink The NextLink from the previous successful call to List operation. * @param callback The callback */ listOwnersNext(nextPageLink: string, callback: msRest.ServiceCallback): void; /** * @param nextPageLink The NextLink from the previous successful call to List operation. * @param options The optional parameters * @param callback The callback */ listOwnersNext(nextPageLink: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; listOwnersNext(nextPageLink: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { nextPageLink, options }, listOwnersNextOperationSpec, callback) as Promise; } } // Operation Specifications const serializer = new msRest.Serializer(Mappers); const createOperationSpec: msRest.OperationSpec = { httpMethod: "POST", path: "{tenantID}/servicePrincipals", urlParameters: [ Parameters.tenantID ], queryParameters: [ Parameters.apiVersion ], headerParameters: [ Parameters.acceptLanguage ], requestBody: { parameterPath: "parameters", mapper: { ...Mappers.ServicePrincipalCreateParameters, required: true } }, responses: { 201: { bodyMapper: Mappers.ServicePrincipal }, default: { bodyMapper: Mappers.GraphError } }, serializer }; const listOperationSpec: msRest.OperationSpec = { httpMethod: "GET", path: "{tenantID}/servicePrincipals", urlParameters: [ Parameters.tenantID ], queryParameters: [ Parameters.filter, Parameters.apiVersion ], headerParameters: [ Parameters.acceptLanguage ], responses: { 200: { bodyMapper: Mappers.ServicePrincipalListResult }, default: { bodyMapper: Mappers.GraphError } }, serializer }; const updateOperationSpec: msRest.OperationSpec = { httpMethod: "PATCH", path: "{tenantID}/servicePrincipals/{objectId}", urlParameters: [ Parameters.objectId, Parameters.tenantID ], queryParameters: [ Parameters.apiVersion ], headerParameters: [ Parameters.acceptLanguage ], requestBody: { parameterPath: "parameters", mapper: { ...Mappers.ServicePrincipalUpdateParameters, required: true } }, responses: { 204: {}, default: { bodyMapper: Mappers.GraphError } }, serializer }; const deleteMethodOperationSpec: msRest.OperationSpec = { httpMethod: "DELETE", path: "{tenantID}/servicePrincipals/{objectId}", urlParameters: [ Parameters.objectId, Parameters.tenantID ], queryParameters: [ Parameters.apiVersion ], headerParameters: [ Parameters.acceptLanguage ], responses: { 204: {}, default: { bodyMapper: Mappers.GraphError } }, serializer }; const getOperationSpec: msRest.OperationSpec = { httpMethod: "GET", path: "{tenantID}/servicePrincipals/{objectId}", urlParameters: [ Parameters.objectId, Parameters.tenantID ], queryParameters: [ Parameters.apiVersion ], headerParameters: [ Parameters.acceptLanguage ], responses: { 200: { bodyMapper: Mappers.ServicePrincipal }, default: { bodyMapper: Mappers.GraphError } }, serializer }; const listOwnersOperationSpec: msRest.OperationSpec = { httpMethod: "GET", path: "{tenantID}/servicePrincipals/{objectId}/owners", urlParameters: [ Parameters.objectId, Parameters.tenantID ], queryParameters: [ Parameters.apiVersion ], headerParameters: [ Parameters.acceptLanguage ], responses: { 200: { bodyMapper: Mappers.DirectoryObjectListResult }, default: { bodyMapper: Mappers.GraphError } }, serializer }; const listKeyCredentialsOperationSpec: msRest.OperationSpec = { httpMethod: "GET", path: "{tenantID}/servicePrincipals/{objectId}/keyCredentials", urlParameters: [ Parameters.objectId, Parameters.tenantID ], queryParameters: [ Parameters.apiVersion ], headerParameters: [ Parameters.acceptLanguage ], responses: { 200: { bodyMapper: Mappers.KeyCredentialListResult }, default: { bodyMapper: Mappers.GraphError } }, serializer }; const updateKeyCredentialsOperationSpec: msRest.OperationSpec = { httpMethod: "PATCH", path: "{tenantID}/servicePrincipals/{objectId}/keyCredentials", urlParameters: [ Parameters.objectId, Parameters.tenantID ], queryParameters: [ Parameters.apiVersion ], headerParameters: [ Parameters.acceptLanguage ], requestBody: { parameterPath: { value: "value" }, mapper: { ...Mappers.KeyCredentialsUpdateParameters, required: true } }, responses: { 204: {}, default: { bodyMapper: Mappers.GraphError } }, serializer }; const listPasswordCredentialsOperationSpec: msRest.OperationSpec = { httpMethod: "GET", path: "{tenantID}/servicePrincipals/{objectId}/passwordCredentials", urlParameters: [ Parameters.objectId, Parameters.tenantID ], queryParameters: [ Parameters.apiVersion ], headerParameters: [ Parameters.acceptLanguage ], responses: { 200: { bodyMapper: Mappers.PasswordCredentialListResult }, default: { bodyMapper: Mappers.GraphError } }, serializer }; const updatePasswordCredentialsOperationSpec: msRest.OperationSpec = { httpMethod: "PATCH", path: "{tenantID}/servicePrincipals/{objectId}/passwordCredentials", urlParameters: [ Parameters.objectId, Parameters.tenantID ], queryParameters: [ Parameters.apiVersion ], headerParameters: [ Parameters.acceptLanguage ], requestBody: { parameterPath: { value: "value" }, mapper: { ...Mappers.PasswordCredentialsUpdateParameters, required: true } }, responses: { 204: {}, default: { bodyMapper: Mappers.GraphError } }, serializer }; const listNextOperationSpec: msRest.OperationSpec = { httpMethod: "GET", path: "{tenantID}/{nextLink}", urlParameters: [ Parameters.nextLink, Parameters.tenantID ], queryParameters: [ Parameters.apiVersion ], headerParameters: [ Parameters.acceptLanguage ], responses: { 200: { bodyMapper: Mappers.ServicePrincipalListResult }, default: { bodyMapper: Mappers.GraphError } }, serializer }; const listOwnersNextOperationSpec: msRest.OperationSpec = { httpMethod: "GET", baseUrl: "https://graph.windows.net", path: "{nextLink}", urlParameters: [ Parameters.nextPageLink ], headerParameters: [ Parameters.acceptLanguage ], responses: { 200: { bodyMapper: Mappers.DirectoryObjectListResult }, default: { bodyMapper: Mappers.GraphError } }, serializer };