public override void ExecuteCmdlet() { if (this.InputObject != null) { this.ResourceGroupName = this.InputObject.ResourceGroupName; this.Name = this.InputObject.Name; } else if (!string.IsNullOrWhiteSpace(this.ResourceId)) { var parsedResourceId = new ResourceIdentifier(this.ResourceId); this.ResourceGroupName = parsedResourceId.ResourceGroupName; this.Name = parsedResourceId.ResourceName; } if (!string.IsNullOrWhiteSpace(this.Name)) { var psServiceTopologyResource = new PSServiceTopologyResource() { ResourceGroupName = this.ResourceGroupName, Name = this.Name }; psServiceTopologyResource = this.DeploymentManagerClient.GetServiceTopology(psServiceTopologyResource); this.WriteObject(psServiceTopologyResource); } else { var psServiceTopologyResources = this.DeploymentManagerClient.ListServiceTopologies(this.ResourceGroupName); this.WriteObject(psServiceTopologyResources, enumerateCollection: true); } }
internal PSServiceTopologyResource PutServiceTopology(PSServiceTopologyResource psTopologyResource) { var serviceTopologyResource = _client.ServiceTopologies.CreateOrUpdate( psTopologyResource.ToSdkType(), psTopologyResource.ResourceGroupName, psTopologyResource.Name); return(new PSServiceTopologyResource(psTopologyResource.ResourceGroupName, serviceTopologyResource)); }
private bool Delete() { var topologyToDelete = new PSServiceTopologyResource() { ResourceGroupName = this.ResourceGroupName, Name = this.Name }; return(this.DeploymentManagerClient.DeleteServiceTopology(topologyToDelete)); }
public override void ExecuteCmdlet() { if (this.ShouldProcess(this.Name, Messages.CreateServiceTopology)) { var topologyResource = new PSServiceTopologyResource() { ResourceGroupName = this.ResourceGroupName, Name = this.Name, Location = this.Location, ArtifactSourceId = this.ArtifactSourceId, Tags = this.Tag }; if (this.DeploymentManagerClient.ServiceTopologyExists(topologyResource)) { throw new PSArgumentException(Messages.ServiceTopologyAlreadyExists); } topologyResource = this.DeploymentManagerClient.PutServiceTopology(topologyResource); this.WriteObject(topologyResource); } }
internal bool DeleteServiceTopology(PSServiceTopologyResource psServiceTopologyResource) { var result = _client.ServiceTopologies.DeleteWithHttpMessagesAsync(psServiceTopologyResource.ResourceGroupName, psServiceTopologyResource.Name).GetAwaiter().GetResult(); return(result.Response.StatusCode == HttpStatusCode.OK || result.Response.StatusCode == HttpStatusCode.NoContent); }
internal PSServiceTopologyResource GetServiceTopology(PSServiceTopologyResource pSServiceTopologyResource) { var serviceTopologyResource = _client.ServiceTopologies.Get(pSServiceTopologyResource.ResourceGroupName, pSServiceTopologyResource.Name); return(new PSServiceTopologyResource(pSServiceTopologyResource.ResourceGroupName, serviceTopologyResource)); }
internal bool ServiceTopologyExists(PSServiceTopologyResource psServiceTopologyResource) { return(DeploymentManagerClient.ResourceExists(psServiceTopologyResource, this.GetServiceTopology)); }