Giter Site home page Giter Site logo

go-jamf-api's Introduction

Jamf API in Go

Mostly implemented Golang library for the Jamf Pro API.

The Classic API support is written manually, UAPI support is written programmatically using the OpenAPI Generator based upon the publicly available swagger docs.

Classic API Usage

Example Code

package main

import (
	"fmt"
	"time"
    "log"

	"github.com/yohan460/go-jamf-api"
)

func main() {
	url := "https://example.jamfcloud.com"
	client, err := jamf.NewClient(
        url,
        jamf.WithOAuth("client-id", "client-secret"),
    )
	if err != nil {
		log.Fatal(err)
	}

	// Use the client to make requests to the Jamf API
}

UAPI Usage

See Usage docs

UAPI Regeneration

When there is a Jamf UAPI schema upgrade the generate-api.sh file can be run with the new swagger schema as the first parameter to re-generate it

The script contains a couple of patches to ensure it is syntactically correct go code.

go-jamf-api's People

Contributors

caboose1984 avatar forevanyeung avatar jc0b avatar johanmcgwire-cb avatar sioncojp avatar yohan460 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

go-jamf-api's Issues

UpdateComputerInventoryDetailByID issue

Hi, thanks for the nice package.
I have a problem when using the UpdateComputerInventoryDetailByID function since it requires a structure
ComputerInventory as the input.
The problem is that if I take a simple scenario where I only want to change Name filed for example:

ComputerInventoryDataSubsetGeneral{
		Name: "TEST",
}

After calling UpdateComputerInventoryDetailByID with such struct it will pass to JAMF (PATCH /api/v1/computers-inventory-detail) at least such JSON:

{"name":"TEST","remoteManagement":{},"reportDate":"0001-01-01T00:00:00Z","lastContactTime":"0001-01-01T00:00:00Z","lastCloudBackupDate":"0001-01-01T00:00:00Z","lastEnrolledDate":"0001-01-01T00:00:00Z","mdmProfileExpiration":"0001-01-01T00:00:00Z"}

Jamf server will return HTTP 400 in this case.

But if you will look into Jamf docs about which fields actually can be passed via API (https://developer.jamf.com/jamf-pro/reference/patch_v1-computers-inventory-detail-id) you can see that there no way to update anything.

Only idea which i can suggest here it allow to pass into NewClient pointer to custom json marshal unmarshal functions which will add flexibility to solve this issue since wrote own marshal function more correct way for me. Of course i can implement own function and call DoRequest directly as workaround with custom JSON.

New API URL and pagesize limitations for Jamf Pro API

Hi,

This is a followup of Yohan460/terraform-provider-jamf#13

Not sure about that but it seems that API URLs used in this project are https://instance.jamfcloud.com/uapi/vX/... instead of https://instance.jamfcloud.com/api/vX/...

Also: for some endpoints in new Jamf Pro API (like categories for example), there is a page size limit. I did not have any issues with that but you could not list more than 2000 object per page (Jamf Pro limitation), and the default is 100.
I don't know if this has been taken in account.

Ref.: https://learn.jamf.com/en-US/bundle/technical-articles/page/Recovery_Lock_Enablement_in_macOS_Using_the_Jamf_Pro_API.html in Obtaining the Management ID

Recovery_Lock_Enablement_in_macOS_Using_the_Jamf_Pro_API_-_Technical_Articles___Jamf

Unmarshall issue on ComputerDataSubsetSoftware structure

Hello,

When trying to unmarshall the return body for JSSResource/computers/id/295/subset/General&Hardware&Location&Software, I got an error when processing the ComputerDataSubsetSoftware structure.

The error is:
xml: invalid tag in field Text of type struct { Text string \"xml:\\\",chardata,omitempty\\\"\"; Name string \"xml:\\\"name,omitempty\\\"\"; PackageName string \"xml:\\\"package_name,omitempty\\\"\"; Version string \"xml:\\\"version,omitempty\\\"\" }: \",chardata,omitempty\"

After analysis, it appears that the Text field may not be present (this is correctly managed by the omitempty), but the associated name starts by a comma ,chardata

Removing the extra comma allow to solve this issue.

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.