From afb090dc8389e3ef35a6840b2b08d408fa775329 Mon Sep 17 00:00:00 2001 From: ShocOne <62835948+ShocOne@users.noreply.github.com> Date: Thu, 20 Feb 2025 16:33:27 +0000 Subject: [PATCH] debugging --- .../ExportiOSUpdatesToJson.go | 8 +-- .../ExportmacOSUpdatesToJson.go | 4 +- examples/GetMacOSUpdates/GetMacOSUpdates.go | 6 +- examples/GetiOSUpdates/GetiOSUpdates.go | 6 +- sdk/{sofaios => sofa}/sofa_ios.go | 34 +++++----- sdk/{sofamacos => sofa}/sofa_macos.go | 62 +++++++++---------- 6 files changed, 59 insertions(+), 61 deletions(-) rename sdk/{sofaios => sofa}/sofa_ios.go (74%) rename sdk/{sofamacos => sofa}/sofa_macos.go (67%) diff --git a/examples/ExportiOSUpdatesToJson/ExportiOSUpdatesToJson.go b/examples/ExportiOSUpdatesToJson/ExportiOSUpdatesToJson.go index b9869fe..68e5137 100644 --- a/examples/ExportiOSUpdatesToJson/ExportiOSUpdatesToJson.go +++ b/examples/ExportiOSUpdatesToJson/ExportiOSUpdatesToJson.go @@ -1,6 +1,4 @@ -// main_ios.go -// Fetches iOS update data using the SOFA feed and exports to JSON file. - +// examples/ExportiOSUpdatesToJson/ExportiOSUpdatesToJson.go package main import ( @@ -10,13 +8,13 @@ import ( "os" "time" - "github.com/deploymenttheory/go-api-sdk-sofa/sdk/sofaios" + "github.com/deploymenttheory/go-api-sdk-sofa/sdk/sofa" ) func main() { fmt.Println("Fetching iOS updates...") - data, err := sofaios.GetiOSUpdates() + data, err := sofa.GetiOSUpdates() if err != nil { log.Fatalf("Error fetching iOS updates: %v", err) } diff --git a/examples/ExportmacOSUpdatesToJson/ExportmacOSUpdatesToJson.go b/examples/ExportmacOSUpdatesToJson/ExportmacOSUpdatesToJson.go index 8373d26..42c7914 100644 --- a/examples/ExportmacOSUpdatesToJson/ExportmacOSUpdatesToJson.go +++ b/examples/ExportmacOSUpdatesToJson/ExportmacOSUpdatesToJson.go @@ -10,13 +10,13 @@ import ( "os" "time" - "github.com/deploymenttheory/go-api-sdk-sofa/sdk/sofamacos" + "github.com/deploymenttheory/go-api-sdk-sofa/sdk/sofa" ) func main() { fmt.Println("Fetching iOS updates...") - data, err := sofamacos.GetMacOSUpdates() + data, err := sofa.GetMacOSUpdates() if err != nil { log.Fatalf("Error fetching iOS updates: %v", err) } diff --git a/examples/GetMacOSUpdates/GetMacOSUpdates.go b/examples/GetMacOSUpdates/GetMacOSUpdates.go index a420e1c..50636c2 100644 --- a/examples/GetMacOSUpdates/GetMacOSUpdates.go +++ b/examples/GetMacOSUpdates/GetMacOSUpdates.go @@ -1,4 +1,4 @@ -// main_ios.go +// GetMacOSUpdates.go // Fetches and displays full iOS update data using the SOFA feed. package main @@ -8,13 +8,13 @@ import ( "fmt" "log" - "github.com/deploymenttheory/go-api-sdk-sofa/sdk/sofamacos" + "github.com/deploymenttheory/go-api-sdk-sofa/sdk/sofa" ) func main() { fmt.Println("Fetching iOS updates...") - data, err := sofamacos.GetMacOSUpdates() + data, err := sofa.GetMacOSUpdates() if err != nil { log.Fatalf("Error fetching iOS updates: %v", err) } diff --git a/examples/GetiOSUpdates/GetiOSUpdates.go b/examples/GetiOSUpdates/GetiOSUpdates.go index f4f88de..c3b9b4e 100644 --- a/examples/GetiOSUpdates/GetiOSUpdates.go +++ b/examples/GetiOSUpdates/GetiOSUpdates.go @@ -1,4 +1,4 @@ -// main_ios.go +// GetiOSUpdates.go // Fetches and displays full iOS update data using the SOFA feed. package main @@ -8,13 +8,13 @@ import ( "fmt" "log" - "github.com/deploymenttheory/go-api-sdk-sofa/sdk/sofaios" + "github.com/deploymenttheory/go-api-sdk-sofa/sdk/sofa" ) func main() { fmt.Println("Fetching iOS updates...") - data, err := sofaios.GetiOSUpdates() + data, err := sofa.GetiOSUpdates() if err != nil { log.Fatalf("Error fetching iOS updates: %v", err) } diff --git a/sdk/sofaios/sofa_ios.go b/sdk/sofa/sofa_ios.go similarity index 74% rename from sdk/sofaios/sofa_ios.go rename to sdk/sofa/sofa_ios.go index a3a39cb..344ec75 100644 --- a/sdk/sofaios/sofa_ios.go +++ b/sdk/sofa/sofa_ios.go @@ -1,9 +1,9 @@ -// ios_updates_client.go +// sofa_ios.go // SOFA | A MacAdmin's Simple Organized Feed for Apple Software Updates // API reference: https://sofafeed.macadmins.io/v1/ios_data_feed.json // This client retrieves iOS update data in JSON format. -package sofaios +package sofa import ( "encoding/json" @@ -15,21 +15,21 @@ import ( // API Endpoint const uriAPIiOSUpdates = "https://sofafeed.macadmins.io/v1/ios_data_feed.json" -// Root represents the top-level structure of the iOS update feed response -type Root struct { - UpdateHash string `json:"UpdateHash"` - OSVersions []OSVersion `json:"OSVersions"` +// ResourceSofaiOSRoot represents the top-level structure of the iOS update feed response +type ResourceSofaiOSRoot struct { + UpdateHash string `json:"UpdateHash"` + OSVersions []iOSVersion `json:"OSVersions"` } -// OSVersion represents an iOS version entry -type OSVersion struct { - OSVersion string `json:"OSVersion"` - Latest ReleaseInfo `json:"Latest"` - SecurityReleases []SecurityUpdate `json:"SecurityReleases"` +// iOSVersion represents an iOS version entry +type iOSVersion struct { + OSVersion string `json:"OSVersion"` + Latest iOSReleaseInfo `json:"Latest"` + SecurityReleases []iOSSecurityUpdate `json:"SecurityReleases"` } -// ReleaseInfo represents the latest release details -type ReleaseInfo struct { +// iOSReleaseInfo represents the latest release details +type iOSReleaseInfo struct { ProductVersion string `json:"ProductVersion"` Build string `json:"Build"` ReleaseDate string `json:"ReleaseDate"` @@ -41,8 +41,8 @@ type ReleaseInfo struct { CVEs map[string]bool `json:"CVEs"` } -// SecurityUpdate represents security updates for an iOS version -type SecurityUpdate struct { +// iOSSecurityUpdate represents security updates for an iOS version +type iOSSecurityUpdate struct { UpdateName string `json:"UpdateName"` ProductName string `json:"ProductName"` ProductVersion string `json:"ProductVersion"` @@ -57,7 +57,7 @@ type SecurityUpdate struct { } // GetiOSUpdates fetches iOS update data from the API -func GetiOSUpdates() (*Root, error) { +func GetiOSUpdates() (*ResourceSofaiOSRoot, error) { client := &http.Client{Timeout: 10 * time.Second} resp, err := client.Get(uriAPIiOSUpdates) if err != nil { @@ -69,7 +69,7 @@ func GetiOSUpdates() (*Root, error) { return nil, fmt.Errorf("unexpected response code: %d", resp.StatusCode) } - var data Root + var data ResourceSofaiOSRoot if err := json.NewDecoder(resp.Body).Decode(&data); err != nil { return nil, fmt.Errorf("failed to decode response: %w", err) } diff --git a/sdk/sofamacos/sofa_macos.go b/sdk/sofa/sofa_macos.go similarity index 67% rename from sdk/sofamacos/sofa_macos.go rename to sdk/sofa/sofa_macos.go index a7d5c49..0bdbec0 100644 --- a/sdk/sofamacos/sofa_macos.go +++ b/sdk/sofa/sofa_macos.go @@ -1,9 +1,9 @@ -// macos_updates_client.go +// sofa_macos.go // SOFA | A MacAdmin's Simple Organized Feed for Apple Software Updates // API reference: https://sofafeed.macadmins.io/v1/macos_data_feed.json // This client retrieves macOS update data in JSON format. -package sofamacos +package sofa import ( "encoding/json" @@ -15,26 +15,26 @@ import ( // API Endpoint const uriAPIMacOSUpdates = "https://sofafeed.macadmins.io/v1/macos_data_feed.json" -// Root represents the top-level structure of the macOS update feed response -type Root struct { - UpdateHash string `json:"UpdateHash"` - OSVersions []OSVersion `json:"OSVersions"` - XProtectPayloads XProtectPayloads `json:"XProtectPayloads"` - XProtectPlistConfig XProtectPlistConfigData `json:"XProtectPlistConfigData"` - Models map[string]Model `json:"Models"` - InstallationApps InstallationApps `json:"InstallationApps"` +// ResourceSofamacOSRoot represents the top-level structure of the macOS update feed response +type ResourceSofamacOSRoot struct { + UpdateHash string `json:"UpdateHash"` + OSVersions []macOSVersion `json:"OSVersions"` + XProtectPayloads macOSXProtectPayloads `json:"XProtectPayloads"` + XProtectPlistConfig macOSXProtectPlistConfigData `json:"XProtectPlistConfigData"` + Models map[string]macOSModel `json:"Models"` + InstallationApps InstallationApps `json:"InstallationApps"` } -// OSVersion represents an operating system version -type OSVersion struct { - OSVersion string `json:"OSVersion"` - Latest ReleaseInfo `json:"Latest"` - SecurityReleases []SecurityRelease `json:"SecurityReleases"` - SupportedModels []SupportedModel `json:"SupportedModels"` +// macOSVersion represents an operating system version +type macOSVersion struct { + OSVersion string `json:"OSVersion"` + Latest macOSReleaseInfo `json:"Latest"` + SecurityReleases []macOSSecurityRelease `json:"SecurityReleases"` + SupportedModels []macOSSupportedModel `json:"SupportedModels"` } -// ReleaseInfo represents the latest release information -type ReleaseInfo struct { +// macOSReleaseInfo represents the latest release information +type macOSReleaseInfo struct { ProductVersion string `json:"ProductVersion"` Build string `json:"Build"` ReleaseDate string `json:"ReleaseDate"` @@ -46,8 +46,8 @@ type ReleaseInfo struct { UniqueCVEsCount int `json:"UniqueCVEsCount"` } -// SecurityRelease represents a security update -type SecurityRelease struct { +// macOSSecurityRelease represents a security update +type macOSSecurityRelease struct { UpdateName string `json:"UpdateName"` ProductName string `json:"ProductName"` ProductVersion string `json:"ProductVersion"` @@ -61,41 +61,41 @@ type SecurityRelease struct { DaysSincePreviousRelease int `json:"DaysSincePreviousRelease"` } -// SupportedModel represents Mac models supported for an OS version -type SupportedModel struct { +// macOSSupportedModel represents Mac models supported for an OS version +type macOSSupportedModel struct { Model string `json:"Model"` URL string `json:"URL"` Identifiers map[string]string `json:"Identifiers"` } -// XProtectPayloads represents security update configurations -type XProtectPayloads struct { +// macOSXProtectPayloads represents security update configurations +type macOSXProtectPayloads struct { XProtectFramework string `json:"com.apple.XProtectFramework.XProtect"` PluginService string `json:"com.apple.XprotectFramework.PluginService"` ReleaseDate string `json:"ReleaseDate"` } // XProtectPlistConfigData represents the XProtect configuration data -type XProtectPlistConfigData struct { +type macOSXProtectPlistConfigData struct { XProtect string `json:"com.apple.XProtect"` ReleaseDate string `json:"ReleaseDate"` } -// Model represents a Mac model with supported OS versions -type Model struct { +// macOSModel represents a Mac model with supported OS versions +type macOSModel struct { MarketingName string `json:"MarketingName"` SupportedOS []string `json:"SupportedOS"` OSVersions []int `json:"OSVersions"` } -// InstallationApps represents available macOS installation apps +// macOSInstallationApps represents available macOS installation apps type InstallationApps struct { LatestUMA AppEntry `json:"LatestUMA"` AllPreviousUMA []AppEntry `json:"AllPreviousUMA"` LatestMacIPSW MacIPSW `json:"LatestMacIPSW"` } -// AppEntry represents an application entry for macOS installation +// macOSAppEntry represents an application entry for macOS installation type AppEntry struct { Title string `json:"title"` Version string `json:"version"` @@ -113,7 +113,7 @@ type MacIPSW struct { } // GetMacOSUpdates fetches macOS update data from the API -func GetMacOSUpdates() (*Root, error) { +func GetMacOSUpdates() (*ResourceSofamacOSRoot, error) { client := &http.Client{Timeout: 10 * time.Second} resp, err := client.Get(uriAPIMacOSUpdates) if err != nil { @@ -125,7 +125,7 @@ func GetMacOSUpdates() (*Root, error) { return nil, fmt.Errorf("unexpected response code: %d", resp.StatusCode) } - var data Root + var data ResourceSofamacOSRoot if err := json.NewDecoder(resp.Body).Decode(&data); err != nil { return nil, fmt.Errorf("failed to decode response: %w", err) }