Skip to content

Commit

Permalink
debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
ShocOne committed Feb 20, 2025
1 parent 5d51097 commit afb090d
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 61 deletions.
8 changes: 3 additions & 5 deletions examples/ExportiOSUpdatesToJson/ExportiOSUpdatesToJson.go
Original file line number Diff line number Diff line change
@@ -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 (
Expand All @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions examples/ExportmacOSUpdatesToJson/ExportmacOSUpdatesToJson.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
6 changes: 3 additions & 3 deletions examples/GetMacOSUpdates/GetMacOSUpdates.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// main_ios.go
// GetMacOSUpdates.go
// Fetches and displays full iOS update data using the SOFA feed.

package main
Expand All @@ -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)
}
Expand Down
6 changes: 3 additions & 3 deletions examples/GetiOSUpdates/GetiOSUpdates.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// main_ios.go
// GetiOSUpdates.go
// Fetches and displays full iOS update data using the SOFA feed.

package main
Expand All @@ -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)
}
Expand Down
34 changes: 17 additions & 17 deletions sdk/sofaios/sofa_ios.go → sdk/sofa/sofa_ios.go
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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"`
Expand All @@ -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"`
Expand All @@ -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 {
Expand All @@ -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)
}
Expand Down
62 changes: 31 additions & 31 deletions sdk/sofamacos/sofa_macos.go → sdk/sofa/sofa_macos.go
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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"`
Expand All @@ -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"`
Expand All @@ -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"`
Expand All @@ -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 {
Expand All @@ -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)
}
Expand Down

0 comments on commit afb090d

Please sign in to comment.