{"id":17867134,"url":"https://github.com/cdhunt/clc-powershell","last_synced_at":"2025-04-02T22:23:37.474Z","repository":{"id":145808788,"uuid":"41631692","full_name":"cdhunt/clc-powershell","owner":"cdhunt","description":"PowerShell Module for interfacing with CenturyLink Cloud API","archived":false,"fork":false,"pushed_at":"2015-12-03T14:34:47.000Z","size":15,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-08T12:46:39.812Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cdhunt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-08-30T14:34:57.000Z","updated_at":"2016-10-13T15:41:47.000Z","dependencies_parsed_at":"2023-04-14T22:15:12.496Z","dependency_job_id":null,"html_url":"https://github.com/cdhunt/clc-powershell","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdhunt%2Fclc-powershell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdhunt%2Fclc-powershell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdhunt%2Fclc-powershell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdhunt%2Fclc-powershell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cdhunt","download_url":"https://codeload.github.com/cdhunt/clc-powershell/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246900937,"owners_count":20852134,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-28T09:44:16.421Z","updated_at":"2025-04-02T22:23:37.457Z","avatar_url":"https://github.com/cdhunt.png","language":"PowerShell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# clc-powershell\nPowerShell Module for interfacing with CenturyLink Cloud API\n\n\n\n# Install \n\nTo install in your personal modules folder (e.g. ~\\Documents\\WindowsPowerShell\\Modules), run:\n\n```powershell\niex (new-object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/cdhunt/clc-powershell/master/install.ps1')\n```\n\n# Examples\n\n## New Servers\n\n```powershell\n$servers = @()\n\n$servers += [pscustomobject]@{name = \"one\"\n            description = \"powershell FTW\"\n            groupId = '461c0497899e4f49b398987a310383db'\n            sourceServerid = 'CENTOS-6-64-TEMPLATE'\n            cpu = 4\n            memoryGB = 16\n            type = \"standard\"\n            additionalDisks = @{path=\"data\"; sizeGB=200; type=\"partitioned\"}\n            managedOS = $true\n            StorageType = 'standard'}\n\n$servers += [pscustomobject]@{name = \"two\"\n            description = \"powershell FTW\"\n            groupId = '0e8a572112f547339eb0945ca1d50af0'\n            sourceServerid = 'CENTOS-6-64-TEMPLATE'\n            cpu = 1\n            memoryGB = 2\n            type = \"standard\"\n            additionalDisks = @(@{path=\"data\"; sizeGB=50; type=\"partitioned\"})}\n\n$servers | New-ClcServer\n```\n\n## Usage Report\n\nHere is an example script that utilizes this module to get Group and Server details.\n\n```powershell\n$auth = Get-ClcAuthenticationHeader user.name\n$dc = Get-CLCDataCenter -Authentication $auth -AccountAlias ABC -DataCenter VA1 -GroupLink\n$groups = $dc | Expand-ClcLink -Relation group -Authentication $auth\n$servers = $groups.groups.where({$_.name -eq 'Default Group'}).groups | Expand-ClcLink -Relation server -Authentication $auth\n\n$report = foreach ($server in $servers) \n{\n    $billingDetail = $server | Expand-ClcLink -Relation billing -Authentication $auth\n    \n    $ipAddress = $server.details | Select-Object -ExpandProperty ipAddresses -First 1 | Select-Object -ExpandProperty internal\n    $publicAddress = $server.details | Select-Object -ExpandProperty ipAddresses -First 1 | Select-Object -ExpandProperty public -ErrorAction SilentlyContinue\n    $cpu = $server.details.cpu\n    $memoryMB = $server.details.memoryMB\n    $storageGB = $server.details.storageGB\n\n    $hours = 720\n    $cpuCost = $billingDetail.cpu * $cpu * $hours\n    $memoryCost = $billingDetail.memoryGB * ($memoryMB/1024) * $hours\n    $storageCost = $billingDetail.storageGB * $storageGB * $hours\n    $manageCosts = $billingDetail.managedOS  * $hours\n\n    $server | Select-Object Name, \n                            status, \n                            type, \n                            osType, \n                            storageType, \n                            @{N='ipAddress';E={$ipAddress}}, \n                            @{N='cpu';E={$cpu}}, \n                            @{N='memoryMB';E={$memoryMB}}, \n                            @{N='storageGB';E={$storageGB}},\n                            @{N='costPerMonth';E={[Math]::Round( ($cpuCost + $memoryCost + $storageCost + $manageCosts), 2)}} |\n                Write-Output\n}\n\n$sum = $report | Measure-Object -Property cpu, memoryMB, storageGB, costPerMonth -Sum\n$cpuTotal = $sum.Where({$_.Property -eq 'cpu'}).Sum\n$memoryTotal = $sum.Where({$_.Property -eq 'memoryMB'}).Sum\n$storageTotal = $sum.Where({$_.Property -eq 'storageGB'}).Sum\n$costTotal = $sum.Where({$_.Property -eq 'costPerMonth'}).Sum\n\n$report += [PSCustomObject]@{name=\"TOTAL\"\n                             status='-'\n                             type='-'\n                             osType='-'\n                             storageType='-'\n                             ipAddress='-'\n                             cpu = $cpuTotal\n                             memoryMB = $memoryTotal\n                             storageGB = $storageTotal\n                             costPerMonth= $costTotal }\n\n$report | Format-Table -AutoSize\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcdhunt%2Fclc-powershell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcdhunt%2Fclc-powershell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcdhunt%2Fclc-powershell/lists"}