Skip to content

wolveix/fleet-go

Repository files navigation

Fleet Go SDK

Go SDK for interacting with the Fleet API.

Note: this is incomplete, as I only implemented what I needed (+ low-hanging fruit). PRs welcome!.

Usage

You can retrieve your API key via: https://fleetdm.com/docs/rest-api/rest-api#retrieve-your-api-token

package main

import (
	"fmt"
	"log"
	"time"

	"github.com/wolveix/fleet-go"
)

func main() {
	key := "your_api_key_here"
	service := fleet.New("https://your.fleet.domain", key, 15*time.Second, false)

	user, err := service.FindMe()
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(user.Email)
}

Retrieve Hosts

package main

import (
	"fmt"
	"log"
	"time"

	"github.com/wolveix/fleet-go"
)

func main() {
	key := "your_api_key_here"
	service := fleet.New("https://your.fleet.domain", key, 15*time.Second, false)

	hosts, err := service.FindHosts()
	if err != nil {
		log.Fatal(err)
	}
	
	for _, host := range hosts {
		fmt.Printf("Host details:\n- Hostname: %s\n- OS Version: %s\n\n", host.Hostname, host.OSVersion)
    }
}

License

BSD licensed. See the LICENSE file for details.

About

A library to interface with FleetDM's API

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages