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); } }
internal PSArtifactSource PutArtifactSource(PSArtifactSource psArtifactSource) { var artifactSource = _client.ArtifactSources.CreateOrUpdate( psArtifactSource.ResourceGroupName, psArtifactSource.Name, psArtifactSource.ToSdkType()); return(new PSArtifactSource(psArtifactSource.ResourceGroupName, artifactSource)); }
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); } }
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); }
internal PSArtifactSource GetArtifactSource(PSArtifactSource psArtifactSource) { var artifactSource = _client.ArtifactSources.Get(psArtifactSource.ResourceGroupName, psArtifactSource.Name); return(new PSArtifactSource(psArtifactSource.ResourceGroupName, artifactSource)); }
internal bool ArtifactSourceExists(PSArtifactSource psArtifactSource) { return(DeploymentManagerClient.ResourceExists(psArtifactSource, this.GetArtifactSource)); }