GitHub.Meta.psm1

[Cmdletbinding()]
param()

$scriptName = $MyInvocation.MyCommand.Name
Write-Verbose "[$scriptName] Importing subcomponents"

#region - Data import
Write-Verbose "[$scriptName] - [data] - Processing folder"
$dataFolder = (Join-Path $PSScriptRoot 'data')
Write-Verbose "[$scriptName] - [data] - [$dataFolder]"
Get-ChildItem -Path "$dataFolder" -Recurse -Force -Include '*.psd1' -ErrorAction SilentlyContinue | ForEach-Object {
    Write-Verbose "[$scriptName] - [data] - [$($_.Name)] - Importing"
    New-Variable -Name $_.BaseName -Value (Import-PowerShellDataFile -Path $_.FullName) -Force
    Write-Verbose "[$scriptName] - [data] - [$($_.Name)] - Done"
}

Write-Verbose "[$scriptName] - [data] - Done"
#endregion - Data import

#region - From public
Write-Verbose "[$scriptName] - [public] - Processing folder"

#region - From public/Meta
Write-Verbose "[$scriptName] - [public/Meta] - Processing folder"

#region - From public/Meta/Get-GitHubApiVersions.ps1
Write-Verbose "[$scriptName] - [public/Meta/Get-GitHubApiVersions.ps1] - Importing"

#Requires -Modules GitHub

function Get-GitHubApiVersions {
    <#
        .SYNOPSIS
        Get all API versions.

        .DESCRIPTION
        Get all supported GitHub API versions.

        .EXAMPLE
        Get-GitHubApiVersions

        Get all supported GitHub API versions.

        .NOTES
        https://docs.github.com/rest/meta/meta#get-all-api-versions
    #>

    [OutputType([string[]])]
    [CmdletBinding()]
    param ()

    $inputObject = @{
        ApiEndpoint = '/versions'
        Method      = 'GET'
    }

    $response = Invoke-GitHubAPI @inputObject

    $response
}

Write-Verbose "[$scriptName] - [public/Meta/Get-GitHubApiVersions.ps1] - Done"
#endregion - From public/Meta/Get-GitHubApiVersions.ps1
#region - From public/Meta/Get-GitHubMeta.ps1
Write-Verbose "[$scriptName] - [public/Meta/Get-GitHubMeta.ps1] - Importing"

#Requires -Modules GitHub

function Get-GitHubMeta {
    <#
        .SYNOPSIS
        Get GitHub meta information.

        .DESCRIPTION
        Returns meta information about GitHub, including a list of GitHub's IP addresses. For more information, see "[About GitHub's IP addresses](https://docs.github.com/articles/about-github-s-ip-addresses/)."

        The API's response also includes a list of GitHub's domain names.

        The values shown in the documentation's response are example values. You must always query the API directly to get the latest values.

        **Note:** This endpoint returns both IPv4 and IPv6 addresses. However, not all features support IPv6. You should refer to the specific documentation for each feature to determine if IPv6 is supported.

        .EXAMPLE
        Get-GitHubMeta

        Returns meta information about GitHub, including a list of GitHub's IP addresses.

        .NOTES
        https://docs.github.com/rest/meta/meta#get-apiname-meta-information
    #>

    [OutputType([object])]
    [CmdletBinding()]
    param ()

    $inputObject = @{
        ApiEndpoint = '/meta'
        Method      = 'GET'
    }

    $response = Invoke-GitHubAPI @inputObject

    $response
}

Write-Verbose "[$scriptName] - [public/Meta/Get-GitHubMeta.ps1] - Done"
#endregion - From public/Meta/Get-GitHubMeta.ps1
#region - From public/Meta/Get-GitHubOctocat.ps1
Write-Verbose "[$scriptName] - [public/Meta/Get-GitHubOctocat.ps1] - Importing"

#Requires -Modules GitHub

function Get-GitHubOctocat {
    <#
        .SYNOPSIS
        Get Octocat.

        .DESCRIPTION
        Get the octocat as ASCII art.

        .EXAMPLE
        Get-GitHubOctocat

        Get the octocat as ASCII art

        .EXAMPLE
        Get-GitHubOctocat -S 'The glass is never half empty. It's just twice as big as it needs to be.'

        Get the octocat as ASCII art with a custom saying

        .NOTES
        https://docs.github.com/rest/meta/meta#get-octocat
    #>

    [OutputType([string])]
    [CmdletBinding()]
    param (
        # The words to show in Octocat's speech bubble
        [Parameter()]
        [Alias('Say')]
        [Alias('Saying')]
        [string]
        $S = "The glass is never half empty. Its just twice as big as it needs to be."
    )

    # $query = [System.Web.HttpUtility]::UrlEncode($S)
    # $query = [System.Uri]::EscapeDataString($S)

    $body = @{
        s = $S
    }

    $inputObject = @{
        APIEndpoint = "/octocat"
        Method      = 'GET'
        Body        = $body
    }

    $response = Invoke-GitHubAPI @inputObject

    $response
}

Write-Verbose "[$scriptName] - [public/Meta/Get-GitHubOctocat.ps1] - Done"
#endregion - From public/Meta/Get-GitHubOctocat.ps1
#region - From public/Meta/Get-GitHubRoot.ps1
Write-Verbose "[$scriptName] - [public/Meta/Get-GitHubRoot.ps1] - Importing"

#Requires -Modules GitHub

function Get-GitHubRoot {
    <#
        .SYNOPSIS
        GitHub API Root.

        .DESCRIPTION
        Get Hypermedia links to resources accessible in GitHub's REST API.

        .EXAMPLE
        Get-GitHubRoot

        Get the root endpoint for the GitHub API.

        .NOTES
        https://docs.github.com/rest/meta/meta#github-api-root
    #>

    [CmdletBinding()]
    param ()

    $InputObject = @{
        APIEndpoint = '/'
        Method      = 'GET'
    }

    $response = Invoke-GitHubAPI @InputObject

    $response
}

Write-Verbose "[$scriptName] - [public/Meta/Get-GitHubRoot.ps1] - Done"
#endregion - From public/Meta/Get-GitHubRoot.ps1
#region - From public/Meta/Get-GitHubZen.ps1
Write-Verbose "[$scriptName] - [public/Meta/Get-GitHubZen.ps1] - Importing"

#Requires -Modules GitHub

function Get-GitHubZen {
    <#
    .SYNOPSIS
    Get the Zen of GitHub.

    .DESCRIPTION
    Get a random sentence from the Zen of GitHub.

    .EXAMPLE
    Get-GitHubZen

    Get a random sentence from the Zen of GitHub.

    .NOTES
    https://docs.github.com/rest/meta/meta#get-the-zen-of-github
    #>

    [CmdletBinding()]
    param ()

    $InputObject = @{
        APIEndpoint = '/zen'
        Method      = 'GET'
    }

    $Response = Invoke-GitHubAPI @InputObject

    $Response
}

Write-Verbose "[$scriptName] - [public/Meta/Get-GitHubZen.ps1] - Done"
#endregion - From public/Meta/Get-GitHubZen.ps1

Write-Verbose "[$scriptName] - [public/Meta] - Done"
#endregion - From public/Meta


Write-Verbose "[$scriptName] - [public] - Done"
#endregion - From public

#region - From GitHub.Meta.ps1
Write-Verbose "[$scriptName] - [GitHub.Meta.ps1] - Importing"

$scriptFilePath = $MyInvocation.MyCommand.Path

Write-Verbose "[$scriptFilePath] - Initializing GitHub module..." -Verbose
Write-Verbose "[$scriptName] - [GitHub.Meta.ps1] - Done"
#endregion - From GitHub.Meta.ps1

Export-ModuleMember -Function 'Get-GitHubApiVersions','Get-GitHubMeta','Get-GitHubOctocat','Get-GitHubRoot','Get-GitHubZen' -Cmdlet '' -Variable '' -Alias '*'