@@ -340,6 +340,112 @@ public static BinaryData GetMockDesiredStateConfigurationTypesTgz()
340340 ( "types.json" , StreamHelper . GetString ( stream => TypeSerializer . Serialize ( stream , factory . GetTypes ( ) ) ) ) ) ;
341341 }
342342
343+ public static BinaryData GetMockMsGraphTypesTgz ( string extensionName , string extensionVersion , string apiVersion )
344+ {
345+ var factory = new TypeFactory ( [ ] ) ;
346+
347+ var stringType = factory . Create ( ( ) => new StringType ( ) ) ;
348+ var booleanType = factory . Create ( ( ) => new BooleanType ( ) ) ;
349+ var anyType = factory . Create ( ( ) => new AnyType ( ) ) ;
350+ var stringArrayType = factory . Create ( ( ) => new ArrayType ( factory . GetReference ( stringType ) ) ) ;
351+ var anyArrayType = factory . Create ( ( ) => new ArrayType ( factory . GetReference ( anyType ) ) ) ;
352+
353+ var stringTypeRef = factory . GetReference ( stringType ) ;
354+ var booleanTypeRef = factory . GetReference ( booleanType ) ;
355+ var anyTypeRef = factory . GetReference ( anyType ) ;
356+ var stringArrayTypeRef = factory . GetReference ( stringArrayType ) ;
357+ var anyArrayTypeRef = factory . GetReference ( anyArrayType ) ;
358+
359+ ObjectTypeProperty Property ( ITypeReference typeRef , ObjectTypePropertyFlags flags = ObjectTypePropertyFlags . None ) => new ( typeRef , flags , null ) ;
360+
361+ ResourceType Resource ( string name , Dictionary < string , ObjectTypeProperty > properties )
362+ {
363+ var bodyType = factory . Create ( ( ) => new ObjectType ( name , properties , null ) ) ;
364+
365+ return factory . Create ( ( ) => new ResourceType (
366+ name ,
367+ factory . GetReference ( bodyType ) ,
368+ null ,
369+ writableScopes_in : ScopeType . All ,
370+ readableScopes_in : ScopeType . All ) ) ;
371+ }
372+
373+ Dictionary < string , ObjectTypeProperty > ApplicationProperties ( ) => new ( )
374+ {
375+ [ "uniqueName" ] = Property ( stringTypeRef , ObjectTypePropertyFlags . Required ) ,
376+ [ "displayName" ] = Property ( stringTypeRef ) ,
377+ [ "appId" ] = Property ( stringTypeRef , ObjectTypePropertyFlags . ReadOnly ) ,
378+ [ "id" ] = Property ( stringTypeRef , ObjectTypePropertyFlags . ReadOnly ) ,
379+ [ "appRoles" ] = Property ( anyArrayTypeRef ) ,
380+ [ "api" ] = Property ( anyTypeRef ) ,
381+ } ;
382+
383+ ResourceType [ ] resourceTypes = apiVersion switch
384+ {
385+ "beta" =>
386+ [
387+ Resource ( "Microsoft.Graph/applications@beta" , ApplicationProperties ( ) ) ,
388+ Resource ( "Microsoft.Graph/servicePrincipals@beta" , new ( )
389+ {
390+ [ "appId" ] = Property ( stringTypeRef , ObjectTypePropertyFlags . Required ) ,
391+ [ "id" ] = Property ( stringTypeRef , ObjectTypePropertyFlags . ReadOnly ) ,
392+ } ) ,
393+ Resource ( "Microsoft.Graph/oauth2PermissionGrants@beta" , new ( )
394+ {
395+ [ "clientId" ] = Property ( stringTypeRef ) ,
396+ [ "consentType" ] = Property ( stringTypeRef ) ,
397+ [ "resourceId" ] = Property ( stringTypeRef ) ,
398+ [ "scope" ] = Property ( stringTypeRef ) ,
399+ [ "id" ] = Property ( stringTypeRef , ObjectTypePropertyFlags . ReadOnly ) ,
400+ } ) ,
401+ Resource ( "Microsoft.Graph/appRoleAssignedTo@beta" , new ( )
402+ {
403+ [ "appRoleId" ] = Property ( stringTypeRef ) ,
404+ [ "principalId" ] = Property ( stringTypeRef ) ,
405+ [ "resourceId" ] = Property ( stringTypeRef ) ,
406+ [ "id" ] = Property ( stringTypeRef , ObjectTypePropertyFlags . ReadOnly ) ,
407+ } ) ,
408+ Resource ( "Microsoft.Graph/groups@beta" , new ( )
409+ {
410+ [ "uniqueName" ] = Property ( stringTypeRef , ObjectTypePropertyFlags . Required ) ,
411+ [ "displayName" ] = Property ( stringTypeRef ) ,
412+ [ "mailEnabled" ] = Property ( booleanTypeRef ) ,
413+ [ "mailNickname" ] = Property ( stringTypeRef ) ,
414+ [ "securityEnabled" ] = Property ( booleanTypeRef ) ,
415+ [ "groupTypes" ] = Property ( stringArrayTypeRef ) ,
416+ [ "owners" ] = Property ( stringArrayTypeRef ) ,
417+ [ "id" ] = Property ( stringTypeRef , ObjectTypePropertyFlags . ReadOnly ) ,
418+ } ) ,
419+ ] ,
420+ "v1.0" =>
421+ [
422+ Resource ( "Microsoft.Graph/applications@v1.0" , ApplicationProperties ( ) ) ,
423+ Resource ( "Microsoft.Graph/applications/federatedIdentityCredentials@v1.0" , new ( )
424+ {
425+ [ "name" ] = Property ( stringTypeRef , ObjectTypePropertyFlags . Required ) ,
426+ [ "audiences" ] = Property ( stringArrayTypeRef ) ,
427+ [ "description" ] = Property ( stringTypeRef ) ,
428+ [ "issuer" ] = Property ( stringTypeRef ) ,
429+ [ "subject" ] = Property ( stringTypeRef ) ,
430+ [ "id" ] = Property ( stringTypeRef , ObjectTypePropertyFlags . ReadOnly ) ,
431+ } ) ,
432+ ] ,
433+ _ => throw new ArgumentException ( $ "Unsupported Microsoft Graph API version '{ apiVersion } '.", nameof ( apiVersion ) ) ,
434+ } ;
435+
436+ var settings = new TypeSettings ( name : extensionName , version : extensionVersion , isSingleton : false , configurationType : null ! ) ;
437+ var index = new TypeIndex (
438+ resourceTypes . ToDictionary ( x => x . Name , x => new CrossFileTypeReference ( "types.json" , factory . GetIndex ( x ) ) ) ,
439+ new Dictionary < string , IReadOnlyDictionary < string , IReadOnlyList < CrossFileTypeReference > > > ( ) ,
440+ [ ] ,
441+ settings ,
442+ null ) ;
443+
444+ return GetTypesTgzBytesFromFiles (
445+ ( "index.json" , StreamHelper . GetString ( stream => TypeSerializer . SerializeIndex ( stream , index ) ) ) ,
446+ ( "types.json" , StreamHelper . GetString ( stream => TypeSerializer . Serialize ( stream , factory . GetTypes ( ) ) ) ) ) ;
447+ }
448+
343449 public static BinaryData GetTypesTgzBytesFromFiles ( params ( string filePath , string contents ) [ ] files )
344450 {
345451 var stream = new MemoryStream ( ) ;
0 commit comments