/// <summary>
        /// Process Records
        /// </summary>
        protected override void ProcessRecord()
        {
            var qb = new QuerystringBuilder();

            if (Names != null && Names.Any())
            {
                qb.Add("usernames", string.Join(",", Names));
            }

            if (EmailAddresses != null && EmailAddresses.Any())
            {
                qb.Add("emailAddresses", string.Join(",", EmailAddresses));
            }

            if (!string.IsNullOrWhiteSpace(Domain))
            {
                qb.Add("domain", Domain);
            }

            var preparedUrl = $"/public/users{qb.Build()}";

            WriteDebug(preparedUrl);
            var result = Session.ApiClient.Get <IEnumerable <Models.User> >(preparedUrl);

            WriteObject(result, true);
        }
示例#2
0
        protected override void ProcessRecord()
        {
            var qb = new QuerystringBuilder();

            var           environments = new Model.ProtectionSource.EnvironmentEnum[] { Model.ProtectionSource.EnvironmentEnum.KPhysical };
            List <string> envs         = environments.ToList().ConvertAll <string>(x => x.ToString().First().ToString().ToLower() + x.ToString().Substring(1));

            qb.Add("environment", string.Join(",", envs));

            var url     = $"/public/protectionSources{qb.Build()}";
            var results = Session.ApiClient.Get <IEnumerable <ProtectionSourceNode> >(url);

            results = FlattenNodes(results);

            List <AgentInformation> agents = new List <AgentInformation>();

            foreach (var result in results)
            {
                if (result.ProtectionSource.PhysicalProtectionSource.Agents != null)
                {
                    agents.AddRange(result.ProtectionSource.PhysicalProtectionSource.Agents);
                }
            }

            WriteObject(agents, true);
        }
        protected override void ProcessRecord()
        {
            var qb = new QuerystringBuilder();

            if (Ids != null && Ids.Any())
            {
                qb.Add("ids", Ids);
            }

            if (Names != null && Names.Any())
            {
                qb.Add("names", Names);
            }

            if (ClusterPartitionIds != null && ClusterPartitionIds.Any())
            {
                qb.Add("clusterPartitionIds", ClusterPartitionIds);
            }

            if (FetchStats.IsPresent)
            {
                qb.Add("fetchStats", true.ToString());
            }

            var preparedUrl = $"/public/viewBoxes{qb.Build()}";
            var result      = Session.ApiClient.Get <IEnumerable <ViewBox> >(preparedUrl);

            WriteObject(result, true);
        }
        protected override void ProcessRecord()
        {
            var qb = new QuerystringBuilder();

            var environments = new EnvironmentEnum[] { EnvironmentEnum.kPhysical };

            qb.Add("environment", string.Join(",", environments));

            var url     = $"/public/protectionSources{qb.Build()}";
            var results = Session.ApiClient.Get <IEnumerable <ProtectionSourceNode> >(url);

            results = FlattenNodes(results);

            List <AgentInformation> agents = new List <AgentInformation>();

            foreach (var result in results)
            {
                if (result.ProtectionSource.PhysicalProtectionSource.Agents != null)
                {
                    agents.AddRange(result.ProtectionSource.PhysicalProtectionSource.Agents);
                }
            }

            WriteObject(agents, true);
        }
示例#5
0
        protected override void ProcessRecord()
        {
            var qb = new QuerystringBuilder();

            if (Environments != null && Environments.Any())
            {
                List <string> envs = Environments.ToList().ConvertAll <string>(x => x.ToString().First().ToString().ToLower() + x.ToString().Substring(1));
                qb.Add("environments", string.Join(",", envs));
            }

            if (Ids != null && Ids.Any())
            {
                qb.Add("ids", string.Join(",", Ids));
            }

            if (Names != null && Names.Any())
            {
                qb.Add("names", string.Join(",", Names));
            }

            var preparedUrl = $"/public/protectionPolicies{qb.Build()}";
            var result      = Session.ApiClient.Get <IEnumerable <Model.ProtectionPolicy> >(preparedUrl);

            WriteObject(result, true);
        }
示例#6
0
        /// <summary>
        /// Process Records
        /// </summary>
        protected override void ProcessRecord()
        {
            var queries = new QuerystringBuilder();

            if (StartIndex != null)
            {
                queries.Add("startIndex", StartIndex.Value);
            }

            if (PageCount != null)
            {
                queries.Add("pageCount", PageCount.Value);
            }

            if (Domains != null && Domains.Any())
            {
                queries.Add("domains", string.Join(",", Domains));
            }

            if (EntityTypes != null && EntityTypes.Any())
            {
                queries.Add("entityTypes", string.Join(",", EntityTypes));
            }

            if (Actions != null && Actions.Any())
            {
                queries.Add("actions", string.Join(",", Actions));
            }

            if (!string.IsNullOrWhiteSpace(Search))
            {
                queries.Add("search", Search.Trim());
            }

            if (UserNames != null && UserNames.Any())
            {
                queries.Add("userNames", string.Join(",", UserNames));
            }

            if (StartTime.HasValue)
            {
                queries.Add("startTimeUsecs", StartTime.ToString());
            }

            if (EndTime.HasValue)
            {
                queries.Add("endTimeUsecs", EndTime.ToString());
            }

            var preparedUrl = $"/public/auditLogs/cluster{queries.Build()}";

            WriteDebug(preparedUrl);
            var result = Session.ApiClient.Get <Model.ClusterAuditLogsSearchResult>(preparedUrl);

            WriteObject(result.ClusterAuditLogs, true);
        }
        protected override void ProcessRecord()
        {
            var qb = new QuerystringBuilder();

            qb.Add("includeInactive", IncludeInactive);

            if (MatchAliasNames.IsPresent)
            {
                qb.Add("matchAliasNames", true.ToString());
            }

            if (ViewNames != null && ViewNames.Any())
            {
                qb.Add("viewNames", ViewNames);
            }

            if (ViewBoxIds != null && ViewBoxIds.Any())
            {
                qb.Add("viewBoxIds", ViewBoxIds);
            }

            if (ViewBoxNames != null && ViewBoxNames.Any())
            {
                qb.Add("viewBoxNames", ViewBoxNames);
            }

            if (MatchPartialNames.IsPresent)
            {
                qb.Add("matchPartialNames", true.ToString());
            }

            if (MaxCount.HasValue)
            {
                qb.Add("maxCount", MaxCount.Value);
            }

            if (MaxViewId.HasValue)
            {
                qb.Add("maxViewId", MaxViewId.Value);
            }

            if (JobIds != null && JobIds.Any())
            {
                qb.Add("jobIds", JobIds);
            }

            if (SortByLogicalUsage.IsPresent)
            {
                qb.Add("SortByLogicalUsage", true.ToString());
            }

            var preparedUrl = $"/public/views{qb.Build()}";
            var result      = Session.ApiClient.Get <GetViewsResult>(preparedUrl);

            WriteObject(result.Views, true);
        }
        protected override void ProcessRecord()
        {
            var qb = new QuerystringBuilder();

            if (Id.HasValue)
            {
                var url    = $"/public/protectionSources/objects/{Id.ToString()}";
                var result = Session.ApiClient.Get <Model.ProtectionSource>(url);
                WriteObject(result);
            }
            else
            {
                if (Environments != null && Environments.Any())
                {
                    List <string> environments =
                        Environments.ToList().ConvertAll <string>(x => x.ToString().First().ToString().ToLower() + x.ToString().Substring(1));
                    qb.Add("environments", string.Join(",", environments));
                }

                var url     = $"/public/protectionSources/rootNodes{qb.Build()}";
                var results = Session.ApiClient.Get <List <ProtectionSourceNode> >(url);

                // Get the list of all group nodes
                var groups = results.Where(x => x.RegistrationInfo == null).ToList();

                foreach (var group in groups)
                {
                    // Get children for each group node
                    qb = new QuerystringBuilder();
                    qb.Add("id", group.ProtectionSource.Id.ToString());
                    url = $"/public/protectionSources{qb.Build()}";
                    var children = Session.ApiClient.Get <List <ProtectionSourceNode> >(url);
                    children = FlattenNodes(children);

                    foreach (var child in children)
                    {
                        if (child.RegistrationInfo != null)
                        {
                            results.Add(child);
                        }
                    }
                }

                // Skip kView, kAgent, kPuppeteer environment types and group nodes themselves
                results = results.Where(x =>
                                        (x.ProtectionSource.Environment != Model.ProtectionSource.EnvironmentEnum.KAgent) &&
                                        (x.ProtectionSource.Environment != Model.ProtectionSource.EnvironmentEnum.KView) &&
                                        (x.ProtectionSource.Environment != Model.ProtectionSource.EnvironmentEnum.KPuppeteer) &&
                                        (x.RegistrationInfo != null)
                                        ).ToList();

                // Make sure each source id is only listed once as it might repeat under different environments
                var sources = results.GroupBy(x => x.ProtectionSource.Id).Select(y => y.FirstOrDefault());
                WriteObject(sources, true);
            }
        }
        protected override void ProcessRecord()
        {
            var qb = new QuerystringBuilder();

            qb.Add("viewNames", ViewName);

            var preparedUrl = $"/public/views{qb.Build()}";
            var result      = Session.ApiClient.Get <GetViewsResult>(preparedUrl);
            var view        = result.Views.Where(x => x.Name.Equals(ViewName)).FirstOrDefault();

            WriteObject(view.Aliases, true);
        }
示例#10
0
        /// <summary>
        /// Process Record
        /// </summary>
        protected override void ProcessRecord()
        {
            var qb = new QuerystringBuilder();

            if (ParentSourceId != null)
            {
                qb.Add("vCenterId", ParentSourceId.Value);
            }

            if (Names != null && Names.Any())
            {
                qb.Add("names", string.Join(",", Names));
            }

            if (Uuids != null && Uuids.Any())
            {
                qb.Add("uuids", string.Join(",", Uuids));
            }

            if (Unprotected.IsPresent && Protected.IsPresent)
            {
                throw new Exception("The parameters 'Unprotected' and 'Protected' can not be specified together");
            }

            if (Unprotected.IsPresent)
            {
                // Get a list of all the vms
                var url = $"/public/protectionSources/virtualMachines{ qb.Build()}";
                var vms = Session.ApiClient.Get <IEnumerable <Models.ProtectionSource> >(url);

                // Get a list of protected vms
                qb.Add("protected", true);
                url = $"/public/protectionSources/virtualMachines{ qb.Build()}";
                var protectedVms = Session.ApiClient.Get <IEnumerable <Models.ProtectionSource> >(url);

                // Return the vms that are not in the list of protected vms
                var result = vms.Where(x => !protectedVms.Any(y => x.Id == y.Id));

                WriteObject(result, true);
            }
            else
            {
                if (Protected.IsPresent)
                {
                    qb.Add("protected", true);
                }

                var url    = $"/public/protectionSources/virtualMachines{ qb.Build()}";
                var result = Session.ApiClient.Get <IEnumerable <Models.ProtectionSource> >(url);
                WriteObject(result, true);
            }
        }
        protected override void ProcessRecord()
        {
            var qb = new QuerystringBuilder();

            if (FetchStats.IsPresent)
            {
                qb.Add("fetchStats", true);
            }

            var preparedUrl = $"/public/cluster{qb.Build()}";
            var result      = Session.ApiClient.Get <Models.Cluster>(preparedUrl);

            WriteObject(result);
        }
        protected override void ProcessRecord()
        {
            var qb = new QuerystringBuilder();

            if (Id.HasValue)
            {
                var url    = $"/public/protectionSources/objects/{Id.ToString()}";
                var result = Session.ApiClient.Get <Model.ProtectionSource>(url);
                WriteObject(result);
            }
            else
            {
                if (IncludeDatastores.IsPresent)
                {
                    qb.Add("includeDatastores", true);
                }

                if (IncludeNetworks.IsPresent)
                {
                    qb.Add("includeNetworks", true);
                }

                if (IncludeVMFolders.IsPresent)
                {
                    qb.Add("includeVMFolders", true);
                }

                if (Environments != null && Environments.Any())
                {
                    List <string> envs = Environments.ToList().ConvertAll <string>(x => x.ToString().First().ToString().ToLower() + x.ToString().Substring(1));
                    qb.Add("environments", string.Join(",", envs));
                }

                if (ExcludeTypes != null && ExcludeTypes.Any())
                {
                    qb.Add("excludeTypes", ExcludeTypes);
                }

                var url     = $"/public/protectionSources{qb.Build()}";
                var results = Session.ApiClient.Get <IEnumerable <ProtectionSourceNode> >(url);
                results = FlattenNodes(results);

                // Extract ProtectionSource objects
                List <Model.ProtectionSource> sources = results.Select(x => x.ProtectionSource).ToList();

                WriteObject(sources, true);
            }
        }
示例#13
0
        /// <summary>
        /// Process Records
        /// </summary>
        protected override void ProcessRecord()
        {
            var qb = new QuerystringBuilder();

            if (Name != null && Name.Any())
            {
                qb.Add("name", string.Join(",", Name));
            }

            var preparedUrl = $"/public/privileges{qb.Build()}";

            WriteDebug(preparedUrl);
            var result = Session.ApiClient.Get <IEnumerable <Models.PrivilegeInfo> >(preparedUrl);

            WriteObject(result, true);
        }
        /// <summary>
        /// Process Records
        /// </summary>
        protected override void ProcessRecord()
        {
            var qb = new QuerystringBuilder();

            if (!string.IsNullOrWhiteSpace(Name))
            {
                qb.Add("name", Name);
            }

            var preparedUrl = $"/public/roles{qb.Build()}";

            WriteDebug(preparedUrl);
            var result = Session.ApiClient.Get <IEnumerable <Model.Role> >(preparedUrl);

            WriteObject(result, true);
        }
示例#15
0
        /// <summary>
        /// Process Record
        /// </summary>
        protected override void ProcessRecord()
        {
            var qb = new QuerystringBuilder();

            qb.Add("application", "kSQL");

            var url     = $"/public/protectionSources/applicationServers{ qb.Build()}";
            var results = Session.ApiClient.Get <IEnumerable <Models.RegisteredApplicationServer> >(url);

            var protectionSources = new List <Models.ProtectionSource>();

            if (results != null)
            {
                foreach (var result in results)
                {
                    protectionSources.Add(result.RegisteredProtectionSource);
                    protectionSources.Add(result.ApplicationServer.ProtectionSource);

                    if (result.ApplicationServer.ApplicationNodes != null)
                    {
                        foreach (var applicationNode in result.ApplicationServer.ApplicationNodes)
                        {
                            protectionSources.Add(applicationNode.ProtectionSource);

                            if (applicationNode.Nodes != null)
                            {
                                foreach (var node in applicationNode.Nodes)
                                {
                                    protectionSources.Add(node.ProtectionSource);
                                }
                            }
                        }
                    }
                }
            }

            // Only include kSQL environment type
            protectionSources = protectionSources.Where(x => x.Environment == Models.EnvironmentEnum.kSQL).ToList();

            // Make sure each source id is only listed once
            var sources = protectionSources.GroupBy(x => x.Id).Select(y => y.FirstOrDefault());

            WriteObject(sources, true);
        }
        protected override void ProcessRecord()
        {
            var qb = new QuerystringBuilder();

            if (Environments != null && Environments.Any())
            {
                qb.Add("environments", string.Join(",", Environments));
            }

            if (Ids != null && Ids.Any())
            {
                qb.Add("ids", string.Join(",", Ids));
            }

            if (Names != null && Names.Any())
            {
                qb.Add("names", string.Join(",", Names));
            }

            var preparedUrl = $"/public/protectionPolicies{qb.Build()}";
            var result      = Session.ApiClient.Get <IEnumerable <Models.ProtectionPolicy> >(preparedUrl);

            WriteObject(result, true);
        }
示例#17
0
        /// <summary>
        /// Process Record
        /// </summary>
        protected override void ProcessRecord()
        {
            var qb = new QuerystringBuilder();

            if (!string.IsNullOrWhiteSpace(JobName))
            {
                var job = RestApiCommon.GetProtectionJobByName(Session.ApiClient, JobName);
                JobId = job.Id;
            }

            if (JobId.HasValue && JobId != null)
            {
                qb.Add("jobId", JobId.Value);
            }

            if (StartedTime.HasValue && StartedTime != null)
            {
                qb.Add("startedTimeUsecs", StartedTime.Value);
            }

            if (EndTime.HasValue && EndTime != null)
            {
                qb.Add("endTimeUsecs", EndTime.Value);
            }

            if (NumRuns.HasValue && NumRuns != null)
            {
                qb.Add("numRuns", NumRuns.Value);
            }

            if (ExcludeTasks.IsPresent)
            {
                qb.Add("excludeTasks", true);
            }

            if (SourceId.HasValue && SourceId != null)
            {
                qb.Add("sourceId", SourceId.Value);
            }

            if (ExcludeErrorRuns.IsPresent)
            {
                qb.Add("excludeErrorRuns", true);
            }

            if (StartTime.HasValue && StartTime != null)
            {
                qb.Add("startTimeUsecs", StartTime.Value);
            }

            if (RunTypes != null && RunTypes.Any())
            {
                qb.Add("runTypes", string.Join(",", RunTypes));
            }

            if (ExcludeNonRestoreableRuns.IsPresent)
            {
                qb.Add("excludeNonRestoreableRuns", true);
            }

            var url     = $"/public/protectionRuns{ qb.Build()}";
            var results = Session.ApiClient.Get <IEnumerable <ProtectionRunInstance> >(url);

            // Hide deleted protection jobs unless explicitly asked for
            if (!IncludeDeleted.IsPresent)
            {
                results = results.Where(x => !(x.JobName.StartsWith("_DELETED"))).ToList();
            }
            WriteObject(results, true);
        }