Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        public PSArtifact CreateArtifact(string scope, string blueprintName, string artifactName, Artifact artifactObject)
        {
            var artifact = blueprintManagementClient.Artifacts.CreateOrUpdate(scope, blueprintName, artifactName, artifactObject);

            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);
        }