public override void ExecuteCmdlet() { var scope = Blueprint.Scope; try { if (this.IsParameterBound(c => c.Name)) { WriteObject(BlueprintClient.GetArtifact(scope, Blueprint.Name, Name, BlueprintVersion)); } else { WriteObject(BlueprintClient.ListArtifacts(scope, Blueprint.Name, BlueprintVersion)); } } catch (Exception ex) { WriteExceptionError(ex); } }
protected void ThrowIfArtifactExits(string scope, string blueprintName, string artifactName) { PSArtifact artifact = null; try { artifact = BlueprintClient.GetArtifact(scope, blueprintName, artifactName, null); } catch (Exception ex) { if (ex is CloudException cex && cex.Response.StatusCode != System.Net.HttpStatusCode.NotFound) { // if exception is for a reason other than .NotFound, pass it to the caller. throw; } } if (artifact != null) { throw new Exception(string.Format(Resources.ArtifactExists, artifactName, blueprintName)); } }