Remove replace directives and use own fork to make go get work again (#1028)

See https://github.com/golang/go/issues/30354
go get doesn't honor the go.mod replace options.
This commit is contained in:
Wim
2020-03-08 17:08:18 +01:00
committed by GitHub
parent 2a0bc11b68
commit 9785edd263
3308 changed files with 291 additions and 291 deletions

14
vendor/github.com/matterbridge/discordgo/.travis.yml generated vendored Normal file
View File

@@ -0,0 +1,14 @@
language: go
go:
- 1.9.x
- 1.10.x
- 1.11.x
install:
- go get github.com/bwmarrin/discordgo
- go get -v .
- go get -v golang.org/x/lint/golint
script:
- diff <(gofmt -d .) <(echo -n)
- go vet -x ./...
- golint -set_exit_status ./...
- go test -v -race ./...

28
vendor/github.com/matterbridge/discordgo/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,28 @@
Copyright (c) 2015, Bruce Marriner
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of discordgo nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

130
vendor/github.com/matterbridge/discordgo/README.md generated vendored Normal file
View File

@@ -0,0 +1,130 @@
# DiscordGo
[![GoDoc](https://godoc.org/github.com/bwmarrin/discordgo?status.svg)](https://godoc.org/github.com/bwmarrin/discordgo) [![Go report](http://goreportcard.com/badge/bwmarrin/discordgo)](http://goreportcard.com/report/bwmarrin/discordgo) [![Build Status](https://travis-ci.org/bwmarrin/discordgo.svg?branch=master)](https://travis-ci.org/bwmarrin/discordgo) [![Discord Gophers](https://img.shields.io/badge/Discord%20Gophers-%23discordgo-blue.svg)](https://discord.gg/0f1SbxBZjYoCtNPP) [![Discord API](https://img.shields.io/badge/Discord%20API-%23go_discordgo-blue.svg)](https://discordapp.com/invite/discord-api)
<img align="right" src="http://bwmarrin.github.io/discordgo/img/discordgo.png">
DiscordGo is a [Go](https://golang.org/) package that provides low level
bindings to the [Discord](https://discordapp.com/) chat client API. DiscordGo
has nearly complete support for all of the Discord API endpoints, websocket
interface, and voice interface.
If you would like to help the DiscordGo package please use
[this link](https://discordapp.com/oauth2/authorize?client_id=173113690092994561&scope=bot)
to add the official DiscordGo test bot **dgo** to your server. This provides
indispensable help to this project.
* See [dgVoice](https://github.com/bwmarrin/dgvoice) package for an example of
additional voice helper functions and features for DiscordGo.
* See [dca](https://github.com/bwmarrin/dca) for an **experimental** stand alone
tool that wraps `ffmpeg` to create opus encoded audio appropriate for use with
Discord (and DiscordGo).
**For help with this package or general Go discussion, please join the [Discord
Gophers](https://discord.gg/0f1SbxBZjYq9jLBk) chat server.**
## Getting Started
### master vs develop Branch
* The master branch represents the latest released version of DiscordGo. This
branch will always have a stable and tested version of the library. Each release
is tagged and you can easily download a specific release and view release notes
on the github [releases](https://github.com/bwmarrin/discordgo/releases) page.
* The develop branch is where all development happens and almost always has
new features over the master branch. However breaking changes are frequently
added to develop and even sometimes bugs are introduced. Bugs get fixed and
the breaking changes get documented before pushing to master.
*So, what should you use?*
If you can accept the constant changing nature of *develop*, it is the
recommended branch to use. Otherwise, if you want to tail behind development
slightly and have a more stable package with documented releases, use *master*.
### Installing
This assumes you already have a working Go environment, if not please see
[this page](https://golang.org/doc/install) first.
`go get` *will always pull the latest released version from the master branch.*
```sh
go get github.com/bwmarrin/discordgo
```
If you want to use the develop branch, follow these steps next.
```sh
cd $GOPATH/src/github.com/bwmarrin/discordgo
git checkout develop
```
### Usage
Import the package into your project.
```go
import "github.com/bwmarrin/discordgo"
```
Construct a new Discord client which can be used to access the variety of
Discord API functions and to set callback functions for Discord events.
```go
discord, err := discordgo.New("Bot " + "authentication token")
```
See Documentation and Examples below for more detailed information.
## Documentation
**NOTICE** : This library and the Discord API are unfinished.
Because of that there may be major changes to library in the future.
The DiscordGo code is fairly well documented at this point and is currently
the only documentation available. Both GoDoc and GoWalker (below) present
that information in a nice format.
- [![GoDoc](https://godoc.org/github.com/bwmarrin/discordgo?status.svg)](https://godoc.org/github.com/bwmarrin/discordgo)
- [![Go Walker](http://gowalker.org/api/v1/badge)](https://gowalker.org/github.com/bwmarrin/discordgo)
- Hand crafted documentation coming eventually.
## Examples
Below is a list of examples and other projects using DiscordGo. Please submit
an issue if you would like your project added or removed from this list.
- [DiscordGo Examples](https://github.com/bwmarrin/discordgo/tree/master/examples) - A collection of example programs written with DiscordGo
- [Awesome DiscordGo](https://github.com/bwmarrin/discordgo/wiki/Awesome-DiscordGo) - A curated list of high quality projects using DiscordGo
## Troubleshooting
For help with common problems please reference the
[Troubleshooting](https://github.com/bwmarrin/discordgo/wiki/Troubleshooting)
section of the project wiki.
## Contributing
Contributions are very welcomed, however please follow the below guidelines.
- First open an issue describing the bug or enhancement so it can be
discussed.
- Fork the develop branch and make your changes.
- Try to match current naming conventions as closely as possible.
- This package is intended to be a low level direct mapping of the Discord API,
so please avoid adding enhancements outside of that scope without first
discussing it.
- Create a Pull Request with your changes against the develop branch.
## List of Discord APIs
See [this chart](https://abal.moe/Discord/Libraries.html) for a feature
comparison and list of other Discord API libraries.
## Special Thanks
[Chris Rhodes](https://github.com/iopred) - For the DiscordGo logo and tons of PRs.

147
vendor/github.com/matterbridge/discordgo/discord.go generated vendored Normal file
View File

@@ -0,0 +1,147 @@
// Discordgo - Discord bindings for Go
// Available at https://github.com/matterbridge/discordgo
// Copyright 2015-2016 Bruce Marriner <bruce@sqls.net>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// This file contains high level helper functions and easy entry points for the
// entire discordgo package. These functions are being developed and are very
// experimental at this point. They will most likely change so please use the
// low level functions if that's a problem.
// Package discordgo provides Discord binding for Go
package discordgo
import (
"errors"
"fmt"
"net/http"
"time"
)
// VERSION of DiscordGo, follows Semantic Versioning. (http://semver.org/)
const VERSION = "0.20.2"
// ErrMFA will be risen by New when the user has 2FA.
var ErrMFA = errors.New("account has 2FA enabled")
// New creates a new Discord session and will automate some startup
// tasks if given enough information to do so. Currently you can pass zero
// arguments and it will return an empty Discord session.
// There are 3 ways to call New:
// With a single auth token - All requests will use the token blindly,
// no verification of the token will be done and requests may fail.
// IF THE TOKEN IS FOR A BOT, IT MUST BE PREFIXED WITH `BOT `
// eg: `"Bot <token>"`
// With an email and password - Discord will sign in with the provided
// credentials.
// With an email, password and auth token - Discord will verify the auth
// token, if it is invalid it will sign in with the provided
// credentials. This is the Discord recommended way to sign in.
//
// NOTE: While email/pass authentication is supported by DiscordGo it is
// HIGHLY DISCOURAGED by Discord. Please only use email/pass to obtain a token
// and then use that authentication token for all future connections.
// Also, doing any form of automation with a user (non Bot) account may result
// in that account being permanently banned from Discord.
func New(args ...interface{}) (s *Session, err error) {
// Create an empty Session interface.
s = &Session{
State: NewState(),
Ratelimiter: NewRatelimiter(),
StateEnabled: true,
Compress: true,
ShouldReconnectOnError: true,
ShardID: 0,
ShardCount: 1,
MaxRestRetries: 3,
Client: &http.Client{Timeout: (20 * time.Second)},
UserAgent: "DiscordBot (https://github.com/matterbridge/discordgo, v" + VERSION + ")",
sequence: new(int64),
LastHeartbeatAck: time.Now().UTC(),
}
// If no arguments are passed return the empty Session interface.
if args == nil {
return
}
// Variables used below when parsing func arguments
var auth, pass string
// Parse passed arguments
for _, arg := range args {
switch v := arg.(type) {
case []string:
if len(v) > 3 {
err = fmt.Errorf("too many string parameters provided")
return
}
// First string is either token or username
if len(v) > 0 {
auth = v[0]
}
// If second string exists, it must be a password.
if len(v) > 1 {
pass = v[1]
}
// If third string exists, it must be an auth token.
if len(v) > 2 {
s.Token = v[2]
}
case string:
// First string must be either auth token or username.
// Second string must be a password.
// Only 2 input strings are supported.
if auth == "" {
auth = v
} else if pass == "" {
pass = v
} else if s.Token == "" {
s.Token = v
} else {
err = fmt.Errorf("too many string parameters provided")
return
}
// case Config:
// TODO: Parse configuration struct
default:
err = fmt.Errorf("unsupported parameter type provided")
return
}
}
// If only one string was provided, assume it is an auth token.
// Otherwise get auth token from Discord, if a token was specified
// Discord will verify it for free, or log the user in if it is
// invalid.
if pass == "" {
s.Token = auth
} else {
err = s.Login(auth, pass)
if err != nil || s.Token == "" {
if s.MFA {
err = ErrMFA
} else {
err = fmt.Errorf("Unable to fetch discord authentication token. %v", err)
}
return
}
}
// The Session is now able to have RestAPI methods called on it.
// It is recommended that you now call Open() so that events will trigger.
return
}

150
vendor/github.com/matterbridge/discordgo/endpoints.go generated vendored Normal file
View File

@@ -0,0 +1,150 @@
// Discordgo - Discord bindings for Go
// Available at https://github.com/bwmarrin/discordgo
// Copyright 2015-2016 Bruce Marriner <bruce@sqls.net>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// This file contains variables for all known Discord end points. All functions
// throughout the Discordgo package use these variables for all connections
// to Discord. These are all exported and you may modify them if needed.
package discordgo
import "strconv"
// APIVersion is the Discord API version used for the REST and Websocket API.
var APIVersion = "6"
// Known Discord API Endpoints.
var (
EndpointStatus = "https://status.discordapp.com/api/v2/"
EndpointSm = EndpointStatus + "scheduled-maintenances/"
EndpointSmActive = EndpointSm + "active.json"
EndpointSmUpcoming = EndpointSm + "upcoming.json"
EndpointDiscord = "https://discordapp.com/"
EndpointAPI = EndpointDiscord + "api/v" + APIVersion + "/"
EndpointGuilds = EndpointAPI + "guilds/"
EndpointChannels = EndpointAPI + "channels/"
EndpointUsers = EndpointAPI + "users/"
EndpointGateway = EndpointAPI + "gateway"
EndpointGatewayBot = EndpointGateway + "/bot"
EndpointWebhooks = EndpointAPI + "webhooks/"
EndpointCDN = "https://cdn.discordapp.com/"
EndpointCDNAttachments = EndpointCDN + "attachments/"
EndpointCDNAvatars = EndpointCDN + "avatars/"
EndpointCDNIcons = EndpointCDN + "icons/"
EndpointCDNSplashes = EndpointCDN + "splashes/"
EndpointCDNChannelIcons = EndpointCDN + "channel-icons/"
EndpointCDNBanners = EndpointCDN + "banners/"
EndpointAuth = EndpointAPI + "auth/"
EndpointLogin = EndpointAuth + "login"
EndpointLogout = EndpointAuth + "logout"
EndpointVerify = EndpointAuth + "verify"
EndpointVerifyResend = EndpointAuth + "verify/resend"
EndpointForgotPassword = EndpointAuth + "forgot"
EndpointResetPassword = EndpointAuth + "reset"
EndpointRegister = EndpointAuth + "register"
EndpointVoice = EndpointAPI + "/voice/"
EndpointVoiceRegions = EndpointVoice + "regions"
EndpointVoiceIce = EndpointVoice + "ice"
EndpointTutorial = EndpointAPI + "tutorial/"
EndpointTutorialIndicators = EndpointTutorial + "indicators"
EndpointTrack = EndpointAPI + "track"
EndpointSso = EndpointAPI + "sso"
EndpointReport = EndpointAPI + "report"
EndpointIntegrations = EndpointAPI + "integrations"
EndpointUser = func(uID string) string { return EndpointUsers + uID }
EndpointUserAvatar = func(uID, aID string) string { return EndpointCDNAvatars + uID + "/" + aID + ".png" }
EndpointUserAvatarAnimated = func(uID, aID string) string { return EndpointCDNAvatars + uID + "/" + aID + ".gif" }
EndpointDefaultUserAvatar = func(uDiscriminator string) string {
uDiscriminatorInt, _ := strconv.Atoi(uDiscriminator)
return EndpointCDN + "embed/avatars/" + strconv.Itoa(uDiscriminatorInt%5) + ".png"
}
EndpointUserSettings = func(uID string) string { return EndpointUsers + uID + "/settings" }
EndpointUserGuilds = func(uID string) string { return EndpointUsers + uID + "/guilds" }
EndpointUserGuild = func(uID, gID string) string { return EndpointUsers + uID + "/guilds/" + gID }
EndpointUserGuildSettings = func(uID, gID string) string { return EndpointUsers + uID + "/guilds/" + gID + "/settings" }
EndpointUserChannels = func(uID string) string { return EndpointUsers + uID + "/channels" }
EndpointUserDevices = func(uID string) string { return EndpointUsers + uID + "/devices" }
EndpointUserConnections = func(uID string) string { return EndpointUsers + uID + "/connections" }
EndpointUserNotes = func(uID string) string { return EndpointUsers + "@me/notes/" + uID }
EndpointGuild = func(gID string) string { return EndpointGuilds + gID }
EndpointGuildChannels = func(gID string) string { return EndpointGuilds + gID + "/channels" }
EndpointGuildMembers = func(gID string) string { return EndpointGuilds + gID + "/members" }
EndpointGuildMember = func(gID, uID string) string { return EndpointGuilds + gID + "/members/" + uID }
EndpointGuildMemberRole = func(gID, uID, rID string) string { return EndpointGuilds + gID + "/members/" + uID + "/roles/" + rID }
EndpointGuildBans = func(gID string) string { return EndpointGuilds + gID + "/bans" }
EndpointGuildBan = func(gID, uID string) string { return EndpointGuilds + gID + "/bans/" + uID }
EndpointGuildIntegrations = func(gID string) string { return EndpointGuilds + gID + "/integrations" }
EndpointGuildIntegration = func(gID, iID string) string { return EndpointGuilds + gID + "/integrations/" + iID }
EndpointGuildIntegrationSync = func(gID, iID string) string { return EndpointGuilds + gID + "/integrations/" + iID + "/sync" }
EndpointGuildRoles = func(gID string) string { return EndpointGuilds + gID + "/roles" }
EndpointGuildRole = func(gID, rID string) string { return EndpointGuilds + gID + "/roles/" + rID }
EndpointGuildInvites = func(gID string) string { return EndpointGuilds + gID + "/invites" }
EndpointGuildEmbed = func(gID string) string { return EndpointGuilds + gID + "/embed" }
EndpointGuildPrune = func(gID string) string { return EndpointGuilds + gID + "/prune" }
EndpointGuildIcon = func(gID, hash string) string { return EndpointCDNIcons + gID + "/" + hash + ".png" }
EndpointGuildIconAnimated = func(gID, hash string) string { return EndpointCDNIcons + gID + "/" + hash + ".gif" }
EndpointGuildSplash = func(gID, hash string) string { return EndpointCDNSplashes + gID + "/" + hash + ".png" }
EndpointGuildWebhooks = func(gID string) string { return EndpointGuilds + gID + "/webhooks" }
EndpointGuildAuditLogs = func(gID string) string { return EndpointGuilds + gID + "/audit-logs" }
EndpointGuildEmojis = func(gID string) string { return EndpointGuilds + gID + "/emojis" }
EndpointGuildEmoji = func(gID, eID string) string { return EndpointGuilds + gID + "/emojis/" + eID }
EndpointGuildBanner = func(gID, hash string) string { return EndpointCDNBanners + gID + "/" + hash + ".png" }
EndpointChannel = func(cID string) string { return EndpointChannels + cID }
EndpointChannelPermissions = func(cID string) string { return EndpointChannels + cID + "/permissions" }
EndpointChannelPermission = func(cID, tID string) string { return EndpointChannels + cID + "/permissions/" + tID }
EndpointChannelInvites = func(cID string) string { return EndpointChannels + cID + "/invites" }
EndpointChannelTyping = func(cID string) string { return EndpointChannels + cID + "/typing" }
EndpointChannelMessages = func(cID string) string { return EndpointChannels + cID + "/messages" }
EndpointChannelMessage = func(cID, mID string) string { return EndpointChannels + cID + "/messages/" + mID }
EndpointChannelMessageAck = func(cID, mID string) string { return EndpointChannels + cID + "/messages/" + mID + "/ack" }
EndpointChannelMessagesBulkDelete = func(cID string) string { return EndpointChannel(cID) + "/messages/bulk-delete" }
EndpointChannelMessagesPins = func(cID string) string { return EndpointChannel(cID) + "/pins" }
EndpointChannelMessagePin = func(cID, mID string) string { return EndpointChannel(cID) + "/pins/" + mID }
EndpointGroupIcon = func(cID, hash string) string { return EndpointCDNChannelIcons + cID + "/" + hash + ".png" }
EndpointChannelWebhooks = func(cID string) string { return EndpointChannel(cID) + "/webhooks" }
EndpointWebhook = func(wID string) string { return EndpointWebhooks + wID }
EndpointWebhookToken = func(wID, token string) string { return EndpointWebhooks + wID + "/" + token }
EndpointMessageReactionsAll = func(cID, mID string) string {
return EndpointChannelMessage(cID, mID) + "/reactions"
}
EndpointMessageReactions = func(cID, mID, eID string) string {
return EndpointChannelMessage(cID, mID) + "/reactions/" + eID
}
EndpointMessageReaction = func(cID, mID, eID, uID string) string {
return EndpointMessageReactions(cID, mID, eID) + "/" + uID
}
EndpointRelationships = func() string { return EndpointUsers + "@me" + "/relationships" }
EndpointRelationship = func(uID string) string { return EndpointRelationships() + "/" + uID }
EndpointRelationshipsMutual = func(uID string) string { return EndpointUsers + uID + "/relationships" }
EndpointGuildCreate = EndpointAPI + "guilds"
EndpointInvite = func(iID string) string { return EndpointAPI + "invite/" + iID }
EndpointIntegrationsJoin = func(iID string) string { return EndpointAPI + "integrations/" + iID + "/join" }
EndpointEmoji = func(eID string) string { return EndpointAPI + "emojis/" + eID + ".png" }
EndpointEmojiAnimated = func(eID string) string { return EndpointAPI + "emojis/" + eID + ".gif" }
EndpointOauth2 = EndpointAPI + "oauth2/"
EndpointApplications = EndpointOauth2 + "applications"
EndpointApplication = func(aID string) string { return EndpointApplications + "/" + aID }
EndpointApplicationsBot = func(aID string) string { return EndpointApplications + "/" + aID + "/bot" }
EndpointApplicationAssets = func(aID string) string { return EndpointApplications + "/" + aID + "/assets" }
)

247
vendor/github.com/matterbridge/discordgo/event.go generated vendored Normal file
View File

@@ -0,0 +1,247 @@
package discordgo
// EventHandler is an interface for Discord events.
type EventHandler interface {
// Type returns the type of event this handler belongs to.
Type() string
// Handle is called whenever an event of Type() happens.
// It is the receivers responsibility to type assert that the interface
// is the expected struct.
Handle(*Session, interface{})
}
// EventInterfaceProvider is an interface for providing empty interfaces for
// Discord events.
type EventInterfaceProvider interface {
// Type is the type of event this handler belongs to.
Type() string
// New returns a new instance of the struct this event handler handles.
// This is called once per event.
// The struct is provided to all handlers of the same Type().
New() interface{}
}
// interfaceEventType is the event handler type for interface{} events.
const interfaceEventType = "__INTERFACE__"
// interfaceEventHandler is an event handler for interface{} events.
type interfaceEventHandler func(*Session, interface{})
// Type returns the event type for interface{} events.
func (eh interfaceEventHandler) Type() string {
return interfaceEventType
}
// Handle is the handler for an interface{} event.
func (eh interfaceEventHandler) Handle(s *Session, i interface{}) {
eh(s, i)
}
var registeredInterfaceProviders = map[string]EventInterfaceProvider{}
// registerInterfaceProvider registers a provider so that DiscordGo can
// access it's New() method.
func registerInterfaceProvider(eh EventInterfaceProvider) {
if _, ok := registeredInterfaceProviders[eh.Type()]; ok {
return
// XXX:
// if we should error here, we need to do something with it.
// fmt.Errorf("event %s already registered", eh.Type())
}
registeredInterfaceProviders[eh.Type()] = eh
return
}
// eventHandlerInstance is a wrapper around an event handler, as functions
// cannot be compared directly.
type eventHandlerInstance struct {
eventHandler EventHandler
}
// addEventHandler adds an event handler that will be fired anytime
// the Discord WSAPI matching eventHandler.Type() fires.
func (s *Session) addEventHandler(eventHandler EventHandler) func() {
s.handlersMu.Lock()
defer s.handlersMu.Unlock()
if s.handlers == nil {
s.handlers = map[string][]*eventHandlerInstance{}
}
ehi := &eventHandlerInstance{eventHandler}
s.handlers[eventHandler.Type()] = append(s.handlers[eventHandler.Type()], ehi)
return func() {
s.removeEventHandlerInstance(eventHandler.Type(), ehi)
}
}
// addEventHandler adds an event handler that will be fired the next time
// the Discord WSAPI matching eventHandler.Type() fires.
func (s *Session) addEventHandlerOnce(eventHandler EventHandler) func() {
s.handlersMu.Lock()
defer s.handlersMu.Unlock()
if s.onceHandlers == nil {
s.onceHandlers = map[string][]*eventHandlerInstance{}
}
ehi := &eventHandlerInstance{eventHandler}
s.onceHandlers[eventHandler.Type()] = append(s.onceHandlers[eventHandler.Type()], ehi)
return func() {
s.removeEventHandlerInstance(eventHandler.Type(), ehi)
}
}
// AddHandler allows you to add an event handler that will be fired anytime
// the Discord WSAPI event that matches the function fires.
// The first parameter is a *Session, and the second parameter is a pointer
// to a struct corresponding to the event for which you want to listen.
//
// eg:
// Session.AddHandler(func(s *discordgo.Session, m *discordgo.MessageCreate) {
// })
//
// or:
// Session.AddHandler(func(s *discordgo.Session, m *discordgo.PresenceUpdate) {
// })
//
// List of events can be found at this page, with corresponding names in the
// library for each event: https://discordapp.com/developers/docs/topics/gateway#event-names
// There are also synthetic events fired by the library internally which are
// available for handling, like Connect, Disconnect, and RateLimit.
// events.go contains all of the Discord WSAPI and synthetic events that can be handled.
//
// The return value of this method is a function, that when called will remove the
// event handler.
func (s *Session) AddHandler(handler interface{}) func() {
eh := handlerForInterface(handler)
if eh == nil {
s.log(LogError, "Invalid handler type, handler will never be called")
return func() {}
}
return s.addEventHandler(eh)
}
// AddHandlerOnce allows you to add an event handler that will be fired the next time
// the Discord WSAPI event that matches the function fires.
// See AddHandler for more details.
func (s *Session) AddHandlerOnce(handler interface{}) func() {
eh := handlerForInterface(handler)
if eh == nil {
s.log(LogError, "Invalid handler type, handler will never be called")
return func() {}
}
return s.addEventHandlerOnce(eh)
}
// removeEventHandler instance removes an event handler instance.
func (s *Session) removeEventHandlerInstance(t string, ehi *eventHandlerInstance) {
s.handlersMu.Lock()
defer s.handlersMu.Unlock()
handlers := s.handlers[t]
for i := range handlers {
if handlers[i] == ehi {
s.handlers[t] = append(handlers[:i], handlers[i+1:]...)
}
}
onceHandlers := s.onceHandlers[t]
for i := range onceHandlers {
if onceHandlers[i] == ehi {
s.onceHandlers[t] = append(onceHandlers[:i], handlers[i+1:]...)
}
}
}
// Handles calling permanent and once handlers for an event type.
func (s *Session) handle(t string, i interface{}) {
for _, eh := range s.handlers[t] {
if s.SyncEvents {
eh.eventHandler.Handle(s, i)
} else {
go eh.eventHandler.Handle(s, i)
}
}
if len(s.onceHandlers[t]) > 0 {
for _, eh := range s.onceHandlers[t] {
if s.SyncEvents {
eh.eventHandler.Handle(s, i)
} else {
go eh.eventHandler.Handle(s, i)
}
}
s.onceHandlers[t] = nil
}
}
// Handles an event type by calling internal methods, firing handlers and firing the
// interface{} event.
func (s *Session) handleEvent(t string, i interface{}) {
s.handlersMu.RLock()
defer s.handlersMu.RUnlock()
// All events are dispatched internally first.
s.onInterface(i)
// Then they are dispatched to anyone handling interface{} events.
s.handle(interfaceEventType, i)
// Finally they are dispatched to any typed handlers.
s.handle(t, i)
}
// setGuildIds will set the GuildID on all the members of a guild.
// This is done as event data does not have it set.
func setGuildIds(g *Guild) {
for _, c := range g.Channels {
c.GuildID = g.ID
}
for _, m := range g.Members {
m.GuildID = g.ID
}
for _, vs := range g.VoiceStates {
vs.GuildID = g.ID
}
}
// onInterface handles all internal events and routes them to the appropriate internal handler.
func (s *Session) onInterface(i interface{}) {
switch t := i.(type) {
case *Ready:
for _, g := range t.Guilds {
setGuildIds(g)
}
s.onReady(t)
case *GuildCreate:
setGuildIds(t.Guild)
case *GuildUpdate:
setGuildIds(t.Guild)
case *VoiceServerUpdate:
go s.onVoiceServerUpdate(t)
case *VoiceStateUpdate:
go s.onVoiceStateUpdate(t)
}
err := s.State.OnInterface(s, i)
if err != nil {
s.log(LogDebug, "error dispatching internal event, %s", err)
}
}
// onReady handles the ready event.
func (s *Session) onReady(r *Ready) {
// Store the SessionID within the Session struct.
s.sessionID = r.SessionID
}

1054
vendor/github.com/matterbridge/discordgo/eventhandlers.go generated vendored Normal file

File diff suppressed because it is too large Load Diff

264
vendor/github.com/matterbridge/discordgo/events.go generated vendored Normal file
View File

@@ -0,0 +1,264 @@
package discordgo
import (
"encoding/json"
)
// This file contains all the possible structs that can be
// handled by AddHandler/EventHandler.
// DO NOT ADD ANYTHING BUT EVENT HANDLER STRUCTS TO THIS FILE.
//go:generate go run tools/cmd/eventhandlers/main.go
// Connect is the data for a Connect event.
// This is a synthetic event and is not dispatched by Discord.
type Connect struct{}
// Disconnect is the data for a Disconnect event.
// This is a synthetic event and is not dispatched by Discord.
type Disconnect struct{}
// RateLimit is the data for a RateLimit event.
// This is a synthetic event and is not dispatched by Discord.
type RateLimit struct {
*TooManyRequests
URL string
}
// Event provides a basic initial struct for all websocket events.
type Event struct {
Operation int `json:"op"`
Sequence int64 `json:"s"`
Type string `json:"t"`
RawData json.RawMessage `json:"d"`
// Struct contains one of the other types in this file.
Struct interface{} `json:"-"`
}
// A Ready stores all data for the websocket READY event.
type Ready struct {
Version int `json:"v"`
SessionID string `json:"session_id"`
User *User `json:"user"`
ReadState []*ReadState `json:"read_state"`
PrivateChannels []*Channel `json:"private_channels"`
Guilds []*Guild `json:"guilds"`
// Undocumented fields
Settings *Settings `json:"user_settings"`
UserGuildSettings []*UserGuildSettings `json:"user_guild_settings"`
Relationships []*Relationship `json:"relationships"`
Presences []*Presence `json:"presences"`
Notes map[string]string `json:"notes"`
}
// ChannelCreate is the data for a ChannelCreate event.
type ChannelCreate struct {
*Channel
}
// ChannelUpdate is the data for a ChannelUpdate event.
type ChannelUpdate struct {
*Channel
}
// ChannelDelete is the data for a ChannelDelete event.
type ChannelDelete struct {
*Channel
}
// ChannelPinsUpdate stores data for a ChannelPinsUpdate event.
type ChannelPinsUpdate struct {
LastPinTimestamp string `json:"last_pin_timestamp"`
ChannelID string `json:"channel_id"`
GuildID string `json:"guild_id,omitempty"`
}
// GuildCreate is the data for a GuildCreate event.
type GuildCreate struct {
*Guild
}
// GuildUpdate is the data for a GuildUpdate event.
type GuildUpdate struct {
*Guild
}
// GuildDelete is the data for a GuildDelete event.
type GuildDelete struct {
*Guild
}
// GuildBanAdd is the data for a GuildBanAdd event.
type GuildBanAdd struct {
User *User `json:"user"`
GuildID string `json:"guild_id"`
}
// GuildBanRemove is the data for a GuildBanRemove event.
type GuildBanRemove struct {
User *User `json:"user"`
GuildID string `json:"guild_id"`
}
// GuildMemberAdd is the data for a GuildMemberAdd event.
type GuildMemberAdd struct {
*Member
}
// GuildMemberUpdate is the data for a GuildMemberUpdate event.
type GuildMemberUpdate struct {
*Member
}
// GuildMemberRemove is the data for a GuildMemberRemove event.
type GuildMemberRemove struct {
*Member
}
// GuildRoleCreate is the data for a GuildRoleCreate event.
type GuildRoleCreate struct {
*GuildRole
}
// GuildRoleUpdate is the data for a GuildRoleUpdate event.
type GuildRoleUpdate struct {
*GuildRole
}
// A GuildRoleDelete is the data for a GuildRoleDelete event.
type GuildRoleDelete struct {
RoleID string `json:"role_id"`
GuildID string `json:"guild_id"`
}
// A GuildEmojisUpdate is the data for a guild emoji update event.
type GuildEmojisUpdate struct {
GuildID string `json:"guild_id"`
Emojis []*Emoji `json:"emojis"`
}
// A GuildMembersChunk is the data for a GuildMembersChunk event.
type GuildMembersChunk struct {
GuildID string `json:"guild_id"`
Members []*Member `json:"members"`
}
// GuildIntegrationsUpdate is the data for a GuildIntegrationsUpdate event.
type GuildIntegrationsUpdate struct {
GuildID string `json:"guild_id"`
}
// MessageAck is the data for a MessageAck event.
type MessageAck struct {
MessageID string `json:"message_id"`
ChannelID string `json:"channel_id"`
}
// MessageCreate is the data for a MessageCreate event.
type MessageCreate struct {
*Message
}
// MessageUpdate is the data for a MessageUpdate event.
type MessageUpdate struct {
*Message
// BeforeUpdate will be nil if the Message was not previously cached in the state cache.
BeforeUpdate *Message `json:"-"`
}
// MessageDelete is the data for a MessageDelete event.
type MessageDelete struct {
*Message
}
// MessageReactionAdd is the data for a MessageReactionAdd event.
type MessageReactionAdd struct {
*MessageReaction
}
// MessageReactionRemove is the data for a MessageReactionRemove event.
type MessageReactionRemove struct {
*MessageReaction
}
// MessageReactionRemoveAll is the data for a MessageReactionRemoveAll event.
type MessageReactionRemoveAll struct {
*MessageReaction
}
// PresencesReplace is the data for a PresencesReplace event.
type PresencesReplace []*Presence
// PresenceUpdate is the data for a PresenceUpdate event.
type PresenceUpdate struct {
Presence
GuildID string `json:"guild_id"`
Roles []string `json:"roles"`
}
// Resumed is the data for a Resumed event.
type Resumed struct {
Trace []string `json:"_trace"`
}
// RelationshipAdd is the data for a RelationshipAdd event.
type RelationshipAdd struct {
*Relationship
}
// RelationshipRemove is the data for a RelationshipRemove event.
type RelationshipRemove struct {
*Relationship
}
// TypingStart is the data for a TypingStart event.
type TypingStart struct {
UserID string `json:"user_id"`
ChannelID string `json:"channel_id"`
GuildID string `json:"guild_id,omitempty"`
Timestamp int `json:"timestamp"`
}
// UserUpdate is the data for a UserUpdate event.
type UserUpdate struct {
*User
}
// UserSettingsUpdate is the data for a UserSettingsUpdate event.
type UserSettingsUpdate map[string]interface{}
// UserGuildSettingsUpdate is the data for a UserGuildSettingsUpdate event.
type UserGuildSettingsUpdate struct {
*UserGuildSettings
}
// UserNoteUpdate is the data for a UserNoteUpdate event.
type UserNoteUpdate struct {
ID string `json:"id"`
Note string `json:"note"`
}
// VoiceServerUpdate is the data for a VoiceServerUpdate event.
type VoiceServerUpdate struct {
Token string `json:"token"`
GuildID string `json:"guild_id"`
Endpoint string `json:"endpoint"`
}
// VoiceStateUpdate is the data for a VoiceStateUpdate event.
type VoiceStateUpdate struct {
*VoiceState
}
// MessageDeleteBulk is the data for a MessageDeleteBulk event
type MessageDeleteBulk struct {
Messages []string `json:"ids"`
ChannelID string `json:"channel_id"`
GuildID string `json:"guild_id"`
}
// WebhooksUpdate is the data for a WebhooksUpdate event
type WebhooksUpdate struct {
GuildID string `json:"guild_id"`
ChannelID string `json:"channel_id"`
}

6
vendor/github.com/matterbridge/discordgo/go.mod generated vendored Normal file
View File

@@ -0,0 +1,6 @@
module github.com/matterbridge/discordgo
require (
github.com/gorilla/websocket v1.4.0
golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16
)

4
vendor/github.com/matterbridge/discordgo/go.sum generated vendored Normal file
View File

@@ -0,0 +1,4 @@
github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q=
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16 h1:y6ce7gCWtnH+m3dCjzQ1PCuwl28DDIc3VNnvY29DlIA=
golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=

103
vendor/github.com/matterbridge/discordgo/logging.go generated vendored Normal file
View File

@@ -0,0 +1,103 @@
// Discordgo - Discord bindings for Go
// Available at https://github.com/bwmarrin/discordgo
// Copyright 2015-2016 Bruce Marriner <bruce@sqls.net>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// This file contains code related to discordgo package logging
package discordgo
import (
"fmt"
"log"
"runtime"
"strings"
)
const (
// LogError level is used for critical errors that could lead to data loss
// or panic that would not be returned to a calling function.
LogError int = iota
// LogWarning level is used for very abnormal events and errors that are
// also returned to a calling function.
LogWarning
// LogInformational level is used for normal non-error activity
LogInformational
// LogDebug level is for very detailed non-error activity. This is
// very spammy and will impact performance.
LogDebug
)
// Logger can be used to replace the standard logging for discordgo
var Logger func(msgL, caller int, format string, a ...interface{})
// msglog provides package wide logging consistancy for discordgo
// the format, a... portion this command follows that of fmt.Printf
// msgL : LogLevel of the message
// caller : 1 + the number of callers away from the message source
// format : Printf style message format
// a ... : comma separated list of values to pass
func msglog(msgL, caller int, format string, a ...interface{}) {
if Logger != nil {
Logger(msgL, caller, format, a...)
} else {
pc, file, line, _ := runtime.Caller(caller)
files := strings.Split(file, "/")
file = files[len(files)-1]
name := runtime.FuncForPC(pc).Name()
fns := strings.Split(name, ".")
name = fns[len(fns)-1]
msg := fmt.Sprintf(format, a...)
log.Printf("[DG%d] %s:%d:%s() %s\n", msgL, file, line, name, msg)
}
}
// helper function that wraps msglog for the Session struct
// This adds a check to insure the message is only logged
// if the session log level is equal or higher than the
// message log level
func (s *Session) log(msgL int, format string, a ...interface{}) {
if msgL > s.LogLevel {
return
}
msglog(msgL, 2, format, a...)
}
// helper function that wraps msglog for the VoiceConnection struct
// This adds a check to insure the message is only logged
// if the voice connection log level is equal or higher than the
// message log level
func (v *VoiceConnection) log(msgL int, format string, a ...interface{}) {
if msgL > v.LogLevel {
return
}
msglog(msgL, 2, format, a...)
}
// printJSON is a helper function to display JSON data in a easy to read format.
/* NOT USED ATM
func printJSON(body []byte) {
var prettyJSON bytes.Buffer
error := json.Indent(&prettyJSON, body, "", "\t")
if error != nil {
log.Print("JSON parse error: ", error)
}
log.Println(string(prettyJSON.Bytes()))
}
*/

370
vendor/github.com/matterbridge/discordgo/message.go generated vendored Normal file
View File

@@ -0,0 +1,370 @@
// Discordgo - Discord bindings for Go
// Available at https://github.com/bwmarrin/discordgo
// Copyright 2015-2016 Bruce Marriner <bruce@sqls.net>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// This file contains code related to the Message struct
package discordgo
import (
"io"
"regexp"
"strings"
)
// MessageType is the type of Message
type MessageType int
// Block contains the valid known MessageType values
const (
MessageTypeDefault MessageType = iota
MessageTypeRecipientAdd
MessageTypeRecipientRemove
MessageTypeCall
MessageTypeChannelNameChange
MessageTypeChannelIconChange
MessageTypeChannelPinnedMessage
MessageTypeGuildMemberJoin
MessageTypeUserPremiumGuildSubscription
MessageTypeUserPremiumGuildSubscriptionTierOne
MessageTypeUserPremiumGuildSubscriptionTierTwo
MessageTypeUserPremiumGuildSubscriptionTierThree
MessageTypeChannelFollowAdd
)
// A Message stores all data related to a specific Discord message.
type Message struct {
// The ID of the message.
ID string `json:"id"`
// The ID of the channel in which the message was sent.
ChannelID string `json:"channel_id"`
// The ID of the guild in which the message was sent.
GuildID string `json:"guild_id,omitempty"`
// The content of the message.
Content string `json:"content"`
// The time at which the messsage was sent.
// CAUTION: this field may be removed in a
// future API version; it is safer to calculate
// the creation time via the ID.
Timestamp Timestamp `json:"timestamp"`
// The time at which the last edit of the message
// occurred, if it has been edited.
EditedTimestamp Timestamp `json:"edited_timestamp"`
// The roles mentioned in the message.
MentionRoles []string `json:"mention_roles"`
// Whether the message is text-to-speech.
Tts bool `json:"tts"`
// Whether the message mentions everyone.
MentionEveryone bool `json:"mention_everyone"`
// The author of the message. This is not guaranteed to be a
// valid user (webhook-sent messages do not possess a full author).
Author *User `json:"author"`
// A list of attachments present in the message.
Attachments []*MessageAttachment `json:"attachments"`
// A list of embeds present in the message. Multiple
// embeds can currently only be sent by webhooks.
Embeds []*MessageEmbed `json:"embeds"`
// A list of users mentioned in the message.
Mentions []*User `json:"mentions"`
// A list of reactions to the message.
Reactions []*MessageReactions `json:"reactions"`
// Whether the message is pinned or not.
Pinned bool `json:"pinned"`
// The type of the message.
Type MessageType `json:"type"`
// The webhook ID of the message, if it was generated by a webhook
WebhookID string `json:"webhook_id"`
// Member properties for this message's author,
// contains only partial information
Member *Member `json:"member"`
// Channels specifically mentioned in this message
// Not all channel mentions in a message will appear in mention_channels.
// Only textual channels that are visible to everyone in a lurkable guild will ever be included.
// Only crossposted messages (via Channel Following) currently include mention_channels at all.
// If no mentions in the message meet these requirements, this field will not be sent.
MentionChannels []*Channel `json:"mention_channels"`
// Is sent with Rich Presence-related chat embeds
Activity *MessageActivity `json:"activity"`
// Is sent with Rich Presence-related chat embeds
Application *MessageApplication `json:"application"`
// MessageReference contains reference data sent with crossposted messages
MessageReference *MessageReference `json:"message_reference"`
// The flags of the message, which describe extra features of a message.
// This is a combination of bit masks; the presence of a certain permission can
// be checked by performing a bitwise AND between this int and the flag.
Flags int `json:"flags"`
}
// File stores info about files you e.g. send in messages.
type File struct {
Name string
ContentType string
Reader io.Reader
}
// MessageSend stores all parameters you can send with ChannelMessageSendComplex.
type MessageSend struct {
Content string `json:"content,omitempty"`
Embed *MessageEmbed `json:"embed,omitempty"`
Tts bool `json:"tts"`
Files []*File `json:"-"`
// TODO: Remove this when compatibility is not required.
File *File `json:"-"`
}
// MessageEdit is used to chain parameters via ChannelMessageEditComplex, which
// is also where you should get the instance from.
type MessageEdit struct {
Content *string `json:"content,omitempty"`
Embed *MessageEmbed `json:"embed,omitempty"`
ID string
Channel string
}
// NewMessageEdit returns a MessageEdit struct, initialized
// with the Channel and ID.
func NewMessageEdit(channelID string, messageID string) *MessageEdit {
return &MessageEdit{
Channel: channelID,
ID: messageID,
}
}
// SetContent is the same as setting the variable Content,
// except it doesn't take a pointer.
func (m *MessageEdit) SetContent(str string) *MessageEdit {
m.Content = &str
return m
}
// SetEmbed is a convenience function for setting the embed,
// so you can chain commands.
func (m *MessageEdit) SetEmbed(embed *MessageEmbed) *MessageEdit {
m.Embed = embed
return m
}
// A MessageAttachment stores data for message attachments.
type MessageAttachment struct {
ID string `json:"id"`
URL string `json:"url"`
ProxyURL string `json:"proxy_url"`
Filename string `json:"filename"`
Width int `json:"width"`
Height int `json:"height"`
Size int `json:"size"`
}
// MessageEmbedFooter is a part of a MessageEmbed struct.
type MessageEmbedFooter struct {
Text string `json:"text,omitempty"`
IconURL string `json:"icon_url,omitempty"`
ProxyIconURL string `json:"proxy_icon_url,omitempty"`
}
// MessageEmbedImage is a part of a MessageEmbed struct.
type MessageEmbedImage struct {
URL string `json:"url,omitempty"`
ProxyURL string `json:"proxy_url,omitempty"`
Width int `json:"width,omitempty"`
Height int `json:"height,omitempty"`
}
// MessageEmbedThumbnail is a part of a MessageEmbed struct.
type MessageEmbedThumbnail struct {
URL string `json:"url,omitempty"`
ProxyURL string `json:"proxy_url,omitempty"`
Width int `json:"width,omitempty"`
Height int `json:"height,omitempty"`
}
// MessageEmbedVideo is a part of a MessageEmbed struct.
type MessageEmbedVideo struct {
URL string `json:"url,omitempty"`
ProxyURL string `json:"proxy_url,omitempty"`
Width int `json:"width,omitempty"`
Height int `json:"height,omitempty"`
}
// MessageEmbedProvider is a part of a MessageEmbed struct.
type MessageEmbedProvider struct {
URL string `json:"url,omitempty"`
Name string `json:"name,omitempty"`
}
// MessageEmbedAuthor is a part of a MessageEmbed struct.
type MessageEmbedAuthor struct {
URL string `json:"url,omitempty"`
Name string `json:"name,omitempty"`
IconURL string `json:"icon_url,omitempty"`
ProxyIconURL string `json:"proxy_icon_url,omitempty"`
}
// MessageEmbedField is a part of a MessageEmbed struct.
type MessageEmbedField struct {
Name string `json:"name,omitempty"`
Value string `json:"value,omitempty"`
Inline bool `json:"inline,omitempty"`
}
// An MessageEmbed stores data for message embeds.
type MessageEmbed struct {
URL string `json:"url,omitempty"`
Type string `json:"type,omitempty"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Timestamp string `json:"timestamp,omitempty"`
Color int `json:"color,omitempty"`
Footer *MessageEmbedFooter `json:"footer,omitempty"`
Image *MessageEmbedImage `json:"image,omitempty"`
Thumbnail *MessageEmbedThumbnail `json:"thumbnail,omitempty"`
Video *MessageEmbedVideo `json:"video,omitempty"`
Provider *MessageEmbedProvider `json:"provider,omitempty"`
Author *MessageEmbedAuthor `json:"author,omitempty"`
Fields []*MessageEmbedField `json:"fields,omitempty"`
}
// MessageReactions holds a reactions object for a message.
type MessageReactions struct {
Count int `json:"count"`
Me bool `json:"me"`
Emoji *Emoji `json:"emoji"`
}
// MessageActivity is sent with Rich Presence-related chat embeds
type MessageActivity struct {
Type MessageActivityType `json:"type"`
PartyID string `json:"party_id"`
}
// MessageActivityType is the type of message activity
type MessageActivityType int
// Constants for the different types of Message Activity
const (
MessageActivityTypeJoin = iota + 1
MessageActivityTypeSpectate
MessageActivityTypeListen
MessageActivityTypeJoinRequest
)
// MessageFlag describes an extra feature of the message
type MessageFlag int
// Constants for the different bit offsets of Message Flags
const (
// This message has been published to subscribed channels (via Channel Following)
MessageFlagCrossposted = 1 << iota
// This message originated from a message in another channel (via Channel Following)
MessageFlagIsCrosspost
// Do not include any embeds when serializing this message
MessageFlagSuppressEmbeds
)
// MessageApplication is sent with Rich Presence-related chat embeds
type MessageApplication struct {
ID string `json:"id"`
CoverImage string `json:"cover_image"`
Description string `json:"description"`
Icon string `json:"icon"`
Name string `json:"name"`
}
// MessageReference contains reference data sent with crossposted messages
type MessageReference struct {
MessageID string `json:"message_id"`
ChannelID string `json:"channel_id"`
GuildID string `json:"guild_id"`
}
// ContentWithMentionsReplaced will replace all @<id> mentions with the
// username of the mention.
func (m *Message) ContentWithMentionsReplaced() (content string) {
content = m.Content
for _, user := range m.Mentions {
content = strings.NewReplacer(
"<@"+user.ID+">", "@"+user.Username,
"<@!"+user.ID+">", "@"+user.Username,
).Replace(content)
}
return
}
var patternChannels = regexp.MustCompile("<#[^>]*>")
// ContentWithMoreMentionsReplaced will replace all @<id> mentions with the
// username of the mention, but also role IDs and more.
func (m *Message) ContentWithMoreMentionsReplaced(s *Session) (content string, err error) {
content = m.Content
if !s.StateEnabled {
content = m.ContentWithMentionsReplaced()
return
}
channel, err := s.State.Channel(m.ChannelID)
if err != nil {
content = m.ContentWithMentionsReplaced()
return
}
for _, user := range m.Mentions {
nick := user.Username
member, err := s.State.Member(channel.GuildID, user.ID)
if err == nil && member.Nick != "" {
nick = member.Nick
}
content = strings.NewReplacer(
"<@"+user.ID+">", "@"+user.Username,
"<@!"+user.ID+">", "@"+nick,
).Replace(content)
}
for _, roleID := range m.MentionRoles {
role, err := s.State.Role(channel.GuildID, roleID)
if err != nil || !role.Mentionable {
continue
}
content = strings.Replace(content, "<@&"+role.ID+">", "@"+role.Name, -1)
}
content = patternChannels.ReplaceAllStringFunc(content, func(mention string) string {
channel, err := s.State.Channel(mention[2 : len(mention)-1])
if err != nil || channel.Type == ChannelTypeGuildVoice {
return mention
}
return "#" + channel.Name
})
return
}

17
vendor/github.com/matterbridge/discordgo/mkdocs.yml generated vendored Normal file
View File

@@ -0,0 +1,17 @@
site_name: DiscordGo
site_author: Bruce Marriner
site_url: http://bwmarrin.github.io/discordgo/
repo_url: https://github.com/bwmarrin/discordgo
dev_addr: 0.0.0.0:8000
theme: yeti
markdown_extensions:
- smarty
- toc:
permalink: True
- sane_lists
pages:
- 'Home': 'index.md'
- 'Getting Started': 'GettingStarted.md'

145
vendor/github.com/matterbridge/discordgo/oauth2.go generated vendored Normal file
View File

@@ -0,0 +1,145 @@
// Discordgo - Discord bindings for Go
// Available at https://github.com/bwmarrin/discordgo
// Copyright 2015-2016 Bruce Marriner <bruce@sqls.net>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// This file contains functions related to Discord OAuth2 endpoints
package discordgo
// ------------------------------------------------------------------------------------------------
// Code specific to Discord OAuth2 Applications
// ------------------------------------------------------------------------------------------------
// An Application struct stores values for a Discord OAuth2 Application
type Application struct {
ID string `json:"id,omitempty"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Icon string `json:"icon,omitempty"`
Secret string `json:"secret,omitempty"`
RedirectURIs *[]string `json:"redirect_uris,omitempty"`
BotRequireCodeGrant bool `json:"bot_require_code_grant,omitempty"`
BotPublic bool `json:"bot_public,omitempty"`
RPCApplicationState int `json:"rpc_application_state,omitempty"`
Flags int `json:"flags,omitempty"`
Owner *User `json:"owner"`
Bot *User `json:"bot"`
}
// Application returns an Application structure of a specific Application
// appID : The ID of an Application
func (s *Session) Application(appID string) (st *Application, err error) {
body, err := s.RequestWithBucketID("GET", EndpointApplication(appID), nil, EndpointApplication(""))
if err != nil {
return
}
err = unmarshal(body, &st)
return
}
// Applications returns all applications for the authenticated user
func (s *Session) Applications() (st []*Application, err error) {
body, err := s.RequestWithBucketID("GET", EndpointApplications, nil, EndpointApplications)
if err != nil {
return
}
err = unmarshal(body, &st)
return
}
// ApplicationCreate creates a new Application
// name : Name of Application / Bot
// uris : Redirect URIs (Not required)
func (s *Session) ApplicationCreate(ap *Application) (st *Application, err error) {
data := struct {
Name string `json:"name"`
Description string `json:"description"`
RedirectURIs *[]string `json:"redirect_uris,omitempty"`
}{ap.Name, ap.Description, ap.RedirectURIs}
body, err := s.RequestWithBucketID("POST", EndpointApplications, data, EndpointApplications)
if err != nil {
return
}
err = unmarshal(body, &st)
return
}
// ApplicationUpdate updates an existing Application
// var : desc
func (s *Session) ApplicationUpdate(appID string, ap *Application) (st *Application, err error) {
data := struct {
Name string `json:"name"`
Description string `json:"description"`
RedirectURIs *[]string `json:"redirect_uris,omitempty"`
}{ap.Name, ap.Description, ap.RedirectURIs}
body, err := s.RequestWithBucketID("PUT", EndpointApplication(appID), data, EndpointApplication(""))
if err != nil {
return
}
err = unmarshal(body, &st)
return
}
// ApplicationDelete deletes an existing Application
// appID : The ID of an Application
func (s *Session) ApplicationDelete(appID string) (err error) {
_, err = s.RequestWithBucketID("DELETE", EndpointApplication(appID), nil, EndpointApplication(""))
if err != nil {
return
}
return
}
// Asset struct stores values for an asset of an application
type Asset struct {
Type int `json:"type"`
ID string `json:"id"`
Name string `json:"name"`
}
// ApplicationAssets returns an application's assets
func (s *Session) ApplicationAssets(appID string) (ass []*Asset, err error) {
body, err := s.RequestWithBucketID("GET", EndpointApplicationAssets(appID), nil, EndpointApplicationAssets(""))
if err != nil {
return
}
err = unmarshal(body, &ass)
return
}
// ------------------------------------------------------------------------------------------------
// Code specific to Discord OAuth2 Application Bots
// ------------------------------------------------------------------------------------------------
// ApplicationBotCreate creates an Application Bot Account
//
// appID : The ID of an Application
//
// NOTE: func name may change, if I can think up something better.
func (s *Session) ApplicationBotCreate(appID string) (st *User, err error) {
body, err := s.RequestWithBucketID("POST", EndpointApplicationsBot(appID), nil, EndpointApplicationsBot(""))
if err != nil {
return
}
err = unmarshal(body, &st)
return
}

194
vendor/github.com/matterbridge/discordgo/ratelimit.go generated vendored Normal file
View File

@@ -0,0 +1,194 @@
package discordgo
import (
"net/http"
"strconv"
"strings"
"sync"
"sync/atomic"
"time"
)
// customRateLimit holds information for defining a custom rate limit
type customRateLimit struct {
suffix string
requests int
reset time.Duration
}
// RateLimiter holds all ratelimit buckets
type RateLimiter struct {
sync.Mutex
global *int64
buckets map[string]*Bucket
globalRateLimit time.Duration
customRateLimits []*customRateLimit
}
// NewRatelimiter returns a new RateLimiter
func NewRatelimiter() *RateLimiter {
return &RateLimiter{
buckets: make(map[string]*Bucket),
global: new(int64),
customRateLimits: []*customRateLimit{
&customRateLimit{
suffix: "//reactions//",
requests: 1,
reset: 200 * time.Millisecond,
},
},
}
}
// GetBucket retrieves or creates a bucket
func (r *RateLimiter) GetBucket(key string) *Bucket {
r.Lock()
defer r.Unlock()
if bucket, ok := r.buckets[key]; ok {
return bucket
}
b := &Bucket{
Remaining: 1,
Key: key,
global: r.global,
}
// Check if there is a custom ratelimit set for this bucket ID.
for _, rl := range r.customRateLimits {
if strings.HasSuffix(b.Key, rl.suffix) {
b.customRateLimit = rl
break
}
}
r.buckets[key] = b
return b
}
// GetWaitTime returns the duration you should wait for a Bucket
func (r *RateLimiter) GetWaitTime(b *Bucket, minRemaining int) time.Duration {
// If we ran out of calls and the reset time is still ahead of us
// then we need to take it easy and relax a little
if b.Remaining < minRemaining && b.reset.After(time.Now()) {
return b.reset.Sub(time.Now())
}
// Check for global ratelimits
sleepTo := time.Unix(0, atomic.LoadInt64(r.global))
if now := time.Now(); now.Before(sleepTo) {
return sleepTo.Sub(now)
}
return 0
}
// LockBucket Locks until a request can be made
func (r *RateLimiter) LockBucket(bucketID string) *Bucket {
return r.LockBucketObject(r.GetBucket(bucketID))
}
// LockBucketObject Locks an already resolved bucket until a request can be made
func (r *RateLimiter) LockBucketObject(b *Bucket) *Bucket {
b.Lock()
if wait := r.GetWaitTime(b, 1); wait > 0 {
time.Sleep(wait)
}
b.Remaining--
return b
}
// Bucket represents a ratelimit bucket, each bucket gets ratelimited individually (-global ratelimits)
type Bucket struct {
sync.Mutex
Key string
Remaining int
limit int
reset time.Time
global *int64
lastReset time.Time
customRateLimit *customRateLimit
Userdata interface{}
}
// Release unlocks the bucket and reads the headers to update the buckets ratelimit info
// and locks up the whole thing in case if there's a global ratelimit.
func (b *Bucket) Release(headers http.Header) error {
defer b.Unlock()
// Check if the bucket uses a custom ratelimiter
if rl := b.customRateLimit; rl != nil {
if time.Now().Sub(b.lastReset) >= rl.reset {
b.Remaining = rl.requests - 1
b.lastReset = time.Now()
}
if b.Remaining < 1 {
b.reset = time.Now().Add(rl.reset)
}
return nil
}
if headers == nil {
return nil
}
remaining := headers.Get("X-RateLimit-Remaining")
reset := headers.Get("X-RateLimit-Reset")
global := headers.Get("X-RateLimit-Global")
retryAfter := headers.Get("Retry-After")
// Update global and per bucket reset time if the proper headers are available
// If global is set, then it will block all buckets until after Retry-After
// If Retry-After without global is provided it will use that for the new reset
// time since it's more accurate than X-RateLimit-Reset.
// If Retry-After after is not proided, it will update the reset time from X-RateLimit-Reset
if retryAfter != "" {
parsedAfter, err := strconv.ParseInt(retryAfter, 10, 64)
if err != nil {
return err
}
resetAt := time.Now().Add(time.Duration(parsedAfter) * time.Millisecond)
// Lock either this single bucket or all buckets
if global != "" {
atomic.StoreInt64(b.global, resetAt.UnixNano())
} else {
b.reset = resetAt
}
} else if reset != "" {
// Calculate the reset time by using the date header returned from discord
discordTime, err := http.ParseTime(headers.Get("Date"))
if err != nil {
return err
}
unix, err := strconv.ParseInt(reset, 10, 64)
if err != nil {
return err
}
// Calculate the time until reset and add it to the current local time
// some extra time is added because without it i still encountered 429's.
// The added amount is the lowest amount that gave no 429's
// in 1k requests
delta := time.Unix(unix, 0).Sub(discordTime) + time.Millisecond*250
b.reset = time.Now().Add(delta)
}
// Udpate remaining if header is present
if remaining != "" {
parsedRemaining, err := strconv.ParseInt(remaining, 10, 32)
if err != nil {
return err
}
b.Remaining = int(parsedRemaining)
}
return nil
}

2296
vendor/github.com/matterbridge/discordgo/restapi.go generated vendored Normal file

File diff suppressed because it is too large Load Diff

1022
vendor/github.com/matterbridge/discordgo/state.go generated vendored Normal file

File diff suppressed because it is too large Load Diff

1039
vendor/github.com/matterbridge/discordgo/structs.go generated vendored Normal file

File diff suppressed because it is too large Load Diff

57
vendor/github.com/matterbridge/discordgo/types.go generated vendored Normal file
View File

@@ -0,0 +1,57 @@
// Discordgo - Discord bindings for Go
// Available at https://github.com/bwmarrin/discordgo
// Copyright 2015-2016 Bruce Marriner <bruce@sqls.net>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// This file contains custom types, currently only a timestamp wrapper.
package discordgo
import (
"encoding/json"
"net/http"
"time"
)
// Timestamp stores a timestamp, as sent by the Discord API.
type Timestamp string
// Parse parses a timestamp string into a time.Time object.
// The only time this can fail is if Discord changes their timestamp format.
func (t Timestamp) Parse() (time.Time, error) {
return time.Parse(time.RFC3339, string(t))
}
// RESTError stores error information about a request with a bad response code.
// Message is not always present, there are cases where api calls can fail
// without returning a json message.
type RESTError struct {
Request *http.Request
Response *http.Response
ResponseBody []byte
Message *APIErrorMessage // Message may be nil.
}
func newRestError(req *http.Request, resp *http.Response, body []byte) *RESTError {
restErr := &RESTError{
Request: req,
Response: resp,
ResponseBody: body,
}
// Attempt to decode the error and assume no message was provided if it fails
var msg *APIErrorMessage
err := json.Unmarshal(body, &msg)
if err == nil {
restErr.Message = msg
}
return restErr
}
func (r RESTError) Error() string {
return "HTTP " + r.Response.Status + ", " + string(r.ResponseBody)
}

69
vendor/github.com/matterbridge/discordgo/user.go generated vendored Normal file
View File

@@ -0,0 +1,69 @@
package discordgo
import "strings"
// A User stores all data for an individual Discord user.
type User struct {
// The ID of the user.
ID string `json:"id"`
// The email of the user. This is only present when
// the application possesses the email scope for the user.
Email string `json:"email"`
// The user's username.
Username string `json:"username"`
// The hash of the user's avatar. Use Session.UserAvatar
// to retrieve the avatar itself.
Avatar string `json:"avatar"`
// The user's chosen language option.
Locale string `json:"locale"`
// The discriminator of the user (4 numbers after name).
Discriminator string `json:"discriminator"`
// The token of the user. This is only present for
// the user represented by the current session.
Token string `json:"token"`
// Whether the user's email is verified.
Verified bool `json:"verified"`
// Whether the user has multi-factor authentication enabled.
MFAEnabled bool `json:"mfa_enabled"`
// Whether the user is a bot.
Bot bool `json:"bot"`
}
// String returns a unique identifier of the form username#discriminator
func (u *User) String() string {
return u.Username + "#" + u.Discriminator
}
// Mention return a string which mentions the user
func (u *User) Mention() string {
return "<@" + u.ID + ">"
}
// AvatarURL returns a URL to the user's avatar.
// size: The size of the user's avatar as a power of two
// if size is an empty string, no size parameter will
// be added to the URL.
func (u *User) AvatarURL(size string) string {
var URL string
if u.Avatar == "" {
URL = EndpointDefaultUserAvatar(u.Discriminator)
} else if strings.HasPrefix(u.Avatar, "a_") {
URL = EndpointUserAvatarAnimated(u.ID, u.Avatar)
} else {
URL = EndpointUserAvatar(u.ID, u.Avatar)
}
if size != "" {
return URL + "?size=" + size
}
return URL
}

17
vendor/github.com/matterbridge/discordgo/util.go generated vendored Normal file
View File

@@ -0,0 +1,17 @@
package discordgo
import (
"strconv"
"time"
)
// SnowflakeTimestamp returns the creation time of a Snowflake ID relative to the creation of Discord.
func SnowflakeTimestamp(ID string) (t time.Time, err error) {
i, err := strconv.ParseInt(ID, 10, 64)
if err != nil {
return
}
timestamp := (i >> 22) + 1420070400000
t = time.Unix(timestamp/1000, 0)
return
}

887
vendor/github.com/matterbridge/discordgo/voice.go generated vendored Normal file
View File

@@ -0,0 +1,887 @@
// Discordgo - Discord bindings for Go
// Available at https://github.com/bwmarrin/discordgo
// Copyright 2015-2016 Bruce Marriner <bruce@sqls.net>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// This file contains code related to Discord voice suppport
package discordgo
import (
"encoding/binary"
"encoding/json"
"fmt"
"net"
"strconv"
"strings"
"sync"
"time"
"github.com/gorilla/websocket"
"golang.org/x/crypto/nacl/secretbox"
)
// ------------------------------------------------------------------------------------------------
// Code related to both VoiceConnection Websocket and UDP connections.
// ------------------------------------------------------------------------------------------------
// A VoiceConnection struct holds all the data and functions related to a Discord Voice Connection.
type VoiceConnection struct {
sync.RWMutex
Debug bool // If true, print extra logging -- DEPRECATED
LogLevel int
Ready bool // If true, voice is ready to send/receive audio
UserID string
GuildID string
ChannelID string
deaf bool
mute bool
speaking bool
reconnecting bool // If true, voice connection is trying to reconnect
OpusSend chan []byte // Chan for sending opus audio
OpusRecv chan *Packet // Chan for receiving opus audio
wsConn *websocket.Conn
wsMutex sync.Mutex
udpConn *net.UDPConn
session *Session
sessionID string
token string
endpoint string
// Used to send a close signal to goroutines
close chan struct{}
// Used to allow blocking until connected
connected chan bool
// Used to pass the sessionid from onVoiceStateUpdate
// sessionRecv chan string UNUSED ATM
op4 voiceOP4
op2 voiceOP2
voiceSpeakingUpdateHandlers []VoiceSpeakingUpdateHandler
}
// VoiceSpeakingUpdateHandler type provides a function definition for the
// VoiceSpeakingUpdate event
type VoiceSpeakingUpdateHandler func(vc *VoiceConnection, vs *VoiceSpeakingUpdate)
// Speaking sends a speaking notification to Discord over the voice websocket.
// This must be sent as true prior to sending audio and should be set to false
// once finished sending audio.
// b : Send true if speaking, false if not.
func (v *VoiceConnection) Speaking(b bool) (err error) {
v.log(LogDebug, "called (%t)", b)
type voiceSpeakingData struct {
Speaking bool `json:"speaking"`
Delay int `json:"delay"`
}
type voiceSpeakingOp struct {
Op int `json:"op"` // Always 5
Data voiceSpeakingData `json:"d"`
}
if v.wsConn == nil {
return fmt.Errorf("no VoiceConnection websocket")
}
data := voiceSpeakingOp{5, voiceSpeakingData{b, 0}}
v.wsMutex.Lock()
err = v.wsConn.WriteJSON(data)
v.wsMutex.Unlock()
v.Lock()
defer v.Unlock()
if err != nil {
v.speaking = false
v.log(LogError, "Speaking() write json error, %s", err)
return
}
v.speaking = b
return
}
// ChangeChannel sends Discord a request to change channels within a Guild
// !!! NOTE !!! This function may be removed in favour of just using ChannelVoiceJoin
func (v *VoiceConnection) ChangeChannel(channelID string, mute, deaf bool) (err error) {
v.log(LogInformational, "called")
data := voiceChannelJoinOp{4, voiceChannelJoinData{&v.GuildID, &channelID, mute, deaf}}
v.wsMutex.Lock()
err = v.session.wsConn.WriteJSON(data)
v.wsMutex.Unlock()
if err != nil {
return
}
v.ChannelID = channelID
v.deaf = deaf
v.mute = mute
v.speaking = false
return
}
// Disconnect disconnects from this voice channel and closes the websocket
// and udp connections to Discord.
func (v *VoiceConnection) Disconnect() (err error) {
// Send a OP4 with a nil channel to disconnect
if v.sessionID != "" {
data := voiceChannelJoinOp{4, voiceChannelJoinData{&v.GuildID, nil, true, true}}
v.session.wsMutex.Lock()
err = v.session.wsConn.WriteJSON(data)
v.session.wsMutex.Unlock()
v.sessionID = ""
}
// Close websocket and udp connections
v.Close()
v.log(LogInformational, "Deleting VoiceConnection %s", v.GuildID)
v.session.Lock()
delete(v.session.VoiceConnections, v.GuildID)
v.session.Unlock()
return
}
// Close closes the voice ws and udp connections
func (v *VoiceConnection) Close() {
v.log(LogInformational, "called")
v.Lock()
defer v.Unlock()
v.Ready = false
v.speaking = false
if v.close != nil {
v.log(LogInformational, "closing v.close")
close(v.close)
v.close = nil
}
if v.udpConn != nil {
v.log(LogInformational, "closing udp")
err := v.udpConn.Close()
if err != nil {
v.log(LogError, "error closing udp connection, %s", err)
}
v.udpConn = nil
}
if v.wsConn != nil {
v.log(LogInformational, "sending close frame")
// To cleanly close a connection, a client should send a close
// frame and wait for the server to close the connection.
v.wsMutex.Lock()
err := v.wsConn.WriteMessage(websocket.CloseMessage, websocket.FormatCloseMessage(websocket.CloseNormalClosure, ""))
v.wsMutex.Unlock()
if err != nil {
v.log(LogError, "error closing websocket, %s", err)
}
// TODO: Wait for Discord to actually close the connection.
time.Sleep(1 * time.Second)
v.log(LogInformational, "closing websocket")
err = v.wsConn.Close()
if err != nil {
v.log(LogError, "error closing websocket, %s", err)
}
v.wsConn = nil
}
}
// AddHandler adds a Handler for VoiceSpeakingUpdate events.
func (v *VoiceConnection) AddHandler(h VoiceSpeakingUpdateHandler) {
v.Lock()
defer v.Unlock()
v.voiceSpeakingUpdateHandlers = append(v.voiceSpeakingUpdateHandlers, h)
}
// VoiceSpeakingUpdate is a struct for a VoiceSpeakingUpdate event.
type VoiceSpeakingUpdate struct {
UserID string `json:"user_id"`
SSRC int `json:"ssrc"`
Speaking bool `json:"speaking"`
}
// ------------------------------------------------------------------------------------------------
// Unexported Internal Functions Below.
// ------------------------------------------------------------------------------------------------
// A voiceOP4 stores the data for the voice operation 4 websocket event
// which provides us with the NaCl SecretBox encryption key
type voiceOP4 struct {
SecretKey [32]byte `json:"secret_key"`
Mode string `json:"mode"`
}
// A voiceOP2 stores the data for the voice operation 2 websocket event
// which is sort of like the voice READY packet
type voiceOP2 struct {
SSRC uint32 `json:"ssrc"`
Port int `json:"port"`
Modes []string `json:"modes"`
HeartbeatInterval time.Duration `json:"heartbeat_interval"`
IP string `json:"ip"`
}
// WaitUntilConnected waits for the Voice Connection to
// become ready, if it does not become ready it returns an err
func (v *VoiceConnection) waitUntilConnected() error {
v.log(LogInformational, "called")
i := 0
for {
v.RLock()
ready := v.Ready
v.RUnlock()
if ready {
return nil
}
if i > 10 {
return fmt.Errorf("timeout waiting for voice")
}
time.Sleep(1 * time.Second)
i++
}
}
// Open opens a voice connection. This should be called
// after VoiceChannelJoin is used and the data VOICE websocket events
// are captured.
func (v *VoiceConnection) open() (err error) {
v.log(LogInformational, "called")
v.Lock()
defer v.Unlock()
// Don't open a websocket if one is already open
if v.wsConn != nil {
v.log(LogWarning, "refusing to overwrite non-nil websocket")
return
}
// TODO temp? loop to wait for the SessionID
i := 0
for {
if v.sessionID != "" {
break
}
if i > 20 { // only loop for up to 1 second total
return fmt.Errorf("did not receive voice Session ID in time")
}
time.Sleep(50 * time.Millisecond)
i++
}
// Connect to VoiceConnection Websocket
vg := "wss://" + strings.TrimSuffix(v.endpoint, ":80")
v.log(LogInformational, "connecting to voice endpoint %s", vg)
v.wsConn, _, err = websocket.DefaultDialer.Dial(vg, nil)
if err != nil {
v.log(LogWarning, "error connecting to voice endpoint %s, %s", vg, err)
v.log(LogDebug, "voice struct: %#v\n", v)
return
}
type voiceHandshakeData struct {
ServerID string `json:"server_id"`
UserID string `json:"user_id"`
SessionID string `json:"session_id"`
Token string `json:"token"`
}
type voiceHandshakeOp struct {
Op int `json:"op"` // Always 0
Data voiceHandshakeData `json:"d"`
}
data := voiceHandshakeOp{0, voiceHandshakeData{v.GuildID, v.UserID, v.sessionID, v.token}}
err = v.wsConn.WriteJSON(data)
if err != nil {
v.log(LogWarning, "error sending init packet, %s", err)
return
}
v.close = make(chan struct{})
go v.wsListen(v.wsConn, v.close)
// add loop/check for Ready bool here?
// then return false if not ready?
// but then wsListen will also err.
return
}
// wsListen listens on the voice websocket for messages and passes them
// to the voice event handler. This is automatically called by the Open func
func (v *VoiceConnection) wsListen(wsConn *websocket.Conn, close <-chan struct{}) {
v.log(LogInformational, "called")
for {
_, message, err := v.wsConn.ReadMessage()
if err != nil {
// Detect if we have been closed manually. If a Close() has already
// happened, the websocket we are listening on will be different to the
// current session.
v.RLock()
sameConnection := v.wsConn == wsConn
v.RUnlock()
if sameConnection {
v.log(LogError, "voice endpoint %s websocket closed unexpectantly, %s", v.endpoint, err)
// Start reconnect goroutine then exit.
go v.reconnect()
}
return
}
// Pass received message to voice event handler
select {
case <-close:
return
default:
go v.onEvent(message)
}
}
}
// wsEvent handles any voice websocket events. This is only called by the
// wsListen() function.
func (v *VoiceConnection) onEvent(message []byte) {
v.log(LogDebug, "received: %s", string(message))
var e Event
if err := json.Unmarshal(message, &e); err != nil {
v.log(LogError, "unmarshall error, %s", err)
return
}
switch e.Operation {
case 2: // READY
if err := json.Unmarshal(e.RawData, &v.op2); err != nil {
v.log(LogError, "OP2 unmarshall error, %s, %s", err, string(e.RawData))
return
}
// Start the voice websocket heartbeat to keep the connection alive
go v.wsHeartbeat(v.wsConn, v.close, v.op2.HeartbeatInterval)
// TODO monitor a chan/bool to verify this was successful
// Start the UDP connection
err := v.udpOpen()
if err != nil {
v.log(LogError, "error opening udp connection, %s", err)
return
}
// Start the opusSender.
// TODO: Should we allow 48000/960 values to be user defined?
if v.OpusSend == nil {
v.OpusSend = make(chan []byte, 2)
}
go v.opusSender(v.udpConn, v.close, v.OpusSend, 48000, 960)
// Start the opusReceiver
if !v.deaf {
if v.OpusRecv == nil {
v.OpusRecv = make(chan *Packet, 2)
}
go v.opusReceiver(v.udpConn, v.close, v.OpusRecv)
}
return
case 3: // HEARTBEAT response
// add code to use this to track latency?
return
case 4: // udp encryption secret key
v.Lock()
defer v.Unlock()
v.op4 = voiceOP4{}
if err := json.Unmarshal(e.RawData, &v.op4); err != nil {
v.log(LogError, "OP4 unmarshall error, %s, %s", err, string(e.RawData))
return
}
return
case 5:
if len(v.voiceSpeakingUpdateHandlers) == 0 {
return
}
voiceSpeakingUpdate := &VoiceSpeakingUpdate{}
if err := json.Unmarshal(e.RawData, voiceSpeakingUpdate); err != nil {
v.log(LogError, "OP5 unmarshall error, %s, %s", err, string(e.RawData))
return
}
for _, h := range v.voiceSpeakingUpdateHandlers {
h(v, voiceSpeakingUpdate)
}
default:
v.log(LogDebug, "unknown voice operation, %d, %s", e.Operation, string(e.RawData))
}
return
}
type voiceHeartbeatOp struct {
Op int `json:"op"` // Always 3
Data int `json:"d"`
}
// NOTE :: When a guild voice server changes how do we shut this down
// properly, so a new connection can be setup without fuss?
//
// wsHeartbeat sends regular heartbeats to voice Discord so it knows the client
// is still connected. If you do not send these heartbeats Discord will
// disconnect the websocket connection after a few seconds.
func (v *VoiceConnection) wsHeartbeat(wsConn *websocket.Conn, close <-chan struct{}, i time.Duration) {
if close == nil || wsConn == nil {
return
}
var err error
ticker := time.NewTicker(i * time.Millisecond)
defer ticker.Stop()
for {
v.log(LogDebug, "sending heartbeat packet")
v.wsMutex.Lock()
err = wsConn.WriteJSON(voiceHeartbeatOp{3, int(time.Now().Unix())})
v.wsMutex.Unlock()
if err != nil {
v.log(LogError, "error sending heartbeat to voice endpoint %s, %s", v.endpoint, err)
return
}
select {
case <-ticker.C:
// continue loop and send heartbeat
case <-close:
return
}
}
}
// ------------------------------------------------------------------------------------------------
// Code related to the VoiceConnection UDP connection
// ------------------------------------------------------------------------------------------------
type voiceUDPData struct {
Address string `json:"address"` // Public IP of machine running this code
Port uint16 `json:"port"` // UDP Port of machine running this code
Mode string `json:"mode"` // always "xsalsa20_poly1305"
}
type voiceUDPD struct {
Protocol string `json:"protocol"` // Always "udp" ?
Data voiceUDPData `json:"data"`
}
type voiceUDPOp struct {
Op int `json:"op"` // Always 1
Data voiceUDPD `json:"d"`
}
// udpOpen opens a UDP connection to the voice server and completes the
// initial required handshake. This connection is left open in the session
// and can be used to send or receive audio. This should only be called
// from voice.wsEvent OP2
func (v *VoiceConnection) udpOpen() (err error) {
v.Lock()
defer v.Unlock()
if v.wsConn == nil {
return fmt.Errorf("nil voice websocket")
}
if v.udpConn != nil {
return fmt.Errorf("udp connection already open")
}
if v.close == nil {
return fmt.Errorf("nil close channel")
}
if v.endpoint == "" {
return fmt.Errorf("empty endpoint")
}
host := v.op2.IP + ":" + strconv.Itoa(v.op2.Port)
addr, err := net.ResolveUDPAddr("udp", host)
if err != nil {
v.log(LogWarning, "error resolving udp host %s, %s", host, err)
return
}
v.log(LogInformational, "connecting to udp addr %s", addr.String())
v.udpConn, err = net.DialUDP("udp", nil, addr)
if err != nil {
v.log(LogWarning, "error connecting to udp addr %s, %s", addr.String(), err)
return
}
// Create a 70 byte array and put the SSRC code from the Op 2 VoiceConnection event
// into it. Then send that over the UDP connection to Discord
sb := make([]byte, 70)
binary.BigEndian.PutUint32(sb, v.op2.SSRC)
_, err = v.udpConn.Write(sb)
if err != nil {
v.log(LogWarning, "udp write error to %s, %s", addr.String(), err)
return
}
// Create a 70 byte array and listen for the initial handshake response
// from Discord. Once we get it parse the IP and PORT information out
// of the response. This should be our public IP and PORT as Discord
// saw us.
rb := make([]byte, 70)
rlen, _, err := v.udpConn.ReadFromUDP(rb)
if err != nil {
v.log(LogWarning, "udp read error, %s, %s", addr.String(), err)
return
}
if rlen < 70 {
v.log(LogWarning, "received udp packet too small")
return fmt.Errorf("received udp packet too small")
}
// Loop over position 4 through 20 to grab the IP address
// Should never be beyond position 20.
var ip string
for i := 4; i < 20; i++ {
if rb[i] == 0 {
break
}
ip += string(rb[i])
}
// Grab port from position 68 and 69
port := binary.BigEndian.Uint16(rb[68:70])
// Take the data from above and send it back to Discord to finalize
// the UDP connection handshake.
data := voiceUDPOp{1, voiceUDPD{"udp", voiceUDPData{ip, port, "xsalsa20_poly1305"}}}
v.wsMutex.Lock()
err = v.wsConn.WriteJSON(data)
v.wsMutex.Unlock()
if err != nil {
v.log(LogWarning, "udp write error, %#v, %s", data, err)
return
}
// start udpKeepAlive
go v.udpKeepAlive(v.udpConn, v.close, 5*time.Second)
// TODO: find a way to check that it fired off okay
return
}
// udpKeepAlive sends a udp packet to keep the udp connection open
// This is still a bit of a "proof of concept"
func (v *VoiceConnection) udpKeepAlive(udpConn *net.UDPConn, close <-chan struct{}, i time.Duration) {
if udpConn == nil || close == nil {
return
}
var err error
var sequence uint64
packet := make([]byte, 8)
ticker := time.NewTicker(i)
defer ticker.Stop()
for {
binary.LittleEndian.PutUint64(packet, sequence)
sequence++
_, err = udpConn.Write(packet)
if err != nil {
v.log(LogError, "write error, %s", err)
return
}
select {
case <-ticker.C:
// continue loop and send keepalive
case <-close:
return
}
}
}
// opusSender will listen on the given channel and send any
// pre-encoded opus audio to Discord. Supposedly.
func (v *VoiceConnection) opusSender(udpConn *net.UDPConn, close <-chan struct{}, opus <-chan []byte, rate, size int) {
if udpConn == nil || close == nil {
return
}
// VoiceConnection is now ready to receive audio packets
// TODO: this needs reviewed as I think there must be a better way.
v.Lock()
v.Ready = true
v.Unlock()
defer func() {
v.Lock()
v.Ready = false
v.Unlock()
}()
var sequence uint16
var timestamp uint32
var recvbuf []byte
var ok bool
udpHeader := make([]byte, 12)
var nonce [24]byte
// build the parts that don't change in the udpHeader
udpHeader[0] = 0x80
udpHeader[1] = 0x78
binary.BigEndian.PutUint32(udpHeader[8:], v.op2.SSRC)
// start a send loop that loops until buf chan is closed
ticker := time.NewTicker(time.Millisecond * time.Duration(size/(rate/1000)))
defer ticker.Stop()
for {
// Get data from chan. If chan is closed, return.
select {
case <-close:
return
case recvbuf, ok = <-opus:
if !ok {
return
}
// else, continue loop
}
v.RLock()
speaking := v.speaking
v.RUnlock()
if !speaking {
err := v.Speaking(true)
if err != nil {
v.log(LogError, "error sending speaking packet, %s", err)
}
}
// Add sequence and timestamp to udpPacket
binary.BigEndian.PutUint16(udpHeader[2:], sequence)
binary.BigEndian.PutUint32(udpHeader[4:], timestamp)
// encrypt the opus data
copy(nonce[:], udpHeader)
v.RLock()
sendbuf := secretbox.Seal(udpHeader, recvbuf, &nonce, &v.op4.SecretKey)
v.RUnlock()
// block here until we're exactly at the right time :)
// Then send rtp audio packet to Discord over UDP
select {
case <-close:
return
case <-ticker.C:
// continue
}
_, err := udpConn.Write(sendbuf)
if err != nil {
v.log(LogError, "udp write error, %s", err)
v.log(LogDebug, "voice struct: %#v\n", v)
return
}
if (sequence) == 0xFFFF {
sequence = 0
} else {
sequence++
}
if (timestamp + uint32(size)) >= 0xFFFFFFFF {
timestamp = 0
} else {
timestamp += uint32(size)
}
}
}
// A Packet contains the headers and content of a received voice packet.
type Packet struct {
SSRC uint32
Sequence uint16
Timestamp uint32
Type []byte
Opus []byte
PCM []int16
}
// opusReceiver listens on the UDP socket for incoming packets
// and sends them across the given channel
// NOTE :: This function may change names later.
func (v *VoiceConnection) opusReceiver(udpConn *net.UDPConn, close <-chan struct{}, c chan *Packet) {
if udpConn == nil || close == nil {
return
}
recvbuf := make([]byte, 1024)
var nonce [24]byte
for {
rlen, err := udpConn.Read(recvbuf)
if err != nil {
// Detect if we have been closed manually. If a Close() has already
// happened, the udp connection we are listening on will be different
// to the current session.
v.RLock()
sameConnection := v.udpConn == udpConn
v.RUnlock()
if sameConnection {
v.log(LogError, "udp read error, %s, %s", v.endpoint, err)
v.log(LogDebug, "voice struct: %#v\n", v)
go v.reconnect()
}
return
}
select {
case <-close:
return
default:
// continue loop
}
// For now, skip anything except audio.
if rlen < 12 || (recvbuf[0] != 0x80 && recvbuf[0] != 0x90) {
continue
}
// build a audio packet struct
p := Packet{}
p.Type = recvbuf[0:2]
p.Sequence = binary.BigEndian.Uint16(recvbuf[2:4])
p.Timestamp = binary.BigEndian.Uint32(recvbuf[4:8])
p.SSRC = binary.BigEndian.Uint32(recvbuf[8:12])
// decrypt opus data
copy(nonce[:], recvbuf[0:12])
p.Opus, _ = secretbox.Open(nil, recvbuf[12:rlen], &nonce, &v.op4.SecretKey)
if len(p.Opus) > 8 && recvbuf[0] == 0x90 {
// Extension bit is set, first 8 bytes is the extended header
p.Opus = p.Opus[8:]
}
if c != nil {
select {
case c <- &p:
case <-close:
return
}
}
}
}
// Reconnect will close down a voice connection then immediately try to
// reconnect to that session.
// NOTE : This func is messy and a WIP while I find what works.
// It will be cleaned up once a proven stable option is flushed out.
// aka: this is ugly shit code, please don't judge too harshly.
func (v *VoiceConnection) reconnect() {
v.log(LogInformational, "called")
v.Lock()
if v.reconnecting {
v.log(LogInformational, "already reconnecting to channel %s, exiting", v.ChannelID)
v.Unlock()
return
}
v.reconnecting = true
v.Unlock()
defer func() { v.reconnecting = false }()
// Close any currently open connections
v.Close()
wait := time.Duration(1)
for {
<-time.After(wait * time.Second)
wait *= 2
if wait > 600 {
wait = 600
}
if v.session.DataReady == false || v.session.wsConn == nil {
v.log(LogInformational, "cannot reconnect to channel %s with unready session", v.ChannelID)
continue
}
v.log(LogInformational, "trying to reconnect to channel %s", v.ChannelID)
_, err := v.session.ChannelVoiceJoin(v.GuildID, v.ChannelID, v.mute, v.deaf)
if err == nil {
v.log(LogInformational, "successfully reconnected to channel %s", v.ChannelID)
return
}
v.log(LogInformational, "error reconnecting to channel %s, %s", v.ChannelID, err)
// if the reconnect above didn't work lets just send a disconnect
// packet to reset things.
// Send a OP4 with a nil channel to disconnect
data := voiceChannelJoinOp{4, voiceChannelJoinData{&v.GuildID, nil, true, true}}
v.session.wsMutex.Lock()
err = v.session.wsConn.WriteJSON(data)
v.session.wsMutex.Unlock()
if err != nil {
v.log(LogError, "error sending disconnect packet, %s", err)
}
}
}

884
vendor/github.com/matterbridge/discordgo/wsapi.go generated vendored Normal file
View File

@@ -0,0 +1,884 @@
// Discordgo - Discord bindings for Go
// Available at https://github.com/bwmarrin/discordgo
// Copyright 2015-2016 Bruce Marriner <bruce@sqls.net>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// This file contains low level functions for interacting with the Discord
// data websocket interface.
package discordgo
import (
"bytes"
"compress/zlib"
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
"runtime"
"sync/atomic"
"time"
"github.com/gorilla/websocket"
)
// ErrWSAlreadyOpen is thrown when you attempt to open
// a websocket that already is open.
var ErrWSAlreadyOpen = errors.New("web socket already opened")
// ErrWSNotFound is thrown when you attempt to use a websocket
// that doesn't exist
var ErrWSNotFound = errors.New("no websocket connection exists")
// ErrWSShardBounds is thrown when you try to use a shard ID that is
// less than the total shard count
var ErrWSShardBounds = errors.New("ShardID must be less than ShardCount")
type resumePacket struct {
Op int `json:"op"`
Data struct {
Token string `json:"token"`
SessionID string `json:"session_id"`
Sequence int64 `json:"seq"`
} `json:"d"`
}
// Open creates a websocket connection to Discord.
// See: https://discordapp.com/developers/docs/topics/gateway#connecting
func (s *Session) Open() error {
s.log(LogInformational, "called")
var err error
// Prevent Open or other major Session functions from
// being called while Open is still running.
s.Lock()
defer s.Unlock()
// If the websock is already open, bail out here.
if s.wsConn != nil {
return ErrWSAlreadyOpen
}
// Get the gateway to use for the Websocket connection
if s.gateway == "" {
s.gateway, err = s.Gateway()
if err != nil {
return err
}
// Add the version and encoding to the URL
s.gateway = s.gateway + "?v=" + APIVersion + "&encoding=json"
}
// Connect to the Gateway
s.log(LogInformational, "connecting to gateway %s", s.gateway)
header := http.Header{}
header.Add("accept-encoding", "zlib")
s.wsConn, _, err = websocket.DefaultDialer.Dial(s.gateway, header)
if err != nil {
s.log(LogWarning, "error connecting to gateway %s, %s", s.gateway, err)
s.gateway = "" // clear cached gateway
s.wsConn = nil // Just to be safe.
return err
}
s.wsConn.SetCloseHandler(func(code int, text string) error {
return nil
})
defer func() {
// because of this, all code below must set err to the error
// when exiting with an error :) Maybe someone has a better
// way :)
if err != nil {
s.wsConn.Close()
s.wsConn = nil
}
}()
// The first response from Discord should be an Op 10 (Hello) Packet.
// When processed by onEvent the heartbeat goroutine will be started.
mt, m, err := s.wsConn.ReadMessage()
if err != nil {
return err
}
e, err := s.onEvent(mt, m)
if err != nil {
return err
}
if e.Operation != 10 {
err = fmt.Errorf("expecting Op 10, got Op %d instead", e.Operation)
return err
}
s.log(LogInformational, "Op 10 Hello Packet received from Discord")
s.LastHeartbeatAck = time.Now().UTC()
var h helloOp
if err = json.Unmarshal(e.RawData, &h); err != nil {
err = fmt.Errorf("error unmarshalling helloOp, %s", err)
return err
}
// Now we send either an Op 2 Identity if this is a brand new
// connection or Op 6 Resume if we are resuming an existing connection.
sequence := atomic.LoadInt64(s.sequence)
if s.sessionID == "" && sequence == 0 {
// Send Op 2 Identity Packet
err = s.identify()
if err != nil {
err = fmt.Errorf("error sending identify packet to gateway, %s, %s", s.gateway, err)
return err
}
} else {
// Send Op 6 Resume Packet
p := resumePacket{}
p.Op = 6
p.Data.Token = s.Token
p.Data.SessionID = s.sessionID
p.Data.Sequence = sequence
s.log(LogInformational, "sending resume packet to gateway")
s.wsMutex.Lock()
err = s.wsConn.WriteJSON(p)
s.wsMutex.Unlock()
if err != nil {
err = fmt.Errorf("error sending gateway resume packet, %s, %s", s.gateway, err)
return err
}
}
// A basic state is a hard requirement for Voice.
// We create it here so the below READY/RESUMED packet can populate
// the state :)
// XXX: Move to New() func?
if s.State == nil {
state := NewState()
state.TrackChannels = false
state.TrackEmojis = false
state.TrackMembers = false
state.TrackRoles = false
state.TrackVoice = false
s.State = state
}
// Now Discord should send us a READY or RESUMED packet.
mt, m, err = s.wsConn.ReadMessage()
if err != nil {
return err
}
e, err = s.onEvent(mt, m)
if err != nil {
return err
}
if e.Type != `READY` && e.Type != `RESUMED` {
// This is not fatal, but it does not follow their API documentation.
s.log(LogWarning, "Expected READY/RESUMED, instead got:\n%#v\n", e)
}
s.log(LogInformational, "First Packet:\n%#v\n", e)
s.log(LogInformational, "We are now connected to Discord, emitting connect event")
s.handleEvent(connectEventType, &Connect{})
// A VoiceConnections map is a hard requirement for Voice.
// XXX: can this be moved to when opening a voice connection?
if s.VoiceConnections == nil {
s.log(LogInformational, "creating new VoiceConnections map")
s.VoiceConnections = make(map[string]*VoiceConnection)
}
// Create listening chan outside of listen, as it needs to happen inside the
// mutex lock and needs to exist before calling heartbeat and listen
// go rountines.
s.listening = make(chan interface{})
// Start sending heartbeats and reading messages from Discord.
go s.heartbeat(s.wsConn, s.listening, h.HeartbeatInterval)
go s.listen(s.wsConn, s.listening)
s.log(LogInformational, "exiting")
return nil
}
// listen polls the websocket connection for events, it will stop when the
// listening channel is closed, or an error occurs.
func (s *Session) listen(wsConn *websocket.Conn, listening <-chan interface{}) {
s.log(LogInformational, "called")
for {
messageType, message, err := wsConn.ReadMessage()
if err != nil {
// Detect if we have been closed manually. If a Close() has already
// happened, the websocket we are listening on will be different to
// the current session.
s.RLock()
sameConnection := s.wsConn == wsConn
s.RUnlock()
if sameConnection {
s.log(LogWarning, "error reading from gateway %s websocket, %s", s.gateway, err)
// There has been an error reading, close the websocket so that
// OnDisconnect event is emitted.
err := s.Close()
if err != nil {
s.log(LogWarning, "error closing session connection, %s", err)
}
s.log(LogInformational, "calling reconnect() now")
s.reconnect()
}
return
}
select {
case <-listening:
return
default:
s.onEvent(messageType, message)
}
}
}
type heartbeatOp struct {
Op int `json:"op"`
Data int64 `json:"d"`
}
type helloOp struct {
HeartbeatInterval time.Duration `json:"heartbeat_interval"`
}
// FailedHeartbeatAcks is the Number of heartbeat intervals to wait until forcing a connection restart.
const FailedHeartbeatAcks time.Duration = 5 * time.Millisecond
// HeartbeatLatency returns the latency between heartbeat acknowledgement and heartbeat send.
func (s *Session) HeartbeatLatency() time.Duration {
return s.LastHeartbeatAck.Sub(s.LastHeartbeatSent)
}
// heartbeat sends regular heartbeats to Discord so it knows the client
// is still connected. If you do not send these heartbeats Discord will
// disconnect the websocket connection after a few seconds.
func (s *Session) heartbeat(wsConn *websocket.Conn, listening <-chan interface{}, heartbeatIntervalMsec time.Duration) {
s.log(LogInformational, "called")
if listening == nil || wsConn == nil {
return
}
var err error
ticker := time.NewTicker(heartbeatIntervalMsec * time.Millisecond)
defer ticker.Stop()
for {
s.RLock()
last := s.LastHeartbeatAck
s.RUnlock()
sequence := atomic.LoadInt64(s.sequence)
s.log(LogDebug, "sending gateway websocket heartbeat seq %d", sequence)
s.wsMutex.Lock()
s.LastHeartbeatSent = time.Now().UTC()
err = wsConn.WriteJSON(heartbeatOp{1, sequence})
s.wsMutex.Unlock()
if err != nil || time.Now().UTC().Sub(last) > (heartbeatIntervalMsec*FailedHeartbeatAcks) {
if err != nil {
s.log(LogError, "error sending heartbeat to gateway %s, %s", s.gateway, err)
} else {
s.log(LogError, "haven't gotten a heartbeat ACK in %v, triggering a reconnection", time.Now().UTC().Sub(last))
}
s.Close()
s.reconnect()
return
}
s.Lock()
s.DataReady = true
s.Unlock()
select {
case <-ticker.C:
// continue loop and send heartbeat
case <-listening:
return
}
}
}
// UpdateStatusData ia provided to UpdateStatusComplex()
type UpdateStatusData struct {
IdleSince *int `json:"since"`
Game *Game `json:"game"`
AFK bool `json:"afk"`
Status string `json:"status"`
}
type updateStatusOp struct {
Op int `json:"op"`
Data UpdateStatusData `json:"d"`
}
func newUpdateStatusData(idle int, gameType GameType, game, url string) *UpdateStatusData {
usd := &UpdateStatusData{
Status: "online",
}
if idle > 0 {
usd.IdleSince = &idle
}
if game != "" {
usd.Game = &Game{
Name: game,
Type: gameType,
URL: url,
}
}
return usd
}
// UpdateStatus is used to update the user's status.
// If idle>0 then set status to idle.
// If game!="" then set game.
// if otherwise, set status to active, and no game.
func (s *Session) UpdateStatus(idle int, game string) (err error) {
return s.UpdateStatusComplex(*newUpdateStatusData(idle, GameTypeGame, game, ""))
}
// UpdateStreamingStatus is used to update the user's streaming status.
// If idle>0 then set status to idle.
// If game!="" then set game.
// If game!="" and url!="" then set the status type to streaming with the URL set.
// if otherwise, set status to active, and no game.
func (s *Session) UpdateStreamingStatus(idle int, game string, url string) (err error) {
gameType := GameTypeGame
if url != "" {
gameType = GameTypeStreaming
}
return s.UpdateStatusComplex(*newUpdateStatusData(idle, gameType, game, url))
}
// UpdateListeningStatus is used to set the user to "Listening to..."
// If game!="" then set to what user is listening to
// Else, set user to active and no game.
func (s *Session) UpdateListeningStatus(game string) (err error) {
return s.UpdateStatusComplex(*newUpdateStatusData(0, GameTypeListening, game, ""))
}
// UpdateStatusComplex allows for sending the raw status update data untouched by discordgo.
func (s *Session) UpdateStatusComplex(usd UpdateStatusData) (err error) {
s.RLock()
defer s.RUnlock()
if s.wsConn == nil {
return ErrWSNotFound
}
s.wsMutex.Lock()
err = s.wsConn.WriteJSON(updateStatusOp{3, usd})
s.wsMutex.Unlock()
return
}
type requestGuildMembersData struct {
GuildID string `json:"guild_id"`
Query string `json:"query"`
Limit int `json:"limit"`
}
type requestGuildMembersOp struct {
Op int `json:"op"`
Data requestGuildMembersData `json:"d"`
}
// RequestGuildMembers requests guild members from the gateway
// The gateway responds with GuildMembersChunk events
// guildID : The ID of the guild to request members of
// query : String that username starts with, leave empty to return all members
// limit : Max number of items to return, or 0 to request all members matched
func (s *Session) RequestGuildMembers(guildID, query string, limit int) (err error) {
s.log(LogInformational, "called")
s.RLock()
defer s.RUnlock()
if s.wsConn == nil {
return ErrWSNotFound
}
data := requestGuildMembersData{
GuildID: guildID,
Query: query,
Limit: limit,
}
s.wsMutex.Lock()
err = s.wsConn.WriteJSON(requestGuildMembersOp{8, data})
s.wsMutex.Unlock()
return
}
// onEvent is the "event handler" for all messages received on the
// Discord Gateway API websocket connection.
//
// If you use the AddHandler() function to register a handler for a
// specific event this function will pass the event along to that handler.
//
// If you use the AddHandler() function to register a handler for the
// "OnEvent" event then all events will be passed to that handler.
func (s *Session) onEvent(messageType int, message []byte) (*Event, error) {
var err error
var reader io.Reader
reader = bytes.NewBuffer(message)
// If this is a compressed message, uncompress it.
if messageType == websocket.BinaryMessage {
z, err2 := zlib.NewReader(reader)
if err2 != nil {
s.log(LogError, "error uncompressing websocket message, %s", err)
return nil, err2
}
defer func() {
err3 := z.Close()
if err3 != nil {
s.log(LogWarning, "error closing zlib, %s", err)
}
}()
reader = z
}
// Decode the event into an Event struct.
var e *Event
decoder := json.NewDecoder(reader)
if err = decoder.Decode(&e); err != nil {
s.log(LogError, "error decoding websocket message, %s", err)
return e, err
}
s.log(LogDebug, "Op: %d, Seq: %d, Type: %s, Data: %s\n\n", e.Operation, e.Sequence, e.Type, string(e.RawData))
// Ping request.
// Must respond with a heartbeat packet within 5 seconds
if e.Operation == 1 {
s.log(LogInformational, "sending heartbeat in response to Op1")
s.wsMutex.Lock()
err = s.wsConn.WriteJSON(heartbeatOp{1, atomic.LoadInt64(s.sequence)})
s.wsMutex.Unlock()
if err != nil {
s.log(LogError, "error sending heartbeat in response to Op1")
return e, err
}
return e, nil
}
// Reconnect
// Must immediately disconnect from gateway and reconnect to new gateway.
if e.Operation == 7 {
s.log(LogInformational, "Closing and reconnecting in response to Op7")
s.Close()
s.reconnect()
return e, nil
}
// Invalid Session
// Must respond with a Identify packet.
if e.Operation == 9 {
s.log(LogInformational, "sending identify packet to gateway in response to Op9")
err = s.identify()
if err != nil {
s.log(LogWarning, "error sending gateway identify packet, %s, %s", s.gateway, err)
return e, err
}
return e, nil
}
if e.Operation == 10 {
// Op10 is handled by Open()
return e, nil
}
if e.Operation == 11 {
s.Lock()
s.LastHeartbeatAck = time.Now().UTC()
s.Unlock()
s.log(LogDebug, "got heartbeat ACK")
return e, nil
}
// Do not try to Dispatch a non-Dispatch Message
if e.Operation != 0 {
// But we probably should be doing something with them.
// TEMP
s.log(LogWarning, "unknown Op: %d, Seq: %d, Type: %s, Data: %s, message: %s", e.Operation, e.Sequence, e.Type, string(e.RawData), string(message))
return e, nil
}
// Store the message sequence
atomic.StoreInt64(s.sequence, e.Sequence)
// Map event to registered event handlers and pass it along to any registered handlers.
if eh, ok := registeredInterfaceProviders[e.Type]; ok {
e.Struct = eh.New()
// Attempt to unmarshal our event.
if err = json.Unmarshal(e.RawData, e.Struct); err != nil {
s.log(LogError, "error unmarshalling %s event, %s", e.Type, err)
}
// Send event to any registered event handlers for it's type.
// Because the above doesn't cancel this, in case of an error
// the struct could be partially populated or at default values.
// However, most errors are due to a single field and I feel
// it's better to pass along what we received than nothing at all.
// TODO: Think about that decision :)
// Either way, READY events must fire, even with errors.
s.handleEvent(e.Type, e.Struct)
} else {
s.log(LogWarning, "unknown event: Op: %d, Seq: %d, Type: %s, Data: %s", e.Operation, e.Sequence, e.Type, string(e.RawData))
}
// For legacy reasons, we send the raw event also, this could be useful for handling unknown events.
s.handleEvent(eventEventType, e)
return e, nil
}
// ------------------------------------------------------------------------------------------------
// Code related to voice connections that initiate over the data websocket
// ------------------------------------------------------------------------------------------------
type voiceChannelJoinData struct {
GuildID *string `json:"guild_id"`
ChannelID *string `json:"channel_id"`
SelfMute bool `json:"self_mute"`
SelfDeaf bool `json:"self_deaf"`
}
type voiceChannelJoinOp struct {
Op int `json:"op"`
Data voiceChannelJoinData `json:"d"`
}
// ChannelVoiceJoin joins the session user to a voice channel.
//
// gID : Guild ID of the channel to join.
// cID : Channel ID of the channel to join.
// mute : If true, you will be set to muted upon joining.
// deaf : If true, you will be set to deafened upon joining.
func (s *Session) ChannelVoiceJoin(gID, cID string, mute, deaf bool) (voice *VoiceConnection, err error) {
s.log(LogInformational, "called")
s.RLock()
voice, _ = s.VoiceConnections[gID]
s.RUnlock()
if voice == nil {
voice = &VoiceConnection{}
s.Lock()
s.VoiceConnections[gID] = voice
s.Unlock()
}
voice.Lock()
voice.GuildID = gID
voice.ChannelID = cID
voice.deaf = deaf
voice.mute = mute
voice.session = s
voice.Unlock()
err = s.ChannelVoiceJoinManual(gID, cID, mute, deaf)
if err != nil {
return
}
// doesn't exactly work perfect yet.. TODO
err = voice.waitUntilConnected()
if err != nil {
s.log(LogWarning, "error waiting for voice to connect, %s", err)
voice.Close()
return
}
return
}
// ChannelVoiceJoinManual initiates a voice session to a voice channel, but does not complete it.
//
// This should only be used when the VoiceServerUpdate will be intercepted and used elsewhere.
//
// gID : Guild ID of the channel to join.
// cID : Channel ID of the channel to join, leave empty to disconnect.
// mute : If true, you will be set to muted upon joining.
// deaf : If true, you will be set to deafened upon joining.
func (s *Session) ChannelVoiceJoinManual(gID, cID string, mute, deaf bool) (err error) {
s.log(LogInformational, "called")
var channelID *string
if cID == "" {
channelID = nil
} else {
channelID = &cID
}
// Send the request to Discord that we want to join the voice channel
data := voiceChannelJoinOp{4, voiceChannelJoinData{&gID, channelID, mute, deaf}}
s.wsMutex.Lock()
err = s.wsConn.WriteJSON(data)
s.wsMutex.Unlock()
return
}
// onVoiceStateUpdate handles Voice State Update events on the data websocket.
func (s *Session) onVoiceStateUpdate(st *VoiceStateUpdate) {
// If we don't have a connection for the channel, don't bother
if st.ChannelID == "" {
return
}
// Check if we have a voice connection to update
s.RLock()
voice, exists := s.VoiceConnections[st.GuildID]
s.RUnlock()
if !exists {
return
}
// We only care about events that are about us.
if s.State.User.ID != st.UserID {
return
}
// Store the SessionID for later use.
voice.Lock()
voice.UserID = st.UserID
voice.sessionID = st.SessionID
voice.ChannelID = st.ChannelID
voice.Unlock()
}
// onVoiceServerUpdate handles the Voice Server Update data websocket event.
//
// This is also fired if the Guild's voice region changes while connected
// to a voice channel. In that case, need to re-establish connection to
// the new region endpoint.
func (s *Session) onVoiceServerUpdate(st *VoiceServerUpdate) {
s.log(LogInformational, "called")
s.RLock()
voice, exists := s.VoiceConnections[st.GuildID]
s.RUnlock()
// If no VoiceConnection exists, just skip this
if !exists {
return
}
// If currently connected to voice ws/udp, then disconnect.
// Has no effect if not connected.
voice.Close()
// Store values for later use
voice.Lock()
voice.token = st.Token
voice.endpoint = st.Endpoint
voice.GuildID = st.GuildID
voice.Unlock()
// Open a connection to the voice server
err := voice.open()
if err != nil {
s.log(LogError, "onVoiceServerUpdate voice.open, %s", err)
}
}
type identifyProperties struct {
OS string `json:"$os"`
Browser string `json:"$browser"`
Device string `json:"$device"`
Referer string `json:"$referer"`
ReferringDomain string `json:"$referring_domain"`
}
type identifyData struct {
Token string `json:"token"`
Properties identifyProperties `json:"properties"`
LargeThreshold int `json:"large_threshold"`
Compress bool `json:"compress"`
Shard *[2]int `json:"shard,omitempty"`
}
type identifyOp struct {
Op int `json:"op"`
Data identifyData `json:"d"`
}
// identify sends the identify packet to the gateway
func (s *Session) identify() error {
properties := identifyProperties{runtime.GOOS,
"Discordgo v" + VERSION,
"",
"",
"",
}
data := identifyData{s.Token,
properties,
250,
s.Compress,
nil,
}
if s.ShardCount > 1 {
if s.ShardID >= s.ShardCount {
return ErrWSShardBounds
}
data.Shard = &[2]int{s.ShardID, s.ShardCount}
}
op := identifyOp{2, data}
s.wsMutex.Lock()
err := s.wsConn.WriteJSON(op)
s.wsMutex.Unlock()
return err
}
func (s *Session) reconnect() {
s.log(LogInformational, "called")
var err error
if s.ShouldReconnectOnError {
wait := time.Duration(1)
for {
s.log(LogInformational, "trying to reconnect to gateway")
err = s.Open()
if err == nil {
s.log(LogInformational, "successfully reconnected to gateway")
// I'm not sure if this is actually needed.
// if the gw reconnect works properly, voice should stay alive
// However, there seems to be cases where something "weird"
// happens. So we're doing this for now just to improve
// stability in those edge cases.
s.RLock()
defer s.RUnlock()
for _, v := range s.VoiceConnections {
s.log(LogInformational, "reconnecting voice connection to guild %s", v.GuildID)
go v.reconnect()
// This is here just to prevent violently spamming the
// voice reconnects
time.Sleep(1 * time.Second)
}
return
}
// Certain race conditions can call reconnect() twice. If this happens, we
// just break out of the reconnect loop
if err == ErrWSAlreadyOpen {
s.log(LogInformational, "Websocket already exists, no need to reconnect")
return
}
s.log(LogError, "error reconnecting to gateway, %s", err)
<-time.After(wait * time.Second)
wait *= 2
if wait > 600 {
wait = 600
}
}
}
}
// Close closes a websocket and stops all listening/heartbeat goroutines.
// TODO: Add support for Voice WS/UDP connections
func (s *Session) Close() (err error) {
s.log(LogInformational, "called")
s.Lock()
s.DataReady = false
if s.listening != nil {
s.log(LogInformational, "closing listening channel")
close(s.listening)
s.listening = nil
}
// TODO: Close all active Voice Connections too
// this should force stop any reconnecting voice channels too
if s.wsConn != nil {
s.log(LogInformational, "sending close frame")
// To cleanly close a connection, a client should send a close
// frame and wait for the server to close the connection.
s.wsMutex.Lock()
err := s.wsConn.WriteMessage(websocket.CloseMessage, websocket.FormatCloseMessage(websocket.CloseNormalClosure, ""))
s.wsMutex.Unlock()
if err != nil {
s.log(LogInformational, "error closing websocket, %s", err)
}
// TODO: Wait for Discord to actually close the connection.
time.Sleep(1 * time.Second)
s.log(LogInformational, "closing gateway websocket")
err = s.wsConn.Close()
if err != nil {
s.log(LogInformational, "error closing websocket, %s", err)
}
s.wsConn = nil
}
s.Unlock()
s.log(LogInformational, "emit disconnect event")
s.handleEvent(disconnectEventType, &Disconnect{})
return
}

201
vendor/github.com/matterbridge/msgraph.go/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@@ -0,0 +1,17 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
// ACL undocumented
type ACL struct {
// Object is the base model of ACL
Object
// Type undocumented
Type *ACLType `json:"type,omitempty"`
// Value undocumented
Value *string `json:"value,omitempty"`
// AccessType undocumented
AccessType *AccessType `json:"accessType,omitempty"`
// IdentitySource undocumented
IdentitySource *string `json:"identitySource,omitempty"`
}

View File

@@ -0,0 +1,41 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
// ACLType undocumented
type ACLType int
const (
// ACLTypeVUser undocumented
ACLTypeVUser ACLType = 1
// ACLTypeVGroup undocumented
ACLTypeVGroup ACLType = 2
// ACLTypeVEveryone undocumented
ACLTypeVEveryone ACLType = 3
// ACLTypeVEveryoneExceptGuests undocumented
ACLTypeVEveryoneExceptGuests ACLType = 4
)
// ACLTypePUser returns a pointer to ACLTypeVUser
func ACLTypePUser() *ACLType {
v := ACLTypeVUser
return &v
}
// ACLTypePGroup returns a pointer to ACLTypeVGroup
func ACLTypePGroup() *ACLType {
v := ACLTypeVGroup
return &v
}
// ACLTypePEveryone returns a pointer to ACLTypeVEveryone
func ACLTypePEveryone() *ACLType {
v := ACLTypeVEveryone
return &v
}
// ACLTypePEveryoneExceptGuests returns a pointer to ACLTypeVEveryoneExceptGuests
func ACLTypePEveryoneExceptGuests() *ACLType {
v := ACLTypeVEveryoneExceptGuests
return &v
}

View File

@@ -0,0 +1,19 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
// APIApplication undocumented
type APIApplication struct {
// Object is the base model of APIApplication
Object
// AcceptMappedClaims undocumented
AcceptMappedClaims *bool `json:"acceptMappedClaims,omitempty"`
// KnownClientApplications undocumented
KnownClientApplications []UUID `json:"knownClientApplications,omitempty"`
// PreAuthorizedApplications undocumented
PreAuthorizedApplications []PreAuthorizedApplication `json:"preAuthorizedApplications,omitempty"`
// RequestedAccessTokenVersion undocumented
RequestedAccessTokenVersion *int `json:"requestedAccessTokenVersion,omitempty"`
// Oauth2PermissionScopes undocumented
Oauth2PermissionScopes []PermissionScope `json:"oauth2PermissionScopes,omitempty"`
}

View File

@@ -0,0 +1,11 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
// APIServicePrincipal undocumented
type APIServicePrincipal struct {
// Object is the base model of APIServicePrincipal
Object
// ResourceSpecificApplicationPermissions undocumented
ResourceSpecificApplicationPermissions []ResourceSpecificPermission `json:"resourceSpecificApplicationPermissions,omitempty"`
}

View File

@@ -0,0 +1,15 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
// AadUserConversationMember undocumented
type AadUserConversationMember struct {
// ConversationMember is the base model of AadUserConversationMember
ConversationMember
// UserID undocumented
UserID *string `json:"userId,omitempty"`
// Email undocumented
Email *string `json:"email,omitempty"`
// User undocumented
User *User `json:"user,omitempty"`
}

View File

@@ -0,0 +1,45 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
import "context"
// AadUserConversationMemberRequestBuilder is request builder for AadUserConversationMember
type AadUserConversationMemberRequestBuilder struct{ BaseRequestBuilder }
// Request returns AadUserConversationMemberRequest
func (b *AadUserConversationMemberRequestBuilder) Request() *AadUserConversationMemberRequest {
return &AadUserConversationMemberRequest{
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
}
}
// AadUserConversationMemberRequest is request for AadUserConversationMember
type AadUserConversationMemberRequest struct{ BaseRequest }
// Get performs GET request for AadUserConversationMember
func (r *AadUserConversationMemberRequest) Get(ctx context.Context) (resObj *AadUserConversationMember, err error) {
var query string
if r.query != nil {
query = "?" + r.query.Encode()
}
err = r.JSONRequest(ctx, "GET", query, nil, &resObj)
return
}
// Update performs PATCH request for AadUserConversationMember
func (r *AadUserConversationMemberRequest) Update(ctx context.Context, reqObj *AadUserConversationMember) error {
return r.JSONRequest(ctx, "PATCH", "", reqObj, nil)
}
// Delete performs DELETE request for AadUserConversationMember
func (r *AadUserConversationMemberRequest) Delete(ctx context.Context) error {
return r.JSONRequest(ctx, "DELETE", "", nil, nil)
}
// User is navigation property
func (b *AadUserConversationMemberRequestBuilder) User() *UserRequestBuilder {
bb := &UserRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/user"
return bb
}

View File

@@ -0,0 +1,9 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
// AccessAction undocumented
type AccessAction struct {
// Object is the base model of AccessAction
Object
}

View File

@@ -0,0 +1,49 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
// AccessLevel undocumented
type AccessLevel int
const (
// AccessLevelVEveryone undocumented
AccessLevelVEveryone AccessLevel = 0
// AccessLevelVInvited undocumented
AccessLevelVInvited AccessLevel = 1
// AccessLevelVLocked undocumented
AccessLevelVLocked AccessLevel = 2
// AccessLevelVSameEnterprise undocumented
AccessLevelVSameEnterprise AccessLevel = 3
// AccessLevelVSameEnterpriseAndFederated undocumented
AccessLevelVSameEnterpriseAndFederated AccessLevel = 4
)
// AccessLevelPEveryone returns a pointer to AccessLevelVEveryone
func AccessLevelPEveryone() *AccessLevel {
v := AccessLevelVEveryone
return &v
}
// AccessLevelPInvited returns a pointer to AccessLevelVInvited
func AccessLevelPInvited() *AccessLevel {
v := AccessLevelVInvited
return &v
}
// AccessLevelPLocked returns a pointer to AccessLevelVLocked
func AccessLevelPLocked() *AccessLevel {
v := AccessLevelVLocked
return &v
}
// AccessLevelPSameEnterprise returns a pointer to AccessLevelVSameEnterprise
func AccessLevelPSameEnterprise() *AccessLevel {
v := AccessLevelVSameEnterprise
return &v
}
// AccessLevelPSameEnterpriseAndFederated returns a pointer to AccessLevelVSameEnterpriseAndFederated
func AccessLevelPSameEnterpriseAndFederated() *AccessLevel {
v := AccessLevelVSameEnterpriseAndFederated
return &v
}

View File

@@ -0,0 +1,37 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
import "time"
// AccessPackageAssignment undocumented
type AccessPackageAssignment struct {
// Entity is the base model of AccessPackageAssignment
Entity
// CatalogID undocumented
CatalogID *string `json:"catalogId,omitempty"`
// AccessPackageID undocumented
AccessPackageID *string `json:"accessPackageId,omitempty"`
// AssignmentPolicyID undocumented
AssignmentPolicyID *string `json:"assignmentPolicyId,omitempty"`
// TargetID undocumented
TargetID *string `json:"targetId,omitempty"`
// AssignmentStatus undocumented
AssignmentStatus *string `json:"assignmentStatus,omitempty"`
// AssignmentState undocumented
AssignmentState *string `json:"assignmentState,omitempty"`
// IsExtended undocumented
IsExtended *bool `json:"isExtended,omitempty"`
// ExpiredDateTime undocumented
ExpiredDateTime *time.Time `json:"expiredDateTime,omitempty"`
// AccessPackage undocumented
AccessPackage *AccessPackage `json:"accessPackage,omitempty"`
// AccessPackageAssignmentPolicy undocumented
AccessPackageAssignmentPolicy *AccessPackageAssignmentPolicy `json:"accessPackageAssignmentPolicy,omitempty"`
// Target undocumented
Target *AccessPackageSubject `json:"target,omitempty"`
// AccessPackageAssignmentRequests undocumented
AccessPackageAssignmentRequests []AccessPackageAssignmentRequestObject `json:"accessPackageAssignmentRequests,omitempty"`
// AccessPackageAssignmentResourceRoles undocumented
AccessPackageAssignmentResourceRoles []AccessPackageAssignmentResourceRole `json:"accessPackageAssignmentResourceRoles,omitempty"`
}

View File

@@ -0,0 +1,39 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
import "time"
// AccessPackageAssignmentPolicy undocumented
type AccessPackageAssignmentPolicy struct {
// Entity is the base model of AccessPackageAssignmentPolicy
Entity
// UserType undocumented
UserType *string `json:"userType,omitempty"`
// AccessPackageID undocumented
AccessPackageID *string `json:"accessPackageId,omitempty"`
// DisplayName undocumented
DisplayName *string `json:"displayName,omitempty"`
// Description undocumented
Description *string `json:"description,omitempty"`
// IsEnabled undocumented
IsEnabled *bool `json:"isEnabled,omitempty"`
// CanExtend undocumented
CanExtend *bool `json:"canExtend,omitempty"`
// DurationInDays undocumented
DurationInDays *int `json:"durationInDays,omitempty"`
// ExpirationDateTime undocumented
ExpirationDateTime *time.Time `json:"expirationDateTime,omitempty"`
// CreatedBy undocumented
CreatedBy *string `json:"createdBy,omitempty"`
// CreatedDateTime undocumented
CreatedDateTime *time.Time `json:"createdDateTime,omitempty"`
// ModifiedBy undocumented
ModifiedBy *string `json:"modifiedBy,omitempty"`
// ModifiedDateTime undocumented
ModifiedDateTime *time.Time `json:"modifiedDateTime,omitempty"`
// AccessPackage undocumented
AccessPackage *AccessPackage `json:"accessPackage,omitempty"`
// AccessPackageCatalog undocumented
AccessPackageCatalog *AccessPackageCatalog `json:"accessPackageCatalog,omitempty"`
}

View File

@@ -0,0 +1,52 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
import "context"
// AccessPackageAssignmentPolicyRequestBuilder is request builder for AccessPackageAssignmentPolicy
type AccessPackageAssignmentPolicyRequestBuilder struct{ BaseRequestBuilder }
// Request returns AccessPackageAssignmentPolicyRequest
func (b *AccessPackageAssignmentPolicyRequestBuilder) Request() *AccessPackageAssignmentPolicyRequest {
return &AccessPackageAssignmentPolicyRequest{
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
}
}
// AccessPackageAssignmentPolicyRequest is request for AccessPackageAssignmentPolicy
type AccessPackageAssignmentPolicyRequest struct{ BaseRequest }
// Get performs GET request for AccessPackageAssignmentPolicy
func (r *AccessPackageAssignmentPolicyRequest) Get(ctx context.Context) (resObj *AccessPackageAssignmentPolicy, err error) {
var query string
if r.query != nil {
query = "?" + r.query.Encode()
}
err = r.JSONRequest(ctx, "GET", query, nil, &resObj)
return
}
// Update performs PATCH request for AccessPackageAssignmentPolicy
func (r *AccessPackageAssignmentPolicyRequest) Update(ctx context.Context, reqObj *AccessPackageAssignmentPolicy) error {
return r.JSONRequest(ctx, "PATCH", "", reqObj, nil)
}
// Delete performs DELETE request for AccessPackageAssignmentPolicy
func (r *AccessPackageAssignmentPolicyRequest) Delete(ctx context.Context) error {
return r.JSONRequest(ctx, "DELETE", "", nil, nil)
}
// AccessPackage is navigation property
func (b *AccessPackageAssignmentPolicyRequestBuilder) AccessPackage() *AccessPackageRequestBuilder {
bb := &AccessPackageRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/accessPackage"
return bb
}
// AccessPackageCatalog is navigation property
func (b *AccessPackageAssignmentPolicyRequestBuilder) AccessPackageCatalog() *AccessPackageCatalogRequestBuilder {
bb := &AccessPackageCatalogRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/accessPackageCatalog"
return bb
}

View File

@@ -0,0 +1,254 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
import (
"context"
"fmt"
"io/ioutil"
"net/http"
"github.com/matterbridge/msgraph.go/jsonx"
)
// AccessPackageAssignmentRequestBuilder is request builder for AccessPackageAssignment
type AccessPackageAssignmentRequestBuilder struct{ BaseRequestBuilder }
// Request returns AccessPackageAssignmentRequest
func (b *AccessPackageAssignmentRequestBuilder) Request() *AccessPackageAssignmentRequest {
return &AccessPackageAssignmentRequest{
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
}
}
// AccessPackageAssignmentRequest is request for AccessPackageAssignment
type AccessPackageAssignmentRequest struct{ BaseRequest }
// Get performs GET request for AccessPackageAssignment
func (r *AccessPackageAssignmentRequest) Get(ctx context.Context) (resObj *AccessPackageAssignment, err error) {
var query string
if r.query != nil {
query = "?" + r.query.Encode()
}
err = r.JSONRequest(ctx, "GET", query, nil, &resObj)
return
}
// Update performs PATCH request for AccessPackageAssignment
func (r *AccessPackageAssignmentRequest) Update(ctx context.Context, reqObj *AccessPackageAssignment) error {
return r.JSONRequest(ctx, "PATCH", "", reqObj, nil)
}
// Delete performs DELETE request for AccessPackageAssignment
func (r *AccessPackageAssignmentRequest) Delete(ctx context.Context) error {
return r.JSONRequest(ctx, "DELETE", "", nil, nil)
}
// AccessPackage is navigation property
func (b *AccessPackageAssignmentRequestBuilder) AccessPackage() *AccessPackageRequestBuilder {
bb := &AccessPackageRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/accessPackage"
return bb
}
// AccessPackageAssignmentPolicy is navigation property
func (b *AccessPackageAssignmentRequestBuilder) AccessPackageAssignmentPolicy() *AccessPackageAssignmentPolicyRequestBuilder {
bb := &AccessPackageAssignmentPolicyRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/accessPackageAssignmentPolicy"
return bb
}
// AccessPackageAssignmentRequests returns request builder for AccessPackageAssignmentRequestObject collection
func (b *AccessPackageAssignmentRequestBuilder) AccessPackageAssignmentRequests() *AccessPackageAssignmentAccessPackageAssignmentRequestsCollectionRequestBuilder {
bb := &AccessPackageAssignmentAccessPackageAssignmentRequestsCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/accessPackageAssignmentRequests"
return bb
}
// AccessPackageAssignmentAccessPackageAssignmentRequestsCollectionRequestBuilder is request builder for AccessPackageAssignmentRequestObject collection
type AccessPackageAssignmentAccessPackageAssignmentRequestsCollectionRequestBuilder struct{ BaseRequestBuilder }
// Request returns request for AccessPackageAssignmentRequestObject collection
func (b *AccessPackageAssignmentAccessPackageAssignmentRequestsCollectionRequestBuilder) Request() *AccessPackageAssignmentAccessPackageAssignmentRequestsCollectionRequest {
return &AccessPackageAssignmentAccessPackageAssignmentRequestsCollectionRequest{
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
}
}
// ID returns request builder for AccessPackageAssignmentRequestObject item
func (b *AccessPackageAssignmentAccessPackageAssignmentRequestsCollectionRequestBuilder) ID(id string) *AccessPackageAssignmentRequestObjectRequestBuilder {
bb := &AccessPackageAssignmentRequestObjectRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/" + id
return bb
}
// AccessPackageAssignmentAccessPackageAssignmentRequestsCollectionRequest is request for AccessPackageAssignmentRequestObject collection
type AccessPackageAssignmentAccessPackageAssignmentRequestsCollectionRequest struct{ BaseRequest }
// Paging perfoms paging operation for AccessPackageAssignmentRequestObject collection
func (r *AccessPackageAssignmentAccessPackageAssignmentRequestsCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}) ([]AccessPackageAssignmentRequestObject, error) {
req, err := r.NewJSONRequest(method, path, obj)
if err != nil {
return nil, err
}
if ctx != nil {
req = req.WithContext(ctx)
}
res, err := r.client.Do(req)
if err != nil {
return nil, err
}
var values []AccessPackageAssignmentRequestObject
for {
defer res.Body.Close()
if res.StatusCode != http.StatusOK {
b, _ := ioutil.ReadAll(res.Body)
errRes := &ErrorResponse{Response: res}
err := jsonx.Unmarshal(b, errRes)
if err != nil {
return nil, fmt.Errorf("%s: %s", res.Status, string(b))
}
return nil, errRes
}
var (
paging Paging
value []AccessPackageAssignmentRequestObject
)
err := jsonx.NewDecoder(res.Body).Decode(&paging)
if err != nil {
return nil, err
}
err = jsonx.Unmarshal(paging.Value, &value)
if err != nil {
return nil, err
}
values = append(values, value...)
if len(paging.NextLink) == 0 {
return values, nil
}
req, err = http.NewRequest("GET", paging.NextLink, nil)
if ctx != nil {
req = req.WithContext(ctx)
}
res, err = r.client.Do(req)
if err != nil {
return nil, err
}
}
}
// Get performs GET request for AccessPackageAssignmentRequestObject collection
func (r *AccessPackageAssignmentAccessPackageAssignmentRequestsCollectionRequest) Get(ctx context.Context) ([]AccessPackageAssignmentRequestObject, error) {
var query string
if r.query != nil {
query = "?" + r.query.Encode()
}
return r.Paging(ctx, "GET", query, nil)
}
// Add performs POST request for AccessPackageAssignmentRequestObject collection
func (r *AccessPackageAssignmentAccessPackageAssignmentRequestsCollectionRequest) Add(ctx context.Context, reqObj *AccessPackageAssignmentRequestObject) (resObj *AccessPackageAssignmentRequestObject, err error) {
err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj)
return
}
// AccessPackageAssignmentResourceRoles returns request builder for AccessPackageAssignmentResourceRole collection
func (b *AccessPackageAssignmentRequestBuilder) AccessPackageAssignmentResourceRoles() *AccessPackageAssignmentAccessPackageAssignmentResourceRolesCollectionRequestBuilder {
bb := &AccessPackageAssignmentAccessPackageAssignmentResourceRolesCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/accessPackageAssignmentResourceRoles"
return bb
}
// AccessPackageAssignmentAccessPackageAssignmentResourceRolesCollectionRequestBuilder is request builder for AccessPackageAssignmentResourceRole collection
type AccessPackageAssignmentAccessPackageAssignmentResourceRolesCollectionRequestBuilder struct{ BaseRequestBuilder }
// Request returns request for AccessPackageAssignmentResourceRole collection
func (b *AccessPackageAssignmentAccessPackageAssignmentResourceRolesCollectionRequestBuilder) Request() *AccessPackageAssignmentAccessPackageAssignmentResourceRolesCollectionRequest {
return &AccessPackageAssignmentAccessPackageAssignmentResourceRolesCollectionRequest{
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
}
}
// ID returns request builder for AccessPackageAssignmentResourceRole item
func (b *AccessPackageAssignmentAccessPackageAssignmentResourceRolesCollectionRequestBuilder) ID(id string) *AccessPackageAssignmentResourceRoleRequestBuilder {
bb := &AccessPackageAssignmentResourceRoleRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/" + id
return bb
}
// AccessPackageAssignmentAccessPackageAssignmentResourceRolesCollectionRequest is request for AccessPackageAssignmentResourceRole collection
type AccessPackageAssignmentAccessPackageAssignmentResourceRolesCollectionRequest struct{ BaseRequest }
// Paging perfoms paging operation for AccessPackageAssignmentResourceRole collection
func (r *AccessPackageAssignmentAccessPackageAssignmentResourceRolesCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}) ([]AccessPackageAssignmentResourceRole, error) {
req, err := r.NewJSONRequest(method, path, obj)
if err != nil {
return nil, err
}
if ctx != nil {
req = req.WithContext(ctx)
}
res, err := r.client.Do(req)
if err != nil {
return nil, err
}
var values []AccessPackageAssignmentResourceRole
for {
defer res.Body.Close()
if res.StatusCode != http.StatusOK {
b, _ := ioutil.ReadAll(res.Body)
errRes := &ErrorResponse{Response: res}
err := jsonx.Unmarshal(b, errRes)
if err != nil {
return nil, fmt.Errorf("%s: %s", res.Status, string(b))
}
return nil, errRes
}
var (
paging Paging
value []AccessPackageAssignmentResourceRole
)
err := jsonx.NewDecoder(res.Body).Decode(&paging)
if err != nil {
return nil, err
}
err = jsonx.Unmarshal(paging.Value, &value)
if err != nil {
return nil, err
}
values = append(values, value...)
if len(paging.NextLink) == 0 {
return values, nil
}
req, err = http.NewRequest("GET", paging.NextLink, nil)
if ctx != nil {
req = req.WithContext(ctx)
}
res, err = r.client.Do(req)
if err != nil {
return nil, err
}
}
}
// Get performs GET request for AccessPackageAssignmentResourceRole collection
func (r *AccessPackageAssignmentAccessPackageAssignmentResourceRolesCollectionRequest) Get(ctx context.Context) ([]AccessPackageAssignmentResourceRole, error) {
var query string
if r.query != nil {
query = "?" + r.query.Encode()
}
return r.Paging(ctx, "GET", query, nil)
}
// Add performs POST request for AccessPackageAssignmentResourceRole collection
func (r *AccessPackageAssignmentAccessPackageAssignmentResourceRolesCollectionRequest) Add(ctx context.Context, reqObj *AccessPackageAssignmentResourceRole) (resObj *AccessPackageAssignmentResourceRole, err error) {
err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj)
return
}
// Target is navigation property
func (b *AccessPackageAssignmentRequestBuilder) Target() *AccessPackageSubjectRequestBuilder {
bb := &AccessPackageSubjectRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/target"
return bb
}

View File

@@ -0,0 +1,35 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
import "context"
// AccessPackageAssignmentRequestObjectCancelRequestParameter undocumented
type AccessPackageAssignmentRequestObjectCancelRequestParameter struct {
}
//
type AccessPackageAssignmentRequestObjectCancelRequestBuilder struct{ BaseRequestBuilder }
// Cancel action undocumented
func (b *AccessPackageAssignmentRequestObjectRequestBuilder) Cancel(reqObj *AccessPackageAssignmentRequestObjectCancelRequestParameter) *AccessPackageAssignmentRequestObjectCancelRequestBuilder {
bb := &AccessPackageAssignmentRequestObjectCancelRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.BaseRequestBuilder.baseURL += "/Cancel"
bb.BaseRequestBuilder.requestObject = reqObj
return bb
}
//
type AccessPackageAssignmentRequestObjectCancelRequest struct{ BaseRequest }
//
func (b *AccessPackageAssignmentRequestObjectCancelRequestBuilder) Request() *AccessPackageAssignmentRequestObjectCancelRequest {
return &AccessPackageAssignmentRequestObjectCancelRequest{
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client, requestObject: b.requestObject},
}
}
//
func (r *AccessPackageAssignmentRequestObjectCancelRequest) Post(ctx context.Context) error {
return r.JSONRequest(ctx, "POST", "", r.requestObject, nil)
}

View File

@@ -0,0 +1,33 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
import "time"
// AccessPackageAssignmentRequestObject undocumented
type AccessPackageAssignmentRequestObject struct {
// Entity is the base model of AccessPackageAssignmentRequestObject
Entity
// RequestType undocumented
RequestType *string `json:"requestType,omitempty"`
// RequestState undocumented
RequestState *string `json:"requestState,omitempty"`
// RequestStatus undocumented
RequestStatus *string `json:"requestStatus,omitempty"`
// IsValidationOnly undocumented
IsValidationOnly *bool `json:"isValidationOnly,omitempty"`
// CreatedDateTime undocumented
CreatedDateTime *time.Time `json:"createdDateTime,omitempty"`
// CompletedDate undocumented
CompletedDate *time.Time `json:"completedDate,omitempty"`
// ExpirationDateTime undocumented
ExpirationDateTime *time.Time `json:"expirationDateTime,omitempty"`
// Justification undocumented
Justification *string `json:"justification,omitempty"`
// AccessPackage undocumented
AccessPackage *AccessPackage `json:"accessPackage,omitempty"`
// AccessPackageAssignment undocumented
AccessPackageAssignment *AccessPackageAssignment `json:"accessPackageAssignment,omitempty"`
// Requestor undocumented
Requestor *AccessPackageSubject `json:"requestor,omitempty"`
}

View File

@@ -0,0 +1,59 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
import "context"
// AccessPackageAssignmentRequestObjectRequestBuilder is request builder for AccessPackageAssignmentRequestObject
type AccessPackageAssignmentRequestObjectRequestBuilder struct{ BaseRequestBuilder }
// Request returns AccessPackageAssignmentRequestObjectRequest
func (b *AccessPackageAssignmentRequestObjectRequestBuilder) Request() *AccessPackageAssignmentRequestObjectRequest {
return &AccessPackageAssignmentRequestObjectRequest{
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
}
}
// AccessPackageAssignmentRequestObjectRequest is request for AccessPackageAssignmentRequestObject
type AccessPackageAssignmentRequestObjectRequest struct{ BaseRequest }
// Get performs GET request for AccessPackageAssignmentRequestObject
func (r *AccessPackageAssignmentRequestObjectRequest) Get(ctx context.Context) (resObj *AccessPackageAssignmentRequestObject, err error) {
var query string
if r.query != nil {
query = "?" + r.query.Encode()
}
err = r.JSONRequest(ctx, "GET", query, nil, &resObj)
return
}
// Update performs PATCH request for AccessPackageAssignmentRequestObject
func (r *AccessPackageAssignmentRequestObjectRequest) Update(ctx context.Context, reqObj *AccessPackageAssignmentRequestObject) error {
return r.JSONRequest(ctx, "PATCH", "", reqObj, nil)
}
// Delete performs DELETE request for AccessPackageAssignmentRequestObject
func (r *AccessPackageAssignmentRequestObjectRequest) Delete(ctx context.Context) error {
return r.JSONRequest(ctx, "DELETE", "", nil, nil)
}
// AccessPackage is navigation property
func (b *AccessPackageAssignmentRequestObjectRequestBuilder) AccessPackage() *AccessPackageRequestBuilder {
bb := &AccessPackageRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/accessPackage"
return bb
}
// AccessPackageAssignment is navigation property
func (b *AccessPackageAssignmentRequestObjectRequestBuilder) AccessPackageAssignment() *AccessPackageAssignmentRequestBuilder {
bb := &AccessPackageAssignmentRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/accessPackageAssignment"
return bb
}
// Requestor is navigation property
func (b *AccessPackageAssignmentRequestObjectRequestBuilder) Requestor() *AccessPackageSubjectRequestBuilder {
bb := &AccessPackageSubjectRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/requestor"
return bb
}

View File

@@ -0,0 +1,23 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
// AccessPackageAssignmentResourceRole undocumented
type AccessPackageAssignmentResourceRole struct {
// Entity is the base model of AccessPackageAssignmentResourceRole
Entity
// OriginID undocumented
OriginID *string `json:"originId,omitempty"`
// OriginSystem undocumented
OriginSystem *string `json:"originSystem,omitempty"`
// Status undocumented
Status *string `json:"status,omitempty"`
// AccessPackageResourceScope undocumented
AccessPackageResourceScope *AccessPackageResourceScope `json:"accessPackageResourceScope,omitempty"`
// AccessPackageResourceRole undocumented
AccessPackageResourceRole *AccessPackageResourceRole `json:"accessPackageResourceRole,omitempty"`
// AccessPackageSubject undocumented
AccessPackageSubject *AccessPackageSubject `json:"accessPackageSubject,omitempty"`
// AccessPackageAssignments undocumented
AccessPackageAssignments []AccessPackageAssignment `json:"accessPackageAssignments,omitempty"`
}

View File

@@ -0,0 +1,160 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
import (
"context"
"fmt"
"io/ioutil"
"net/http"
"github.com/matterbridge/msgraph.go/jsonx"
)
// AccessPackageAssignmentResourceRoleRequestBuilder is request builder for AccessPackageAssignmentResourceRole
type AccessPackageAssignmentResourceRoleRequestBuilder struct{ BaseRequestBuilder }
// Request returns AccessPackageAssignmentResourceRoleRequest
func (b *AccessPackageAssignmentResourceRoleRequestBuilder) Request() *AccessPackageAssignmentResourceRoleRequest {
return &AccessPackageAssignmentResourceRoleRequest{
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
}
}
// AccessPackageAssignmentResourceRoleRequest is request for AccessPackageAssignmentResourceRole
type AccessPackageAssignmentResourceRoleRequest struct{ BaseRequest }
// Get performs GET request for AccessPackageAssignmentResourceRole
func (r *AccessPackageAssignmentResourceRoleRequest) Get(ctx context.Context) (resObj *AccessPackageAssignmentResourceRole, err error) {
var query string
if r.query != nil {
query = "?" + r.query.Encode()
}
err = r.JSONRequest(ctx, "GET", query, nil, &resObj)
return
}
// Update performs PATCH request for AccessPackageAssignmentResourceRole
func (r *AccessPackageAssignmentResourceRoleRequest) Update(ctx context.Context, reqObj *AccessPackageAssignmentResourceRole) error {
return r.JSONRequest(ctx, "PATCH", "", reqObj, nil)
}
// Delete performs DELETE request for AccessPackageAssignmentResourceRole
func (r *AccessPackageAssignmentResourceRoleRequest) Delete(ctx context.Context) error {
return r.JSONRequest(ctx, "DELETE", "", nil, nil)
}
// AccessPackageAssignments returns request builder for AccessPackageAssignment collection
func (b *AccessPackageAssignmentResourceRoleRequestBuilder) AccessPackageAssignments() *AccessPackageAssignmentResourceRoleAccessPackageAssignmentsCollectionRequestBuilder {
bb := &AccessPackageAssignmentResourceRoleAccessPackageAssignmentsCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/accessPackageAssignments"
return bb
}
// AccessPackageAssignmentResourceRoleAccessPackageAssignmentsCollectionRequestBuilder is request builder for AccessPackageAssignment collection
type AccessPackageAssignmentResourceRoleAccessPackageAssignmentsCollectionRequestBuilder struct{ BaseRequestBuilder }
// Request returns request for AccessPackageAssignment collection
func (b *AccessPackageAssignmentResourceRoleAccessPackageAssignmentsCollectionRequestBuilder) Request() *AccessPackageAssignmentResourceRoleAccessPackageAssignmentsCollectionRequest {
return &AccessPackageAssignmentResourceRoleAccessPackageAssignmentsCollectionRequest{
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
}
}
// ID returns request builder for AccessPackageAssignment item
func (b *AccessPackageAssignmentResourceRoleAccessPackageAssignmentsCollectionRequestBuilder) ID(id string) *AccessPackageAssignmentRequestBuilder {
bb := &AccessPackageAssignmentRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/" + id
return bb
}
// AccessPackageAssignmentResourceRoleAccessPackageAssignmentsCollectionRequest is request for AccessPackageAssignment collection
type AccessPackageAssignmentResourceRoleAccessPackageAssignmentsCollectionRequest struct{ BaseRequest }
// Paging perfoms paging operation for AccessPackageAssignment collection
func (r *AccessPackageAssignmentResourceRoleAccessPackageAssignmentsCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}) ([]AccessPackageAssignment, error) {
req, err := r.NewJSONRequest(method, path, obj)
if err != nil {
return nil, err
}
if ctx != nil {
req = req.WithContext(ctx)
}
res, err := r.client.Do(req)
if err != nil {
return nil, err
}
var values []AccessPackageAssignment
for {
defer res.Body.Close()
if res.StatusCode != http.StatusOK {
b, _ := ioutil.ReadAll(res.Body)
errRes := &ErrorResponse{Response: res}
err := jsonx.Unmarshal(b, errRes)
if err != nil {
return nil, fmt.Errorf("%s: %s", res.Status, string(b))
}
return nil, errRes
}
var (
paging Paging
value []AccessPackageAssignment
)
err := jsonx.NewDecoder(res.Body).Decode(&paging)
if err != nil {
return nil, err
}
err = jsonx.Unmarshal(paging.Value, &value)
if err != nil {
return nil, err
}
values = append(values, value...)
if len(paging.NextLink) == 0 {
return values, nil
}
req, err = http.NewRequest("GET", paging.NextLink, nil)
if ctx != nil {
req = req.WithContext(ctx)
}
res, err = r.client.Do(req)
if err != nil {
return nil, err
}
}
}
// Get performs GET request for AccessPackageAssignment collection
func (r *AccessPackageAssignmentResourceRoleAccessPackageAssignmentsCollectionRequest) Get(ctx context.Context) ([]AccessPackageAssignment, error) {
var query string
if r.query != nil {
query = "?" + r.query.Encode()
}
return r.Paging(ctx, "GET", query, nil)
}
// Add performs POST request for AccessPackageAssignment collection
func (r *AccessPackageAssignmentResourceRoleAccessPackageAssignmentsCollectionRequest) Add(ctx context.Context, reqObj *AccessPackageAssignment) (resObj *AccessPackageAssignment, err error) {
err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj)
return
}
// AccessPackageResourceRole is navigation property
func (b *AccessPackageAssignmentResourceRoleRequestBuilder) AccessPackageResourceRole() *AccessPackageResourceRoleRequestBuilder {
bb := &AccessPackageResourceRoleRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/accessPackageResourceRole"
return bb
}
// AccessPackageResourceScope is navigation property
func (b *AccessPackageAssignmentResourceRoleRequestBuilder) AccessPackageResourceScope() *AccessPackageResourceScopeRequestBuilder {
bb := &AccessPackageResourceScopeRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/accessPackageResourceScope"
return bb
}
// AccessPackageSubject is navigation property
func (b *AccessPackageAssignmentResourceRoleRequestBuilder) AccessPackageSubject() *AccessPackageSubjectRequestBuilder {
bb := &AccessPackageSubjectRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/accessPackageSubject"
return bb
}

View File

@@ -0,0 +1,37 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
import "time"
// AccessPackageCatalog undocumented
type AccessPackageCatalog struct {
// Entity is the base model of AccessPackageCatalog
Entity
// DisplayName undocumented
DisplayName *string `json:"displayName,omitempty"`
// Description undocumented
Description *string `json:"description,omitempty"`
// CatalogType undocumented
CatalogType *string `json:"catalogType,omitempty"`
// CatalogStatus undocumented
CatalogStatus *string `json:"catalogStatus,omitempty"`
// IsExternallyVisible undocumented
IsExternallyVisible *bool `json:"isExternallyVisible,omitempty"`
// CreatedBy undocumented
CreatedBy *string `json:"createdBy,omitempty"`
// CreatedDateTime undocumented
CreatedDateTime *time.Time `json:"createdDateTime,omitempty"`
// ModifiedBy undocumented
ModifiedBy *string `json:"modifiedBy,omitempty"`
// ModifiedDateTime undocumented
ModifiedDateTime *time.Time `json:"modifiedDateTime,omitempty"`
// AccessPackageResources undocumented
AccessPackageResources []AccessPackageResource `json:"accessPackageResources,omitempty"`
// AccessPackageResourceRoles undocumented
AccessPackageResourceRoles []AccessPackageResourceRole `json:"accessPackageResourceRoles,omitempty"`
// AccessPackageResourceScopes undocumented
AccessPackageResourceScopes []AccessPackageResourceScope `json:"accessPackageResourceScopes,omitempty"`
// AccessPackages undocumented
AccessPackages []AccessPackage `json:"accessPackages,omitempty"`
}

View File

@@ -0,0 +1,421 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
import (
"context"
"fmt"
"io/ioutil"
"net/http"
"github.com/matterbridge/msgraph.go/jsonx"
)
// AccessPackageCatalogRequestBuilder is request builder for AccessPackageCatalog
type AccessPackageCatalogRequestBuilder struct{ BaseRequestBuilder }
// Request returns AccessPackageCatalogRequest
func (b *AccessPackageCatalogRequestBuilder) Request() *AccessPackageCatalogRequest {
return &AccessPackageCatalogRequest{
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
}
}
// AccessPackageCatalogRequest is request for AccessPackageCatalog
type AccessPackageCatalogRequest struct{ BaseRequest }
// Get performs GET request for AccessPackageCatalog
func (r *AccessPackageCatalogRequest) Get(ctx context.Context) (resObj *AccessPackageCatalog, err error) {
var query string
if r.query != nil {
query = "?" + r.query.Encode()
}
err = r.JSONRequest(ctx, "GET", query, nil, &resObj)
return
}
// Update performs PATCH request for AccessPackageCatalog
func (r *AccessPackageCatalogRequest) Update(ctx context.Context, reqObj *AccessPackageCatalog) error {
return r.JSONRequest(ctx, "PATCH", "", reqObj, nil)
}
// Delete performs DELETE request for AccessPackageCatalog
func (r *AccessPackageCatalogRequest) Delete(ctx context.Context) error {
return r.JSONRequest(ctx, "DELETE", "", nil, nil)
}
// AccessPackageResourceRoles returns request builder for AccessPackageResourceRole collection
func (b *AccessPackageCatalogRequestBuilder) AccessPackageResourceRoles() *AccessPackageCatalogAccessPackageResourceRolesCollectionRequestBuilder {
bb := &AccessPackageCatalogAccessPackageResourceRolesCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/accessPackageResourceRoles"
return bb
}
// AccessPackageCatalogAccessPackageResourceRolesCollectionRequestBuilder is request builder for AccessPackageResourceRole collection
type AccessPackageCatalogAccessPackageResourceRolesCollectionRequestBuilder struct{ BaseRequestBuilder }
// Request returns request for AccessPackageResourceRole collection
func (b *AccessPackageCatalogAccessPackageResourceRolesCollectionRequestBuilder) Request() *AccessPackageCatalogAccessPackageResourceRolesCollectionRequest {
return &AccessPackageCatalogAccessPackageResourceRolesCollectionRequest{
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
}
}
// ID returns request builder for AccessPackageResourceRole item
func (b *AccessPackageCatalogAccessPackageResourceRolesCollectionRequestBuilder) ID(id string) *AccessPackageResourceRoleRequestBuilder {
bb := &AccessPackageResourceRoleRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/" + id
return bb
}
// AccessPackageCatalogAccessPackageResourceRolesCollectionRequest is request for AccessPackageResourceRole collection
type AccessPackageCatalogAccessPackageResourceRolesCollectionRequest struct{ BaseRequest }
// Paging perfoms paging operation for AccessPackageResourceRole collection
func (r *AccessPackageCatalogAccessPackageResourceRolesCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}) ([]AccessPackageResourceRole, error) {
req, err := r.NewJSONRequest(method, path, obj)
if err != nil {
return nil, err
}
if ctx != nil {
req = req.WithContext(ctx)
}
res, err := r.client.Do(req)
if err != nil {
return nil, err
}
var values []AccessPackageResourceRole
for {
defer res.Body.Close()
if res.StatusCode != http.StatusOK {
b, _ := ioutil.ReadAll(res.Body)
errRes := &ErrorResponse{Response: res}
err := jsonx.Unmarshal(b, errRes)
if err != nil {
return nil, fmt.Errorf("%s: %s", res.Status, string(b))
}
return nil, errRes
}
var (
paging Paging
value []AccessPackageResourceRole
)
err := jsonx.NewDecoder(res.Body).Decode(&paging)
if err != nil {
return nil, err
}
err = jsonx.Unmarshal(paging.Value, &value)
if err != nil {
return nil, err
}
values = append(values, value...)
if len(paging.NextLink) == 0 {
return values, nil
}
req, err = http.NewRequest("GET", paging.NextLink, nil)
if ctx != nil {
req = req.WithContext(ctx)
}
res, err = r.client.Do(req)
if err != nil {
return nil, err
}
}
}
// Get performs GET request for AccessPackageResourceRole collection
func (r *AccessPackageCatalogAccessPackageResourceRolesCollectionRequest) Get(ctx context.Context) ([]AccessPackageResourceRole, error) {
var query string
if r.query != nil {
query = "?" + r.query.Encode()
}
return r.Paging(ctx, "GET", query, nil)
}
// Add performs POST request for AccessPackageResourceRole collection
func (r *AccessPackageCatalogAccessPackageResourceRolesCollectionRequest) Add(ctx context.Context, reqObj *AccessPackageResourceRole) (resObj *AccessPackageResourceRole, err error) {
err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj)
return
}
// AccessPackageResourceScopes returns request builder for AccessPackageResourceScope collection
func (b *AccessPackageCatalogRequestBuilder) AccessPackageResourceScopes() *AccessPackageCatalogAccessPackageResourceScopesCollectionRequestBuilder {
bb := &AccessPackageCatalogAccessPackageResourceScopesCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/accessPackageResourceScopes"
return bb
}
// AccessPackageCatalogAccessPackageResourceScopesCollectionRequestBuilder is request builder for AccessPackageResourceScope collection
type AccessPackageCatalogAccessPackageResourceScopesCollectionRequestBuilder struct{ BaseRequestBuilder }
// Request returns request for AccessPackageResourceScope collection
func (b *AccessPackageCatalogAccessPackageResourceScopesCollectionRequestBuilder) Request() *AccessPackageCatalogAccessPackageResourceScopesCollectionRequest {
return &AccessPackageCatalogAccessPackageResourceScopesCollectionRequest{
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
}
}
// ID returns request builder for AccessPackageResourceScope item
func (b *AccessPackageCatalogAccessPackageResourceScopesCollectionRequestBuilder) ID(id string) *AccessPackageResourceScopeRequestBuilder {
bb := &AccessPackageResourceScopeRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/" + id
return bb
}
// AccessPackageCatalogAccessPackageResourceScopesCollectionRequest is request for AccessPackageResourceScope collection
type AccessPackageCatalogAccessPackageResourceScopesCollectionRequest struct{ BaseRequest }
// Paging perfoms paging operation for AccessPackageResourceScope collection
func (r *AccessPackageCatalogAccessPackageResourceScopesCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}) ([]AccessPackageResourceScope, error) {
req, err := r.NewJSONRequest(method, path, obj)
if err != nil {
return nil, err
}
if ctx != nil {
req = req.WithContext(ctx)
}
res, err := r.client.Do(req)
if err != nil {
return nil, err
}
var values []AccessPackageResourceScope
for {
defer res.Body.Close()
if res.StatusCode != http.StatusOK {
b, _ := ioutil.ReadAll(res.Body)
errRes := &ErrorResponse{Response: res}
err := jsonx.Unmarshal(b, errRes)
if err != nil {
return nil, fmt.Errorf("%s: %s", res.Status, string(b))
}
return nil, errRes
}
var (
paging Paging
value []AccessPackageResourceScope
)
err := jsonx.NewDecoder(res.Body).Decode(&paging)
if err != nil {
return nil, err
}
err = jsonx.Unmarshal(paging.Value, &value)
if err != nil {
return nil, err
}
values = append(values, value...)
if len(paging.NextLink) == 0 {
return values, nil
}
req, err = http.NewRequest("GET", paging.NextLink, nil)
if ctx != nil {
req = req.WithContext(ctx)
}
res, err = r.client.Do(req)
if err != nil {
return nil, err
}
}
}
// Get performs GET request for AccessPackageResourceScope collection
func (r *AccessPackageCatalogAccessPackageResourceScopesCollectionRequest) Get(ctx context.Context) ([]AccessPackageResourceScope, error) {
var query string
if r.query != nil {
query = "?" + r.query.Encode()
}
return r.Paging(ctx, "GET", query, nil)
}
// Add performs POST request for AccessPackageResourceScope collection
func (r *AccessPackageCatalogAccessPackageResourceScopesCollectionRequest) Add(ctx context.Context, reqObj *AccessPackageResourceScope) (resObj *AccessPackageResourceScope, err error) {
err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj)
return
}
// AccessPackageResources returns request builder for AccessPackageResource collection
func (b *AccessPackageCatalogRequestBuilder) AccessPackageResources() *AccessPackageCatalogAccessPackageResourcesCollectionRequestBuilder {
bb := &AccessPackageCatalogAccessPackageResourcesCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/accessPackageResources"
return bb
}
// AccessPackageCatalogAccessPackageResourcesCollectionRequestBuilder is request builder for AccessPackageResource collection
type AccessPackageCatalogAccessPackageResourcesCollectionRequestBuilder struct{ BaseRequestBuilder }
// Request returns request for AccessPackageResource collection
func (b *AccessPackageCatalogAccessPackageResourcesCollectionRequestBuilder) Request() *AccessPackageCatalogAccessPackageResourcesCollectionRequest {
return &AccessPackageCatalogAccessPackageResourcesCollectionRequest{
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
}
}
// ID returns request builder for AccessPackageResource item
func (b *AccessPackageCatalogAccessPackageResourcesCollectionRequestBuilder) ID(id string) *AccessPackageResourceRequestBuilder {
bb := &AccessPackageResourceRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/" + id
return bb
}
// AccessPackageCatalogAccessPackageResourcesCollectionRequest is request for AccessPackageResource collection
type AccessPackageCatalogAccessPackageResourcesCollectionRequest struct{ BaseRequest }
// Paging perfoms paging operation for AccessPackageResource collection
func (r *AccessPackageCatalogAccessPackageResourcesCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}) ([]AccessPackageResource, error) {
req, err := r.NewJSONRequest(method, path, obj)
if err != nil {
return nil, err
}
if ctx != nil {
req = req.WithContext(ctx)
}
res, err := r.client.Do(req)
if err != nil {
return nil, err
}
var values []AccessPackageResource
for {
defer res.Body.Close()
if res.StatusCode != http.StatusOK {
b, _ := ioutil.ReadAll(res.Body)
errRes := &ErrorResponse{Response: res}
err := jsonx.Unmarshal(b, errRes)
if err != nil {
return nil, fmt.Errorf("%s: %s", res.Status, string(b))
}
return nil, errRes
}
var (
paging Paging
value []AccessPackageResource
)
err := jsonx.NewDecoder(res.Body).Decode(&paging)
if err != nil {
return nil, err
}
err = jsonx.Unmarshal(paging.Value, &value)
if err != nil {
return nil, err
}
values = append(values, value...)
if len(paging.NextLink) == 0 {
return values, nil
}
req, err = http.NewRequest("GET", paging.NextLink, nil)
if ctx != nil {
req = req.WithContext(ctx)
}
res, err = r.client.Do(req)
if err != nil {
return nil, err
}
}
}
// Get performs GET request for AccessPackageResource collection
func (r *AccessPackageCatalogAccessPackageResourcesCollectionRequest) Get(ctx context.Context) ([]AccessPackageResource, error) {
var query string
if r.query != nil {
query = "?" + r.query.Encode()
}
return r.Paging(ctx, "GET", query, nil)
}
// Add performs POST request for AccessPackageResource collection
func (r *AccessPackageCatalogAccessPackageResourcesCollectionRequest) Add(ctx context.Context, reqObj *AccessPackageResource) (resObj *AccessPackageResource, err error) {
err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj)
return
}
// AccessPackages returns request builder for AccessPackage collection
func (b *AccessPackageCatalogRequestBuilder) AccessPackages() *AccessPackageCatalogAccessPackagesCollectionRequestBuilder {
bb := &AccessPackageCatalogAccessPackagesCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/accessPackages"
return bb
}
// AccessPackageCatalogAccessPackagesCollectionRequestBuilder is request builder for AccessPackage collection
type AccessPackageCatalogAccessPackagesCollectionRequestBuilder struct{ BaseRequestBuilder }
// Request returns request for AccessPackage collection
func (b *AccessPackageCatalogAccessPackagesCollectionRequestBuilder) Request() *AccessPackageCatalogAccessPackagesCollectionRequest {
return &AccessPackageCatalogAccessPackagesCollectionRequest{
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
}
}
// ID returns request builder for AccessPackage item
func (b *AccessPackageCatalogAccessPackagesCollectionRequestBuilder) ID(id string) *AccessPackageRequestBuilder {
bb := &AccessPackageRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/" + id
return bb
}
// AccessPackageCatalogAccessPackagesCollectionRequest is request for AccessPackage collection
type AccessPackageCatalogAccessPackagesCollectionRequest struct{ BaseRequest }
// Paging perfoms paging operation for AccessPackage collection
func (r *AccessPackageCatalogAccessPackagesCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}) ([]AccessPackage, error) {
req, err := r.NewJSONRequest(method, path, obj)
if err != nil {
return nil, err
}
if ctx != nil {
req = req.WithContext(ctx)
}
res, err := r.client.Do(req)
if err != nil {
return nil, err
}
var values []AccessPackage
for {
defer res.Body.Close()
if res.StatusCode != http.StatusOK {
b, _ := ioutil.ReadAll(res.Body)
errRes := &ErrorResponse{Response: res}
err := jsonx.Unmarshal(b, errRes)
if err != nil {
return nil, fmt.Errorf("%s: %s", res.Status, string(b))
}
return nil, errRes
}
var (
paging Paging
value []AccessPackage
)
err := jsonx.NewDecoder(res.Body).Decode(&paging)
if err != nil {
return nil, err
}
err = jsonx.Unmarshal(paging.Value, &value)
if err != nil {
return nil, err
}
values = append(values, value...)
if len(paging.NextLink) == 0 {
return values, nil
}
req, err = http.NewRequest("GET", paging.NextLink, nil)
if ctx != nil {
req = req.WithContext(ctx)
}
res, err = r.client.Do(req)
if err != nil {
return nil, err
}
}
}
// Get performs GET request for AccessPackage collection
func (r *AccessPackageCatalogAccessPackagesCollectionRequest) Get(ctx context.Context) ([]AccessPackage, error) {
var query string
if r.query != nil {
query = "?" + r.query.Encode()
}
return r.Paging(ctx, "GET", query, nil)
}
// Add performs POST request for AccessPackage collection
func (r *AccessPackageCatalogAccessPackagesCollectionRequest) Add(ctx context.Context, reqObj *AccessPackage) (resObj *AccessPackage, err error) {
err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj)
return
}

View File

@@ -0,0 +1,35 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
import "time"
// AccessPackage undocumented
type AccessPackage struct {
// Entity is the base model of AccessPackage
Entity
// CatalogID undocumented
CatalogID *string `json:"catalogId,omitempty"`
// DisplayName undocumented
DisplayName *string `json:"displayName,omitempty"`
// Description undocumented
Description *string `json:"description,omitempty"`
// IsHidden undocumented
IsHidden *bool `json:"isHidden,omitempty"`
// IsRoleScopesVisible undocumented
IsRoleScopesVisible *bool `json:"isRoleScopesVisible,omitempty"`
// CreatedBy undocumented
CreatedBy *string `json:"createdBy,omitempty"`
// CreatedDateTime undocumented
CreatedDateTime *time.Time `json:"createdDateTime,omitempty"`
// ModifiedBy undocumented
ModifiedBy *string `json:"modifiedBy,omitempty"`
// ModifiedDateTime undocumented
ModifiedDateTime *time.Time `json:"modifiedDateTime,omitempty"`
// AccessPackageCatalog undocumented
AccessPackageCatalog *AccessPackageCatalog `json:"accessPackageCatalog,omitempty"`
// AccessPackageResourceRoleScopes undocumented
AccessPackageResourceRoleScopes []AccessPackageResourceRoleScope `json:"accessPackageResourceRoleScopes,omitempty"`
// AccessPackageAssignmentPolicies undocumented
AccessPackageAssignmentPolicies []AccessPackageAssignmentPolicy `json:"accessPackageAssignmentPolicies,omitempty"`
}

View File

@@ -0,0 +1,240 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
import (
"context"
"fmt"
"io/ioutil"
"net/http"
"github.com/matterbridge/msgraph.go/jsonx"
)
// AccessPackageRequestBuilder is request builder for AccessPackage
type AccessPackageRequestBuilder struct{ BaseRequestBuilder }
// Request returns AccessPackageRequest
func (b *AccessPackageRequestBuilder) Request() *AccessPackageRequest {
return &AccessPackageRequest{
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
}
}
// AccessPackageRequest is request for AccessPackage
type AccessPackageRequest struct{ BaseRequest }
// Get performs GET request for AccessPackage
func (r *AccessPackageRequest) Get(ctx context.Context) (resObj *AccessPackage, err error) {
var query string
if r.query != nil {
query = "?" + r.query.Encode()
}
err = r.JSONRequest(ctx, "GET", query, nil, &resObj)
return
}
// Update performs PATCH request for AccessPackage
func (r *AccessPackageRequest) Update(ctx context.Context, reqObj *AccessPackage) error {
return r.JSONRequest(ctx, "PATCH", "", reqObj, nil)
}
// Delete performs DELETE request for AccessPackage
func (r *AccessPackageRequest) Delete(ctx context.Context) error {
return r.JSONRequest(ctx, "DELETE", "", nil, nil)
}
// AccessPackageAssignmentPolicies returns request builder for AccessPackageAssignmentPolicy collection
func (b *AccessPackageRequestBuilder) AccessPackageAssignmentPolicies() *AccessPackageAccessPackageAssignmentPoliciesCollectionRequestBuilder {
bb := &AccessPackageAccessPackageAssignmentPoliciesCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/accessPackageAssignmentPolicies"
return bb
}
// AccessPackageAccessPackageAssignmentPoliciesCollectionRequestBuilder is request builder for AccessPackageAssignmentPolicy collection
type AccessPackageAccessPackageAssignmentPoliciesCollectionRequestBuilder struct{ BaseRequestBuilder }
// Request returns request for AccessPackageAssignmentPolicy collection
func (b *AccessPackageAccessPackageAssignmentPoliciesCollectionRequestBuilder) Request() *AccessPackageAccessPackageAssignmentPoliciesCollectionRequest {
return &AccessPackageAccessPackageAssignmentPoliciesCollectionRequest{
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
}
}
// ID returns request builder for AccessPackageAssignmentPolicy item
func (b *AccessPackageAccessPackageAssignmentPoliciesCollectionRequestBuilder) ID(id string) *AccessPackageAssignmentPolicyRequestBuilder {
bb := &AccessPackageAssignmentPolicyRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/" + id
return bb
}
// AccessPackageAccessPackageAssignmentPoliciesCollectionRequest is request for AccessPackageAssignmentPolicy collection
type AccessPackageAccessPackageAssignmentPoliciesCollectionRequest struct{ BaseRequest }
// Paging perfoms paging operation for AccessPackageAssignmentPolicy collection
func (r *AccessPackageAccessPackageAssignmentPoliciesCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}) ([]AccessPackageAssignmentPolicy, error) {
req, err := r.NewJSONRequest(method, path, obj)
if err != nil {
return nil, err
}
if ctx != nil {
req = req.WithContext(ctx)
}
res, err := r.client.Do(req)
if err != nil {
return nil, err
}
var values []AccessPackageAssignmentPolicy
for {
defer res.Body.Close()
if res.StatusCode != http.StatusOK {
b, _ := ioutil.ReadAll(res.Body)
errRes := &ErrorResponse{Response: res}
err := jsonx.Unmarshal(b, errRes)
if err != nil {
return nil, fmt.Errorf("%s: %s", res.Status, string(b))
}
return nil, errRes
}
var (
paging Paging
value []AccessPackageAssignmentPolicy
)
err := jsonx.NewDecoder(res.Body).Decode(&paging)
if err != nil {
return nil, err
}
err = jsonx.Unmarshal(paging.Value, &value)
if err != nil {
return nil, err
}
values = append(values, value...)
if len(paging.NextLink) == 0 {
return values, nil
}
req, err = http.NewRequest("GET", paging.NextLink, nil)
if ctx != nil {
req = req.WithContext(ctx)
}
res, err = r.client.Do(req)
if err != nil {
return nil, err
}
}
}
// Get performs GET request for AccessPackageAssignmentPolicy collection
func (r *AccessPackageAccessPackageAssignmentPoliciesCollectionRequest) Get(ctx context.Context) ([]AccessPackageAssignmentPolicy, error) {
var query string
if r.query != nil {
query = "?" + r.query.Encode()
}
return r.Paging(ctx, "GET", query, nil)
}
// Add performs POST request for AccessPackageAssignmentPolicy collection
func (r *AccessPackageAccessPackageAssignmentPoliciesCollectionRequest) Add(ctx context.Context, reqObj *AccessPackageAssignmentPolicy) (resObj *AccessPackageAssignmentPolicy, err error) {
err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj)
return
}
// AccessPackageCatalog is navigation property
func (b *AccessPackageRequestBuilder) AccessPackageCatalog() *AccessPackageCatalogRequestBuilder {
bb := &AccessPackageCatalogRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/accessPackageCatalog"
return bb
}
// AccessPackageResourceRoleScopes returns request builder for AccessPackageResourceRoleScope collection
func (b *AccessPackageRequestBuilder) AccessPackageResourceRoleScopes() *AccessPackageAccessPackageResourceRoleScopesCollectionRequestBuilder {
bb := &AccessPackageAccessPackageResourceRoleScopesCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/accessPackageResourceRoleScopes"
return bb
}
// AccessPackageAccessPackageResourceRoleScopesCollectionRequestBuilder is request builder for AccessPackageResourceRoleScope collection
type AccessPackageAccessPackageResourceRoleScopesCollectionRequestBuilder struct{ BaseRequestBuilder }
// Request returns request for AccessPackageResourceRoleScope collection
func (b *AccessPackageAccessPackageResourceRoleScopesCollectionRequestBuilder) Request() *AccessPackageAccessPackageResourceRoleScopesCollectionRequest {
return &AccessPackageAccessPackageResourceRoleScopesCollectionRequest{
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
}
}
// ID returns request builder for AccessPackageResourceRoleScope item
func (b *AccessPackageAccessPackageResourceRoleScopesCollectionRequestBuilder) ID(id string) *AccessPackageResourceRoleScopeRequestBuilder {
bb := &AccessPackageResourceRoleScopeRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/" + id
return bb
}
// AccessPackageAccessPackageResourceRoleScopesCollectionRequest is request for AccessPackageResourceRoleScope collection
type AccessPackageAccessPackageResourceRoleScopesCollectionRequest struct{ BaseRequest }
// Paging perfoms paging operation for AccessPackageResourceRoleScope collection
func (r *AccessPackageAccessPackageResourceRoleScopesCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}) ([]AccessPackageResourceRoleScope, error) {
req, err := r.NewJSONRequest(method, path, obj)
if err != nil {
return nil, err
}
if ctx != nil {
req = req.WithContext(ctx)
}
res, err := r.client.Do(req)
if err != nil {
return nil, err
}
var values []AccessPackageResourceRoleScope
for {
defer res.Body.Close()
if res.StatusCode != http.StatusOK {
b, _ := ioutil.ReadAll(res.Body)
errRes := &ErrorResponse{Response: res}
err := jsonx.Unmarshal(b, errRes)
if err != nil {
return nil, fmt.Errorf("%s: %s", res.Status, string(b))
}
return nil, errRes
}
var (
paging Paging
value []AccessPackageResourceRoleScope
)
err := jsonx.NewDecoder(res.Body).Decode(&paging)
if err != nil {
return nil, err
}
err = jsonx.Unmarshal(paging.Value, &value)
if err != nil {
return nil, err
}
values = append(values, value...)
if len(paging.NextLink) == 0 {
return values, nil
}
req, err = http.NewRequest("GET", paging.NextLink, nil)
if ctx != nil {
req = req.WithContext(ctx)
}
res, err = r.client.Do(req)
if err != nil {
return nil, err
}
}
}
// Get performs GET request for AccessPackageResourceRoleScope collection
func (r *AccessPackageAccessPackageResourceRoleScopesCollectionRequest) Get(ctx context.Context) ([]AccessPackageResourceRoleScope, error) {
var query string
if r.query != nil {
query = "?" + r.query.Encode()
}
return r.Paging(ctx, "GET", query, nil)
}
// Add performs POST request for AccessPackageResourceRoleScope collection
func (r *AccessPackageAccessPackageResourceRoleScopesCollectionRequest) Add(ctx context.Context, reqObj *AccessPackageResourceRoleScope) (resObj *AccessPackageResourceRoleScope, err error) {
err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj)
return
}

View File

@@ -0,0 +1,33 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
import "time"
// AccessPackageResource undocumented
type AccessPackageResource struct {
// Entity is the base model of AccessPackageResource
Entity
// DisplayName undocumented
DisplayName *string `json:"displayName,omitempty"`
// Description undocumented
Description *string `json:"description,omitempty"`
// URL undocumented
URL *string `json:"url,omitempty"`
// ResourceType undocumented
ResourceType *string `json:"resourceType,omitempty"`
// OriginID undocumented
OriginID *string `json:"originId,omitempty"`
// OriginSystem undocumented
OriginSystem *string `json:"originSystem,omitempty"`
// IsPendingOnboarding undocumented
IsPendingOnboarding *bool `json:"isPendingOnboarding,omitempty"`
// AddedBy undocumented
AddedBy *string `json:"addedBy,omitempty"`
// AddedOn undocumented
AddedOn *time.Time `json:"addedOn,omitempty"`
// AccessPackageResourceScopes undocumented
AccessPackageResourceScopes []AccessPackageResourceScope `json:"accessPackageResourceScopes,omitempty"`
// AccessPackageResourceRoles undocumented
AccessPackageResourceRoles []AccessPackageResourceRole `json:"accessPackageResourceRoles,omitempty"`
}

View File

@@ -0,0 +1,233 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
import (
"context"
"fmt"
"io/ioutil"
"net/http"
"github.com/matterbridge/msgraph.go/jsonx"
)
// AccessPackageResourceRequestBuilder is request builder for AccessPackageResource
type AccessPackageResourceRequestBuilder struct{ BaseRequestBuilder }
// Request returns AccessPackageResourceRequest
func (b *AccessPackageResourceRequestBuilder) Request() *AccessPackageResourceRequest {
return &AccessPackageResourceRequest{
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
}
}
// AccessPackageResourceRequest is request for AccessPackageResource
type AccessPackageResourceRequest struct{ BaseRequest }
// Get performs GET request for AccessPackageResource
func (r *AccessPackageResourceRequest) Get(ctx context.Context) (resObj *AccessPackageResource, err error) {
var query string
if r.query != nil {
query = "?" + r.query.Encode()
}
err = r.JSONRequest(ctx, "GET", query, nil, &resObj)
return
}
// Update performs PATCH request for AccessPackageResource
func (r *AccessPackageResourceRequest) Update(ctx context.Context, reqObj *AccessPackageResource) error {
return r.JSONRequest(ctx, "PATCH", "", reqObj, nil)
}
// Delete performs DELETE request for AccessPackageResource
func (r *AccessPackageResourceRequest) Delete(ctx context.Context) error {
return r.JSONRequest(ctx, "DELETE", "", nil, nil)
}
// AccessPackageResourceRoles returns request builder for AccessPackageResourceRole collection
func (b *AccessPackageResourceRequestBuilder) AccessPackageResourceRoles() *AccessPackageResourceAccessPackageResourceRolesCollectionRequestBuilder {
bb := &AccessPackageResourceAccessPackageResourceRolesCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/accessPackageResourceRoles"
return bb
}
// AccessPackageResourceAccessPackageResourceRolesCollectionRequestBuilder is request builder for AccessPackageResourceRole collection
type AccessPackageResourceAccessPackageResourceRolesCollectionRequestBuilder struct{ BaseRequestBuilder }
// Request returns request for AccessPackageResourceRole collection
func (b *AccessPackageResourceAccessPackageResourceRolesCollectionRequestBuilder) Request() *AccessPackageResourceAccessPackageResourceRolesCollectionRequest {
return &AccessPackageResourceAccessPackageResourceRolesCollectionRequest{
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
}
}
// ID returns request builder for AccessPackageResourceRole item
func (b *AccessPackageResourceAccessPackageResourceRolesCollectionRequestBuilder) ID(id string) *AccessPackageResourceRoleRequestBuilder {
bb := &AccessPackageResourceRoleRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/" + id
return bb
}
// AccessPackageResourceAccessPackageResourceRolesCollectionRequest is request for AccessPackageResourceRole collection
type AccessPackageResourceAccessPackageResourceRolesCollectionRequest struct{ BaseRequest }
// Paging perfoms paging operation for AccessPackageResourceRole collection
func (r *AccessPackageResourceAccessPackageResourceRolesCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}) ([]AccessPackageResourceRole, error) {
req, err := r.NewJSONRequest(method, path, obj)
if err != nil {
return nil, err
}
if ctx != nil {
req = req.WithContext(ctx)
}
res, err := r.client.Do(req)
if err != nil {
return nil, err
}
var values []AccessPackageResourceRole
for {
defer res.Body.Close()
if res.StatusCode != http.StatusOK {
b, _ := ioutil.ReadAll(res.Body)
errRes := &ErrorResponse{Response: res}
err := jsonx.Unmarshal(b, errRes)
if err != nil {
return nil, fmt.Errorf("%s: %s", res.Status, string(b))
}
return nil, errRes
}
var (
paging Paging
value []AccessPackageResourceRole
)
err := jsonx.NewDecoder(res.Body).Decode(&paging)
if err != nil {
return nil, err
}
err = jsonx.Unmarshal(paging.Value, &value)
if err != nil {
return nil, err
}
values = append(values, value...)
if len(paging.NextLink) == 0 {
return values, nil
}
req, err = http.NewRequest("GET", paging.NextLink, nil)
if ctx != nil {
req = req.WithContext(ctx)
}
res, err = r.client.Do(req)
if err != nil {
return nil, err
}
}
}
// Get performs GET request for AccessPackageResourceRole collection
func (r *AccessPackageResourceAccessPackageResourceRolesCollectionRequest) Get(ctx context.Context) ([]AccessPackageResourceRole, error) {
var query string
if r.query != nil {
query = "?" + r.query.Encode()
}
return r.Paging(ctx, "GET", query, nil)
}
// Add performs POST request for AccessPackageResourceRole collection
func (r *AccessPackageResourceAccessPackageResourceRolesCollectionRequest) Add(ctx context.Context, reqObj *AccessPackageResourceRole) (resObj *AccessPackageResourceRole, err error) {
err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj)
return
}
// AccessPackageResourceScopes returns request builder for AccessPackageResourceScope collection
func (b *AccessPackageResourceRequestBuilder) AccessPackageResourceScopes() *AccessPackageResourceAccessPackageResourceScopesCollectionRequestBuilder {
bb := &AccessPackageResourceAccessPackageResourceScopesCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/accessPackageResourceScopes"
return bb
}
// AccessPackageResourceAccessPackageResourceScopesCollectionRequestBuilder is request builder for AccessPackageResourceScope collection
type AccessPackageResourceAccessPackageResourceScopesCollectionRequestBuilder struct{ BaseRequestBuilder }
// Request returns request for AccessPackageResourceScope collection
func (b *AccessPackageResourceAccessPackageResourceScopesCollectionRequestBuilder) Request() *AccessPackageResourceAccessPackageResourceScopesCollectionRequest {
return &AccessPackageResourceAccessPackageResourceScopesCollectionRequest{
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
}
}
// ID returns request builder for AccessPackageResourceScope item
func (b *AccessPackageResourceAccessPackageResourceScopesCollectionRequestBuilder) ID(id string) *AccessPackageResourceScopeRequestBuilder {
bb := &AccessPackageResourceScopeRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/" + id
return bb
}
// AccessPackageResourceAccessPackageResourceScopesCollectionRequest is request for AccessPackageResourceScope collection
type AccessPackageResourceAccessPackageResourceScopesCollectionRequest struct{ BaseRequest }
// Paging perfoms paging operation for AccessPackageResourceScope collection
func (r *AccessPackageResourceAccessPackageResourceScopesCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}) ([]AccessPackageResourceScope, error) {
req, err := r.NewJSONRequest(method, path, obj)
if err != nil {
return nil, err
}
if ctx != nil {
req = req.WithContext(ctx)
}
res, err := r.client.Do(req)
if err != nil {
return nil, err
}
var values []AccessPackageResourceScope
for {
defer res.Body.Close()
if res.StatusCode != http.StatusOK {
b, _ := ioutil.ReadAll(res.Body)
errRes := &ErrorResponse{Response: res}
err := jsonx.Unmarshal(b, errRes)
if err != nil {
return nil, fmt.Errorf("%s: %s", res.Status, string(b))
}
return nil, errRes
}
var (
paging Paging
value []AccessPackageResourceScope
)
err := jsonx.NewDecoder(res.Body).Decode(&paging)
if err != nil {
return nil, err
}
err = jsonx.Unmarshal(paging.Value, &value)
if err != nil {
return nil, err
}
values = append(values, value...)
if len(paging.NextLink) == 0 {
return values, nil
}
req, err = http.NewRequest("GET", paging.NextLink, nil)
if ctx != nil {
req = req.WithContext(ctx)
}
res, err = r.client.Do(req)
if err != nil {
return nil, err
}
}
}
// Get performs GET request for AccessPackageResourceScope collection
func (r *AccessPackageResourceAccessPackageResourceScopesCollectionRequest) Get(ctx context.Context) ([]AccessPackageResourceScope, error) {
var query string
if r.query != nil {
query = "?" + r.query.Encode()
}
return r.Paging(ctx, "GET", query, nil)
}
// Add performs POST request for AccessPackageResourceScope collection
func (r *AccessPackageResourceAccessPackageResourceScopesCollectionRequest) Add(ctx context.Context, reqObj *AccessPackageResourceScope) (resObj *AccessPackageResourceScope, err error) {
err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj)
return
}

View File

@@ -0,0 +1,31 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
import "time"
// AccessPackageResourceRequestObject undocumented
type AccessPackageResourceRequestObject struct {
// Entity is the base model of AccessPackageResourceRequestObject
Entity
// CatalogID undocumented
CatalogID *string `json:"catalogId,omitempty"`
// ExecuteImmediately undocumented
ExecuteImmediately *bool `json:"executeImmediately,omitempty"`
// IsValidationOnly undocumented
IsValidationOnly *bool `json:"isValidationOnly,omitempty"`
// RequestType undocumented
RequestType *string `json:"requestType,omitempty"`
// RequestState undocumented
RequestState *string `json:"requestState,omitempty"`
// RequestStatus undocumented
RequestStatus *string `json:"requestStatus,omitempty"`
// Justification undocumented
Justification *string `json:"justification,omitempty"`
// ExpirationDateTime undocumented
ExpirationDateTime *time.Time `json:"expirationDateTime,omitempty"`
// AccessPackageResource undocumented
AccessPackageResource *AccessPackageResource `json:"accessPackageResource,omitempty"`
// Requestor undocumented
Requestor *AccessPackageSubject `json:"requestor,omitempty"`
}

View File

@@ -0,0 +1,52 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
import "context"
// AccessPackageResourceRequestObjectRequestBuilder is request builder for AccessPackageResourceRequestObject
type AccessPackageResourceRequestObjectRequestBuilder struct{ BaseRequestBuilder }
// Request returns AccessPackageResourceRequestObjectRequest
func (b *AccessPackageResourceRequestObjectRequestBuilder) Request() *AccessPackageResourceRequestObjectRequest {
return &AccessPackageResourceRequestObjectRequest{
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
}
}
// AccessPackageResourceRequestObjectRequest is request for AccessPackageResourceRequestObject
type AccessPackageResourceRequestObjectRequest struct{ BaseRequest }
// Get performs GET request for AccessPackageResourceRequestObject
func (r *AccessPackageResourceRequestObjectRequest) Get(ctx context.Context) (resObj *AccessPackageResourceRequestObject, err error) {
var query string
if r.query != nil {
query = "?" + r.query.Encode()
}
err = r.JSONRequest(ctx, "GET", query, nil, &resObj)
return
}
// Update performs PATCH request for AccessPackageResourceRequestObject
func (r *AccessPackageResourceRequestObjectRequest) Update(ctx context.Context, reqObj *AccessPackageResourceRequestObject) error {
return r.JSONRequest(ctx, "PATCH", "", reqObj, nil)
}
// Delete performs DELETE request for AccessPackageResourceRequestObject
func (r *AccessPackageResourceRequestObjectRequest) Delete(ctx context.Context) error {
return r.JSONRequest(ctx, "DELETE", "", nil, nil)
}
// AccessPackageResource is navigation property
func (b *AccessPackageResourceRequestObjectRequestBuilder) AccessPackageResource() *AccessPackageResourceRequestBuilder {
bb := &AccessPackageResourceRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/accessPackageResource"
return bb
}
// Requestor is navigation property
func (b *AccessPackageResourceRequestObjectRequestBuilder) Requestor() *AccessPackageSubjectRequestBuilder {
bb := &AccessPackageSubjectRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/requestor"
return bb
}

View File

@@ -0,0 +1,19 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
// AccessPackageResourceRole undocumented
type AccessPackageResourceRole struct {
// Entity is the base model of AccessPackageResourceRole
Entity
// DisplayName undocumented
DisplayName *string `json:"displayName,omitempty"`
// Description undocumented
Description *string `json:"description,omitempty"`
// OriginID undocumented
OriginID *string `json:"originId,omitempty"`
// OriginSystem undocumented
OriginSystem *string `json:"originSystem,omitempty"`
// AccessPackageResource undocumented
AccessPackageResource *AccessPackageResource `json:"accessPackageResource,omitempty"`
}

View File

@@ -0,0 +1,45 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
import "context"
// AccessPackageResourceRoleRequestBuilder is request builder for AccessPackageResourceRole
type AccessPackageResourceRoleRequestBuilder struct{ BaseRequestBuilder }
// Request returns AccessPackageResourceRoleRequest
func (b *AccessPackageResourceRoleRequestBuilder) Request() *AccessPackageResourceRoleRequest {
return &AccessPackageResourceRoleRequest{
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
}
}
// AccessPackageResourceRoleRequest is request for AccessPackageResourceRole
type AccessPackageResourceRoleRequest struct{ BaseRequest }
// Get performs GET request for AccessPackageResourceRole
func (r *AccessPackageResourceRoleRequest) Get(ctx context.Context) (resObj *AccessPackageResourceRole, err error) {
var query string
if r.query != nil {
query = "?" + r.query.Encode()
}
err = r.JSONRequest(ctx, "GET", query, nil, &resObj)
return
}
// Update performs PATCH request for AccessPackageResourceRole
func (r *AccessPackageResourceRoleRequest) Update(ctx context.Context, reqObj *AccessPackageResourceRole) error {
return r.JSONRequest(ctx, "PATCH", "", reqObj, nil)
}
// Delete performs DELETE request for AccessPackageResourceRole
func (r *AccessPackageResourceRoleRequest) Delete(ctx context.Context) error {
return r.JSONRequest(ctx, "DELETE", "", nil, nil)
}
// AccessPackageResource is navigation property
func (b *AccessPackageResourceRoleRequestBuilder) AccessPackageResource() *AccessPackageResourceRequestBuilder {
bb := &AccessPackageResourceRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/accessPackageResource"
return bb
}

View File

@@ -0,0 +1,23 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
import "time"
// AccessPackageResourceRoleScope undocumented
type AccessPackageResourceRoleScope struct {
// Entity is the base model of AccessPackageResourceRoleScope
Entity
// CreatedBy undocumented
CreatedBy *string `json:"createdBy,omitempty"`
// CreatedDateTime undocumented
CreatedDateTime *time.Time `json:"createdDateTime,omitempty"`
// ModifiedBy undocumented
ModifiedBy *string `json:"modifiedBy,omitempty"`
// ModifiedDateTime undocumented
ModifiedDateTime *time.Time `json:"modifiedDateTime,omitempty"`
// AccessPackageResourceRole undocumented
AccessPackageResourceRole *AccessPackageResourceRole `json:"accessPackageResourceRole,omitempty"`
// AccessPackageResourceScope undocumented
AccessPackageResourceScope *AccessPackageResourceScope `json:"accessPackageResourceScope,omitempty"`
}

View File

@@ -0,0 +1,52 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
import "context"
// AccessPackageResourceRoleScopeRequestBuilder is request builder for AccessPackageResourceRoleScope
type AccessPackageResourceRoleScopeRequestBuilder struct{ BaseRequestBuilder }
// Request returns AccessPackageResourceRoleScopeRequest
func (b *AccessPackageResourceRoleScopeRequestBuilder) Request() *AccessPackageResourceRoleScopeRequest {
return &AccessPackageResourceRoleScopeRequest{
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
}
}
// AccessPackageResourceRoleScopeRequest is request for AccessPackageResourceRoleScope
type AccessPackageResourceRoleScopeRequest struct{ BaseRequest }
// Get performs GET request for AccessPackageResourceRoleScope
func (r *AccessPackageResourceRoleScopeRequest) Get(ctx context.Context) (resObj *AccessPackageResourceRoleScope, err error) {
var query string
if r.query != nil {
query = "?" + r.query.Encode()
}
err = r.JSONRequest(ctx, "GET", query, nil, &resObj)
return
}
// Update performs PATCH request for AccessPackageResourceRoleScope
func (r *AccessPackageResourceRoleScopeRequest) Update(ctx context.Context, reqObj *AccessPackageResourceRoleScope) error {
return r.JSONRequest(ctx, "PATCH", "", reqObj, nil)
}
// Delete performs DELETE request for AccessPackageResourceRoleScope
func (r *AccessPackageResourceRoleScopeRequest) Delete(ctx context.Context) error {
return r.JSONRequest(ctx, "DELETE", "", nil, nil)
}
// AccessPackageResourceRole is navigation property
func (b *AccessPackageResourceRoleScopeRequestBuilder) AccessPackageResourceRole() *AccessPackageResourceRoleRequestBuilder {
bb := &AccessPackageResourceRoleRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/accessPackageResourceRole"
return bb
}
// AccessPackageResourceScope is navigation property
func (b *AccessPackageResourceRoleScopeRequestBuilder) AccessPackageResourceScope() *AccessPackageResourceScopeRequestBuilder {
bb := &AccessPackageResourceScopeRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/accessPackageResourceScope"
return bb
}

View File

@@ -0,0 +1,25 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
// AccessPackageResourceScope undocumented
type AccessPackageResourceScope struct {
// Entity is the base model of AccessPackageResourceScope
Entity
// DisplayName undocumented
DisplayName *string `json:"displayName,omitempty"`
// Description undocumented
Description *string `json:"description,omitempty"`
// OriginID undocumented
OriginID *string `json:"originId,omitempty"`
// OriginSystem undocumented
OriginSystem *string `json:"originSystem,omitempty"`
// RoleOriginID undocumented
RoleOriginID *string `json:"roleOriginId,omitempty"`
// IsRootScope undocumented
IsRootScope *bool `json:"isRootScope,omitempty"`
// URL undocumented
URL *string `json:"url,omitempty"`
// AccessPackageResource undocumented
AccessPackageResource *AccessPackageResource `json:"accessPackageResource,omitempty"`
}

View File

@@ -0,0 +1,45 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
import "context"
// AccessPackageResourceScopeRequestBuilder is request builder for AccessPackageResourceScope
type AccessPackageResourceScopeRequestBuilder struct{ BaseRequestBuilder }
// Request returns AccessPackageResourceScopeRequest
func (b *AccessPackageResourceScopeRequestBuilder) Request() *AccessPackageResourceScopeRequest {
return &AccessPackageResourceScopeRequest{
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
}
}
// AccessPackageResourceScopeRequest is request for AccessPackageResourceScope
type AccessPackageResourceScopeRequest struct{ BaseRequest }
// Get performs GET request for AccessPackageResourceScope
func (r *AccessPackageResourceScopeRequest) Get(ctx context.Context) (resObj *AccessPackageResourceScope, err error) {
var query string
if r.query != nil {
query = "?" + r.query.Encode()
}
err = r.JSONRequest(ctx, "GET", query, nil, &resObj)
return
}
// Update performs PATCH request for AccessPackageResourceScope
func (r *AccessPackageResourceScopeRequest) Update(ctx context.Context, reqObj *AccessPackageResourceScope) error {
return r.JSONRequest(ctx, "PATCH", "", reqObj, nil)
}
// Delete performs DELETE request for AccessPackageResourceScope
func (r *AccessPackageResourceScopeRequest) Delete(ctx context.Context) error {
return r.JSONRequest(ctx, "DELETE", "", nil, nil)
}
// AccessPackageResource is navigation property
func (b *AccessPackageResourceScopeRequestBuilder) AccessPackageResource() *AccessPackageResourceRequestBuilder {
bb := &AccessPackageResourceRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/accessPackageResource"
return bb
}

View File

@@ -0,0 +1,23 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
// AccessPackageSubject undocumented
type AccessPackageSubject struct {
// Entity is the base model of AccessPackageSubject
Entity
// ObjectID undocumented
ObjectID *string `json:"objectId,omitempty"`
// AltSecID undocumented
AltSecID *string `json:"altSecId,omitempty"`
// DisplayName undocumented
DisplayName *string `json:"displayName,omitempty"`
// PrincipalName undocumented
PrincipalName *string `json:"principalName,omitempty"`
// Email undocumented
Email *string `json:"email,omitempty"`
// OnPremisesSecurityIdentifier undocumented
OnPremisesSecurityIdentifier *string `json:"onPremisesSecurityIdentifier,omitempty"`
// Type undocumented
Type *string `json:"type,omitempty"`
}

View File

@@ -0,0 +1,38 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
import "context"
// AccessPackageSubjectRequestBuilder is request builder for AccessPackageSubject
type AccessPackageSubjectRequestBuilder struct{ BaseRequestBuilder }
// Request returns AccessPackageSubjectRequest
func (b *AccessPackageSubjectRequestBuilder) Request() *AccessPackageSubjectRequest {
return &AccessPackageSubjectRequest{
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
}
}
// AccessPackageSubjectRequest is request for AccessPackageSubject
type AccessPackageSubjectRequest struct{ BaseRequest }
// Get performs GET request for AccessPackageSubject
func (r *AccessPackageSubjectRequest) Get(ctx context.Context) (resObj *AccessPackageSubject, err error) {
var query string
if r.query != nil {
query = "?" + r.query.Encode()
}
err = r.JSONRequest(ctx, "GET", query, nil, &resObj)
return
}
// Update performs PATCH request for AccessPackageSubject
func (r *AccessPackageSubjectRequest) Update(ctx context.Context, reqObj *AccessPackageSubject) error {
return r.JSONRequest(ctx, "PATCH", "", reqObj, nil)
}
// Delete performs DELETE request for AccessPackageSubject
func (r *AccessPackageSubjectRequest) Delete(ctx context.Context) error {
return r.JSONRequest(ctx, "DELETE", "", nil, nil)
}

View File

@@ -0,0 +1,125 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
import "context"
// AccessReviewStopRequestParameter undocumented
type AccessReviewStopRequestParameter struct {
}
// AccessReviewSendReminderRequestParameter undocumented
type AccessReviewSendReminderRequestParameter struct {
}
// AccessReviewResetDecisionsRequestParameter undocumented
type AccessReviewResetDecisionsRequestParameter struct {
}
// AccessReviewApplyDecisionsRequestParameter undocumented
type AccessReviewApplyDecisionsRequestParameter struct {
}
//
type AccessReviewStopRequestBuilder struct{ BaseRequestBuilder }
// Stop action undocumented
func (b *AccessReviewRequestBuilder) Stop(reqObj *AccessReviewStopRequestParameter) *AccessReviewStopRequestBuilder {
bb := &AccessReviewStopRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.BaseRequestBuilder.baseURL += "/stop"
bb.BaseRequestBuilder.requestObject = reqObj
return bb
}
//
type AccessReviewStopRequest struct{ BaseRequest }
//
func (b *AccessReviewStopRequestBuilder) Request() *AccessReviewStopRequest {
return &AccessReviewStopRequest{
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client, requestObject: b.requestObject},
}
}
//
func (r *AccessReviewStopRequest) Post(ctx context.Context) error {
return r.JSONRequest(ctx, "POST", "", r.requestObject, nil)
}
//
type AccessReviewSendReminderRequestBuilder struct{ BaseRequestBuilder }
// SendReminder action undocumented
func (b *AccessReviewRequestBuilder) SendReminder(reqObj *AccessReviewSendReminderRequestParameter) *AccessReviewSendReminderRequestBuilder {
bb := &AccessReviewSendReminderRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.BaseRequestBuilder.baseURL += "/sendReminder"
bb.BaseRequestBuilder.requestObject = reqObj
return bb
}
//
type AccessReviewSendReminderRequest struct{ BaseRequest }
//
func (b *AccessReviewSendReminderRequestBuilder) Request() *AccessReviewSendReminderRequest {
return &AccessReviewSendReminderRequest{
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client, requestObject: b.requestObject},
}
}
//
func (r *AccessReviewSendReminderRequest) Post(ctx context.Context) error {
return r.JSONRequest(ctx, "POST", "", r.requestObject, nil)
}
//
type AccessReviewResetDecisionsRequestBuilder struct{ BaseRequestBuilder }
// ResetDecisions action undocumented
func (b *AccessReviewRequestBuilder) ResetDecisions(reqObj *AccessReviewResetDecisionsRequestParameter) *AccessReviewResetDecisionsRequestBuilder {
bb := &AccessReviewResetDecisionsRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.BaseRequestBuilder.baseURL += "/resetDecisions"
bb.BaseRequestBuilder.requestObject = reqObj
return bb
}
//
type AccessReviewResetDecisionsRequest struct{ BaseRequest }
//
func (b *AccessReviewResetDecisionsRequestBuilder) Request() *AccessReviewResetDecisionsRequest {
return &AccessReviewResetDecisionsRequest{
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client, requestObject: b.requestObject},
}
}
//
func (r *AccessReviewResetDecisionsRequest) Post(ctx context.Context) error {
return r.JSONRequest(ctx, "POST", "", r.requestObject, nil)
}
//
type AccessReviewApplyDecisionsRequestBuilder struct{ BaseRequestBuilder }
// ApplyDecisions action undocumented
func (b *AccessReviewRequestBuilder) ApplyDecisions(reqObj *AccessReviewApplyDecisionsRequestParameter) *AccessReviewApplyDecisionsRequestBuilder {
bb := &AccessReviewApplyDecisionsRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.BaseRequestBuilder.baseURL += "/applyDecisions"
bb.BaseRequestBuilder.requestObject = reqObj
return bb
}
//
type AccessReviewApplyDecisionsRequest struct{ BaseRequest }
//
func (b *AccessReviewApplyDecisionsRequestBuilder) Request() *AccessReviewApplyDecisionsRequest {
return &AccessReviewApplyDecisionsRequest{
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client, requestObject: b.requestObject},
}
}
//
func (r *AccessReviewApplyDecisionsRequest) Post(ctx context.Context) error {
return r.JSONRequest(ctx, "POST", "", r.requestObject, nil)
}

View File

@@ -0,0 +1,29 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
import "time"
// AccessReviewDecision undocumented
type AccessReviewDecision struct {
// Entity is the base model of AccessReviewDecision
Entity
// AccessReviewID undocumented
AccessReviewID *string `json:"accessReviewId,omitempty"`
// ReviewedBy undocumented
ReviewedBy *UserIdentity `json:"reviewedBy,omitempty"`
// ReviewedDateTime undocumented
ReviewedDateTime *time.Time `json:"reviewedDateTime,omitempty"`
// ReviewResult undocumented
ReviewResult *string `json:"reviewResult,omitempty"`
// Justification undocumented
Justification *string `json:"justification,omitempty"`
// AppliedBy undocumented
AppliedBy *UserIdentity `json:"appliedBy,omitempty"`
// AppliedDateTime undocumented
AppliedDateTime *time.Time `json:"appliedDateTime,omitempty"`
// ApplyResult undocumented
ApplyResult *string `json:"applyResult,omitempty"`
// AccessRecommendation undocumented
AccessRecommendation *string `json:"accessRecommendation,omitempty"`
}

View File

@@ -0,0 +1,38 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
import "context"
// AccessReviewDecisionRequestBuilder is request builder for AccessReviewDecision
type AccessReviewDecisionRequestBuilder struct{ BaseRequestBuilder }
// Request returns AccessReviewDecisionRequest
func (b *AccessReviewDecisionRequestBuilder) Request() *AccessReviewDecisionRequest {
return &AccessReviewDecisionRequest{
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
}
}
// AccessReviewDecisionRequest is request for AccessReviewDecision
type AccessReviewDecisionRequest struct{ BaseRequest }
// Get performs GET request for AccessReviewDecision
func (r *AccessReviewDecisionRequest) Get(ctx context.Context) (resObj *AccessReviewDecision, err error) {
var query string
if r.query != nil {
query = "?" + r.query.Encode()
}
err = r.JSONRequest(ctx, "GET", query, nil, &resObj)
return
}
// Update performs PATCH request for AccessReviewDecision
func (r *AccessReviewDecisionRequest) Update(ctx context.Context, reqObj *AccessReviewDecision) error {
return r.JSONRequest(ctx, "PATCH", "", reqObj, nil)
}
// Delete performs DELETE request for AccessReviewDecision
func (r *AccessReviewDecisionRequest) Delete(ctx context.Context) error {
return r.JSONRequest(ctx, "DELETE", "", nil, nil)
}

View File

@@ -0,0 +1,39 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
import "time"
// AccessReview undocumented
type AccessReview struct {
// Entity is the base model of AccessReview
Entity
// DisplayName undocumented
DisplayName *string `json:"displayName,omitempty"`
// StartDateTime undocumented
StartDateTime *time.Time `json:"startDateTime,omitempty"`
// EndDateTime undocumented
EndDateTime *time.Time `json:"endDateTime,omitempty"`
// Status undocumented
Status *string `json:"status,omitempty"`
// CreatedBy undocumented
CreatedBy *UserIdentity `json:"createdBy,omitempty"`
// BusinessFlowTemplateID undocumented
BusinessFlowTemplateID *string `json:"businessFlowTemplateId,omitempty"`
// ReviewerType undocumented
ReviewerType *string `json:"reviewerType,omitempty"`
// Description undocumented
Description *string `json:"description,omitempty"`
// Settings undocumented
Settings *AccessReviewSettings `json:"settings,omitempty"`
// ReviewedEntity undocumented
ReviewedEntity *Identity `json:"reviewedEntity,omitempty"`
// Reviewers undocumented
Reviewers []AccessReviewReviewer `json:"reviewers,omitempty"`
// Decisions undocumented
Decisions []AccessReviewDecision `json:"decisions,omitempty"`
// MyDecisions undocumented
MyDecisions []AccessReviewDecision `json:"myDecisions,omitempty"`
// Instances undocumented
Instances []AccessReview `json:"instances,omitempty"`
}

View File

@@ -0,0 +1,17 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
// AccessReviewRecurrenceSettings undocumented
type AccessReviewRecurrenceSettings struct {
// Object is the base model of AccessReviewRecurrenceSettings
Object
// RecurrenceType undocumented
RecurrenceType *string `json:"recurrenceType,omitempty"`
// RecurrenceEndType undocumented
RecurrenceEndType *string `json:"recurrenceEndType,omitempty"`
// DurationInDays undocumented
DurationInDays *int `json:"durationInDays,omitempty"`
// RecurrenceCount undocumented
RecurrenceCount *int `json:"recurrenceCount,omitempty"`
}

View File

@@ -0,0 +1,421 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
import (
"context"
"fmt"
"io/ioutil"
"net/http"
"github.com/matterbridge/msgraph.go/jsonx"
)
// AccessReviewRequestBuilder is request builder for AccessReview
type AccessReviewRequestBuilder struct{ BaseRequestBuilder }
// Request returns AccessReviewRequest
func (b *AccessReviewRequestBuilder) Request() *AccessReviewRequest {
return &AccessReviewRequest{
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
}
}
// AccessReviewRequest is request for AccessReview
type AccessReviewRequest struct{ BaseRequest }
// Get performs GET request for AccessReview
func (r *AccessReviewRequest) Get(ctx context.Context) (resObj *AccessReview, err error) {
var query string
if r.query != nil {
query = "?" + r.query.Encode()
}
err = r.JSONRequest(ctx, "GET", query, nil, &resObj)
return
}
// Update performs PATCH request for AccessReview
func (r *AccessReviewRequest) Update(ctx context.Context, reqObj *AccessReview) error {
return r.JSONRequest(ctx, "PATCH", "", reqObj, nil)
}
// Delete performs DELETE request for AccessReview
func (r *AccessReviewRequest) Delete(ctx context.Context) error {
return r.JSONRequest(ctx, "DELETE", "", nil, nil)
}
// Decisions returns request builder for AccessReviewDecision collection
func (b *AccessReviewRequestBuilder) Decisions() *AccessReviewDecisionsCollectionRequestBuilder {
bb := &AccessReviewDecisionsCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/decisions"
return bb
}
// AccessReviewDecisionsCollectionRequestBuilder is request builder for AccessReviewDecision collection
type AccessReviewDecisionsCollectionRequestBuilder struct{ BaseRequestBuilder }
// Request returns request for AccessReviewDecision collection
func (b *AccessReviewDecisionsCollectionRequestBuilder) Request() *AccessReviewDecisionsCollectionRequest {
return &AccessReviewDecisionsCollectionRequest{
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
}
}
// ID returns request builder for AccessReviewDecision item
func (b *AccessReviewDecisionsCollectionRequestBuilder) ID(id string) *AccessReviewDecisionRequestBuilder {
bb := &AccessReviewDecisionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/" + id
return bb
}
// AccessReviewDecisionsCollectionRequest is request for AccessReviewDecision collection
type AccessReviewDecisionsCollectionRequest struct{ BaseRequest }
// Paging perfoms paging operation for AccessReviewDecision collection
func (r *AccessReviewDecisionsCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}) ([]AccessReviewDecision, error) {
req, err := r.NewJSONRequest(method, path, obj)
if err != nil {
return nil, err
}
if ctx != nil {
req = req.WithContext(ctx)
}
res, err := r.client.Do(req)
if err != nil {
return nil, err
}
var values []AccessReviewDecision
for {
defer res.Body.Close()
if res.StatusCode != http.StatusOK {
b, _ := ioutil.ReadAll(res.Body)
errRes := &ErrorResponse{Response: res}
err := jsonx.Unmarshal(b, errRes)
if err != nil {
return nil, fmt.Errorf("%s: %s", res.Status, string(b))
}
return nil, errRes
}
var (
paging Paging
value []AccessReviewDecision
)
err := jsonx.NewDecoder(res.Body).Decode(&paging)
if err != nil {
return nil, err
}
err = jsonx.Unmarshal(paging.Value, &value)
if err != nil {
return nil, err
}
values = append(values, value...)
if len(paging.NextLink) == 0 {
return values, nil
}
req, err = http.NewRequest("GET", paging.NextLink, nil)
if ctx != nil {
req = req.WithContext(ctx)
}
res, err = r.client.Do(req)
if err != nil {
return nil, err
}
}
}
// Get performs GET request for AccessReviewDecision collection
func (r *AccessReviewDecisionsCollectionRequest) Get(ctx context.Context) ([]AccessReviewDecision, error) {
var query string
if r.query != nil {
query = "?" + r.query.Encode()
}
return r.Paging(ctx, "GET", query, nil)
}
// Add performs POST request for AccessReviewDecision collection
func (r *AccessReviewDecisionsCollectionRequest) Add(ctx context.Context, reqObj *AccessReviewDecision) (resObj *AccessReviewDecision, err error) {
err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj)
return
}
// Instances returns request builder for AccessReview collection
func (b *AccessReviewRequestBuilder) Instances() *AccessReviewInstancesCollectionRequestBuilder {
bb := &AccessReviewInstancesCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/instances"
return bb
}
// AccessReviewInstancesCollectionRequestBuilder is request builder for AccessReview collection
type AccessReviewInstancesCollectionRequestBuilder struct{ BaseRequestBuilder }
// Request returns request for AccessReview collection
func (b *AccessReviewInstancesCollectionRequestBuilder) Request() *AccessReviewInstancesCollectionRequest {
return &AccessReviewInstancesCollectionRequest{
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
}
}
// ID returns request builder for AccessReview item
func (b *AccessReviewInstancesCollectionRequestBuilder) ID(id string) *AccessReviewRequestBuilder {
bb := &AccessReviewRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/" + id
return bb
}
// AccessReviewInstancesCollectionRequest is request for AccessReview collection
type AccessReviewInstancesCollectionRequest struct{ BaseRequest }
// Paging perfoms paging operation for AccessReview collection
func (r *AccessReviewInstancesCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}) ([]AccessReview, error) {
req, err := r.NewJSONRequest(method, path, obj)
if err != nil {
return nil, err
}
if ctx != nil {
req = req.WithContext(ctx)
}
res, err := r.client.Do(req)
if err != nil {
return nil, err
}
var values []AccessReview
for {
defer res.Body.Close()
if res.StatusCode != http.StatusOK {
b, _ := ioutil.ReadAll(res.Body)
errRes := &ErrorResponse{Response: res}
err := jsonx.Unmarshal(b, errRes)
if err != nil {
return nil, fmt.Errorf("%s: %s", res.Status, string(b))
}
return nil, errRes
}
var (
paging Paging
value []AccessReview
)
err := jsonx.NewDecoder(res.Body).Decode(&paging)
if err != nil {
return nil, err
}
err = jsonx.Unmarshal(paging.Value, &value)
if err != nil {
return nil, err
}
values = append(values, value...)
if len(paging.NextLink) == 0 {
return values, nil
}
req, err = http.NewRequest("GET", paging.NextLink, nil)
if ctx != nil {
req = req.WithContext(ctx)
}
res, err = r.client.Do(req)
if err != nil {
return nil, err
}
}
}
// Get performs GET request for AccessReview collection
func (r *AccessReviewInstancesCollectionRequest) Get(ctx context.Context) ([]AccessReview, error) {
var query string
if r.query != nil {
query = "?" + r.query.Encode()
}
return r.Paging(ctx, "GET", query, nil)
}
// Add performs POST request for AccessReview collection
func (r *AccessReviewInstancesCollectionRequest) Add(ctx context.Context, reqObj *AccessReview) (resObj *AccessReview, err error) {
err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj)
return
}
// MyDecisions returns request builder for AccessReviewDecision collection
func (b *AccessReviewRequestBuilder) MyDecisions() *AccessReviewMyDecisionsCollectionRequestBuilder {
bb := &AccessReviewMyDecisionsCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/myDecisions"
return bb
}
// AccessReviewMyDecisionsCollectionRequestBuilder is request builder for AccessReviewDecision collection
type AccessReviewMyDecisionsCollectionRequestBuilder struct{ BaseRequestBuilder }
// Request returns request for AccessReviewDecision collection
func (b *AccessReviewMyDecisionsCollectionRequestBuilder) Request() *AccessReviewMyDecisionsCollectionRequest {
return &AccessReviewMyDecisionsCollectionRequest{
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
}
}
// ID returns request builder for AccessReviewDecision item
func (b *AccessReviewMyDecisionsCollectionRequestBuilder) ID(id string) *AccessReviewDecisionRequestBuilder {
bb := &AccessReviewDecisionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/" + id
return bb
}
// AccessReviewMyDecisionsCollectionRequest is request for AccessReviewDecision collection
type AccessReviewMyDecisionsCollectionRequest struct{ BaseRequest }
// Paging perfoms paging operation for AccessReviewDecision collection
func (r *AccessReviewMyDecisionsCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}) ([]AccessReviewDecision, error) {
req, err := r.NewJSONRequest(method, path, obj)
if err != nil {
return nil, err
}
if ctx != nil {
req = req.WithContext(ctx)
}
res, err := r.client.Do(req)
if err != nil {
return nil, err
}
var values []AccessReviewDecision
for {
defer res.Body.Close()
if res.StatusCode != http.StatusOK {
b, _ := ioutil.ReadAll(res.Body)
errRes := &ErrorResponse{Response: res}
err := jsonx.Unmarshal(b, errRes)
if err != nil {
return nil, fmt.Errorf("%s: %s", res.Status, string(b))
}
return nil, errRes
}
var (
paging Paging
value []AccessReviewDecision
)
err := jsonx.NewDecoder(res.Body).Decode(&paging)
if err != nil {
return nil, err
}
err = jsonx.Unmarshal(paging.Value, &value)
if err != nil {
return nil, err
}
values = append(values, value...)
if len(paging.NextLink) == 0 {
return values, nil
}
req, err = http.NewRequest("GET", paging.NextLink, nil)
if ctx != nil {
req = req.WithContext(ctx)
}
res, err = r.client.Do(req)
if err != nil {
return nil, err
}
}
}
// Get performs GET request for AccessReviewDecision collection
func (r *AccessReviewMyDecisionsCollectionRequest) Get(ctx context.Context) ([]AccessReviewDecision, error) {
var query string
if r.query != nil {
query = "?" + r.query.Encode()
}
return r.Paging(ctx, "GET", query, nil)
}
// Add performs POST request for AccessReviewDecision collection
func (r *AccessReviewMyDecisionsCollectionRequest) Add(ctx context.Context, reqObj *AccessReviewDecision) (resObj *AccessReviewDecision, err error) {
err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj)
return
}
// Reviewers returns request builder for AccessReviewReviewer collection
func (b *AccessReviewRequestBuilder) Reviewers() *AccessReviewReviewersCollectionRequestBuilder {
bb := &AccessReviewReviewersCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/reviewers"
return bb
}
// AccessReviewReviewersCollectionRequestBuilder is request builder for AccessReviewReviewer collection
type AccessReviewReviewersCollectionRequestBuilder struct{ BaseRequestBuilder }
// Request returns request for AccessReviewReviewer collection
func (b *AccessReviewReviewersCollectionRequestBuilder) Request() *AccessReviewReviewersCollectionRequest {
return &AccessReviewReviewersCollectionRequest{
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
}
}
// ID returns request builder for AccessReviewReviewer item
func (b *AccessReviewReviewersCollectionRequestBuilder) ID(id string) *AccessReviewReviewerRequestBuilder {
bb := &AccessReviewReviewerRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/" + id
return bb
}
// AccessReviewReviewersCollectionRequest is request for AccessReviewReviewer collection
type AccessReviewReviewersCollectionRequest struct{ BaseRequest }
// Paging perfoms paging operation for AccessReviewReviewer collection
func (r *AccessReviewReviewersCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}) ([]AccessReviewReviewer, error) {
req, err := r.NewJSONRequest(method, path, obj)
if err != nil {
return nil, err
}
if ctx != nil {
req = req.WithContext(ctx)
}
res, err := r.client.Do(req)
if err != nil {
return nil, err
}
var values []AccessReviewReviewer
for {
defer res.Body.Close()
if res.StatusCode != http.StatusOK {
b, _ := ioutil.ReadAll(res.Body)
errRes := &ErrorResponse{Response: res}
err := jsonx.Unmarshal(b, errRes)
if err != nil {
return nil, fmt.Errorf("%s: %s", res.Status, string(b))
}
return nil, errRes
}
var (
paging Paging
value []AccessReviewReviewer
)
err := jsonx.NewDecoder(res.Body).Decode(&paging)
if err != nil {
return nil, err
}
err = jsonx.Unmarshal(paging.Value, &value)
if err != nil {
return nil, err
}
values = append(values, value...)
if len(paging.NextLink) == 0 {
return values, nil
}
req, err = http.NewRequest("GET", paging.NextLink, nil)
if ctx != nil {
req = req.WithContext(ctx)
}
res, err = r.client.Do(req)
if err != nil {
return nil, err
}
}
}
// Get performs GET request for AccessReviewReviewer collection
func (r *AccessReviewReviewersCollectionRequest) Get(ctx context.Context) ([]AccessReviewReviewer, error) {
var query string
if r.query != nil {
query = "?" + r.query.Encode()
}
return r.Paging(ctx, "GET", query, nil)
}
// Add performs POST request for AccessReviewReviewer collection
func (r *AccessReviewReviewersCollectionRequest) Add(ctx context.Context, reqObj *AccessReviewReviewer) (resObj *AccessReviewReviewer, err error) {
err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj)
return
}

View File

@@ -0,0 +1,13 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
// AccessReviewReviewer undocumented
type AccessReviewReviewer struct {
// Entity is the base model of AccessReviewReviewer
Entity
// DisplayName undocumented
DisplayName *string `json:"displayName,omitempty"`
// UserPrincipalName undocumented
UserPrincipalName *string `json:"userPrincipalName,omitempty"`
}

View File

@@ -0,0 +1,38 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
import "context"
// AccessReviewReviewerRequestBuilder is request builder for AccessReviewReviewer
type AccessReviewReviewerRequestBuilder struct{ BaseRequestBuilder }
// Request returns AccessReviewReviewerRequest
func (b *AccessReviewReviewerRequestBuilder) Request() *AccessReviewReviewerRequest {
return &AccessReviewReviewerRequest{
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
}
}
// AccessReviewReviewerRequest is request for AccessReviewReviewer
type AccessReviewReviewerRequest struct{ BaseRequest }
// Get performs GET request for AccessReviewReviewer
func (r *AccessReviewReviewerRequest) Get(ctx context.Context) (resObj *AccessReviewReviewer, err error) {
var query string
if r.query != nil {
query = "?" + r.query.Encode()
}
err = r.JSONRequest(ctx, "GET", query, nil, &resObj)
return
}
// Update performs PATCH request for AccessReviewReviewer
func (r *AccessReviewReviewerRequest) Update(ctx context.Context, reqObj *AccessReviewReviewer) error {
return r.JSONRequest(ctx, "PATCH", "", reqObj, nil)
}
// Delete performs DELETE request for AccessReviewReviewer
func (r *AccessReviewReviewerRequest) Delete(ctx context.Context) error {
return r.JSONRequest(ctx, "DELETE", "", nil, nil)
}

View File

@@ -0,0 +1,27 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
// AccessReviewSettings undocumented
type AccessReviewSettings struct {
// Object is the base model of AccessReviewSettings
Object
// MailNotificationsEnabled undocumented
MailNotificationsEnabled *bool `json:"mailNotificationsEnabled,omitempty"`
// RemindersEnabled undocumented
RemindersEnabled *bool `json:"remindersEnabled,omitempty"`
// JustificationRequiredOnApproval undocumented
JustificationRequiredOnApproval *bool `json:"justificationRequiredOnApproval,omitempty"`
// RecurrenceSettings undocumented
RecurrenceSettings *AccessReviewRecurrenceSettings `json:"recurrenceSettings,omitempty"`
// AutoReviewEnabled undocumented
AutoReviewEnabled *bool `json:"autoReviewEnabled,omitempty"`
// ActivityDurationInDays undocumented
ActivityDurationInDays *int `json:"activityDurationInDays,omitempty"`
// AutoReviewSettings undocumented
AutoReviewSettings *AutoReviewSettings `json:"autoReviewSettings,omitempty"`
// AutoApplyReviewResultsEnabled undocumented
AutoApplyReviewResultsEnabled *bool `json:"autoApplyReviewResultsEnabled,omitempty"`
// AccessRecommendationsEnabled undocumented
AccessRecommendationsEnabled *bool `json:"accessRecommendationsEnabled,omitempty"`
}

View File

@@ -0,0 +1,25 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
// AccessScope undocumented
type AccessScope int
const (
// AccessScopeVInOrganization undocumented
AccessScopeVInOrganization AccessScope = 0
// AccessScopeVNotInOrganization undocumented
AccessScopeVNotInOrganization AccessScope = 1
)
// AccessScopePInOrganization returns a pointer to AccessScopeVInOrganization
func AccessScopePInOrganization() *AccessScope {
v := AccessScopeVInOrganization
return &v
}
// AccessScopePNotInOrganization returns a pointer to AccessScopeVNotInOrganization
func AccessScopePNotInOrganization() *AccessScope {
v := AccessScopeVNotInOrganization
return &v
}

View File

@@ -0,0 +1,25 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
// AccessType undocumented
type AccessType int
const (
// AccessTypeVGrant undocumented
AccessTypeVGrant AccessType = 1
// AccessTypeVDeny undocumented
AccessTypeVDeny AccessType = 2
)
// AccessTypePGrant returns a pointer to AccessTypeVGrant
func AccessTypePGrant() *AccessType {
v := AccessTypeVGrant
return &v
}
// AccessTypePDeny returns a pointer to AccessTypeVDeny
func AccessTypePDeny() *AccessType {
v := AccessTypeVDeny
return &v
}

View File

@@ -0,0 +1,13 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
// AccountAlias undocumented
type AccountAlias struct {
// Object is the base model of AccountAlias
Object
// ID undocumented
ID *string `json:"id,omitempty"`
// IDType undocumented
IDType *string `json:"idType,omitempty"`
}

View File

@@ -0,0 +1,23 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
import "time"
// Account undocumented
type Account struct {
// Entity is the base model of Account
Entity
// Number undocumented
Number *string `json:"number,omitempty"`
// DisplayName undocumented
DisplayName *string `json:"displayName,omitempty"`
// Category undocumented
Category *string `json:"category,omitempty"`
// SubCategory undocumented
SubCategory *string `json:"subCategory,omitempty"`
// Blocked undocumented
Blocked *bool `json:"blocked,omitempty"`
// LastModifiedDateTime undocumented
LastModifiedDateTime *time.Time `json:"lastModifiedDateTime,omitempty"`
}

View File

@@ -0,0 +1,38 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
import "context"
// AccountRequestBuilder is request builder for Account
type AccountRequestBuilder struct{ BaseRequestBuilder }
// Request returns AccountRequest
func (b *AccountRequestBuilder) Request() *AccountRequest {
return &AccountRequest{
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
}
}
// AccountRequest is request for Account
type AccountRequest struct{ BaseRequest }
// Get performs GET request for Account
func (r *AccountRequest) Get(ctx context.Context) (resObj *Account, err error) {
var query string
if r.query != nil {
query = "?" + r.query.Encode()
}
err = r.JSONRequest(ctx, "GET", query, nil, &resObj)
return
}
// Update performs PATCH request for Account
func (r *AccountRequest) Update(ctx context.Context, reqObj *Account) error {
return r.JSONRequest(ctx, "PATCH", "", reqObj, nil)
}
// Delete performs DELETE request for Account
func (r *AccountRequest) Delete(ctx context.Context) error {
return r.JSONRequest(ctx, "DELETE", "", nil, nil)
}

View File

@@ -0,0 +1,57 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
// AccountStatus undocumented
type AccountStatus int
const (
// AccountStatusVUnknown undocumented
AccountStatusVUnknown AccountStatus = 0
// AccountStatusVStaged undocumented
AccountStatusVStaged AccountStatus = 1
// AccountStatusVActive undocumented
AccountStatusVActive AccountStatus = 2
// AccountStatusVSuspended undocumented
AccountStatusVSuspended AccountStatus = 3
// AccountStatusVDeleted undocumented
AccountStatusVDeleted AccountStatus = 4
// AccountStatusVUnknownFutureValue undocumented
AccountStatusVUnknownFutureValue AccountStatus = 127
)
// AccountStatusPUnknown returns a pointer to AccountStatusVUnknown
func AccountStatusPUnknown() *AccountStatus {
v := AccountStatusVUnknown
return &v
}
// AccountStatusPStaged returns a pointer to AccountStatusVStaged
func AccountStatusPStaged() *AccountStatus {
v := AccountStatusVStaged
return &v
}
// AccountStatusPActive returns a pointer to AccountStatusVActive
func AccountStatusPActive() *AccountStatus {
v := AccountStatusVActive
return &v
}
// AccountStatusPSuspended returns a pointer to AccountStatusVSuspended
func AccountStatusPSuspended() *AccountStatus {
v := AccountStatusVSuspended
return &v
}
// AccountStatusPDeleted returns a pointer to AccountStatusVDeleted
func AccountStatusPDeleted() *AccountStatus {
v := AccountStatusVDeleted
return &v
}
// AccountStatusPUnknownFutureValue returns a pointer to AccountStatusVUnknownFutureValue
func AccountStatusPUnknownFutureValue() *AccountStatus {
v := AccountStatusVUnknownFutureValue
return &v
}

View File

@@ -0,0 +1,41 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
// ActionSource undocumented
type ActionSource int
const (
// ActionSourceVManual undocumented
ActionSourceVManual ActionSource = 0
// ActionSourceVAutomatic undocumented
ActionSourceVAutomatic ActionSource = 1
// ActionSourceVRecommended undocumented
ActionSourceVRecommended ActionSource = 2
// ActionSourceVDefault undocumented
ActionSourceVDefault ActionSource = 3
)
// ActionSourcePManual returns a pointer to ActionSourceVManual
func ActionSourcePManual() *ActionSource {
v := ActionSourceVManual
return &v
}
// ActionSourcePAutomatic returns a pointer to ActionSourceVAutomatic
func ActionSourcePAutomatic() *ActionSource {
v := ActionSourceVAutomatic
return &v
}
// ActionSourcePRecommended returns a pointer to ActionSourceVRecommended
func ActionSourcePRecommended() *ActionSource {
v := ActionSourceVRecommended
return &v
}
// ActionSourcePDefault returns a pointer to ActionSourceVDefault
func ActionSourcePDefault() *ActionSource {
v := ActionSourceVDefault
return &v
}

View File

@@ -0,0 +1,65 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
// ActionState undocumented
type ActionState int
const (
// ActionStateVNone undocumented
ActionStateVNone ActionState = 0
// ActionStateVPending undocumented
ActionStateVPending ActionState = 1
// ActionStateVCanceled undocumented
ActionStateVCanceled ActionState = 2
// ActionStateVActive undocumented
ActionStateVActive ActionState = 3
// ActionStateVDone undocumented
ActionStateVDone ActionState = 4
// ActionStateVFailed undocumented
ActionStateVFailed ActionState = 5
// ActionStateVNotSupported undocumented
ActionStateVNotSupported ActionState = 6
)
// ActionStatePNone returns a pointer to ActionStateVNone
func ActionStatePNone() *ActionState {
v := ActionStateVNone
return &v
}
// ActionStatePPending returns a pointer to ActionStateVPending
func ActionStatePPending() *ActionState {
v := ActionStateVPending
return &v
}
// ActionStatePCanceled returns a pointer to ActionStateVCanceled
func ActionStatePCanceled() *ActionState {
v := ActionStateVCanceled
return &v
}
// ActionStatePActive returns a pointer to ActionStateVActive
func ActionStatePActive() *ActionState {
v := ActionStateVActive
return &v
}
// ActionStatePDone returns a pointer to ActionStateVDone
func ActionStatePDone() *ActionState {
v := ActionStateVDone
return &v
}
// ActionStatePFailed returns a pointer to ActionStateVFailed
func ActionStatePFailed() *ActionState {
v := ActionStateVFailed
return &v
}
// ActionStatePNotSupported returns a pointer to ActionStateVNotSupported
func ActionStatePNotSupported() *ActionState {
v := ActionStateVNotSupported
return &v
}

View File

@@ -0,0 +1,13 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
// ActiveDirectoryWindowsAutopilotDeploymentProfile Windows Autopilot Deployment Profile
type ActiveDirectoryWindowsAutopilotDeploymentProfile struct {
// WindowsAutopilotDeploymentProfile is the base model of ActiveDirectoryWindowsAutopilotDeploymentProfile
WindowsAutopilotDeploymentProfile
// HybridAzureADJoinSkipConnectivityCheck The Autopilot Hybrid Azure AD join flow will continue even if it does not establish domain controller connectivity during OOBE.
HybridAzureADJoinSkipConnectivityCheck *bool `json:"hybridAzureADJoinSkipConnectivityCheck,omitempty"`
// DomainJoinConfiguration undocumented
DomainJoinConfiguration *WindowsDomainJoinConfiguration `json:"domainJoinConfiguration,omitempty"`
}

View File

@@ -0,0 +1,45 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
import "context"
// ActiveDirectoryWindowsAutopilotDeploymentProfileRequestBuilder is request builder for ActiveDirectoryWindowsAutopilotDeploymentProfile
type ActiveDirectoryWindowsAutopilotDeploymentProfileRequestBuilder struct{ BaseRequestBuilder }
// Request returns ActiveDirectoryWindowsAutopilotDeploymentProfileRequest
func (b *ActiveDirectoryWindowsAutopilotDeploymentProfileRequestBuilder) Request() *ActiveDirectoryWindowsAutopilotDeploymentProfileRequest {
return &ActiveDirectoryWindowsAutopilotDeploymentProfileRequest{
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
}
}
// ActiveDirectoryWindowsAutopilotDeploymentProfileRequest is request for ActiveDirectoryWindowsAutopilotDeploymentProfile
type ActiveDirectoryWindowsAutopilotDeploymentProfileRequest struct{ BaseRequest }
// Get performs GET request for ActiveDirectoryWindowsAutopilotDeploymentProfile
func (r *ActiveDirectoryWindowsAutopilotDeploymentProfileRequest) Get(ctx context.Context) (resObj *ActiveDirectoryWindowsAutopilotDeploymentProfile, err error) {
var query string
if r.query != nil {
query = "?" + r.query.Encode()
}
err = r.JSONRequest(ctx, "GET", query, nil, &resObj)
return
}
// Update performs PATCH request for ActiveDirectoryWindowsAutopilotDeploymentProfile
func (r *ActiveDirectoryWindowsAutopilotDeploymentProfileRequest) Update(ctx context.Context, reqObj *ActiveDirectoryWindowsAutopilotDeploymentProfile) error {
return r.JSONRequest(ctx, "PATCH", "", reqObj, nil)
}
// Delete performs DELETE request for ActiveDirectoryWindowsAutopilotDeploymentProfile
func (r *ActiveDirectoryWindowsAutopilotDeploymentProfileRequest) Delete(ctx context.Context) error {
return r.JSONRequest(ctx, "DELETE", "", nil, nil)
}
// DomainJoinConfiguration is navigation property
func (b *ActiveDirectoryWindowsAutopilotDeploymentProfileRequestBuilder) DomainJoinConfiguration() *WindowsDomainJoinConfigurationRequestBuilder {
bb := &WindowsDomainJoinConfigurationRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/domainJoinConfiguration"
return bb
}

View File

@@ -0,0 +1,41 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
// ActivityDomain undocumented
type ActivityDomain int
const (
// ActivityDomainVUnknown undocumented
ActivityDomainVUnknown ActivityDomain = 0
// ActivityDomainVWork undocumented
ActivityDomainVWork ActivityDomain = 1
// ActivityDomainVPersonal undocumented
ActivityDomainVPersonal ActivityDomain = 2
// ActivityDomainVUnrestricted undocumented
ActivityDomainVUnrestricted ActivityDomain = 3
)
// ActivityDomainPUnknown returns a pointer to ActivityDomainVUnknown
func ActivityDomainPUnknown() *ActivityDomain {
v := ActivityDomainVUnknown
return &v
}
// ActivityDomainPWork returns a pointer to ActivityDomainVWork
func ActivityDomainPWork() *ActivityDomain {
v := ActivityDomainVWork
return &v
}
// ActivityDomainPPersonal returns a pointer to ActivityDomainVPersonal
func ActivityDomainPPersonal() *ActivityDomain {
v := ActivityDomainVPersonal
return &v
}
// ActivityDomainPUnrestricted returns a pointer to ActivityDomainVUnrestricted
func ActivityDomainPUnrestricted() *ActivityDomain {
v := ActivityDomainVUnrestricted
return &v
}

View File

@@ -0,0 +1,29 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
import "time"
// ActivityHistoryItem undocumented
type ActivityHistoryItem struct {
// Entity is the base model of ActivityHistoryItem
Entity
// Status undocumented
Status *Status `json:"status,omitempty"`
// ActiveDurationSeconds undocumented
ActiveDurationSeconds *int `json:"activeDurationSeconds,omitempty"`
// CreatedDateTime undocumented
CreatedDateTime *time.Time `json:"createdDateTime,omitempty"`
// LastActiveDateTime undocumented
LastActiveDateTime *time.Time `json:"lastActiveDateTime,omitempty"`
// LastModifiedDateTime undocumented
LastModifiedDateTime *time.Time `json:"lastModifiedDateTime,omitempty"`
// ExpirationDateTime undocumented
ExpirationDateTime *time.Time `json:"expirationDateTime,omitempty"`
// StartedDateTime undocumented
StartedDateTime *time.Time `json:"startedDateTime,omitempty"`
// UserTimezone undocumented
UserTimezone *string `json:"userTimezone,omitempty"`
// Activity undocumented
Activity *UserActivity `json:"activity,omitempty"`
}

View File

@@ -0,0 +1,45 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
import "context"
// ActivityHistoryItemRequestBuilder is request builder for ActivityHistoryItem
type ActivityHistoryItemRequestBuilder struct{ BaseRequestBuilder }
// Request returns ActivityHistoryItemRequest
func (b *ActivityHistoryItemRequestBuilder) Request() *ActivityHistoryItemRequest {
return &ActivityHistoryItemRequest{
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
}
}
// ActivityHistoryItemRequest is request for ActivityHistoryItem
type ActivityHistoryItemRequest struct{ BaseRequest }
// Get performs GET request for ActivityHistoryItem
func (r *ActivityHistoryItemRequest) Get(ctx context.Context) (resObj *ActivityHistoryItem, err error) {
var query string
if r.query != nil {
query = "?" + r.query.Encode()
}
err = r.JSONRequest(ctx, "GET", query, nil, &resObj)
return
}
// Update performs PATCH request for ActivityHistoryItem
func (r *ActivityHistoryItemRequest) Update(ctx context.Context, reqObj *ActivityHistoryItem) error {
return r.JSONRequest(ctx, "PATCH", "", reqObj, nil)
}
// Delete performs DELETE request for ActivityHistoryItem
func (r *ActivityHistoryItemRequest) Delete(ctx context.Context) error {
return r.JSONRequest(ctx, "DELETE", "", nil, nil)
}
// Activity is navigation property
func (b *ActivityHistoryItemRequestBuilder) Activity() *UserActivityRequestBuilder {
bb := &UserActivityRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/activity"
return bb
}

View File

@@ -0,0 +1,21 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
import "time"
// ActivityStatistics undocumented
type ActivityStatistics struct {
// Entity is the base model of ActivityStatistics
Entity
// Activity undocumented
Activity *AnalyticsActivityType `json:"activity,omitempty"`
// StartDate undocumented
StartDate *time.Time `json:"startDate,omitempty"`
// EndDate undocumented
EndDate *time.Time `json:"endDate,omitempty"`
// TimeZoneUsed undocumented
TimeZoneUsed *string `json:"timeZoneUsed,omitempty"`
// Duration undocumented
Duration *time.Duration `json:"duration,omitempty"`
}

View File

@@ -0,0 +1,38 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
import "context"
// ActivityStatisticsRequestBuilder is request builder for ActivityStatistics
type ActivityStatisticsRequestBuilder struct{ BaseRequestBuilder }
// Request returns ActivityStatisticsRequest
func (b *ActivityStatisticsRequestBuilder) Request() *ActivityStatisticsRequest {
return &ActivityStatisticsRequest{
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
}
}
// ActivityStatisticsRequest is request for ActivityStatistics
type ActivityStatisticsRequest struct{ BaseRequest }
// Get performs GET request for ActivityStatistics
func (r *ActivityStatisticsRequest) Get(ctx context.Context) (resObj *ActivityStatistics, err error) {
var query string
if r.query != nil {
query = "?" + r.query.Encode()
}
err = r.JSONRequest(ctx, "GET", query, nil, &resObj)
return
}
// Update performs PATCH request for ActivityStatistics
func (r *ActivityStatisticsRequest) Update(ctx context.Context, reqObj *ActivityStatistics) error {
return r.JSONRequest(ctx, "PATCH", "", reqObj, nil)
}
// Delete performs DELETE request for ActivityStatistics
func (r *ActivityStatisticsRequest) Delete(ctx context.Context) error {
return r.JSONRequest(ctx, "DELETE", "", nil, nil)
}

View File

@@ -0,0 +1,33 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
// ActivityType undocumented
type ActivityType int
const (
// ActivityTypeVSignin undocumented
ActivityTypeVSignin ActivityType = 0
// ActivityTypeVUser undocumented
ActivityTypeVUser ActivityType = 1
// ActivityTypeVUnknownFutureValue undocumented
ActivityTypeVUnknownFutureValue ActivityType = 2
)
// ActivityTypePSignin returns a pointer to ActivityTypeVSignin
func ActivityTypePSignin() *ActivityType {
v := ActivityTypeVSignin
return &v
}
// ActivityTypePUser returns a pointer to ActivityTypeVUser
func ActivityTypePUser() *ActivityType {
v := ActivityTypeVUser
return &v
}
// ActivityTypePUnknownFutureValue returns a pointer to ActivityTypeVUnknownFutureValue
func ActivityTypePUnknownFutureValue() *ActivityType {
v := ActivityTypeVUnknownFutureValue
return &v
}

View File

@@ -0,0 +1,23 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
// AddContentFooterAction undocumented
type AddContentFooterAction struct {
// InformationProtectionAction is the base model of AddContentFooterAction
InformationProtectionAction
// UIElementName undocumented
UIElementName *string `json:"uiElementName,omitempty"`
// Text undocumented
Text *string `json:"text,omitempty"`
// FontName undocumented
FontName *string `json:"fontName,omitempty"`
// FontSize undocumented
FontSize *int `json:"fontSize,omitempty"`
// FontColor undocumented
FontColor *string `json:"fontColor,omitempty"`
// Alignment undocumented
Alignment *ContentAlignment `json:"alignment,omitempty"`
// Margin undocumented
Margin *int `json:"margin,omitempty"`
}

View File

@@ -0,0 +1,23 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
// AddContentHeaderAction undocumented
type AddContentHeaderAction struct {
// InformationProtectionAction is the base model of AddContentHeaderAction
InformationProtectionAction
// UIElementName undocumented
UIElementName *string `json:"uiElementName,omitempty"`
// Text undocumented
Text *string `json:"text,omitempty"`
// FontName undocumented
FontName *string `json:"fontName,omitempty"`
// FontSize undocumented
FontSize *int `json:"fontSize,omitempty"`
// FontColor undocumented
FontColor *string `json:"fontColor,omitempty"`
// Alignment undocumented
Alignment *ContentAlignment `json:"alignment,omitempty"`
// Margin undocumented
Margin *int `json:"margin,omitempty"`
}

View File

@@ -0,0 +1,13 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
// AddFooter undocumented
type AddFooter struct {
// MarkContent is the base model of AddFooter
MarkContent
// Margin undocumented
Margin *int `json:"margin,omitempty"`
// Alignment undocumented
Alignment *Alignment `json:"alignment,omitempty"`
}

View File

@@ -0,0 +1,13 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
// AddHeader undocumented
type AddHeader struct {
// MarkContent is the base model of AddHeader
MarkContent
// Margin undocumented
Margin *int `json:"margin,omitempty"`
// Alignment undocumented
Alignment *Alignment `json:"alignment,omitempty"`
}

View File

@@ -0,0 +1,15 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
// AddIn undocumented
type AddIn struct {
// Object is the base model of AddIn
Object
// ID undocumented
ID *UUID `json:"id,omitempty"`
// Type undocumented
Type *string `json:"type,omitempty"`
// Properties undocumented
Properties []KeyValue `json:"properties,omitempty"`
}

View File

@@ -0,0 +1,21 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
// AddWatermarkAction undocumented
type AddWatermarkAction struct {
// InformationProtectionAction is the base model of AddWatermarkAction
InformationProtectionAction
// UIElementName undocumented
UIElementName *string `json:"uiElementName,omitempty"`
// Layout undocumented
Layout *WatermarkLayout `json:"layout,omitempty"`
// Text undocumented
Text *string `json:"text,omitempty"`
// FontName undocumented
FontName *string `json:"fontName,omitempty"`
// FontSize undocumented
FontSize *int `json:"fontSize,omitempty"`
// FontColor undocumented
FontColor *string `json:"fontColor,omitempty"`
}

View File

@@ -0,0 +1,11 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
// AddWatermark undocumented
type AddWatermark struct {
// MarkContent is the base model of AddWatermark
MarkContent
// Orientation undocumented
Orientation *PageOrientation `json:"orientation,omitempty"`
}

View File

@@ -0,0 +1,13 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
// AdminConsent undocumented
type AdminConsent struct {
// Object is the base model of AdminConsent
Object
// ShareAPNSData The admin consent state of sharing user and device data to Apple.
ShareAPNSData *AdminConsentState `json:"shareAPNSData,omitempty"`
// ShareUserExperienceAnalyticsData Gets or sets the admin consent for sharing User experience analytics data.
ShareUserExperienceAnalyticsData *AdminConsentState `json:"shareUserExperienceAnalyticsData,omitempty"`
}

View File

@@ -0,0 +1,33 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
// AdminConsentState undocumented
type AdminConsentState int
const (
// AdminConsentStateVNotConfigured undocumented
AdminConsentStateVNotConfigured AdminConsentState = 0
// AdminConsentStateVGranted undocumented
AdminConsentStateVGranted AdminConsentState = 1
// AdminConsentStateVNotGranted undocumented
AdminConsentStateVNotGranted AdminConsentState = 2
)
// AdminConsentStatePNotConfigured returns a pointer to AdminConsentStateVNotConfigured
func AdminConsentStatePNotConfigured() *AdminConsentState {
v := AdminConsentStateVNotConfigured
return &v
}
// AdminConsentStatePGranted returns a pointer to AdminConsentStateVGranted
func AdminConsentStatePGranted() *AdminConsentState {
v := AdminConsentStateVGranted
return &v
}
// AdminConsentStatePNotGranted returns a pointer to AdminConsentStateVNotGranted
func AdminConsentStatePNotGranted() *AdminConsentState {
v := AdminConsentStateVNotGranted
return &v
}

View File

@@ -0,0 +1,21 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
// AdministrativeUnit undocumented
type AdministrativeUnit struct {
// DirectoryObject is the base model of AdministrativeUnit
DirectoryObject
// DisplayName undocumented
DisplayName *string `json:"displayName,omitempty"`
// Description undocumented
Description *string `json:"description,omitempty"`
// Visibility undocumented
Visibility *string `json:"visibility,omitempty"`
// Members undocumented
Members []DirectoryObject `json:"members,omitempty"`
// ScopedRoleMembers undocumented
ScopedRoleMembers []ScopedRoleMembership `json:"scopedRoleMembers,omitempty"`
// Extensions undocumented
Extensions []Extension `json:"extensions,omitempty"`
}

View File

@@ -0,0 +1,327 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
import (
"context"
"fmt"
"io/ioutil"
"net/http"
"github.com/matterbridge/msgraph.go/jsonx"
)
// AdministrativeUnitRequestBuilder is request builder for AdministrativeUnit
type AdministrativeUnitRequestBuilder struct{ BaseRequestBuilder }
// Request returns AdministrativeUnitRequest
func (b *AdministrativeUnitRequestBuilder) Request() *AdministrativeUnitRequest {
return &AdministrativeUnitRequest{
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
}
}
// AdministrativeUnitRequest is request for AdministrativeUnit
type AdministrativeUnitRequest struct{ BaseRequest }
// Get performs GET request for AdministrativeUnit
func (r *AdministrativeUnitRequest) Get(ctx context.Context) (resObj *AdministrativeUnit, err error) {
var query string
if r.query != nil {
query = "?" + r.query.Encode()
}
err = r.JSONRequest(ctx, "GET", query, nil, &resObj)
return
}
// Update performs PATCH request for AdministrativeUnit
func (r *AdministrativeUnitRequest) Update(ctx context.Context, reqObj *AdministrativeUnit) error {
return r.JSONRequest(ctx, "PATCH", "", reqObj, nil)
}
// Delete performs DELETE request for AdministrativeUnit
func (r *AdministrativeUnitRequest) Delete(ctx context.Context) error {
return r.JSONRequest(ctx, "DELETE", "", nil, nil)
}
// Extensions returns request builder for Extension collection
func (b *AdministrativeUnitRequestBuilder) Extensions() *AdministrativeUnitExtensionsCollectionRequestBuilder {
bb := &AdministrativeUnitExtensionsCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/extensions"
return bb
}
// AdministrativeUnitExtensionsCollectionRequestBuilder is request builder for Extension collection
type AdministrativeUnitExtensionsCollectionRequestBuilder struct{ BaseRequestBuilder }
// Request returns request for Extension collection
func (b *AdministrativeUnitExtensionsCollectionRequestBuilder) Request() *AdministrativeUnitExtensionsCollectionRequest {
return &AdministrativeUnitExtensionsCollectionRequest{
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
}
}
// ID returns request builder for Extension item
func (b *AdministrativeUnitExtensionsCollectionRequestBuilder) ID(id string) *ExtensionRequestBuilder {
bb := &ExtensionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/" + id
return bb
}
// AdministrativeUnitExtensionsCollectionRequest is request for Extension collection
type AdministrativeUnitExtensionsCollectionRequest struct{ BaseRequest }
// Paging perfoms paging operation for Extension collection
func (r *AdministrativeUnitExtensionsCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}) ([]Extension, error) {
req, err := r.NewJSONRequest(method, path, obj)
if err != nil {
return nil, err
}
if ctx != nil {
req = req.WithContext(ctx)
}
res, err := r.client.Do(req)
if err != nil {
return nil, err
}
var values []Extension
for {
defer res.Body.Close()
if res.StatusCode != http.StatusOK {
b, _ := ioutil.ReadAll(res.Body)
errRes := &ErrorResponse{Response: res}
err := jsonx.Unmarshal(b, errRes)
if err != nil {
return nil, fmt.Errorf("%s: %s", res.Status, string(b))
}
return nil, errRes
}
var (
paging Paging
value []Extension
)
err := jsonx.NewDecoder(res.Body).Decode(&paging)
if err != nil {
return nil, err
}
err = jsonx.Unmarshal(paging.Value, &value)
if err != nil {
return nil, err
}
values = append(values, value...)
if len(paging.NextLink) == 0 {
return values, nil
}
req, err = http.NewRequest("GET", paging.NextLink, nil)
if ctx != nil {
req = req.WithContext(ctx)
}
res, err = r.client.Do(req)
if err != nil {
return nil, err
}
}
}
// Get performs GET request for Extension collection
func (r *AdministrativeUnitExtensionsCollectionRequest) Get(ctx context.Context) ([]Extension, error) {
var query string
if r.query != nil {
query = "?" + r.query.Encode()
}
return r.Paging(ctx, "GET", query, nil)
}
// Add performs POST request for Extension collection
func (r *AdministrativeUnitExtensionsCollectionRequest) Add(ctx context.Context, reqObj *Extension) (resObj *Extension, err error) {
err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj)
return
}
// Members returns request builder for DirectoryObject collection
func (b *AdministrativeUnitRequestBuilder) Members() *AdministrativeUnitMembersCollectionRequestBuilder {
bb := &AdministrativeUnitMembersCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/members"
return bb
}
// AdministrativeUnitMembersCollectionRequestBuilder is request builder for DirectoryObject collection
type AdministrativeUnitMembersCollectionRequestBuilder struct{ BaseRequestBuilder }
// Request returns request for DirectoryObject collection
func (b *AdministrativeUnitMembersCollectionRequestBuilder) Request() *AdministrativeUnitMembersCollectionRequest {
return &AdministrativeUnitMembersCollectionRequest{
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
}
}
// ID returns request builder for DirectoryObject item
func (b *AdministrativeUnitMembersCollectionRequestBuilder) ID(id string) *DirectoryObjectRequestBuilder {
bb := &DirectoryObjectRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/" + id
return bb
}
// AdministrativeUnitMembersCollectionRequest is request for DirectoryObject collection
type AdministrativeUnitMembersCollectionRequest struct{ BaseRequest }
// Paging perfoms paging operation for DirectoryObject collection
func (r *AdministrativeUnitMembersCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}) ([]DirectoryObject, error) {
req, err := r.NewJSONRequest(method, path, obj)
if err != nil {
return nil, err
}
if ctx != nil {
req = req.WithContext(ctx)
}
res, err := r.client.Do(req)
if err != nil {
return nil, err
}
var values []DirectoryObject
for {
defer res.Body.Close()
if res.StatusCode != http.StatusOK {
b, _ := ioutil.ReadAll(res.Body)
errRes := &ErrorResponse{Response: res}
err := jsonx.Unmarshal(b, errRes)
if err != nil {
return nil, fmt.Errorf("%s: %s", res.Status, string(b))
}
return nil, errRes
}
var (
paging Paging
value []DirectoryObject
)
err := jsonx.NewDecoder(res.Body).Decode(&paging)
if err != nil {
return nil, err
}
err = jsonx.Unmarshal(paging.Value, &value)
if err != nil {
return nil, err
}
values = append(values, value...)
if len(paging.NextLink) == 0 {
return values, nil
}
req, err = http.NewRequest("GET", paging.NextLink, nil)
if ctx != nil {
req = req.WithContext(ctx)
}
res, err = r.client.Do(req)
if err != nil {
return nil, err
}
}
}
// Get performs GET request for DirectoryObject collection
func (r *AdministrativeUnitMembersCollectionRequest) Get(ctx context.Context) ([]DirectoryObject, error) {
var query string
if r.query != nil {
query = "?" + r.query.Encode()
}
return r.Paging(ctx, "GET", query, nil)
}
// Add performs POST request for DirectoryObject collection
func (r *AdministrativeUnitMembersCollectionRequest) Add(ctx context.Context, reqObj *DirectoryObject) (resObj *DirectoryObject, err error) {
err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj)
return
}
// ScopedRoleMembers returns request builder for ScopedRoleMembership collection
func (b *AdministrativeUnitRequestBuilder) ScopedRoleMembers() *AdministrativeUnitScopedRoleMembersCollectionRequestBuilder {
bb := &AdministrativeUnitScopedRoleMembersCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/scopedRoleMembers"
return bb
}
// AdministrativeUnitScopedRoleMembersCollectionRequestBuilder is request builder for ScopedRoleMembership collection
type AdministrativeUnitScopedRoleMembersCollectionRequestBuilder struct{ BaseRequestBuilder }
// Request returns request for ScopedRoleMembership collection
func (b *AdministrativeUnitScopedRoleMembersCollectionRequestBuilder) Request() *AdministrativeUnitScopedRoleMembersCollectionRequest {
return &AdministrativeUnitScopedRoleMembersCollectionRequest{
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
}
}
// ID returns request builder for ScopedRoleMembership item
func (b *AdministrativeUnitScopedRoleMembersCollectionRequestBuilder) ID(id string) *ScopedRoleMembershipRequestBuilder {
bb := &ScopedRoleMembershipRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/" + id
return bb
}
// AdministrativeUnitScopedRoleMembersCollectionRequest is request for ScopedRoleMembership collection
type AdministrativeUnitScopedRoleMembersCollectionRequest struct{ BaseRequest }
// Paging perfoms paging operation for ScopedRoleMembership collection
func (r *AdministrativeUnitScopedRoleMembersCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}) ([]ScopedRoleMembership, error) {
req, err := r.NewJSONRequest(method, path, obj)
if err != nil {
return nil, err
}
if ctx != nil {
req = req.WithContext(ctx)
}
res, err := r.client.Do(req)
if err != nil {
return nil, err
}
var values []ScopedRoleMembership
for {
defer res.Body.Close()
if res.StatusCode != http.StatusOK {
b, _ := ioutil.ReadAll(res.Body)
errRes := &ErrorResponse{Response: res}
err := jsonx.Unmarshal(b, errRes)
if err != nil {
return nil, fmt.Errorf("%s: %s", res.Status, string(b))
}
return nil, errRes
}
var (
paging Paging
value []ScopedRoleMembership
)
err := jsonx.NewDecoder(res.Body).Decode(&paging)
if err != nil {
return nil, err
}
err = jsonx.Unmarshal(paging.Value, &value)
if err != nil {
return nil, err
}
values = append(values, value...)
if len(paging.NextLink) == 0 {
return values, nil
}
req, err = http.NewRequest("GET", paging.NextLink, nil)
if ctx != nil {
req = req.WithContext(ctx)
}
res, err = r.client.Do(req)
if err != nil {
return nil, err
}
}
}
// Get performs GET request for ScopedRoleMembership collection
func (r *AdministrativeUnitScopedRoleMembersCollectionRequest) Get(ctx context.Context) ([]ScopedRoleMembership, error) {
var query string
if r.query != nil {
query = "?" + r.query.Encode()
}
return r.Paging(ctx, "GET", query, nil)
}
// Add performs POST request for ScopedRoleMembership collection
func (r *AdministrativeUnitScopedRoleMembersCollectionRequest) Add(ctx context.Context, reqObj *ScopedRoleMembership) (resObj *ScopedRoleMembership, err error) {
err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj)
return
}

View File

@@ -0,0 +1,25 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
// AdministratorConfiguredDeviceComplianceState undocumented
type AdministratorConfiguredDeviceComplianceState int
const (
// AdministratorConfiguredDeviceComplianceStateVBasedOnDeviceCompliancePolicy undocumented
AdministratorConfiguredDeviceComplianceStateVBasedOnDeviceCompliancePolicy AdministratorConfiguredDeviceComplianceState = 0
// AdministratorConfiguredDeviceComplianceStateVNonCompliant undocumented
AdministratorConfiguredDeviceComplianceStateVNonCompliant AdministratorConfiguredDeviceComplianceState = 1
)
// AdministratorConfiguredDeviceComplianceStatePBasedOnDeviceCompliancePolicy returns a pointer to AdministratorConfiguredDeviceComplianceStateVBasedOnDeviceCompliancePolicy
func AdministratorConfiguredDeviceComplianceStatePBasedOnDeviceCompliancePolicy() *AdministratorConfiguredDeviceComplianceState {
v := AdministratorConfiguredDeviceComplianceStateVBasedOnDeviceCompliancePolicy
return &v
}
// AdministratorConfiguredDeviceComplianceStatePNonCompliant returns a pointer to AdministratorConfiguredDeviceComplianceStateVNonCompliant
func AdministratorConfiguredDeviceComplianceStatePNonCompliant() *AdministratorConfiguredDeviceComplianceState {
v := AdministratorConfiguredDeviceComplianceStateVNonCompliant
return &v
}

View File

@@ -0,0 +1,145 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
// AdvancedBitLockerState undocumented
type AdvancedBitLockerState int
const (
// AdvancedBitLockerStateVSuccess undocumented
AdvancedBitLockerStateVSuccess AdvancedBitLockerState = 0
// AdvancedBitLockerStateVNoUserConsent undocumented
AdvancedBitLockerStateVNoUserConsent AdvancedBitLockerState = 1
// AdvancedBitLockerStateVOsVolumeEncryptionMethodMismatch undocumented
AdvancedBitLockerStateVOsVolumeEncryptionMethodMismatch AdvancedBitLockerState = 2
// AdvancedBitLockerStateVOsVolumeTpmRequired undocumented
AdvancedBitLockerStateVOsVolumeTpmRequired AdvancedBitLockerState = 4
// AdvancedBitLockerStateVOsVolumeTpmOnlyRequired undocumented
AdvancedBitLockerStateVOsVolumeTpmOnlyRequired AdvancedBitLockerState = 8
// AdvancedBitLockerStateVOsVolumeTpmPinRequired undocumented
AdvancedBitLockerStateVOsVolumeTpmPinRequired AdvancedBitLockerState = 16
// AdvancedBitLockerStateVOsVolumeTpmStartupKeyRequired undocumented
AdvancedBitLockerStateVOsVolumeTpmStartupKeyRequired AdvancedBitLockerState = 32
// AdvancedBitLockerStateVOsVolumeTpmPinStartupKeyRequired undocumented
AdvancedBitLockerStateVOsVolumeTpmPinStartupKeyRequired AdvancedBitLockerState = 64
// AdvancedBitLockerStateVOsVolumeUnprotected undocumented
AdvancedBitLockerStateVOsVolumeUnprotected AdvancedBitLockerState = 128
// AdvancedBitLockerStateVRecoveryKeyBackupFailed undocumented
AdvancedBitLockerStateVRecoveryKeyBackupFailed AdvancedBitLockerState = 256
// AdvancedBitLockerStateVFixedDriveNotEncrypted undocumented
AdvancedBitLockerStateVFixedDriveNotEncrypted AdvancedBitLockerState = 512
// AdvancedBitLockerStateVFixedDriveEncryptionMethodMismatch undocumented
AdvancedBitLockerStateVFixedDriveEncryptionMethodMismatch AdvancedBitLockerState = 1024
// AdvancedBitLockerStateVLoggedOnUserNonAdmin undocumented
AdvancedBitLockerStateVLoggedOnUserNonAdmin AdvancedBitLockerState = 2048
// AdvancedBitLockerStateVWindowsRecoveryEnvironmentNotConfigured undocumented
AdvancedBitLockerStateVWindowsRecoveryEnvironmentNotConfigured AdvancedBitLockerState = 4096
// AdvancedBitLockerStateVTpmNotAvailable undocumented
AdvancedBitLockerStateVTpmNotAvailable AdvancedBitLockerState = 8192
// AdvancedBitLockerStateVTpmNotReady undocumented
AdvancedBitLockerStateVTpmNotReady AdvancedBitLockerState = 16384
// AdvancedBitLockerStateVNetworkError undocumented
AdvancedBitLockerStateVNetworkError AdvancedBitLockerState = 32768
)
// AdvancedBitLockerStatePSuccess returns a pointer to AdvancedBitLockerStateVSuccess
func AdvancedBitLockerStatePSuccess() *AdvancedBitLockerState {
v := AdvancedBitLockerStateVSuccess
return &v
}
// AdvancedBitLockerStatePNoUserConsent returns a pointer to AdvancedBitLockerStateVNoUserConsent
func AdvancedBitLockerStatePNoUserConsent() *AdvancedBitLockerState {
v := AdvancedBitLockerStateVNoUserConsent
return &v
}
// AdvancedBitLockerStatePOsVolumeEncryptionMethodMismatch returns a pointer to AdvancedBitLockerStateVOsVolumeEncryptionMethodMismatch
func AdvancedBitLockerStatePOsVolumeEncryptionMethodMismatch() *AdvancedBitLockerState {
v := AdvancedBitLockerStateVOsVolumeEncryptionMethodMismatch
return &v
}
// AdvancedBitLockerStatePOsVolumeTpmRequired returns a pointer to AdvancedBitLockerStateVOsVolumeTpmRequired
func AdvancedBitLockerStatePOsVolumeTpmRequired() *AdvancedBitLockerState {
v := AdvancedBitLockerStateVOsVolumeTpmRequired
return &v
}
// AdvancedBitLockerStatePOsVolumeTpmOnlyRequired returns a pointer to AdvancedBitLockerStateVOsVolumeTpmOnlyRequired
func AdvancedBitLockerStatePOsVolumeTpmOnlyRequired() *AdvancedBitLockerState {
v := AdvancedBitLockerStateVOsVolumeTpmOnlyRequired
return &v
}
// AdvancedBitLockerStatePOsVolumeTpmPinRequired returns a pointer to AdvancedBitLockerStateVOsVolumeTpmPinRequired
func AdvancedBitLockerStatePOsVolumeTpmPinRequired() *AdvancedBitLockerState {
v := AdvancedBitLockerStateVOsVolumeTpmPinRequired
return &v
}
// AdvancedBitLockerStatePOsVolumeTpmStartupKeyRequired returns a pointer to AdvancedBitLockerStateVOsVolumeTpmStartupKeyRequired
func AdvancedBitLockerStatePOsVolumeTpmStartupKeyRequired() *AdvancedBitLockerState {
v := AdvancedBitLockerStateVOsVolumeTpmStartupKeyRequired
return &v
}
// AdvancedBitLockerStatePOsVolumeTpmPinStartupKeyRequired returns a pointer to AdvancedBitLockerStateVOsVolumeTpmPinStartupKeyRequired
func AdvancedBitLockerStatePOsVolumeTpmPinStartupKeyRequired() *AdvancedBitLockerState {
v := AdvancedBitLockerStateVOsVolumeTpmPinStartupKeyRequired
return &v
}
// AdvancedBitLockerStatePOsVolumeUnprotected returns a pointer to AdvancedBitLockerStateVOsVolumeUnprotected
func AdvancedBitLockerStatePOsVolumeUnprotected() *AdvancedBitLockerState {
v := AdvancedBitLockerStateVOsVolumeUnprotected
return &v
}
// AdvancedBitLockerStatePRecoveryKeyBackupFailed returns a pointer to AdvancedBitLockerStateVRecoveryKeyBackupFailed
func AdvancedBitLockerStatePRecoveryKeyBackupFailed() *AdvancedBitLockerState {
v := AdvancedBitLockerStateVRecoveryKeyBackupFailed
return &v
}
// AdvancedBitLockerStatePFixedDriveNotEncrypted returns a pointer to AdvancedBitLockerStateVFixedDriveNotEncrypted
func AdvancedBitLockerStatePFixedDriveNotEncrypted() *AdvancedBitLockerState {
v := AdvancedBitLockerStateVFixedDriveNotEncrypted
return &v
}
// AdvancedBitLockerStatePFixedDriveEncryptionMethodMismatch returns a pointer to AdvancedBitLockerStateVFixedDriveEncryptionMethodMismatch
func AdvancedBitLockerStatePFixedDriveEncryptionMethodMismatch() *AdvancedBitLockerState {
v := AdvancedBitLockerStateVFixedDriveEncryptionMethodMismatch
return &v
}
// AdvancedBitLockerStatePLoggedOnUserNonAdmin returns a pointer to AdvancedBitLockerStateVLoggedOnUserNonAdmin
func AdvancedBitLockerStatePLoggedOnUserNonAdmin() *AdvancedBitLockerState {
v := AdvancedBitLockerStateVLoggedOnUserNonAdmin
return &v
}
// AdvancedBitLockerStatePWindowsRecoveryEnvironmentNotConfigured returns a pointer to AdvancedBitLockerStateVWindowsRecoveryEnvironmentNotConfigured
func AdvancedBitLockerStatePWindowsRecoveryEnvironmentNotConfigured() *AdvancedBitLockerState {
v := AdvancedBitLockerStateVWindowsRecoveryEnvironmentNotConfigured
return &v
}
// AdvancedBitLockerStatePTpmNotAvailable returns a pointer to AdvancedBitLockerStateVTpmNotAvailable
func AdvancedBitLockerStatePTpmNotAvailable() *AdvancedBitLockerState {
v := AdvancedBitLockerStateVTpmNotAvailable
return &v
}
// AdvancedBitLockerStatePTpmNotReady returns a pointer to AdvancedBitLockerStateVTpmNotReady
func AdvancedBitLockerStatePTpmNotReady() *AdvancedBitLockerState {
v := AdvancedBitLockerStateVTpmNotReady
return &v
}
// AdvancedBitLockerStatePNetworkError returns a pointer to AdvancedBitLockerStateVNetworkError
func AdvancedBitLockerStatePNetworkError() *AdvancedBitLockerState {
v := AdvancedBitLockerStateVNetworkError
return &v
}

View File

@@ -0,0 +1,35 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
import "time"
// AdvancedThreatProtectionOnboardingDeviceSettingState ATP onboarding State for a given device.
type AdvancedThreatProtectionOnboardingDeviceSettingState struct {
// Entity is the base model of AdvancedThreatProtectionOnboardingDeviceSettingState
Entity
// PlatformType Device platform type
PlatformType *DeviceType `json:"platformType,omitempty"`
// Setting The setting class name and property name.
Setting *string `json:"setting,omitempty"`
// SettingName The Setting Name that is being reported
SettingName *string `json:"settingName,omitempty"`
// DeviceID The Device Id that is being reported
DeviceID *string `json:"deviceId,omitempty"`
// DeviceName The Device Name that is being reported
DeviceName *string `json:"deviceName,omitempty"`
// UserID The user Id that is being reported
UserID *string `json:"userId,omitempty"`
// UserEmail The User email address that is being reported
UserEmail *string `json:"userEmail,omitempty"`
// UserName The User Name that is being reported
UserName *string `json:"userName,omitempty"`
// UserPrincipalName The User PrincipalName that is being reported
UserPrincipalName *string `json:"userPrincipalName,omitempty"`
// DeviceModel The device model that is being reported
DeviceModel *string `json:"deviceModel,omitempty"`
// State The compliance state of the setting
State *ComplianceStatus `json:"state,omitempty"`
// ComplianceGracePeriodExpirationDateTime The DateTime when device compliance grace period expires
ComplianceGracePeriodExpirationDateTime *time.Time `json:"complianceGracePeriodExpirationDateTime,omitempty"`
}

View File

@@ -0,0 +1,38 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
import "context"
// AdvancedThreatProtectionOnboardingDeviceSettingStateRequestBuilder is request builder for AdvancedThreatProtectionOnboardingDeviceSettingState
type AdvancedThreatProtectionOnboardingDeviceSettingStateRequestBuilder struct{ BaseRequestBuilder }
// Request returns AdvancedThreatProtectionOnboardingDeviceSettingStateRequest
func (b *AdvancedThreatProtectionOnboardingDeviceSettingStateRequestBuilder) Request() *AdvancedThreatProtectionOnboardingDeviceSettingStateRequest {
return &AdvancedThreatProtectionOnboardingDeviceSettingStateRequest{
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
}
}
// AdvancedThreatProtectionOnboardingDeviceSettingStateRequest is request for AdvancedThreatProtectionOnboardingDeviceSettingState
type AdvancedThreatProtectionOnboardingDeviceSettingStateRequest struct{ BaseRequest }
// Get performs GET request for AdvancedThreatProtectionOnboardingDeviceSettingState
func (r *AdvancedThreatProtectionOnboardingDeviceSettingStateRequest) Get(ctx context.Context) (resObj *AdvancedThreatProtectionOnboardingDeviceSettingState, err error) {
var query string
if r.query != nil {
query = "?" + r.query.Encode()
}
err = r.JSONRequest(ctx, "GET", query, nil, &resObj)
return
}
// Update performs PATCH request for AdvancedThreatProtectionOnboardingDeviceSettingState
func (r *AdvancedThreatProtectionOnboardingDeviceSettingStateRequest) Update(ctx context.Context, reqObj *AdvancedThreatProtectionOnboardingDeviceSettingState) error {
return r.JSONRequest(ctx, "PATCH", "", reqObj, nil)
}
// Delete performs DELETE request for AdvancedThreatProtectionOnboardingDeviceSettingState
func (r *AdvancedThreatProtectionOnboardingDeviceSettingStateRequest) Delete(ctx context.Context) error {
return r.JSONRequest(ctx, "DELETE", "", nil, nil)
}

View File

@@ -0,0 +1,27 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
// AdvancedThreatProtectionOnboardingStateSummary Windows defender advanced threat protection onboarding state summary across the account.
type AdvancedThreatProtectionOnboardingStateSummary struct {
// Entity is the base model of AdvancedThreatProtectionOnboardingStateSummary
Entity
// UnknownDeviceCount Number of unknown devices
UnknownDeviceCount *int `json:"unknownDeviceCount,omitempty"`
// NotApplicableDeviceCount Number of not applicable devices
NotApplicableDeviceCount *int `json:"notApplicableDeviceCount,omitempty"`
// CompliantDeviceCount Number of compliant devices
CompliantDeviceCount *int `json:"compliantDeviceCount,omitempty"`
// RemediatedDeviceCount Number of remediated devices
RemediatedDeviceCount *int `json:"remediatedDeviceCount,omitempty"`
// NonCompliantDeviceCount Number of NonCompliant devices
NonCompliantDeviceCount *int `json:"nonCompliantDeviceCount,omitempty"`
// ErrorDeviceCount Number of error devices
ErrorDeviceCount *int `json:"errorDeviceCount,omitempty"`
// ConflictDeviceCount Number of conflict devices
ConflictDeviceCount *int `json:"conflictDeviceCount,omitempty"`
// NotAssignedDeviceCount Number of not assigned devices
NotAssignedDeviceCount *int `json:"notAssignedDeviceCount,omitempty"`
// AdvancedThreatProtectionOnboardingDeviceSettingStates undocumented
AdvancedThreatProtectionOnboardingDeviceSettingStates []AdvancedThreatProtectionOnboardingDeviceSettingState `json:"advancedThreatProtectionOnboardingDeviceSettingStates,omitempty"`
}

View File

@@ -0,0 +1,139 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
import (
"context"
"fmt"
"io/ioutil"
"net/http"
"github.com/matterbridge/msgraph.go/jsonx"
)
// AdvancedThreatProtectionOnboardingStateSummaryRequestBuilder is request builder for AdvancedThreatProtectionOnboardingStateSummary
type AdvancedThreatProtectionOnboardingStateSummaryRequestBuilder struct{ BaseRequestBuilder }
// Request returns AdvancedThreatProtectionOnboardingStateSummaryRequest
func (b *AdvancedThreatProtectionOnboardingStateSummaryRequestBuilder) Request() *AdvancedThreatProtectionOnboardingStateSummaryRequest {
return &AdvancedThreatProtectionOnboardingStateSummaryRequest{
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
}
}
// AdvancedThreatProtectionOnboardingStateSummaryRequest is request for AdvancedThreatProtectionOnboardingStateSummary
type AdvancedThreatProtectionOnboardingStateSummaryRequest struct{ BaseRequest }
// Get performs GET request for AdvancedThreatProtectionOnboardingStateSummary
func (r *AdvancedThreatProtectionOnboardingStateSummaryRequest) Get(ctx context.Context) (resObj *AdvancedThreatProtectionOnboardingStateSummary, err error) {
var query string
if r.query != nil {
query = "?" + r.query.Encode()
}
err = r.JSONRequest(ctx, "GET", query, nil, &resObj)
return
}
// Update performs PATCH request for AdvancedThreatProtectionOnboardingStateSummary
func (r *AdvancedThreatProtectionOnboardingStateSummaryRequest) Update(ctx context.Context, reqObj *AdvancedThreatProtectionOnboardingStateSummary) error {
return r.JSONRequest(ctx, "PATCH", "", reqObj, nil)
}
// Delete performs DELETE request for AdvancedThreatProtectionOnboardingStateSummary
func (r *AdvancedThreatProtectionOnboardingStateSummaryRequest) Delete(ctx context.Context) error {
return r.JSONRequest(ctx, "DELETE", "", nil, nil)
}
// AdvancedThreatProtectionOnboardingDeviceSettingStates returns request builder for AdvancedThreatProtectionOnboardingDeviceSettingState collection
func (b *AdvancedThreatProtectionOnboardingStateSummaryRequestBuilder) AdvancedThreatProtectionOnboardingDeviceSettingStates() *AdvancedThreatProtectionOnboardingStateSummaryAdvancedThreatProtectionOnboardingDeviceSettingStatesCollectionRequestBuilder {
bb := &AdvancedThreatProtectionOnboardingStateSummaryAdvancedThreatProtectionOnboardingDeviceSettingStatesCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/advancedThreatProtectionOnboardingDeviceSettingStates"
return bb
}
// AdvancedThreatProtectionOnboardingStateSummaryAdvancedThreatProtectionOnboardingDeviceSettingStatesCollectionRequestBuilder is request builder for AdvancedThreatProtectionOnboardingDeviceSettingState collection
type AdvancedThreatProtectionOnboardingStateSummaryAdvancedThreatProtectionOnboardingDeviceSettingStatesCollectionRequestBuilder struct{ BaseRequestBuilder }
// Request returns request for AdvancedThreatProtectionOnboardingDeviceSettingState collection
func (b *AdvancedThreatProtectionOnboardingStateSummaryAdvancedThreatProtectionOnboardingDeviceSettingStatesCollectionRequestBuilder) Request() *AdvancedThreatProtectionOnboardingStateSummaryAdvancedThreatProtectionOnboardingDeviceSettingStatesCollectionRequest {
return &AdvancedThreatProtectionOnboardingStateSummaryAdvancedThreatProtectionOnboardingDeviceSettingStatesCollectionRequest{
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
}
}
// ID returns request builder for AdvancedThreatProtectionOnboardingDeviceSettingState item
func (b *AdvancedThreatProtectionOnboardingStateSummaryAdvancedThreatProtectionOnboardingDeviceSettingStatesCollectionRequestBuilder) ID(id string) *AdvancedThreatProtectionOnboardingDeviceSettingStateRequestBuilder {
bb := &AdvancedThreatProtectionOnboardingDeviceSettingStateRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
bb.baseURL += "/" + id
return bb
}
// AdvancedThreatProtectionOnboardingStateSummaryAdvancedThreatProtectionOnboardingDeviceSettingStatesCollectionRequest is request for AdvancedThreatProtectionOnboardingDeviceSettingState collection
type AdvancedThreatProtectionOnboardingStateSummaryAdvancedThreatProtectionOnboardingDeviceSettingStatesCollectionRequest struct{ BaseRequest }
// Paging perfoms paging operation for AdvancedThreatProtectionOnboardingDeviceSettingState collection
func (r *AdvancedThreatProtectionOnboardingStateSummaryAdvancedThreatProtectionOnboardingDeviceSettingStatesCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}) ([]AdvancedThreatProtectionOnboardingDeviceSettingState, error) {
req, err := r.NewJSONRequest(method, path, obj)
if err != nil {
return nil, err
}
if ctx != nil {
req = req.WithContext(ctx)
}
res, err := r.client.Do(req)
if err != nil {
return nil, err
}
var values []AdvancedThreatProtectionOnboardingDeviceSettingState
for {
defer res.Body.Close()
if res.StatusCode != http.StatusOK {
b, _ := ioutil.ReadAll(res.Body)
errRes := &ErrorResponse{Response: res}
err := jsonx.Unmarshal(b, errRes)
if err != nil {
return nil, fmt.Errorf("%s: %s", res.Status, string(b))
}
return nil, errRes
}
var (
paging Paging
value []AdvancedThreatProtectionOnboardingDeviceSettingState
)
err := jsonx.NewDecoder(res.Body).Decode(&paging)
if err != nil {
return nil, err
}
err = jsonx.Unmarshal(paging.Value, &value)
if err != nil {
return nil, err
}
values = append(values, value...)
if len(paging.NextLink) == 0 {
return values, nil
}
req, err = http.NewRequest("GET", paging.NextLink, nil)
if ctx != nil {
req = req.WithContext(ctx)
}
res, err = r.client.Do(req)
if err != nil {
return nil, err
}
}
}
// Get performs GET request for AdvancedThreatProtectionOnboardingDeviceSettingState collection
func (r *AdvancedThreatProtectionOnboardingStateSummaryAdvancedThreatProtectionOnboardingDeviceSettingStatesCollectionRequest) Get(ctx context.Context) ([]AdvancedThreatProtectionOnboardingDeviceSettingState, error) {
var query string
if r.query != nil {
query = "?" + r.query.Encode()
}
return r.Paging(ctx, "GET", query, nil)
}
// Add performs POST request for AdvancedThreatProtectionOnboardingDeviceSettingState collection
func (r *AdvancedThreatProtectionOnboardingStateSummaryAdvancedThreatProtectionOnboardingDeviceSettingStatesCollectionRequest) Add(ctx context.Context, reqObj *AdvancedThreatProtectionOnboardingDeviceSettingState) (resObj *AdvancedThreatProtectionOnboardingDeviceSettingState, err error) {
err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj)
return
}

View File

@@ -0,0 +1,31 @@
// Code generated by msgraph-generate.go DO NOT EDIT.
package msgraph
import "time"
// AgedAccountsPayable undocumented
type AgedAccountsPayable struct {
// Entity is the base model of AgedAccountsPayable
Entity
// VendorNumber undocumented
VendorNumber *string `json:"vendorNumber,omitempty"`
// Name undocumented
Name *string `json:"name,omitempty"`
// CurrencyCode undocumented
CurrencyCode *string `json:"currencyCode,omitempty"`
// BalanceDue undocumented
BalanceDue *int `json:"balanceDue,omitempty"`
// CurrentAmount undocumented
CurrentAmount *int `json:"currentAmount,omitempty"`
// Period1Amount undocumented
Period1Amount *int `json:"period1Amount,omitempty"`
// Period2Amount undocumented
Period2Amount *int `json:"period2Amount,omitempty"`
// Period3Amount undocumented
Period3Amount *int `json:"period3Amount,omitempty"`
// AgedAsOfDate undocumented
AgedAsOfDate *time.Time `json:"agedAsOfDate,omitempty"`
// PeriodLengthFilter undocumented
PeriodLengthFilter *string `json:"periodLengthFilter,omitempty"`
}

Some files were not shown because too many files have changed in this diff Show More