private void NewEndpoint()
        {
#pragma warning disable CS0618
            var endpoint = CdnManagementClient.Endpoints.Create(
                ResourceGroupName,
                ProfileName,
                EndpointName, new Management.Cdn.Models.Endpoint
            {
                ContentTypesToCompress = ContentTypesToCompress,
                IsCompressionEnabled   = IsCompressionEnabled,
                IsHttpAllowed          = IsHttpAllowed,
                IsHttpsAllowed         = IsHttpsAllowed,
                Location         = Location,
                OriginHostHeader = OriginHostHeader,
                OriginPath       = OriginPath,
                Origins          = new List <DeepCreatedOrigin> {
                    new DeepCreatedOrigin(OriginName, OriginHostName, HttpPort, HttpsPort)
                },
                QueryStringCachingBehavior = QueryStringCachingBehavior != null ?
                                             QueryStringCachingBehavior.Value.CastEnum <PSQueryStringCachingBehavior, QueryStringCachingBehavior>() :
                                             (QueryStringCachingBehavior?)null,
                OptimizationType = OptimizationType,
                GeoFilters       = GeoFilters == null ? null : GeoFilters.Select(g => g.ToSdkGeoFilter()).ToList(),
                Tags             = Tag.ToDictionaryTags()
            });
#pragma warning restore CS0618

            WriteVerbose(Resources.Success);
            WriteObject(endpoint.ToPsEndpoint());
        }
        private void NewEndpoint()
        {
            try
            {
                Management.Cdn.Models.Endpoint endpoint = new Management.Cdn.Models.Endpoint();
                endpoint.ContentTypesToCompress = ContentTypesToCompress;
                endpoint.IsCompressionEnabled   = IsCompressionEnabled;
                endpoint.IsHttpAllowed          = IsHttpAllowed;
                endpoint.IsHttpsAllowed         = IsHttpsAllowed;
                endpoint.Location         = Location;
                endpoint.OriginHostHeader = OriginHostHeader;
                endpoint.OriginPath       = OriginPath;
                endpoint.OptimizationType = OptimizationType;
                endpoint.ProbePath        = ProbePath;
                endpoint.DeliveryPolicy   = DeliveryPolicy?.ToSdkDeliveryPolicy();
                endpoint.GeoFilters       = GeoFilters?.Select(g => g.ToSdkGeoFilter()).ToList();
                endpoint.Tags             = Tag.ToDictionaryTags();

                endpoint.Origins = new List <DeepCreatedOrigin>();
                endpoint.Origins.Add(CreateOrigin());

                if (!String.IsNullOrWhiteSpace(OriginGroupName))
                {
                    endpoint.OriginGroups = new List <DeepCreatedOriginGroup>();
                    endpoint.OriginGroups.Add(CreateOriginGroup());
                }

                if (QueryStringCachingBehavior != null)
                {
                    endpoint.QueryStringCachingBehavior = QueryStringCachingBehavior.Value.CastEnum <PSQueryStringCachingBehavior, QueryStringCachingBehavior>();
                }
                else
                {
                    endpoint.QueryStringCachingBehavior = (QueryStringCachingBehavior?)null;
                }

                if (!String.IsNullOrWhiteSpace(DefaultOriginGroup))
                {
                    endpoint.DefaultOriginGroup = new ResourceReference(DefaultOriginGroup);
                }


                var createdEndpoint = CdnManagementClient.Endpoints.Create(ResourceGroupName, ProfileName, EndpointName, endpoint);

                WriteVerbose(Resources.Success);
                WriteObject(createdEndpoint.ToPsEndpoint());
            }
            catch (ErrorResponseException e)
            {
                throw new PSArgumentException(string.Format("Error response received.Error Message: '{0}'",
                                                            e.Response.Content));
            }
        }
        private void NewEndpoint()
        {
            try
            {
                var endpoint = CdnManagementClient.Endpoints.Create(
                    ResourceGroupName,
                    ProfileName,
                    EndpointName, new Management.Cdn.Models.Endpoint
                {
                    ContentTypesToCompress = ContentTypesToCompress,
                    IsCompressionEnabled   = IsCompressionEnabled,
                    IsHttpAllowed          = IsHttpAllowed,
                    IsHttpsAllowed         = IsHttpsAllowed,
                    Location         = Location,
                    OriginHostHeader = OriginHostHeader,
                    OriginPath       = OriginPath,
                    Origins          = new List <DeepCreatedOrigin> {
                        new DeepCreatedOrigin(OriginName, OriginHostName, HttpPort, HttpsPort)
                    },
                    QueryStringCachingBehavior = QueryStringCachingBehavior != null ?
                                                 QueryStringCachingBehavior.Value.CastEnum <PSQueryStringCachingBehavior, QueryStringCachingBehavior>() :
                                                 (QueryStringCachingBehavior?)null,
                    OptimizationType = OptimizationType,
                    ProbePath        = ProbePath,
                    GeoFilters       = GeoFilters?.Select(g => g.ToSdkGeoFilter()).ToList(),
                    DeliveryPolicy   = DeliveryPolicy?.ToSdkDeliveryPolicy(),
                    Tags             = Tag.ToDictionaryTags()
                });

                WriteVerbose(Resources.Success);
                WriteObject(endpoint.ToPsEndpoint());
            }
            catch (Microsoft.Azure.Management.Cdn.Models.ErrorResponseException e)
            {
                throw new PSArgumentException(string.Format("Error response received.Error Message: '{0}'",
                                                            e.Response.Content));
            }
        }