Documentation ¶
Overview ¶
Package scim provides Slack SCIM API client.
Example ¶
package main import ( "context" "fmt" "log" "gopkg.in/h2non/gock.v1" "github.com/suzuki-shunsuke/go-slack-scimapi/scim" ) const ( token = "Slack Token" ) func main() { // use mock for example defer gock.Off() gock.New("https://api.slack.com"). Get("/scim/v1/Users"). MatchType("json").Reply(200). BodyString(`{"totalResults": 1, "Resources": [{"userName": "other_username"}]}`) client := scim.NewClient(token) ctx := context.Background() users, resp, err := client.GetUsers(ctx, nil, "") if err != nil { log.Fatal(err) } fmt.Printf("%d %d\n", resp.StatusCode, len(users.Resources)) }
Output: 200 1
Index ¶
- Variables
- func IsErrorDefault(resp *http.Response) bool
- func ParseErrorRespDefault(resp *http.Response) error
- func ParseRespDefault(resp *http.Response, output interface{}) error
- type Address
- type Attribute
- type AuthenticationScheme
- type BulkConfig
- type ChangePasswordConfig
- type Client
- func (c *Client) CreateGroup(ctx context.Context, group *Group) (*Group, *http.Response, error)
- func (c *Client) CreateGroupResp(ctx context.Context, group *Group) (*http.Response, error)
- func (c *Client) CreateUser(ctx context.Context, user *User) (*User, *http.Response, error)
- func (c *Client) CreateUserResp(ctx context.Context, user *User) (*http.Response, error)
- func (c *Client) DeleteGroup(ctx context.Context, id string) (*http.Response, error)
- func (c *Client) DeleteGroupResp(ctx context.Context, id string) (*http.Response, error)
- func (c *Client) DeleteUser(ctx context.Context, id string) (*http.Response, error)
- func (c *Client) DeleteUserResp(ctx context.Context, id string) (*http.Response, error)
- func (c *Client) GetGroup(ctx context.Context, id string) (*Group, *http.Response, error)
- func (c *Client) GetGroupResp(ctx context.Context, id string) (*http.Response, error)
- func (c *Client) GetGroupSchema(ctx context.Context) (*Schema, *http.Response, error)
- func (c *Client) GetGroupSchemaResp(ctx context.Context) (*http.Response, error)
- func (c *Client) GetGroups(ctx context.Context, page *Pagination, filter string) (*Groups, *http.Response, error)
- func (c *Client) GetGroupsResp(ctx context.Context, page *Pagination, filter string) (*http.Response, error)
- func (c *Client) GetServiceProviderConfig(ctx context.Context) (*ServiceProviderConfig, *http.Response, error)
- func (c *Client) GetServiceProviderConfigResp(ctx context.Context) (*http.Response, error)
- func (c *Client) GetUser(ctx context.Context, id string) (*User, *http.Response, error)
- func (c *Client) GetUserResp(ctx context.Context, id string) (*http.Response, error)
- func (c *Client) GetUserSchema(ctx context.Context) (*Schema, *http.Response, error)
- func (c *Client) GetUserSchemaResp(ctx context.Context) (*http.Response, error)
- func (c *Client) GetUsers(ctx context.Context, page *Pagination, filter string) (*Users, *http.Response, error)
- func (c *Client) GetUsersResp(ctx context.Context, page *Pagination, filter string) (*http.Response, error)
- func (c *Client) PatchGroup(ctx context.Context, id string, group *Group) (*http.Response, error)
- func (c *Client) PatchGroupResp(ctx context.Context, id string, group *Group) (*http.Response, error)
- func (c *Client) PatchUser(ctx context.Context, id string, user *UserPatch) (*User, *http.Response, error)
- func (c *Client) PatchUserResp(ctx context.Context, id string, user *UserPatch) (*http.Response, error)
- func (c *Client) PutGroup(ctx context.Context, id string, group *Group) (*Group, *http.Response, error)
- func (c *Client) PutGroupResp(ctx context.Context, id string, group *Group) (*http.Response, error)
- func (c *Client) PutUser(ctx context.Context, id string, user *User) (*User, *http.Response, error)
- func (c *Client) PutUserResp(ctx context.Context, id string, user *User) (*http.Response, error)
- func (c *Client) SetEndpoint(endpoint string)
- func (c *Client) SetHTTPClient(client *http.Client)
- func (c *Client) SetIsError(fn IsError)
- func (c *Client) SetParseErrorResp(fn ParseErrorResp)
- func (c *Client) SetParseResp(fn ParseResp)
- func (c *Client) WithEndpoint(endpoint string) *Client
- func (c *Client) WithHTTPClient(client *http.Client) *Client
- func (c *Client) WithIsError(fn IsError) *Client
- func (c *Client) WithParseErrorResp(fn ParseErrorResp) *Client
- func (c *Client) WithParseResp(fn ParseResp) *Client
- type Email
- type EnterpriseUserSchemaExtension
- type EnterpriseUserSchemaExtensionPatch
- type Error
- type EtagConfig
- type FilterConfig
- type Group
- type Groups
- type IsError
- type Manager
- type Member
- type Meta
- type Name
- type NamePatch
- type Pagination
- type ParseErrorResp
- type ParseResp
- type PatchConfig
- type PhoneNumber
- type Photo
- type Role
- type Schema
- type ServiceProviderConfig
- type SortConfig
- type User
- type UserPatch
- type Users
- type XMLDataFormatConfig
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var (
// DefaultEndpoint is the default Slack SCIM API endpoint.
DefaultEndpoint = "https://api.slack.com/scim/v1"
)
Functions ¶
func IsErrorDefault ¶
IsErrorDefault is a default function for client to judge the request is successful or not by the response.
func ParseErrorRespDefault ¶
ParseErrorRespDefault is the default function for client to process the failed request's response.
func ParseRespDefault ¶
ParseRespDefault is the default function for client to process the succeeded request's response.
Types ¶
type Address ¶
type Address struct { StreetAddress string `json:"streetAddress,omitempty"` Locality string `json:"locality,omitempty"` Region string `json:"region,omitempty"` PostalCode string `json:"postalCode,omitempty"` Country string `json:"country,omitempty"` Primary bool `json:"primary,omitempty"` }
Address is a physical mailing address for a user.
type Attribute ¶
type Attribute struct { MultiValued bool `json:"multiValued"` ReadOnly bool `json:"readOnly"` Required bool `json:"required"` CaseExact bool `json:"caseExact"` Name string `json:"name"` Type string `json:"type"` Description string `json:"description"` Schema string `json:"schema"` MultiValuedAttributeChildName string `json:"multiValuedAttributeChildName,omitempty"` SubAttributes []Attribute `json:"subAttributes,omitempty"` CanonicalValues []string `json:"canonicalValues,omitempty"` }
Attribute specifies the set of Resource attributes.
func (*Attribute) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler .
type AuthenticationScheme ¶
type AuthenticationScheme struct { Primary bool `json:"primary"` Type string `json:"type"` Name string `json:"name"` Description string `json:"description"` SpecURL string `json:"specUrl"` }
AuthenticationScheme specifies supported Authentication Scheme properties. http://www.simplecloud.info/specs/draft-scim-core-schema-01.html#rfc.section.9
type BulkConfig ¶
type BulkConfig struct { Supported bool `json:"supported"` MaxOperations int `json:"maxOperations"` MaxPlayloadSize int `json:"maxPlayloadSize"` }
BulkConfig specifies BULK configuration options. http://www.simplecloud.info/specs/draft-scim-core-schema-01.html#rfc.section.9
type ChangePasswordConfig ¶
type ChangePasswordConfig struct {
Supported bool `json:"supported"`
}
ChangePasswordConfig specifies Change Password configuration options. http://www.simplecloud.info/specs/draft-scim-core-schema-01.html#rfc.section.9
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a Slack SCIM API client. Client should be created by the function NewClient .
func (*Client) CreateGroup ¶
CreateGroup calls POST /Groups API and returns a created group. The returned response body is closed.
func (*Client) CreateGroupResp ¶
CreateGroupResp calls POST /Groups API and returns a HTTP response. If the returned error is nil, the returned response isn't nil and you have to close the response body. Internally, this method returns the returned values of *http.Client.Do .
func (*Client) CreateUser ¶
CreateUser calls POST /Users API and returns a created user. The returned response body is closed.
func (*Client) CreateUserResp ¶
CreateUserResp calls POST /Users API and returns a HTTP response. If the returned error is nil, the returned response isn't nil and you have to close the response body. Internally, this method returns the returned values of *http.Client.Do .
func (*Client) DeleteGroup ¶
DeleteGroup calls DELETE /Groups/{id} API. The returned response body is closed.
func (*Client) DeleteGroupResp ¶
DeleteGroupResp calls DELETE /Groups/{id} API and returns a HTTP response. If the returned error is nil, the returned response isn't nil and you have to close the response body. Internally, this method returns the returned values of *http.Client.Do .
func (*Client) DeleteUser ¶
DeleteUser calls DELETE /Users/{id} API. The returned response body is closed.
func (*Client) DeleteUserResp ¶
DeleteUserResp calls DELETE /Users/{id} API and returns a HTTP response. If the returned error is nil, the returned response isn't nil and you have to close the response body. Internally, this method returns the returned values of *http.Client.Do .
func (*Client) GetGroup ¶
GetGroup calls GET /Groups/{id} API and returns a group. The returned response body is closed.
func (*Client) GetGroupResp ¶
GetGroupResp calls GET /Groups/{id} API and returns a HTTP response. If the returned error is nil, the returned response isn't nil and you have to close the response body. Internally, this method returns the returned values of *http.Client.Do .
func (*Client) GetGroupSchema ¶
GetGroupSchema calls GET /Schemas/Groups API and returns a group schema. The returned response body is closed.
func (*Client) GetGroupSchemaResp ¶
GetGroupSchemaResp calls GET /Schemas/Groups API and returns a HTTP response. If the returned error is nil, the returned response isn't nil and you have to close the response body. Internally, this method returns the returned values of *http.Client.Do .
func (*Client) GetGroups ¶
func (c *Client) GetGroups( ctx context.Context, page *Pagination, filter string, ) (*Groups, *http.Response, error)
GetGroups calls GET /Groups API and returns groups. The returned response body is closed.
func (*Client) GetGroupsResp ¶
func (c *Client) GetGroupsResp(ctx context.Context, page *Pagination, filter string) (*http.Response, error)
GetGroupsResp calls GET /Groups API and returns a HTTP response. If the returned error is nil, the returned response isn't nil and you have to close the response body. Internally, this method returns the returned values of *http.Client.Do .
func (*Client) GetServiceProviderConfig ¶
func (c *Client) GetServiceProviderConfig(ctx context.Context) (*ServiceProviderConfig, *http.Response, error)
GetServiceProviderConfig calls GET /ServiceProviderConfigs API and returns service provider configuration. The returned response body is closed.
func (*Client) GetServiceProviderConfigResp ¶
GetServiceProviderConfigResp calls GET /ServiceProviderConfigs API and returns a HTTP response. Internally, this method returns the returned values of *http.Client.Do .
func (*Client) GetUser ¶
GetUser calls GET /Users/{id} API and returns a user. The returned response body is closed.
func (*Client) GetUserResp ¶
GetUserResp calls GET /Users/{id} API and returns a HTTP response. If the returned error is nil, the returned response isn't nil and you have to close the response body. Internally, this method returns the returned values of *http.Client.Do .
func (*Client) GetUserSchema ¶
GetUserSchema calls GET /Schemas/Users API and returns a user schema. The returned response body is closed.
func (*Client) GetUserSchemaResp ¶
GetUserSchemaResp calls GET /Schemas/Users API and returns a HTTP response. If the returned error is nil, the returned response isn't nil and you have to close the response body. Internally, this method returns the returned values of *http.Client.Do .
func (*Client) GetUsers ¶
func (c *Client) GetUsers( ctx context.Context, page *Pagination, filter string, ) (*Users, *http.Response, error)
GetUsers calls GET /Users API and returns users. The returned response body is closed.
func (*Client) GetUsersResp ¶
func (c *Client) GetUsersResp(ctx context.Context, page *Pagination, filter string) (*http.Response, error)
GetUsersResp calls GET /Users API and returns a HTTP response. If the returned error is nil, the returned response isn't nil and you have to close the response body. Internally, this method returns the returned values of *http.Client.Do .
func (*Client) PatchGroup ¶
PatchGroup calls PATCH /Groups/{id} API. The returned response body is closed.
func (*Client) PatchGroupResp ¶
func (c *Client) PatchGroupResp(ctx context.Context, id string, group *Group) (*http.Response, error)
PatchGroupResp calls PATCH /Groups/{id} API and returns a HTTP response. If the returned error is nil, the returned response isn't nil and you have to close the response body. Internally, this method returns the returned values of *http.Client.Do .
func (*Client) PatchUser ¶
func (c *Client) PatchUser(ctx context.Context, id string, user *UserPatch) (*User, *http.Response, error)
PatchUser calls PATCH /Users/{id} API and returns a updated user. The returned response body is closed.
func (*Client) PatchUserResp ¶
func (c *Client) PatchUserResp(ctx context.Context, id string, user *UserPatch) (*http.Response, error)
PatchUserResp calls PATCH /Users/{id} API and returns a HTTP response. If the returned error is nil, the returned response isn't nil and you have to close the response body. Internally, this method returns the returned values of *http.Client.Do .
func (*Client) PutGroup ¶
func (c *Client) PutGroup(ctx context.Context, id string, group *Group) (*Group, *http.Response, error)
PutGroup calls PUT /Groups/{id} API and returns a updated group. The returned response body is closed.
func (*Client) PutGroupResp ¶
PutGroupResp calls PUT /Groups/{id} API and returns a HTTP response. If the returned error is nil, the returned response isn't nil and you have to close the response body. Internally, this method returns the returned values of *http.Client.Do .
func (*Client) PutUser ¶
PutUser calls PUT /Users/{id} API and returns a updated user. The returned response body is closed.
func (*Client) PutUserResp ¶
PutUserResp calls PUT /Users/{id} API and returns a HTTP response. If the returned error is nil, the returned response isn't nil and you have to close the response body. Internally, this method returns the returned values of *http.Client.Do .
func (*Client) SetEndpoint ¶
SetEndpoint sets fn to c. If endpoint is empty, DefaultEndpoint is used.
func (*Client) SetHTTPClient ¶ added in v0.2.0
SetHTTPClient sets the *http.Client to c. If client is nil, http.DefaultClient is set.
func (*Client) SetIsError ¶
SetIsError sets fn to c. If fn is nil, IsErrorDefault is used.
func (*Client) SetParseErrorResp ¶
func (c *Client) SetParseErrorResp(fn ParseErrorResp)
SetParseErrorResp sets fn to c. fn shouldn't close the response body. If fn is nil, ParseErrorRespDefault is used.
func (*Client) SetParseResp ¶
SetParseResp sets fn to c. fn shouldn't close the response body. If fn is nil, ParseRespDefault is used.
func (*Client) WithEndpoint ¶
WithEndpoint returns a shallow copy of c with its endpoint changed to endpoint. If endpoint is empty, DefaultEndpoint is used.
func (*Client) WithHTTPClient ¶ added in v0.2.0
WithHTTPClient returns a shallow copy of c with its httpClient changed to client. If client is nil, http.DefaultClient is used.
func (*Client) WithIsError ¶
WithIsError returns a shallow copy of c with its isError changed to fn. If fn is nil, IsErrorDefault is used.
func (*Client) WithParseErrorResp ¶
func (c *Client) WithParseErrorResp(fn ParseErrorResp) *Client
WithParseErrorResp returns a shallow copy of c with its parseErrorResp changed to fn. fn shouldn't close the response body. If fn is nil, ParseErrorRespDefault is used.
func (*Client) WithParseResp ¶
WithParseResp returns a shallow copy of c with its parseResp changed to fn. fn shouldn't close the response body. If fn is nil, ParseRespDefault is used.
type Email ¶
type Email struct { Value string `json:"value,omitempty"` Type string `json:"type,omitempty"` Primary bool `json:"primary,omitempty"` }
Email is an email address for a user.
type EnterpriseUserSchemaExtension ¶
type EnterpriseUserSchemaExtension struct { EmployeeNumber string `json:"employeeNumber,omitempty"` CostCenter string `json:"costCenter,omitempty"` Organization string `json:"organization,omitempty"` Division string `json:"division,omitempty"` Department string `json:"department,omitempty"` Manager *Manager `json:"manager,omitempty"` }
EnterpriseUserSchemaExtension is SCIM Enterprise User Schema Extension.
type EnterpriseUserSchemaExtensionPatch ¶
type EnterpriseUserSchemaExtensionPatch struct { EmployeeNumber *string `json:"employeeNumber,omitempty"` CostCenter *string `json:"costCenter,omitempty"` Organization *string `json:"organization,omitempty"` Division *string `json:"division,omitempty"` Department *string `json:"department,omitempty"` Manager *Manager `json:"manager,omitempty"` }
EnterpriseUserSchemaExtensionPatch is a SCIM Enterprise User Schema Extension for PATH user API's request.
type Error ¶
Error is Slack SCIM API's error response body. https://api.slack.com/scim#errors
type EtagConfig ¶
type EtagConfig struct {
Supported bool `json:"supported"`
}
EtagConfig specifies Etag configuration options. http://www.simplecloud.info/specs/draft-scim-core-schema-01.html#rfc.section.9
type FilterConfig ¶
FilterConfig specifies FILTER options. http://www.simplecloud.info/specs/draft-scim-core-schema-01.html#rfc.section.9
type Group ¶
type Group struct { ID string `json:"id"` DisplayName string `json:"displayName"` Members []Member `json:"members"` Schemas []string `json:"schemas"` Meta *Meta `json:"meta"` }
Group is a group. https://api.slack.com/scim#groups
type Groups ¶
type Groups struct { TotalResults int `json:"totalResults"` ItemPerPage int `json:"itemPerPage"` StartIndex int `json:"startIndex"` Schemas []string `json:"schemas"` Resources []Group }
Groups is a response body of GET groups API.
type Manager ¶
type Manager struct { ManagerID string `json:"managerId,omitempty"` DisplayName string `json:"displayName,omitempty"` }
Manager is a user's manager.
type Meta ¶
type Meta struct { Created string `json:"created"` LastModified string `json:"lastModified"` Location string `json:"location"` Version string `json:"version"` Attributes []string `json:"attributes"` }
Meta is containing resource metadata.
type Name ¶
type Name struct { FamilyName string `json:"familyName,omitempty"` GivenName string `json:"givenName,omitempty"` HonorificPrefix string `json:"honorificPrefix,omitempty"` }
Name is a component of a user's real name.
type NamePatch ¶
type NamePatch struct { FamilyName *string `json:"familyName,omitempty"` GivenName *string `json:"givenName,omitempty"` HonorificPrefix *string `json:"honorificPrefix,omitempty"` }
NamePatch is a user name patch for PATCH user API's request.
type Pagination ¶
Pagination is a pagination parameter.
type ParseErrorResp ¶
ParseErrorResp parses an API error response.
type PatchConfig ¶
type PatchConfig struct {
Supported bool `json:"supported"`
}
PatchConfig specifies PATCH configuration options. http://www.simplecloud.info/specs/draft-scim-core-schema-01.html#rfc.section.9
type PhoneNumber ¶
type PhoneNumber struct { Value string `json:"value,omitempty"` Type string `json:"type,omitempty"` Primary bool `json:"primary,omitempty"` }
PhoneNumber is a phone number for a user.
type Photo ¶
type Photo struct { Value string `json:"value,omitempty"` Type string `json:"type,omitempty"` Primary bool `json:"primary,omitempty"` }
Photo is a URL of a photo of a User.
type Role ¶
type Role struct { Value string `json:"value,omitempty"` Type string `json:"type,omitempty"` Primary bool `json:"primary,omitempty"` }
Role is a role for a user that collectively represent who the user is; e.g., 'Student', "Faculty".
type Schema ¶
type Schema struct { ID string `json:"id"` Name string `json:"name"` Description string `json:"description"` Schema []string `json:"schema"` Endpoint string `json:"endpoint"` Attributes []Attribute `json:"attributes"` }
Schema is a schema. Slack currently supports schemas for users and groups.
func (*Schema) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler .
type ServiceProviderConfig ¶
type ServiceProviderConfig struct { AuthenticationSchemes []AuthenticationScheme `json:"authenticationSchemes"` Patch *PatchConfig `json:"patch"` Bulk *BulkConfig `json:"bulk"` Filter *FilterConfig `json:"filter"` ChangePassword *ChangePasswordConfig `json:"changePassword"` Sort *SortConfig `json:"sort"` Etag *EtagConfig `json:"etag"` XMLDataFormat *XMLDataFormatConfig `json:"xmlDataFormat"` }
ServiceProviderConfig is Slack's configuration details for our SCIM API, including which operations are supported. https://api.slack.com/scim#service_provider_configuration http://www.simplecloud.info/specs/draft-scim-core-schema-01.html#rfc.section.9
type SortConfig ¶
type SortConfig struct {
Supported bool `json:"supported"`
}
SortConfig specifies Sort configuration options. http://www.simplecloud.info/specs/draft-scim-core-schema-01.html#rfc.section.9
type User ¶
type User struct { Active bool `json:"active,omitempty"` ID string `json:"id,omitempty"` ExternalID string `json:"externalId,omitempty"` UserName string `json:"userName,omitempty"` NickName string `json:"nickName,omitempty"` ProfileURL string `json:"profileUrl,omitempty"` DisplayName string `json:"displayName,omitempty"` UserType string `json:"userType,omitempty"` Title string `json:"title,omitempty"` PreferredLanguage string `json:"preferredLanguage,omitempty"` Locale string `json:"locale,omitempty"` Timezone string `json:"timezone,omitempty"` Password string `json:"password,omitempty"` Name *Name `json:"name,omitempty"` Meta *Meta `json:"meta,omitempty"` Emails []Email `json:"emails,omitempty"` Addresses []Address `json:"addresses,omitempty"` PhoneNumbers []PhoneNumber `json:"phoneNumbers,omitempty"` Roles []Role `json:"roles,omitempty"` Photos []Photo `json:"photos,omitempty"` Groups []Group `json:"groups,omitempty"` Schemas []string `json:"schemas"` EnterpriseUserSchemaExtension *EnterpriseUserSchemaExtension `json:"urn:scim:schemas:extension:enterprise:1.0,omitempty"` }
User is a user. https://api.slack.com/scim#users
func (*User) MarshalJSON ¶
MarshalJSON implements json.Marshaler .
func (*User) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler .
type UserPatch ¶
type UserPatch struct { ID string `json:"id,omitempty"` UserName string `json:"userName,omitempty"` Active *bool `json:"active,omitempty"` ExternalID *string `json:"externalId,omitempty"` NickName *string `json:"nickName,omitempty"` ProfileURL *string `json:"profileUrl,omitempty"` DisplayName *string `json:"displayName,omitempty"` UserType *string `json:"userType,omitempty"` Title *string `json:"title,omitempty"` PreferredLanguage *string `json:"preferredLanguage,omitempty"` Locale *string `json:"locale,omitempty"` Timezone *string `json:"timezone,omitempty"` Password *string `json:"password,omitempty"` Name *NamePatch `json:"name,omitempty"` Meta *Meta `json:"meta,omitempty"` Emails []Email `json:"emails,omitempty"` Addresses *[]Address `json:"addresses,omitempty"` PhoneNumbers *[]PhoneNumber `json:"phoneNumbers,omitempty"` Roles *[]Role `json:"roles,omitempty"` Photos *[]Photo `json:"photos,omitempty"` Groups *[]Group `json:"groups,omitempty"` Schemas []string `json:"schemas"` EnterpriseUserSchemaExtension *EnterpriseUserSchemaExtensionPatch `json:"urn:scim:schemas:extension:enterprise:1.0,omitempty"` }
UserPatch is a user patch for PATCH user API's request.
type Users ¶
type Users struct { TotalResults int `json:"totalResults"` ItemPerPage int `json:"itemPerPage"` StartIndex int `json:"startIndex"` Schemas []string `json:"schemas"` Resources []User }
Users is a response body of GET users API .
type XMLDataFormatConfig ¶
type XMLDataFormatConfig struct {
Supported bool `json:"supported"`
}
XMLDataFormatConfig specifies whether the XML data format is supported. http://www.simplecloud.info/specs/draft-scim-core-schema-01.html#rfc.section.9