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); } }
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); }
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)); }
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); }
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)); }
internal bool ServiceUnitExists(PSServiceUnitResource psServiceUnitResource) { return(DeploymentManagerClient.ResourceExists(psServiceUnitResource, this.GetServiceUnit)); }