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

            var existingEndpoint = CdnManagementClient.Endpoints.ListByProfile(ProfileName, ResourceGroupName)
                                   .Where(e => e.Name.ToLower() == EndpointName.ToLower())
                                   .FirstOrDefault();

            if (existingEndpoint == null)
            {
                throw new PSArgumentException(string.Format(
                                                  Resources.Error_DeleteNonExistingEndpoint,
                                                  EndpointName,
                                                  ProfileName,
                                                  ResourceGroupName));
            }

            ConfirmAction(Force,
                          string.Format(Resources.Confirm_RemoveEndpoint, EndpointName, ProfileName, ResourceGroupName),
                          this.MyInvocation.InvocationName,
                          EndpointName,
                          () => CdnManagementClient.Endpoints.DeleteIfExists(EndpointName, ProfileName, ResourceGroupName));

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