public IEnumerable <PSArtifact> ListArtifacts(string scope, string blueprintName, string version)
        {
            var list = new List <PSArtifact>();

            var artifacts = string.IsNullOrEmpty(version)
                ? blueprintManagementClient.Artifacts.List(scope, blueprintName)
                : blueprintManagementClient.PublishedArtifacts.List(scope, blueprintName, version);

            foreach (var artifact in artifacts)
            {
                switch (artifact)
                {
                case TemplateArtifact templateArtifact:
                    list.Add(PSTemplateArtifact.FromArtifactModel(artifact as TemplateArtifact, scope));
                    break;

                case PolicyAssignmentArtifact policyArtifact:
                    list.Add(PSPolicyAssignmentArtifact.FromArtifactModel(artifact as PolicyAssignmentArtifact, scope));
                    break;

                case RoleAssignmentArtifact roleAssignmentArtifact:
                    list.Add(PSRoleAssignmentArtifact.FromArtifactModel(artifact as RoleAssignmentArtifact, scope));
                    break;

                default:
                    throw new NotSupportedException(Resources.ArtifactTypeNotSupported);
                }
            }

            return(list);
        }
        public PSArtifact DeleteArtifact(string scope, string blueprintName, string artifactName)
        {
            var artifact = blueprintManagementClient.Artifacts.Delete(scope, blueprintName, artifactName);

            PSArtifact psArtifact;

            switch (artifact)
            {
            case TemplateArtifact templateArtifact:
                psArtifact = PSTemplateArtifact.FromArtifactModel(artifact as TemplateArtifact, scope);
                break;

            case PolicyAssignmentArtifact policyArtifact:
                psArtifact = PSPolicyAssignmentArtifact.FromArtifactModel(artifact as PolicyAssignmentArtifact, scope);
                break;

            case RoleAssignmentArtifact roleAssignmentArtifact:
                psArtifact = PSRoleAssignmentArtifact.FromArtifactModel(artifact as RoleAssignmentArtifact, scope);
                break;

            default:
                throw new NotSupportedException(Resources.ArtifactTypeNotSupported);
            }

            return(psArtifact);
        }
        public PSArtifact GetArtifact(string scope, string blueprintName, string artifactName, string version)
        {
            var artifact = string.IsNullOrEmpty(version)
                ? blueprintManagementClient.Artifacts.Get(scope, blueprintName, artifactName)
                : blueprintManagementClient.PublishedArtifacts.Get(scope, blueprintName, artifactName, version);

            PSArtifact psArtifact = null;

            switch (artifact)
            {
            case TemplateArtifact templateArtifact:
                psArtifact = PSTemplateArtifact.FromArtifactModel(artifact as TemplateArtifact, scope);
                break;

            case PolicyAssignmentArtifact policyArtifact:
                psArtifact = PSPolicyAssignmentArtifact.FromArtifactModel(artifact as PolicyAssignmentArtifact, scope);
                break;

            case RoleAssignmentArtifact roleAssignmentArtifact:
                psArtifact = PSRoleAssignmentArtifact.FromArtifactModel(artifact as RoleAssignmentArtifact, scope);
                break;

            default:
                throw new NotSupportedException(Resources.ArtifactTypeNotSupported);
            }

            return(psArtifact);
        }