public override void ExecuteCmdlet()
        {
            if (ParameterSetName == ByWorkspaceObjectByName || ParameterSetName == ByWorkspaceObjectByKind)
            {
                ResourceGroupName = Workspace.ResourceGroupName;
                WorkspaceName     = Workspace.Name;
            }

            if (ParameterSetName == ByWorkspaceObjectByName || ParameterSetName == ByWorkspaceNameByName)
            {
                try
                {
                    var dataSource = OperationalInsightsClient.GetDataSource(ResourceGroupName, WorkspaceName, Name);
                    WriteObject(dataSource, true);
                }
                catch (CloudException e)
                {
                    // Get throws NotFound exception if workspace does not exist
                    if (e.Response.StatusCode == HttpStatusCode.NotFound)
                    {
                        return;
                    }

                    throw;
                }
                return;
            }

            if (ParameterSetName == ByWorkspaceObjectByKind || ParameterSetName == ByWorkspaceNameByKind)
            {
                WriteObject(OperationalInsightsClient.FilterPSDataSources(ResourceGroupName, WorkspaceName, Kind), true);
                return;
            }
        }
Example #2
0
        public override void ExecuteCmdlet()
        {
            if (ParameterSetName == ByWorkspaceName)
            {
                WriteWarning(Properties.Resources.GetWorkspaceDataSourceParameterSetWarning);
                return;
            }
            if (ParameterSetName == ByWorkspaceObjectByName || ParameterSetName == ByWorkspaceObjectByKind)
            {
                ResourceGroupName = Workspace.ResourceGroupName;
                WorkspaceName     = Workspace.Name;
            }

            if (ParameterSetName == ByWorkspaceObjectByName || ParameterSetName == ByWorkspaceNameByName)
            {
                try
                {
                    var dataSource = OperationalInsightsClient.GetDataSource(ResourceGroupName, WorkspaceName, Name);
                    WriteObject(dataSource, true);
                }
                catch (Microsoft.Rest.Azure.CloudException e)
                {
                    // Get throws NotFound exception if workspace does not exist
                    if (e.Response.StatusCode == HttpStatusCode.NotFound)
                    {
                        return;
                    }

                    throw;
                }
                return;
            }

            if (ParameterSetName == ByWorkspaceObjectByKind || ParameterSetName == ByWorkspaceNameByKind)
            {
                if (Kind == PSDataSourceKinds.AzureAuditLog)
                {
                    WriteWarning(Properties.Resources.DeprecateAzureAuditLogDataSource);
                    return;
                }
                WriteObject(OperationalInsightsClient.FilterPSDataSources(ResourceGroupName, WorkspaceName, Kind), true);
                return;
            }
        }
        public override void ExecuteCmdlet()
        {
            if (ParameterSetName == ByWorkspaceObjectByName || ParameterSetName == ByWorkspaceObjectByKind)
            {
                ResourceGroupName = Workspace.ResourceGroupName;
                WorkspaceName     = Workspace.Name;
            }

            if (ParameterSetName == ByWorkspaceObjectByName || ParameterSetName == ByWorkspaceNameByName)
            {
                WriteObject(OperationalInsightsClient.GetDataSource(ResourceGroupName, WorkspaceName, Name), true);
                return;
            }

            if (ParameterSetName == ByWorkspaceObjectByKind || ParameterSetName == ByWorkspaceNameByKind)
            {
                WriteObject(OperationalInsightsClient.FilterPSDataSources(ResourceGroupName, WorkspaceName, Kind), true);
                return;
            }
        }