Skip to content

Latest commit

 

History

History
350 lines (229 loc) · 8.93 KB

GroupsAPI.md

File metadata and controls

350 lines (229 loc) · 8.93 KB

Groups API

Method HTTP request Description
CreateGroup Post /v1/groups Create group
DeleteGroup Delete /v1/groups/{groupId} Deletes group
GetGroup Get /v1/groups/{groupId} Retrieve group
GetGroups Get /v1/groups List groups
UpdateGroup Put /v1/groups/{groupId} Update a group

CreateGroup

Group CreateGroup(ctx).Group(group).Execute()

Create group

Example

package main

import (
	"context"
	"fmt"
	"os"
	authress "github.com/authress/authress-sdk.go"
)

func main() {
	group := *authress.NewGroup("Name_example", []authress.User{*authress.NewUser("oauth|userId")}, []authress.User{*authress.NewUser("oauth|userId")}) // Group | 

	url, _ := url.Parse("https://authress.company.com")
	authressClient := authress.NewAuthressClient(authress.AuthressSettings{
		AuthressApiUrl: url,
	})
	resp, r, err := apiClient.Groups.CreateGroup(context.Background()).Group(group).Execute()
	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `Groups.CreateGroup``: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}
	// response from `CreateGroup`: Group
	fmt.Fprintf(os.Stdout, "Response from `Groups.CreateGroup`: %v\n", resp)
}

Path Parameters

Other Parameters

Other parameters are passed through a pointer to a apiCreateGroupRequest struct via the builder pattern

Name Type Description Notes
group Group

Return type

Group

HTTP request headers

  • Content-Type: application/json
  • Accept: application/links+json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

DeleteGroup

DeleteGroup(ctx, groupId).Execute()

Deletes group

Example

package main

import (
	"context"
	"fmt"
	"os"
	authress "github.com/authress/authress-sdk.go"
)

func main() {
	groupId := TODO // GroupId | The identifier of the group.

	url, _ := url.Parse("https://authress.company.com")
	authressClient := authress.NewAuthressClient(authress.AuthressSettings{
		AuthressApiUrl: url,
	})
	r, err := apiClient.Groups.DeleteGroup(context.Background(), groupId).Execute()
	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `Groups.DeleteGroup``: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}
}

Path Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
groupId GroupId The identifier of the group.

Other Parameters

Other parameters are passed through a pointer to a apiDeleteGroupRequest struct via the builder pattern

Name Type Description Notes

Return type

(empty response body)

HTTP request headers

  • Content-Type: Not defined
  • Accept: Not defined

[Back to top] [Back to API list] [Back to Model list] [Back to README]

GetGroup

Group GetGroup(ctx, groupId).Execute()

Retrieve group

Example

package main

import (
	"context"
	"fmt"
	"os"
	authress "github.com/authress/authress-sdk.go"
)

func main() {
	groupId := TODO // GroupId | The identifier of the group.

	url, _ := url.Parse("https://authress.company.com")
	authressClient := authress.NewAuthressClient(authress.AuthressSettings{
		AuthressApiUrl: url,
	})
	resp, r, err := apiClient.Groups.GetGroup(context.Background(), groupId).Execute()
	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `Groups.GetGroup``: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}
	// response from `GetGroup`: Group
	fmt.Fprintf(os.Stdout, "Response from `Groups.GetGroup`: %v\n", resp)
}

Path Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
groupId GroupId The identifier of the group.

Other Parameters

Other parameters are passed through a pointer to a apiGetGroupRequest struct via the builder pattern

Name Type Description Notes

Return type

Group

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/links+json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

GetGroups

GroupCollection GetGroups(ctx).Limit(limit).Cursor(cursor).Filter(filter).Execute()

List groups

Example

package main

import (
	"context"
	"fmt"
	"os"
	authress "github.com/authress/authress-sdk.go"
)

func main() {
	limit := int32(56) // int32 | Max number of results to return (optional) (default to 20)
	cursor := "cursor_example" // string | Continuation cursor for paging (optional)
	filter := "filter_example" // string | Filter to search groups by. This is a case insensitive search through every text field. (optional)

	url, _ := url.Parse("https://authress.company.com")
	authressClient := authress.NewAuthressClient(authress.AuthressSettings{
		AuthressApiUrl: url,
	})
	resp, r, err := apiClient.Groups.GetGroups(context.Background()).Limit(limit).Cursor(cursor).Filter(filter).Execute()
	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `Groups.GetGroups``: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}
	// response from `GetGroups`: GroupCollection
	fmt.Fprintf(os.Stdout, "Response from `Groups.GetGroups`: %v\n", resp)
}

Path Parameters

Other Parameters

Other parameters are passed through a pointer to a apiGetGroupsRequest struct via the builder pattern

Name Type Description Notes
limit int32 Max number of results to return [default to 20]
cursor string Continuation cursor for paging
filter string Filter to search groups by. This is a case insensitive search through every text field.

Return type

GroupCollection

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/links+json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

UpdateGroup

Group UpdateGroup(ctx, groupId).Group(group).IfUnmodifiedSince(ifUnmodifiedSince).Execute()

Update a group

Example

package main

import (
	"context"
	"fmt"
	"os"
    "time"
	authress "github.com/authress/authress-sdk.go"
)

func main() {
	groupId := TODO // GroupId | The identifier of the group.
	group := *authress.NewGroup("Name_example", []authress.User{*authress.NewUser("oauth|userId")}, []authress.User{*authress.NewUser("oauth|userId")}) // Group | 
	ifUnmodifiedSince := time.Now() // time.Time | The expected last time the group was modified. (optional)

	url, _ := url.Parse("https://authress.company.com")
	authressClient := authress.NewAuthressClient(authress.AuthressSettings{
		AuthressApiUrl: url,
	})
	resp, r, err := apiClient.Groups.UpdateGroup(context.Background(), groupId).Group(group).IfUnmodifiedSince(ifUnmodifiedSince).Execute()
	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `Groups.UpdateGroup``: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}
	// response from `UpdateGroup`: Group
	fmt.Fprintf(os.Stdout, "Response from `Groups.UpdateGroup`: %v\n", resp)
}

Path Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
groupId GroupId The identifier of the group.

Other Parameters

Other parameters are passed through a pointer to a apiUpdateGroupRequest struct via the builder pattern

Name Type Description Notes

group | Group | | ifUnmodifiedSince | time.Time | The expected last time the group was modified. |

Return type

Group

HTTP request headers

  • Content-Type: application/json
  • Accept: application/links+json

[Back to top] [Back to API list] [Back to Model list] [Back to README]