Categorygithub.com/owncloud/libre-graph-api-go
repositorypackage
1.0.4
Repository: https://github.com/owncloud/libre-graph-api-go.git
Documentation: pkg.go.dev

# README

Go API client for libregraph

Libre Graph is a free API for cloud collaboration inspired by the MS Graph API.

Overview

This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.

  • API version: v1.0.4
  • Package version: 1.0.0
  • Build package: org.openapitools.codegen.languages.GoClientCodegen

Installation

Install the following dependencies:

go get github.com/stretchr/testify/assert
go get golang.org/x/oauth2
go get golang.org/x/net/context

Put the package under your project folder and add the following in import:

import libregraph "github.com/owncloud/libre-graph-api-go"

To use a proxy, set the environment variable HTTP_PROXY:

os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")

Configuration of Server URL

Default configuration comes with Servers field that contains server objects as defined in the OpenAPI specification.

Select Server Configuration

For using other server than the one defined on index 0 set context value sw.ContextServerIndex of type int.

ctx := context.WithValue(context.Background(), libregraph.ContextServerIndex, 1)

Templated Server URL

Templated server URL is formatted using default variables from configuration or from context value sw.ContextServerVariables of type map[string]string.

ctx := context.WithValue(context.Background(), libregraph.ContextServerVariables, map[string]string{
	"basePath": "v2",
})

Note, enum values are always validated and all unused variables are silently ignored.

URLs Configuration per Operation

Each operation can use different server URL defined using OperationServers map in the Configuration. An operation is uniquely identified by "{classname}Service.{nickname}" string. Similar rules for overriding default operation server index and variables applies by using sw.ContextOperationServerIndices and sw.ContextOperationServerVariables context maps.

ctx := context.WithValue(context.Background(), libregraph.ContextOperationServerIndices, map[string]int{
	"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), libregraph.ContextOperationServerVariables, map[string]map[string]string{
	"{classname}Service.{nickname}": {
		"port": "8443",
	},
})

Documentation for API Endpoints

All URIs are relative to https://ocis.ocis-traefik.latest.owncloud.works/graph/v1.0

ClassMethodHTTP requestDescription
ApplicationsApiGetApplicationGet /applications/{application-id}Get application by id
ApplicationsApiListApplicationsGet /applicationsGet all applications
DrivesApiCreateDrivePost /drivesCreate a new drive of a specific type
DrivesApiDeleteDriveDelete /drives/{drive-id}Delete a specific space
DrivesApiGetDriveGet /drives/{drive-id}Get drive by id
DrivesApiUpdateDrivePatch /drives/{drive-id}Update the drive
DrivesGetDrivesApiListAllDrivesGet /drivesGet all available drives
DrivesRootApiGetRootGet /drives/{drive-id}/rootGet root from arbitrary space
EducationClassApiAddUserToClassPost /education/classes/{class-id}/members/$refAssign a user to a class
EducationClassApiCreateClassPost /education/classesAdd new education class
EducationClassApiDeleteClassDelete /education/classes/{class-id}Delete education class
EducationClassApiDeleteUserFromClassDelete /education/classes/{class-id}/members/{user-id}/$refUnassign user from a class
EducationClassApiGetClassGet /education/classes/{class-id}Get class by key
EducationClassApiListClassMembersGet /education/classes/{class-id}/membersGet the educationClass resources owned by an educationSchool
EducationClassApiListClassesGet /education/classeslist education classes
EducationClassApiUpdateClassPatch /education/classes/{class-id}Update properties of a education class
EducationClassTeachersApiAddTeacherToClassPost /education/classes/{class-id}/teachers/$refAssign a teacher to a class
EducationClassTeachersApiDeleteTeacherFromClassDelete /education/classes/{class-id}/teachers/{user-id}/$refUnassign user as teacher of a class
EducationClassTeachersApiGetTeachersGet /education/classes/{class-id}/teachersGet the teachers for a class
EducationSchoolApiAddClassToSchoolPost /education/schools/{school-id}/classes/$refAssign a class to a school
EducationSchoolApiAddUserToSchoolPost /education/schools/{school-id}/users/$refAssign a user to a school
EducationSchoolApiCreateSchoolPost /education/schoolsAdd new school
EducationSchoolApiDeleteClassFromSchoolDelete /education/schools/{school-id}/classes/{class-id}/$refUnassign class from a school
EducationSchoolApiDeleteSchoolDelete /education/schools/{school-id}Delete school
EducationSchoolApiDeleteUserFromSchoolDelete /education/schools/{school-id}/users/{user-id}/$refUnassign user from a school
EducationSchoolApiGetSchoolGet /education/schools/{school-id}Get the properties of a specific school
EducationSchoolApiListSchoolClassesGet /education/schools/{school-id}/classesGet the educationClass resources owned by an educationSchool
EducationSchoolApiListSchoolUsersGet /education/schools/{school-id}/usersGet the educationUser resources associated with an educationSchool
EducationSchoolApiListSchoolsGet /education/schoolsGet a list of schools and their properties
EducationSchoolApiUpdateSchoolPatch /education/schools/{school-id}Update properties of a school
EducationUserApiCreateEducationUserPost /education/usersAdd new education user
EducationUserApiDeleteEducationUserDelete /education/users/{user-id}Delete educationUser
EducationUserApiGetEducationUserGet /education/users/{user-id}Get properties of educationUser
EducationUserApiListEducationUsersGet /education/usersGet entities from education users
EducationUserApiUpdateEducationUserPatch /education/users/{user-id}Update properties of educationUser
GroupApiAddMemberPost /groups/{group-id}/members/$refAdd a member to a group
GroupApiDeleteGroupDelete /groups/{group-id}Delete entity from groups
GroupApiDeleteMemberDelete /groups/{group-id}/members/{directory-object-id}/$refDelete member from a group
GroupApiGetGroupGet /groups/{group-id}Get entity from groups by key
GroupApiListMembersGet /groups/{group-id}/membersGet a list of the group's direct members
GroupApiUpdateGroupPatch /groups/{group-id}Update entity in groups
GroupsApiCreateGroupPost /groupsAdd new entity to groups
GroupsApiListGroupsGet /groupsGet entities from groups
MeChangepasswordApiChangeOwnPasswordPost /me/changePasswordChanage your own password
MeDriveApiGetHomeGet /me/driveGet personal space for user
MeDriveRootApiHomeGetRootGet /me/drive/rootGet root from personal space
MeDriveRootChildrenApiHomeGetChildrenGet /me/drive/root/childrenGet children from drive
MeDrivesApiListMyDrivesGet /me/drivesGet all drives where the current user is a regular member of
MeUserApiGetOwnUserGet /meGet current user
TagsApiAssignTagsPut /extensions/org.libregraph/tagsAssign tags to a resource
TagsApiGetTagsGet /extensions/org.libregraph/tagsGet all known tags
TagsApiUnassignTagsDelete /extensions/org.libregraph/tagsUnassign tags from a resource
UserApiDeleteUserDelete /users/{user-id}Delete entity from users
UserApiExportPersonalDataPost /users/{user-id}/exportPersonalDataexport personal data of a user
UserApiGetUserGet /users/{user-id}Get entity from users by key
UserApiUpdateUserPatch /users/{user-id}Update entity in users
UserAppRoleAssignmentApiUserCreateAppRoleAssignmentsPost /users/{user-id}/appRoleAssignmentsGrant an appRoleAssignment to a user
UserAppRoleAssignmentApiUserDeleteAppRoleAssignmentsDelete /users/{user-id}/appRoleAssignments/{appRoleAssignment-id}Delete the appRoleAssignment from a user
UserAppRoleAssignmentApiUserListAppRoleAssignmentsGet /users/{user-id}/appRoleAssignmentsGet appRoleAssignments from a user
UsersApiCreateUserPost /usersAdd new entity to users
UsersApiListUsersGet /usersGet entities from users

Documentation For Models

Documentation For Authorization

bearerAuth

  • Type: HTTP Bearer token authentication

Example

auth := context.WithValue(context.Background(), sw.ContextAccessToken, "BEARER_TOKEN_STRING")
r, err := client.Service.Operation(auth, args)

Documentation for Utility Methods

Due to the fact that model structure members are all pointers, this package contains a number of utility functions to easily obtain pointers to values of basic types. Each of these functions takes a value of the given basic type and returns a pointer to it:

  • PtrBool
  • PtrInt
  • PtrInt32
  • PtrInt64
  • PtrFloat
  • PtrFloat32
  • PtrFloat64
  • PtrString
  • PtrTime

Author