Пример #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 psArtifactSource = new PSArtifactSource()
                {
                    ResourceGroupName = this.ResourceGroupName,
                    Name = this.Name,
                };

                psArtifactSource = this.DeploymentManagerClient.GetArtifactSource(psArtifactSource);
                this.WriteObject(psArtifactSource);
            }
            else
            {
                var psArtifactSources = this.DeploymentManagerClient.ListArtifactSources(this.ResourceGroupName);
                this.WriteObject(psArtifactSources, enumerateCollection: true);
            }
        }
Пример #2
0
        internal PSArtifactSource PutArtifactSource(PSArtifactSource psArtifactSource)
        {
            var artifactSource = _client.ArtifactSources.CreateOrUpdate(
                psArtifactSource.ResourceGroupName,
                psArtifactSource.Name,
                psArtifactSource.ToSdkType());

            return(new PSArtifactSource(psArtifactSource.ResourceGroupName, artifactSource));
        }
Пример #3
0
        private bool Delete()
        {
            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;
            }

            var artifactSourceToDelete = new PSArtifactSource()
            {
                ResourceGroupName = this.ResourceGroupName,
                Name = this.Name
            };

            return(this.DeploymentManagerClient.DeleteArtifactSource(artifactSourceToDelete));
        }
        public override void ExecuteCmdlet()
        {
            if (this.ShouldProcess(this.Name, Messages.CreateArtifactSource))
            {
                var psArtifactSource = new PSArtifactSource()
                {
                    ResourceGroupName = this.ResourceGroupName,
                    Name           = this.Name,
                    Location       = this.Location,
                    SourceType     = "AzureStorage",
                    ArtifactRoot   = this.ArtifactRoot,
                    Authentication = this.GetAuthentication(),
                    Tags           = this.Tag
                };

                if (this.DeploymentManagerClient.ArtifactSourceExists(psArtifactSource))
                {
                    throw new PSArgumentException(Messages.ArtifactSourceAlreadyExists);
                }

                psArtifactSource = this.DeploymentManagerClient.PutArtifactSource(psArtifactSource);
                this.WriteObject(psArtifactSource);
            }
        }
Пример #5
0
        internal bool DeleteArtifactSource(PSArtifactSource psArtifactSource)
        {
            var result = _client.ArtifactSources.DeleteWithHttpMessagesAsync(psArtifactSource.ResourceGroupName, psArtifactSource.Name).GetAwaiter().GetResult();

            return(result.Response.StatusCode == HttpStatusCode.OK || result.Response.StatusCode == HttpStatusCode.NoContent);
        }
Пример #6
0
        internal PSArtifactSource GetArtifactSource(PSArtifactSource psArtifactSource)
        {
            var artifactSource = _client.ArtifactSources.Get(psArtifactSource.ResourceGroupName, psArtifactSource.Name);

            return(new PSArtifactSource(psArtifactSource.ResourceGroupName, artifactSource));
        }
Пример #7
0
 internal bool ArtifactSourceExists(PSArtifactSource psArtifactSource)
 {
     return(DeploymentManagerClient.ResourceExists(psArtifactSource, this.GetArtifactSource));
 }