import { PagedAsyncIterableIterator } from "@azure/core-paging" ; import { ServicePrincipals } from "../operationsInterfaces" ; import * as coreClient from "@azure/core-client" ; import * as Mappers from "../models/mappers" ; import * as Parameters from "../models/parameters" ; import { GraphRbacManagementClient } from "../graphRbacManagementClient" ; import { ServicePrincipal , ServicePrincipalsListNextOptionalParams , ServicePrincipalsListOptionalParams , DirectoryObjectUnion , ServicePrincipalsListOwnersNextOptionalParams , ServicePrincipalsListOwnersOptionalParams , KeyCredential , ServicePrincipalsListKeyCredentialsOptionalParams , PasswordCredential , ServicePrincipalsListPasswordCredentialsOptionalParams , ServicePrincipalCreateParameters , ServicePrincipalsCreateOptionalParams , ServicePrincipalsCreateResponse , ServicePrincipalsListResponse , ServicePrincipalUpdateParameters , ServicePrincipalsUpdateOptionalParams , ServicePrincipalsDeleteOptionalParams , ServicePrincipalsGetOptionalParams , ServicePrincipalsGetResponse , ServicePrincipalsListOwnersResponse , ServicePrincipalsListKeyCredentialsResponse , KeyCredentialsUpdateParameters , ServicePrincipalsUpdateKeyCredentialsOptionalParams , ServicePrincipalsListPasswordCredentialsResponse , PasswordCredentialsUpdateParameters , ServicePrincipalsUpdatePasswordCredentialsOptionalParams , ServicePrincipalsListNextResponse , ServicePrincipalsListOwnersNextResponse } from "../models" ; /** Class containing ServicePrincipals operations. */ export class ServicePrincipalsImpl implements ServicePrincipals { private readonly client : GraphRbacManagementClient ; param client constructor ( client ) { this . client = client ; } param options public list ( options ? ) { const iter = this . listPagingAll ( options ) ; return { next ( ) { return iter . next ( ) ; } , [ Symbol . asyncIterator ] ( ) { return this ; } , byPage : ( ) => { return this . listPagingPage ( options ) ; } } ; } private async * listPagingPage ( options ? ) { let result = await this . _list ( options ) ; yield result . value || [ ] ; let continuationToken = result . odataNextLink ; while ( continuationToken ) { result = await this . _listNext ( continuationToken , options ) ; continuationToken = result . odataNextLink ; yield result . value || [ ] ; } } private async * listPagingAll ( options ? ) { for await ( const page of this . listPagingPage ( options ) ) { yield * page ; } } param objectId param options public listOwners ( objectId , options ? ) { const iter = this . listOwnersPagingAll ( objectId , options ) ; return { next ( ) { return iter . next ( ) ; } , [ Symbol . asyncIterator ] ( ) { return this ; } , byPage : ( ) => { return this . listOwnersPagingPage ( objectId , options ) ; } } ; } private async * listOwnersPagingPage ( objectId , options ? ) { let result = await this . _listOwners ( objectId , options ) ; yield result . value || [ ] ; let continuationToken = result . odataNextLink ; while ( continuationToken ) { result = await this . _listOwnersNext ( objectId , continuationToken , options ) ; continuationToken = result . odataNextLink ; yield result . value || [ ] ; } } private async * listOwnersPagingAll ( objectId , options ? ) { for await ( const page of this . listOwnersPagingPage ( objectId , options ) ) { yield * page ; } } param objectId param options public listKeyCredentials ( objectId , options ? ) { const iter = this . listKeyCredentialsPagingAll ( objectId , options ) ; return { next ( ) { return iter . next ( ) ; } , [ Symbol . asyncIterator ] ( ) { return this ; } , byPage : ( ) => { return this . listKeyCredentialsPagingPage ( objectId , options ) ; } } ; } private async * listKeyCredentialsPagingPage ( objectId , options ? ) { let result = await this . _listKeyCredentials ( objectId , options ) ; yield result . value || [ ] ; } private async * listKeyCredentialsPagingAll ( objectId , options ? ) { for await ( const page of this . listKeyCredentialsPagingPage ( objectId , options ) ) { yield * page ; } } param objectId param options public listPasswordCredentials ( objectId , options ? ) { const iter = this . listPasswordCredentialsPagingAll ( objectId , options ) ; return { next ( ) { return iter . next ( ) ; } , [ Symbol . asyncIterator ] ( ) { return this ; } , byPage : ( ) => { return this . listPasswordCredentialsPagingPage ( objectId , options ) ; } } ; } private async * listPasswordCredentialsPagingPage ( objectId , options ? ) { let result = await this . _listPasswordCredentials ( objectId , options ) ; yield result . value || [ ] ; } private async * listPasswordCredentialsPagingAll ( objectId , options ? ) { for await ( const page of this . listPasswordCredentialsPagingPage ( objectId , options ) ) { yield * page ; } } param nextLink param options public listNext ( nextLink , options ? ) { const iter = this . listNextPagingAll ( nextLink , options ) ; return { next ( ) { return iter . next ( ) ; } , [ Symbol . asyncIterator ] ( ) { return this ; } , byPage : ( ) => { return this . listNextPagingPage ( nextLink , options ) ; } } ; } private async * listNextPagingPage ( nextLink , options ? ) { let result = await this . _listNext ( nextLink , options ) ; yield result . value || [ ] ; let continuationToken = result . odataNextLink ; while ( continuationToken ) { result = await this . _listNext ( continuationToken , options ) ; continuationToken = result . odataNextLink ; yield result . value || [ ] ; } } private async * listNextPagingAll ( nextLink , options ? ) { for await ( const page of this . listNextPagingPage ( nextLink , options ) ) { yield * page ; } } param parameters param options create ( parameters , options ? ) { return this . client . sendOperationRequest ( { parameters , options } , createOperationSpec ) ; } param options private _list ( options ? ) { return this . client . sendOperationRequest ( { options } , listOperationSpec ) ; } param objectId param parameters param options update ( objectId , parameters , options ? ) { return this . client . sendOperationRequest ( { objectId , parameters , options } , updateOperationSpec ) ; } param objectId param options delete ( objectId , options ? ) { return this . client . sendOperationRequest ( { objectId , options } , deleteOperationSpec ) ; } param objectId param options get ( objectId , options ? ) { return this . client . sendOperationRequest ( { objectId , options } , getOperationSpec ) ; } param objectId param options private _listOwners ( objectId , options ? ) { return this . client . sendOperationRequest ( { objectId , options } , listOwnersOperationSpec ) ; } param objectId param options private _listKeyCredentials ( objectId , options ? ) { return this . client . sendOperationRequest ( { objectId , options } , listKeyCredentialsOperationSpec ) ; } param objectId param parameters param options updateKeyCredentials ( objectId , parameters , options ? ) { return this . client . sendOperationRequest ( { objectId , parameters , options } , updateKeyCredentialsOperationSpec ) ; } param objectId param options private _listPasswordCredentials ( objectId , options ? ) { return this . client . sendOperationRequest ( { objectId , options } , listPasswordCredentialsOperationSpec ) ; } param objectId param parameters param options updatePasswordCredentials ( objectId , parameters , options ? ) { return this . client . sendOperationRequest ( { objectId , parameters , options } , updatePasswordCredentialsOperationSpec ) ; } param nextLink param options private _listNext ( nextLink , options ? ) { return this . client . sendOperationRequest ( { nextLink , options } , listNextOperationSpec ) ; } param objectId param nextLink param options private _listOwnersNext ( objectId , nextLink , options ? ) { return this . client . sendOperationRequest ( { objectId , nextLink , options } , listOwnersNextOperationSpec ) ; } } const serializer = coreClient . createSerializer ( Mappers , false ) ; const createOperationSpec = { path : "/{tenantID}/servicePrincipals" , httpMethod : "POST" , responses : { 201 : { bodyMapper : Mappers . ServicePrincipal } , default : { bodyMapper : Mappers . GraphError } } , requestBody : Parameters . parameters9 , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . tenantID ] , headerParameters : [ Parameters . accept , Parameters . contentType ] , mediaType : "json" , serializer } ; const listOperationSpec = { path : "/{tenantID}/servicePrincipals" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . ServicePrincipalListResult } , default : { bodyMapper : Mappers . GraphError } } , queryParameters : [ Parameters . apiVersion , Parameters . filter ] , urlParameters : [ Parameters . $host , Parameters . tenantID ] , headerParameters : [ Parameters . accept ] , serializer } ; const updateOperationSpec = { path : "/{tenantID}/servicePrincipals/{objectId}" , httpMethod : "PATCH" , responses : { 204 : { } , default : { bodyMapper : Mappers . GraphError } } , requestBody : Parameters . parameters10 , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . tenantID , Parameters . objectId ] , headerParameters : [ Parameters . accept , Parameters . contentType ] , mediaType : "json" , serializer } ; const deleteOperationSpec = { path : "/{tenantID}/servicePrincipals/{objectId}" , httpMethod : "DELETE" , responses : { 204 : { } , default : { bodyMapper : Mappers . GraphError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . tenantID , Parameters . objectId ] , headerParameters : [ Parameters . accept ] , serializer } ; const getOperationSpec = { path : "/{tenantID}/servicePrincipals/{objectId}" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . ServicePrincipal } , default : { bodyMapper : Mappers . GraphError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . tenantID , Parameters . objectId ] , headerParameters : [ Parameters . accept ] , serializer } ; const listOwnersOperationSpec = { path : "/{tenantID}/servicePrincipals/{objectId}/owners" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . DirectoryObjectListResult } , default : { bodyMapper : Mappers . GraphError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . tenantID , Parameters . objectId ] , headerParameters : [ Parameters . accept ] , serializer } ; const listKeyCredentialsOperationSpec = { path : "/{tenantID}/servicePrincipals/{objectId}/keyCredentials" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . KeyCredentialListResult } , default : { bodyMapper : Mappers . GraphError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . tenantID , Parameters . objectId ] , headerParameters : [ Parameters . accept ] , serializer } ; const updateKeyCredentialsOperationSpec = { path : "/{tenantID}/servicePrincipals/{objectId}/keyCredentials" , httpMethod : "PATCH" , responses : { 204 : { } , default : { bodyMapper : Mappers . GraphError } } , requestBody : Parameters . parameters3 , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . tenantID , Parameters . objectId ] , headerParameters : [ Parameters . accept , Parameters . contentType ] , mediaType : "json" , serializer } ; const listPasswordCredentialsOperationSpec = { path : "/{tenantID}/servicePrincipals/{objectId}/passwordCredentials" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . PasswordCredentialListResult } , default : { bodyMapper : Mappers . GraphError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . tenantID , Parameters . objectId ] , headerParameters : [ Parameters . accept ] , serializer } ; const updatePasswordCredentialsOperationSpec = { path : "/{tenantID}/servicePrincipals/{objectId}/passwordCredentials" , httpMethod : "PATCH" , responses : { 204 : { } , default : { bodyMapper : Mappers . GraphError } } , requestBody : Parameters . parameters4 , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . tenantID , Parameters . objectId ] , headerParameters : [ Parameters . accept , Parameters . contentType ] , mediaType : "json" , serializer } ; const listNextOperationSpec = { path : "/{tenantID}/{nextLink}" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . ServicePrincipalListResult } , default : { bodyMapper : Mappers . GraphError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . tenantID , Parameters . nextLink ] , headerParameters : [ Parameters . accept ] , serializer } ; const listOwnersNextOperationSpec = { path : "{nextLink}" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . DirectoryObjectListResult } , default : { bodyMapper : Mappers . GraphError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . tenantID , Parameters . nextLink , Parameters . objectId ] , headerParameters : [ Parameters . accept ] , serializer } ;