コード例 #1
0
        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);
            }
        }
コード例 #2
0
        internal PSServiceTopologyResource PutServiceTopology(PSServiceTopologyResource psTopologyResource)
        {
            var serviceTopologyResource = _client.ServiceTopologies.CreateOrUpdate(
                psTopologyResource.ToSdkType(),
                psTopologyResource.ResourceGroupName,
                psTopologyResource.Name);

            return(new PSServiceTopologyResource(psTopologyResource.ResourceGroupName, serviceTopologyResource));
        }
コード例 #3
0
        private bool Delete()
        {
            var topologyToDelete = new PSServiceTopologyResource()
            {
                ResourceGroupName = this.ResourceGroupName,
                Name = this.Name
            };

            return(this.DeploymentManagerClient.DeleteServiceTopology(topologyToDelete));
        }
コード例 #4
0
        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);
            }
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        internal PSServiceTopologyResource GetServiceTopology(PSServiceTopologyResource pSServiceTopologyResource)
        {
            var serviceTopologyResource = _client.ServiceTopologies.Get(pSServiceTopologyResource.ResourceGroupName, pSServiceTopologyResource.Name);

            return(new PSServiceTopologyResource(pSServiceTopologyResource.ResourceGroupName, serviceTopologyResource));
        }
コード例 #7
0
 internal bool ServiceTopologyExists(PSServiceTopologyResource psServiceTopologyResource)
 {
     return(DeploymentManagerClient.ResourceExists(psServiceTopologyResource, this.GetServiceTopology));
 }