public CognitiveServicesModels.NetworkRuleSet ToNetworkRuleSet()
        {
            var result = new CognitiveServicesModels.NetworkRuleSet();

            result.DefaultAction = this.DefaultAction.ToString();

            result.IpRules = new List <CognitiveServicesModels.IpRule>();
            if (this.IpRules != null)
            {
                foreach (var ipRule in this.IpRules)
                {
                    result.IpRules.Add(ipRule.ToIpRule());
                }
            }

            result.VirtualNetworkRules = new List <CognitiveServicesModels.VirtualNetworkRule>();
            if (this.VirtualNetworkRules != null)
            {
                foreach (var virtualNetworkRule in this.VirtualNetworkRules)
                {
                    result.VirtualNetworkRules.Add(virtualNetworkRule.ToVirtualNetworkRule());
                }
            }

            return(result);
        }
        public static PSNetworkRuleSet Create(CognitiveServicesModels.NetworkRuleSet networkRuleSet)
        {
            var result = new PSNetworkRuleSet();

            if (networkRuleSet.DefaultAction != null)
            {
                result.DefaultAction = (PSNetWorkRuleDefaultActionEnum)Enum.Parse(typeof(PSNetWorkRuleDefaultActionEnum), networkRuleSet.DefaultAction);
            }
            else
            {
                result.DefaultAction = PSNetWorkRuleDefaultActionEnum.Deny;
            }


            var ipRules = new List <PSIpRule>();

            if (networkRuleSet.IpRules != null)
            {
                foreach (var ipRule in networkRuleSet.IpRules)
                {
                    ipRules.Add(PSIpRule.Create(ipRule));
                }
            }
            result.IpRules = ipRules.ToArray();

            var virtualNetworkRules = new List <PSVirtualNetworkRule>();

            if (networkRuleSet.VirtualNetworkRules != null)
            {
                foreach (var virtualNetworkRule in networkRuleSet.VirtualNetworkRules)
                {
                    virtualNetworkRules.Add(PSVirtualNetworkRule.Create(virtualNetworkRule));
                }
            }
            result.VirtualNetworkRules = virtualNetworkRules.ToArray();

            return(result);
        }
Пример #3
0
 /// <summary>
 /// Initializes a new instance of the
 /// CognitiveServicesAccountProperties class.
 /// </summary>
 /// <param name="provisioningState">Gets the status of the cognitive
 /// services account at the time the operation was called. Possible
 /// values include: 'Creating', 'ResolvingDNS', 'Moving', 'Deleting',
 /// 'Succeeded', 'Failed'</param>
 /// <param name="endpoint">Endpoint of the created account.</param>
 /// <param name="internalId">The internal identifier.</param>
 /// <param name="customSubDomainName">Optional subdomain name used for
 /// token-based authentication.</param>
 /// <param name="networkAcls">A collection of rules governing the
 /// accessibility from specific network locations.</param>
 /// <param name="encryption">The encryption properties for this
 /// resource.</param>
 /// <param name="userOwnedStorage">The storage accounts for this
 /// resource.</param>
 /// <param name="apiProperties">The api properties for special
 /// APIs.</param>
 public CognitiveServicesAccountProperties(string provisioningState = default(string), string endpoint = default(string), string internalId = default(string), string customSubDomainName = default(string), NetworkRuleSet networkAcls = default(NetworkRuleSet), Encryption encryption = default(Encryption), IList <UserOwnedStorage> userOwnedStorage = default(IList <UserOwnedStorage>), CognitiveServicesAccountApiProperties apiProperties = default(CognitiveServicesAccountApiProperties))
 {
     ProvisioningState   = provisioningState;
     Endpoint            = endpoint;
     InternalId          = internalId;
     CustomSubDomainName = customSubDomainName;
     NetworkAcls         = networkAcls;
     Encryption          = encryption;
     UserOwnedStorage    = userOwnedStorage;
     ApiProperties       = apiProperties;
     CustomInit();
 }