Skip to content
This repository has been archived by the owner on Feb 5, 2023. It is now read-only.
/ msgraph.go Public archive
forked from yaegashi/msgraph.go

Microsoft Graph Client Library for Go

License

Notifications You must be signed in to change notification settings

mindstand/msgraph.go

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

73 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

msgraph.go

(Online reference generation is broken due to huge number of files in the package)

v1.0 beta
GoDoc GoDoc

Introduction

Microsoft Graph client library for Go. Still in PoC or pre-alpha stage. Don't use in production.

The library code is auto-generated from the REST API specification available at https://graph.microsoft.com/v1.0/$metadata.

The code generator is written in pure Go, in contrast to the official code generator heavily relying on C# and non-portable .NET Framework.

Changes

  • 2019-11-02 Library API breaking changes:
    • #1 every request method should take a ctx for the first arg
    • #2 package auth renamed to msauth and API changed

Usage

You can choose API version when importing msgraph package:

import msgraph "github.com/yaegashi/msgraph.go/v1.0"
import msgraph "github.com/yaegashi/msgraph.go/beta"

You could benefit from better IDE assisted coding experience because Graph API specs are completely translated to Go codes by msgraph.go.

Code examples in the repository:

Hacking

Run go generate ./gen to download the metadata and generate library code from it.

You need goimports to format outputs and fix imports of them.

$ go get golang.org/x/tools/cmd/goimports
$ rm gen/*.xml
$ go generate ./gen
2019/10/23 03:56:06 Downloading https://graph.microsoft.com/v1.0/$metadata to metadata-v1.0.xml
2019/10/23 03:56:07 Downloading https://graph.microsoft.com/beta/$metadata to metadata-beta.xml
2019/10/23 03:56:07 Creating directory ../v1.0
2019/10/23 03:56:07 Removing ../v1.0/InstallIntentEnum.go
2019/10/23 03:56:07 Removing ../v1.0/EditionUpgradeConfigurationModel.go
2019/10/23 03:56:07 Removing ../v1.0/AssignedPlanModel.go
...
2019/10/23 03:56:07 Creating ../v1.0/msgraph.go
2019/10/23 03:56:07 Creating ../v1.0/ActionStateEnum.go
2019/10/23 03:56:07 Creating ../v1.0/ActivityDomainEnum.go
...
2019/10/23 03:56:10 Formatting ../v1.0/ContentTypeModel.go ../v1.0/AuditLogRootRequest.go ../v1.0/DeviceComplianceScheduledActionForRuleRequest.go ...

Todo

  • Save indented metadata.xml
  • Support Action elements in metadata
  • Support Function elements in metadata
  • Support batch requests
  • Access to additional properties like @odata.type @odata.id
  • Split output into multiple files
  • Generate camel cases in golang manner (IpAddress -> IPAddress)
  • Provide easy way to generate pointers to literals
  • Provide easy way to generate pointers to constants
  • Provide easy way to add queries like $expand $select $filter
  • Every request method should take a ctx as the first arg for better control
  • Online API docs (the output is too big for godoc.org to handle)
  • Unit tests
  • CI
  • Persist OAuth2 tokens in file
  • OAuth2 device auth grant
  • OAuth2 client credentials grant
  • OAuth2 authorization code grant

References

About

Microsoft Graph Client Library for Go

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%