Example #1
0
        public static ApiManagementServiceIdentity MapAssignedIdentity(bool createSystemResourceIdentity, string[] userAssignedIdentity)
        {
            ApiManagementServiceIdentity identity = null;

            if (createSystemResourceIdentity || userAssignedIdentity != null)
            {
                identity = new ApiManagementServiceIdentity();

                if (createSystemResourceIdentity && userAssignedIdentity != null)
                {
                    identity.Type = PsApiManagementServiceIdentityTypes.SystemAndUserAssigned;
                }
                else if (createSystemResourceIdentity)
                {
                    identity.Type = PsApiManagementServiceIdentityTypes.SystemAssigned;
                }
                else
                {
                    identity.Type = PsApiManagementServiceIdentityTypes.UserAssigned;
                }

                if (userAssignedIdentity != null)
                {
                    identity.UserAssignedIdentities = userAssignedIdentity.ToDictionary(i => i, i => new UserIdentityProperties());
                }
            }
            return(identity);
        }
Example #2
0
        internal PsApiManagementServiceIdentity(ApiManagementServiceIdentity serviceIdentity)
            : this()
        {
            if (serviceIdentity == null)
            {
                throw new ArgumentNullException("serviceIdentity");
            }

            Type        = PsApiManagementServiceIdentityType.SystemAssigned;
            PrincipalId = serviceIdentity.PrincipalId.HasValue ? serviceIdentity.PrincipalId.Value.ToString() : null;
            TenantId    = serviceIdentity.TenantId.HasValue ? serviceIdentity.TenantId.Value.ToString() : null;
        }
        internal PsApiManagementServiceIdentity(ApiManagementServiceIdentity serviceIdentity)
            : this()
        {
            if (serviceIdentity == null)
            {
                throw new ArgumentNullException("serviceIdentity");
            }

            Type        = serviceIdentity.Type;
            PrincipalId = serviceIdentity.PrincipalId.HasValue ? serviceIdentity.PrincipalId.Value.ToString() : null;
            TenantId    = serviceIdentity.TenantId.HasValue ? serviceIdentity.TenantId.Value.ToString() : null;

            if (serviceIdentity.UserAssignedIdentities != null)
            {
                UserAssignedIdentity = serviceIdentity.UserAssignedIdentities.ToDictionary(i => i.Key, i => new PsApiManagementUserAssignedInformation(i.Value));
            }
        }