Exemplo n.º 1
0
        public override void ExecuteCmdlet()
        {
            if (ParameterSetName == ObjectParameterSet)
            {
                ResourceGroupName = CdnOrigin.ResourceGroupName;
                ProfileName       = CdnOrigin.ProfileName;
                EndpointName      = CdnOrigin.EndpointName;
                OriginName        = CdnOrigin.Name;
            }

            if (ParameterSetName == ResourceIdParameterSet)
            {
                var parsedResourceId = new ResourceIdentifier(ResourceId);
                ResourceGroupName = parsedResourceId.ResourceGroupName;
                ProfileName       = parsedResourceId.GetProfileName();
                EndpointName      = parsedResourceId.GetEndpointName();
                OriginName        = parsedResourceId.ResourceName;
            }

            ConfirmAction(MyInvocation.InvocationName, OriginName, DeleteOrigin);

            if (PassThru)
            {
                WriteObject(true);
            }
        }
Exemplo n.º 2
0
        public override void ExecuteCmdlet()
        {
            if (ParameterSetName == ObjectParameterSet)
            {
                EndpointName      = CdnEndpoint.Name;
                ProfileName       = CdnEndpoint.ProfileName;
                ResourceGroupName = CdnEndpoint.ResourceGroupName;
            }

            if (ParameterSetName == ResourceIdParameterSet)
            {
                var parsedResourceId = new ResourceIdentifier(ResourceId);
                ResourceGroupName = parsedResourceId.ResourceGroupName;
                ProfileName       = parsedResourceId.GetProfileName();
                EndpointName      = parsedResourceId.GetEndpointName();
                OriginName        = parsedResourceId.ResourceName;
            }

            if (OriginName == null)
            {
                //list all origins on this endpoint
                var origins = CdnManagementClient.Origins.ListByEndpoint(ResourceGroupName, ProfileName, EndpointName).Select(o => o.ToPsOrigin());
                WriteVerbose(Resources.Success);
                WriteObject(origins, true);
            }
            else
            {
                var origin = CdnManagementClient.Origins.Get(ResourceGroupName, ProfileName, EndpointName, OriginName);
                WriteVerbose(Resources.Success);
                WriteObject(origin.ToPsOrigin());
            }
        }
Exemplo n.º 3
0
        public override void ExecuteCmdlet()
        {
            if (ParameterSetName.Equals(ObjectParameterSet, StringComparison.OrdinalIgnoreCase))
            {
                EndpointName      = InputObject.EndpointName;
                ProfileName       = InputObject.ProfileName;
                ResourceGroupName = InputObject.ResourceGroupName;
                CustomDomainName  = InputObject.Name;
            }

            if (ParameterSetName.Equals(ResourceIdParameterSet, StringComparison.OrdinalIgnoreCase))
            {
                var parsedResourceId = new ResourceIdentifier(ResourceId);
                ResourceGroupName = parsedResourceId.ResourceGroupName;
                ProfileName       = parsedResourceId.GetProfileName();
                EndpointName      = parsedResourceId.GetEndpointName();
                CustomDomainName  = parsedResourceId.ResourceName;
            }

            var existingCustomDomain = CdnManagementClient.CustomDomains
                                       .ListByEndpoint(ResourceGroupName, ProfileName, EndpointName)
                                       .FirstOrDefault(cd => cd.Name.ToLower() == CustomDomainName.ToLower());

            if (existingCustomDomain == null)
            {
                throw new PSArgumentException(string.Format(Resources.Error_NonExistingCustomDomain,
                                                            CustomDomainName,
                                                            EndpointName,
                                                            ProfileName,
                                                            ResourceGroupName));
            }

            var parameters = new Management.Cdn.Models.CdnManagedHttpsParameters
            {
                ProtocolType = Management.Cdn.Models.ProtocolType.IPBased,
                CertificateSourceParameters = new Management.Cdn.Models.CdnCertificateSourceParameters {
                    CertificateType = "Shared"
                }
            };

            ConfirmAction(MyInvocation.InvocationName,
                          String.Format("{0} ({1})", existingCustomDomain.Name, existingCustomDomain.HostName),
                          () => CdnManagementClient.CustomDomains.EnableCustomHttps(
                              ResourceGroupName,
                              ProfileName,
                              EndpointName,
                              CustomDomainName,
                              parameters
                              ));

            if (PassThru)
            {
                WriteObject(true);
            }
        }
Exemplo n.º 4
0
        public override void ExecuteCmdlet()
        {
            if (ParameterSetName == ResourceIdParameterSet)
            {
                var parsedResourceId = new ResourceIdentifier(ResourceId);
                ResourceGroupName = parsedResourceId.ResourceGroupName;
                ProfileName       = parsedResourceId.GetProfileName();
                EndpointName      = parsedResourceId.GetEndpointName();
                OriginGroupName   = parsedResourceId.ResourceName;
            }

            try
            {
                var originGroup = CdnManagementClient.OriginGroups.Get(ResourceGroupName, ProfileName, EndpointName, OriginGroupName);
                WriteVerbose(Resources.Success);
                WriteObject(originGroup.ToPsOriginGroup());
            }
            catch (Management.Cdn.Models.ErrorResponseException e)
            {
                throw new PSArgumentException(string.Format("Error response received.Error Message: '{0}'",
                                                            e.Response.Content));
            }
        }
Exemplo n.º 5
0
        public override void ExecuteCmdlet()
        {
            if (ParameterSetName.Equals(ObjectParameterSet, StringComparison.OrdinalIgnoreCase))
            {
                EndpointName      = InputObject.EndpointName;
                ProfileName       = InputObject.ProfileName;
                ResourceGroupName = InputObject.ResourceGroupName;
                CustomDomainName  = InputObject.Name;
            }

            if (ParameterSetName.Equals(ResourceIdParameterSet, StringComparison.OrdinalIgnoreCase))
            {
                var parsedResourceId = new ResourceIdentifier(ResourceId);
                ResourceGroupName = parsedResourceId.ResourceGroupName;
                ProfileName       = parsedResourceId.GetProfileName();
                EndpointName      = parsedResourceId.GetEndpointName();
                CustomDomainName  = parsedResourceId.ResourceName;
            }

            var existingCustomDomain = CdnManagementClient.CustomDomains
                                       .ListByEndpoint(ResourceGroupName, ProfileName, EndpointName)
                                       .FirstOrDefault(cd => cd.Name.ToLower() == CustomDomainName.ToLower());

            if (existingCustomDomain == null)
            {
                throw new PSArgumentException(string.Format(Resources.Error_NonExistingCustomDomain,
                                                            CustomDomainName,
                                                            EndpointName,
                                                            ProfileName,
                                                            ResourceGroupName));
            }

            // Get the Profile so we can lookup its Sku.
            var profile = CdnManagementClient.Profiles.Get(ResourceGroupName, ProfileName);

            // Setup the request parameters according to the profile Sku.
            Management.Cdn.Models.CdnManagedHttpsParameters parameters;
            switch (profile.Sku.Name)
            {
            case Management.Cdn.Models.SkuName.StandardMicrosoft:
                // Microsoft
                parameters = new Management.Cdn.Models.CdnManagedHttpsParameters
                {
                    ProtocolType = Management.Cdn.Models.ProtocolType.ServerNameIndication,
                    CertificateSourceParameters = new Management.Cdn.Models.CdnCertificateSourceParameters {
                        CertificateType = "Dedicated"
                    }
                };
                break;

            case Management.Cdn.Models.SkuName.StandardAkamai:
                // Akamai
                parameters = new Management.Cdn.Models.CdnManagedHttpsParameters
                {
                    ProtocolType = Management.Cdn.Models.ProtocolType.ServerNameIndication,
                    CertificateSourceParameters = new Management.Cdn.Models.CdnCertificateSourceParameters {
                        CertificateType = "Shared"
                    }
                };

                break;

            default:
                // Verizon
                parameters = new Management.Cdn.Models.CdnManagedHttpsParameters
                {
                    ProtocolType = Management.Cdn.Models.ProtocolType.IPBased,
                    CertificateSourceParameters = new Management.Cdn.Models.CdnCertificateSourceParameters {
                        CertificateType = "Shared"
                    }
                };
                break;
            }

            ConfirmAction(MyInvocation.InvocationName,
                          String.Format("{0} ({1})", existingCustomDomain.Name, existingCustomDomain.HostName),
                          () => CdnManagementClient.CustomDomains.EnableCustomHttps(
                              ResourceGroupName,
                              ProfileName,
                              EndpointName,
                              CustomDomainName,
                              parameters
                              ));

            if (PassThru)
            {
                WriteObject(true);
            }
        }