public override void ExecuteCmdlet()
        {
            this.ResolveParameters();
            var psServiceUnitResource = new PSServiceUnitResource()
            {
                ResourceGroupName   = this.ResourceGroupName,
                ServiceTopologyName = this.ServiceTopologyName,
                ServiceName         = this.ServiceName,
                Name = this.Name
            };

            if (!string.IsNullOrWhiteSpace(this.Name))
            {
                var serviceUnitResource = this.DeploymentManagerClient.GetServiceUnit(psServiceUnitResource);
                this.WriteObject(serviceUnitResource);
            }
            else
            {
                var serviceUnitResources = this.DeploymentManagerClient.ListServiceUnits(
                    resourceGroupName: this.ResourceGroupName,
                    serviceTopologyName: this.ServiceTopologyName,
                    serviceName: this.ServiceName);
                this.WriteObject(serviceUnitResources, enumerateCollection: true);
            }
        }
        public override void ExecuteCmdlet()
        {
            if (this.ShouldProcess(this.Name, Messages.CreateServiceUnit))
            {
                this.ResolveParameters();
                var psServiceUnitResource = new PSServiceUnitResource()
                {
                    ResourceGroupName   = this.ResourceGroupName,
                    ServiceTopologyName = this.ServiceTopologyName,
                    ServiceName         = this.ServiceName,
                    Name                = this.Name,
                    Location            = this.Location,
                    TargetResourceGroup = this.TargetResourceGroup,
                    DeploymentMode      = this.DeploymentMode,
                    TemplateUri         = this.TemplateUri,
                    ParametersUri       = this.ParametersUri,
                    TemplateArtifactSourceRelativePath   = this.TemplateArtifactSourceRelativePath,
                    ParametersArtifactSourceRelativePath = this.ParametersArtifactSourceRelativePath,
                    Tags = this.Tag
                };

                if (this.DeploymentManagerClient.ServiceUnitExists(psServiceUnitResource))
                {
                    throw new PSArgumentException(Messages.ServiceUnitAlreadyExists);
                }

                psServiceUnitResource = this.DeploymentManagerClient.PutServiceUnit(psServiceUnitResource);
                this.WriteObject(psServiceUnitResource);
            }
        }
Esempio n. 3
0
        internal bool DeleteServiceUnit(PSServiceUnitResource psServiceUnitResource)
        {
            var result = _client.ServiceUnits.DeleteWithHttpMessagesAsync(
                psServiceUnitResource.ResourceGroupName,
                psServiceUnitResource.ServiceTopologyName,
                psServiceUnitResource.ServiceName,
                psServiceUnitResource.Name).GetAwaiter().GetResult();

            return(result.Response.StatusCode == HttpStatusCode.OK || result.Response.StatusCode == HttpStatusCode.NoContent);
        }
Esempio n. 4
0
        internal PSServiceUnitResource GetServiceUnit(PSServiceUnitResource psServiceUnit)
        {
            var serviceUnit = _client.ServiceUnits.Get(psServiceUnit.ResourceGroupName, psServiceUnit.ServiceTopologyName, psServiceUnit.ServiceName, psServiceUnit.Name);

            return(new PSServiceUnitResource(
                       psServiceUnit.ResourceGroupName,
                       psServiceUnit.ServiceTopologyName,
                       psServiceUnit.ServiceName,
                       serviceUnit));
        }
        private bool Delete()
        {
            var serviceUnitToDelete = new PSServiceUnitResource()
            {
                ResourceGroupName   = this.ResourceGroupName,
                ServiceTopologyName = this.ServiceTopologyName,
                ServiceName         = this.ServiceName,
                Name = this.Name
            };

            return(this.DeploymentManagerClient.DeleteServiceUnit(serviceUnitToDelete));
        }
Esempio n. 6
0
        public override void ExecuteCmdlet()
        {
            this.ResolveParameters();
            var psServiceUnitResource = new PSServiceUnitResource()
            {
                ResourceGroupName   = this.ResourceGroupName,
                ServiceTopologyName = this.ServiceTopologyName,
                ServiceName         = this.ServiceName,
                Name = this.Name
            };

            var serviceUnitResource = this.DeploymentManagerClient.GetServiceUnit(psServiceUnitResource);

            this.WriteObject(serviceUnitResource);
        }
Esempio n. 7
0
        internal PSServiceUnitResource PutServiceUnit(
            PSServiceUnitResource psServiceUnitResource)
        {
            var serviceUnitResource = _client.ServiceUnits.CreateOrUpdate(
                psServiceUnitResource.ResourceGroupName,
                psServiceUnitResource.ServiceTopologyName,
                psServiceUnitResource.ServiceName,
                psServiceUnitResource.Name,
                psServiceUnitResource.ToSdkType());

            return(new PSServiceUnitResource(
                       psServiceUnitResource.ResourceGroupName,
                       psServiceUnitResource.ServiceTopologyName,
                       psServiceUnitResource.ServiceName,
                       serviceUnitResource));
        }
Esempio n. 8
0
 internal bool ServiceUnitExists(PSServiceUnitResource psServiceUnitResource)
 {
     return(DeploymentManagerClient.ResourceExists(psServiceUnitResource, this.GetServiceUnit));
 }