Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/suzuki-shunsuke/go-slack-scimapi
Slack SCIM API client for Golang
https://github.com/suzuki-shunsuke/go-slack-scimapi
api-client golang library oss slack
Last synced: 3 months ago
JSON representation
Slack SCIM API client for Golang
- Host: GitHub
- URL: https://github.com/suzuki-shunsuke/go-slack-scimapi
- Owner: suzuki-shunsuke
- License: mit
- Created: 2019-05-14T08:34:45.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-11-20T19:35:58.000Z (about 2 years ago)
- Last Synced: 2024-06-20T12:57:23.722Z (7 months ago)
- Topics: api-client, golang, library, oss, slack
- Language: Go
- Homepage: https://godoc.org/github.com/suzuki-shunsuke/go-slack-scimapi/scim
- Size: 171 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 27
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-slack-scimapi
[![GoDoc](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)](http://godoc.org/github.com/suzuki-shunsuke/go-slack-scimapi/scim)
[![Build Status](https://cloud.drone.io/api/badges/suzuki-shunsuke/go-slack-scimapi/status.svg)](https://cloud.drone.io/suzuki-shunsuke/go-slack-scimapi)
[![codecov](https://codecov.io/gh/suzuki-shunsuke/go-slack-scimapi/branch/master/graph/badge.svg)](https://codecov.io/gh/suzuki-shunsuke/go-slack-scimapi)
[![Go Report Card](https://goreportcard.com/badge/github.com/suzuki-shunsuke/go-slack-scimapi)](https://goreportcard.com/report/github.com/suzuki-shunsuke/go-slack-scimapi)
[![GitHub last commit](https://img.shields.io/github/last-commit/suzuki-shunsuke/go-slack-scimapi.svg)](https://github.com/suzuki-shunsuke/go-slack-scimapi)
[![GitHub tag](https://img.shields.io/github/tag/suzuki-shunsuke/go-slack-scimapi.svg)](https://github.com/suzuki-shunsuke/go-slack-scimapi/releases)
[![License](http://img.shields.io/badge/license-mit-blue.svg?style=flat-square)](https://raw.githubusercontent.com/suzuki-shunsuke/go-slack-scimapi/master/LICENSE)Slack SCIM API client for Golang
https://api.slack.com/scim
## How to use
### Create a client
```go
client := scim.NewClient("Slack API Token")
```### Get users
Note that returned *http.Response.Body is closed.
```go
ctx := context.Background()
users, resp, err := client.GetUsers(ctx, nil, "")
```#### Pagination
```go
users, resp, err := client.GetUsers(ctx, &scim.Pagination{
Count: 5000,
StartInex: 1,
}, "")
```#### Filter
```go
users, resp, err := client.GetUsers(ctx, nil, `email eq "[email protected]"`)
```### Customize response handling
You can customize client's behavior with methods `Client.WithXXX` and `Client.SetXXX` .
`Client.SetXXX` changes the receiver itself.
On the other hand, `Client.WithXXX` changes a shallow copy of client and returns it.
`Client.WithXXX` is useful for the method chain.```go
client.SetParseResp(func(resp *http.Response, output interface{}) error {
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
return err
}
fmt.Println(string(b))
return json.Unmarshal(b, output)
})
``````go
users, resp, err := client.WithParseErrorResp(func(resp *http.Response) error {
fmt.Println("customize")
return ParseErrorRespDefault(resp)
}).GetUsers(ctx, nil, "")
```### client.XXXResp
`Client.GetUsers` parses response body and returns users.
On the other hand, `Client.GetUsersResp` doesn't parse response body.
Returned response body is open.```go
resp, err := client.GetUsersResp(ctx, nil, "")
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
b, err := ioutil.ReadAll(resp.Body)
``````go
resp, err := client.CreateUser(ctx, &scim.User{
UserName: "foo",
Emails: []scim.Email{
Value: "[email protected]",
},
})
```## License
[MIT](LICENSE)