{"modulePath":"github.com/iochen/msgraph-drive","version":"v0.0.0-20210805134335-d8d83ed1da00","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package drive\n\n## Constants\n\n```go\nconst APIVersion string = \"v1.0\"\n```\nAPIVersion represents the APIVersion of msgraph used by this implementation\n\n```go\nconst BaseURL string = \"https://graph.microsoft.com\"\n```\nBaseURL represents the URL used to perform all ms graph API-calls\n\n```go\nconst LoginBaseURL string = \"https://login.microsoftonline.com\"\n```\nLoginBaseURL represents the basic url used to acquire a token for the msgraph api\n\n```go\nconst MaxPageSize int = 999\n```\nMaxPageSize is the maximum Page size for an API-call. This will be rewritten to use paging some day. Currently limits environments to 999 entries (e.g. Users, CalendarEvents etc.)\n\n## Functions\n\n```go\nfunc NewErr(statusCode int, body []byte) error\n```\n\n## Types\n\n```go\ntype Client struct {\n\tsync.Mutex // lock it when performing an API-call to synchronize it\n\n\tTenantID      string // See https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal#get-tenant-id\n\tApplicationID string // See https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal#get-application-id-and-authentication-key\n\tClientSecret  string // See https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal#get-application-id-and-authentication-key\n\t// contains filtered or unexported fields\n}\n```\nClient represents a msgraph API connection instance.\n\nAn instance can also be json-unmarshalled an will immediately be initialized, hence a Token will be grabbed. If grabbing a token fails the JSON-Unmarshal returns an error.\n\n```go\nfunc NewGraphClient(tenantID, applicationID, clientSecret string) (*Client, error)\n```\nNewGraphClient creates a new Client instance with the given parameters and grab's a token.\n\nReturns an error if the token can not be initialized. This method does not have to be used to create a new Client\n\n```go\nfunc (cli *Client) GetDrive(id string) *Drive\n```\n\n```go\nfunc (cli *Client) String() string\n```\n\n```go\nfunc (cli *Client) UnmarshalJSON(data []byte) error\n```\nUnmarshalJSON implements the json unmarshal to be used by the json-library. This method additionally to loading the TenantID, ApplicationID and ClientSecret immediately gets a Token from msgraph (hence initialize this GraphAPI instance) and returns an error if any of the data provided is incorrect or the token can not be acquired\n\n```go\ntype Drive struct {\n\tID     string\n\tClient *Client\n}\n```\n\n```go\nfunc (drv *Drive) Item(path string) (*Item, error)\n```\n\n```go\nfunc (drv *Drive) ListChildren(path string) ([]*Item, error)\n```\n\n```go\ntype Item struct {\n\tCreatedAt time.Time `json:\"createdDateTime\"`\n\tID        string    `json:\"id\"`\n\tLastMod   time.Time `json:\"lastModifiedDateTime\"`\n\tName      string    `json:\"name\"`\n\tWebURL    string    `json:\"webUrl\"`\n\tSize      int64     `json:\"size\"`\n\n\tCreatedBy struct {\n\t\tUser `json:\"user\"`\n\t} `json:\"createdBy\"`\n\tLastModifiedBy struct {\n\t\tUser `json:\"user\"`\n\t} `json:\"lastModifiedBy\"`\n\n\tParentReference Reference `json:\"parentReference\"`\n\n\tFileSystemInfo struct {\n\t\tCreatedDateTime      time.Time `json:\"createdDateTime\"`\n\t\tLastModifiedDateTime time.Time `json:\"lastModifiedDateTime\"`\n\t} `json:\"fileSystemInfo\"`\n\n\tFolder *struct {\n\t\tChildCount int `json:\"childCount\"`\n\t} `json:\"folder,omitempty\"`\n\n\tDownloadURL string `json:\"@microsoft.graph.downloadUrl,omitempty\"`\n\n\tFile *struct {\n\t\tMimeType string `json:\"mimeType\"`\n\t} `json:\"file,omitempty\"`\n\n\tImage *struct {\n\t\tHeight int `json:\"height\"`\n\t\tWidth  int `json:\"width\"`\n\t} `json:\"image,omitempty\"`\n}\n```\n\n```go\nfunc (item *Item) IsFolder() bool\n```\n\n```go\ntype Reference struct {\n\tDriveID   string `json:\"driveId\"`\n\tDriveType string `json:\"driveType\"`\n\tID        string `json:\"id\"`\n\tPath      string `json:\"path\"`\n}\n```\n\n```go\ntype ReqError struct {\n\tURL        string `json:\"-\"`\n\tStatusCode int    `json:\"-\"`\n\tErr        struct {\n\t\tCode       string `json:\"code\"`\n\t\tMessage    string `json:\"message\"`\n\t\tInnerError struct {\n\t\t\tDate            string `json:\"date\"`\n\t\t\tRequestID       string `json:\"request-id\"`\n\t\t\tClientRequestID string `json:\"client-request-id\"`\n\t\t} `json:\"innerError\"`\n\t} `json:\"error\"`\n\n\tRaw string `json:\"-\"`\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (re *ReqError) Error() string\n```\n\n```go\nfunc (re *ReqError) String() string\n```\n\n```go\ntype Token struct {\n\tTokenType   string    // should always be \"Bearer\" for msgraph API-calls\n\tNotBefore   time.Time // time when the access token starts to be valid\n\tExpiresOn   time.Time // time when the access token expires\n\tResource    string    // will most likely always be https://graph.microsoft.com, hence the BaseURL\n\tAccessToken string    // the access-token itself\n}\n```\n\n```go\nfunc (t Token) GetAccessToken() string\n```\nGetAccessToken teturns the API access token in Bearer format representation ready to send to the API interface.\n\n```go\nfunc (t Token) HasExpired() bool\n```\nHasExpired returns true if the token has already expired.\n\nHint: this is a wrapper for \u003e\u003e!token.IsStillValid()\\\u003c\\\u003c\n\n```go\nfunc (t Token) IsAlreadyValid() bool\n```\nIsAlreadyValid returns true if the token is already valid, hence the NotBefore is before the current time. Otherwise false.\n\nHint: The current time is determined by time.Now()\n\n```go\nfunc (t Token) IsStillValid() bool\n```\nIsStillValid returns true if the token is still valid, hence the current time is before ExpiresOn. Does NOT check it the token is yet valid or in the future.\n\nHint: The current time is determined by time.Now()\n\n```go\nfunc (t Token) IsValid() bool\n```\nIsValid returns true if the token is already valid and is still valid. Otherwise false.\n\nHint: this is a wrapper for \u003e\u003etoken.IsAlreadyValid() \u0026\u0026 token.IsStillValid()\\\u003c\\\u003c\n\n```go\nfunc (t Token) String() string\n```\n\n```go\nfunc (t *Token) UnmarshalJSON(data []byte) error\n```\nUnmarshalJSON implements the json unmarshal to be used by the json-library.\n\nHint: the UnmarshalJSON also checks immediately if the token is valid, hence the current time.Now() is after NotBefore and before ExpiresOn\n\n```go\nfunc (t Token) WantsToBeRefreshed() bool\n```\nWantsToBeRefreshed returns true if the token is already invalid or close to expire (10 second before ExpiresOn), otherwise false. time.Now() is used to determine the current time.\n\n```go\ntype User struct {\n\tEmail       string `json:\"email\"`\n\tID          string `json:\"id\"`\n\tDisplayName string `json:\"displayName\"`\n}\n```\n\n","path":"github.com/iochen/msgraph-drive","name":"drive","synopsis":"","isRedistributable":true}
