public PsApiManagement(ApiManagementServiceResource apiServiceResource) : this() { if (apiServiceResource == null) { throw new ArgumentNullException("apiServiceResource"); } Id = apiServiceResource.Id; Name = apiServiceResource.Name; Location = apiServiceResource.Location; Sku = ApiManagementClient.Mapper.Map <string, PsApiManagementSku>(apiServiceResource.Sku.Name); Capacity = apiServiceResource.Sku.Capacity ?? 1; CreatedTimeUtc = apiServiceResource.CreatedAtUtc; PublisherEmail = apiServiceResource.PublisherEmail; OrganizationName = apiServiceResource.PublisherName; NotificationSenderEmail = apiServiceResource.NotificationSenderEmail; ProvisioningState = apiServiceResource.ProvisioningState; RuntimeUrl = apiServiceResource.GatewayUrl; RuntimeRegionalUrl = apiServiceResource.GatewayRegionalUrl; PortalUrl = apiServiceResource.PortalUrl; DeveloperPortalUrl = apiServiceResource.DeveloperPortalUrl; ManagementApiUrl = apiServiceResource.ManagementApiUrl; ScmUrl = apiServiceResource.ScmUrl; PublicIPAddresses = apiServiceResource.PublicIPAddresses != null?apiServiceResource.PublicIPAddresses.ToArray() : null; PrivateIPAddresses = apiServiceResource.PrivateIPAddresses != null?apiServiceResource.PrivateIPAddresses.ToArray() : null; EnableClientCertificate = apiServiceResource.EnableClientCertificate; VpnType = ApiManagementClient.Mapper.Map <string, PsApiManagementVpnType>(apiServiceResource.VirtualNetworkType); if (apiServiceResource.AdditionalLocations != null) { AdditionalRegions = apiServiceResource.AdditionalLocations .Select(region => new PsApiManagementRegion(region)) .ToList(); } if (apiServiceResource.VirtualNetworkConfiguration != null) { VirtualNetwork = new PsApiManagementVirtualNetwork(apiServiceResource.VirtualNetworkConfiguration); } if (apiServiceResource.HostnameConfigurations != null && apiServiceResource.HostnameConfigurations.Any()) { var portalHostnameResource = apiServiceResource.HostnameConfigurations.FirstOrDefault(conf => conf.Type == HostnameType.Portal); if (portalHostnameResource != null) { PortalCustomHostnameConfiguration = new PsApiManagementCustomHostNameConfiguration(portalHostnameResource); } var proxyHostnameResources = apiServiceResource.HostnameConfigurations.Where(conf => conf.Type == HostnameType.Proxy); if (proxyHostnameResources != null && proxyHostnameResources.Any()) { var proxyCustomHostnameResources = new List <PsApiManagementCustomHostNameConfiguration>(); foreach (var proxyHostNameResource in proxyHostnameResources) { proxyCustomHostnameResources.Add(new PsApiManagementCustomHostNameConfiguration(proxyHostNameResource)); } ProxyCustomHostnameConfiguration = proxyCustomHostnameResources.ToArray(); } var managementHostnameResource = apiServiceResource.HostnameConfigurations.FirstOrDefault(conf => conf.Type == HostnameType.Management); if (managementHostnameResource != null) { ManagementCustomHostnameConfiguration = new PsApiManagementCustomHostNameConfiguration(managementHostnameResource); } var scmHostnameResource = apiServiceResource.HostnameConfigurations.FirstOrDefault(conf => conf.Type == HostnameType.Scm); if (scmHostnameResource != null) { ScmCustomHostnameConfiguration = new PsApiManagementCustomHostNameConfiguration(scmHostnameResource); } var developerPortalResource = apiServiceResource.HostnameConfigurations.FirstOrDefault(conf => conf.Type == HostnameType.DeveloperPortal); if (developerPortalResource != null) { DeveloperPortalHostnameConfiguration = new PsApiManagementCustomHostNameConfiguration(developerPortalResource); } } if (apiServiceResource.Certificates != null && apiServiceResource.Certificates.Any()) { var systemCertificates = new List <PsApiManagementSystemCertificate>(); foreach (var certificate in apiServiceResource.Certificates) { systemCertificates.Add(new PsApiManagementSystemCertificate(certificate)); } SystemCertificates = systemCertificates.ToArray(); } // prepare the SSL settings if (apiServiceResource.CustomProperties != null && apiServiceResource.CustomProperties.Any()) { SslSetting = new PsApiManagementSslSetting(apiServiceResource.CustomProperties); } if (apiServiceResource.Tags != null) { Tags = apiServiceResource.Tags; } if (apiServiceResource.Identity != null) { this.Identity = new PsApiManagementServiceIdentity(apiServiceResource.Identity); } }
public PsApiManagement(ApiManagementServiceResource apiServiceResource) : this() { if (apiServiceResource == null) { throw new ArgumentNullException("apiServiceResource"); } Id = apiServiceResource.Id; Name = apiServiceResource.Name; Location = apiServiceResource.Location; Sku = ApiManagementClient.Mapper.Map <string, PsApiManagementSku>(apiServiceResource.Sku.Name); Capacity = apiServiceResource.Sku.Capacity ?? 1; PublisherEmail = apiServiceResource.PublisherEmail; OrganizationName = apiServiceResource.PublisherName; NotificationSenderEmail = apiServiceResource.NotificationSenderEmail; ProvisioningState = apiServiceResource.ProvisioningState; RuntimeUrl = apiServiceResource.GatewayUrl; RuntimeRegionalUrl = apiServiceResource.GatewayRegionalUrl; PortalUrl = apiServiceResource.PortalUrl; ManagementApiUrl = apiServiceResource.ManagementApiUrl; ScmUrl = apiServiceResource.ScmUrl; PublicIPAddresses = apiServiceResource.PublicIPAddresses != null?apiServiceResource.PublicIPAddresses.ToArray() : null; PrivateIPAddresses = apiServiceResource.PrivateIPAddresses != null?apiServiceResource.PrivateIPAddresses.ToArray() : null; var staticIPList = new List <string>(); if (apiServiceResource.PublicIPAddresses != null) { staticIPList.AddRange(apiServiceResource.PublicIPAddresses); } if (apiServiceResource.PrivateIPAddresses != null) { staticIPList.AddRange(apiServiceResource.PrivateIPAddresses); } #pragma warning disable CS0618 StaticIPs = staticIPList.ToArray(); #pragma warning restore CS0618 VpnType = ApiManagementClient.Mapper.Map <string, PsApiManagementVpnType>(apiServiceResource.VirtualNetworkType); if (apiServiceResource.AdditionalLocations != null) { AdditionalRegions = apiServiceResource.AdditionalLocations .Select(region => new PsApiManagementRegion(region)) .ToList(); } if (apiServiceResource.VirtualNetworkConfiguration != null) { VirtualNetwork = new PsApiManagementVirtualNetwork(apiServiceResource.VirtualNetworkConfiguration); } if (apiServiceResource.HostnameConfigurations != null && apiServiceResource.HostnameConfigurations.Any()) { var portalHostnameResource = apiServiceResource.HostnameConfigurations.FirstOrDefault(conf => conf.Type == HostnameType.Portal); if (portalHostnameResource != null) { #pragma warning disable CS0618 PortalHostnameConfiguration = new PsApiManagementHostnameConfiguration(portalHostnameResource); #pragma warning restore CS0618 PortalCustomHostnameConfiguration = new PsApiManagementCustomHostNameConfiguration(portalHostnameResource); } var proxyHostnameResources = apiServiceResource.HostnameConfigurations.Where(conf => conf.Type == HostnameType.Proxy); if (proxyHostnameResources != null && proxyHostnameResources.Any()) { #pragma warning disable CS0618 ProxyHostnameConfiguration = new PsApiManagementHostnameConfiguration(proxyHostnameResources.First()); #pragma warning restore CS0618 var proxyCustomHostnameResources = new List <PsApiManagementCustomHostNameConfiguration>(); foreach (var proxyHostNameResource in proxyHostnameResources) { proxyCustomHostnameResources.Add(new PsApiManagementCustomHostNameConfiguration(proxyHostNameResource)); } ProxyCustomHostnameConfiguration = proxyCustomHostnameResources.ToArray(); } var managementHostnameResource = apiServiceResource.HostnameConfigurations.FirstOrDefault(conf => conf.Type == HostnameType.Management); if (managementHostnameResource != null) { #pragma warning disable CS0618 ManagementHostnameConfiguration = new PsApiManagementHostnameConfiguration(managementHostnameResource); #pragma warning restore CS0618 ManagementCustomHostnameConfiguration = new PsApiManagementCustomHostNameConfiguration(managementHostnameResource); } var scmHostnameResource = apiServiceResource.HostnameConfigurations.FirstOrDefault(conf => conf.Type == HostnameType.Scm); if (scmHostnameResource != null) { #pragma warning disable CS0618 ScmHostnameConfiguration = new PsApiManagementHostnameConfiguration(scmHostnameResource); #pragma warning restore CS0618 ScmCustomHostnameConfiguration = new PsApiManagementCustomHostNameConfiguration(scmHostnameResource); } } if (apiServiceResource.Certificates != null && apiServiceResource.Certificates.Any()) { var systemCertificates = new List <PsApiManagementSystemCertificate>(); foreach (var certificate in apiServiceResource.Certificates) { systemCertificates.Add(new PsApiManagementSystemCertificate(certificate)); } SystemCertificates = systemCertificates.ToArray(); } if (apiServiceResource.Tags != null) { Tags = apiServiceResource.Tags; } if (apiServiceResource.Identity != null) { this.Identity = new PsApiManagementServiceIdentity(apiServiceResource.Identity); } }