Slide 28
Slide 28 text
実装例
// Databricks クライアント(SDK不要、標準HTTPで十分)
type DatabricksClient struct {
httpClient *http.Client
token string
accountURL string // https://accounts.cloud.databricks.com
}
// ユーザー作成(POST /scim/v2/Users)
func (c *DatabricksClient) CreateUser(user *DatabricksUser) error {
body, _ := json.Marshal(user)
req, _ := http.NewRequest("POST", c.accountURL+"/scim/v2/Users", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+c.token)
req.Header.Set("Content-Type", "application/scim+json")
return c.httpClient.Do(req)
}
// グループへメンバー追加(PATCH /scim/v2/Groups/{id})
func (c *DatabricksClient) AddMemberToGroup(groupID, userID string) error {
patch := map[string]interface{}{
"schemas": []string{"urn:ietf:params:scim:api:messages:2.0:PatchOp"},
"Operations": []map[string]interface{}{{
"op": "add",
"path": "members",
"value": []map[string]string{{"value": userID}},
}},
}
body, _ := json.Marshal(patch)
req, _ := http.NewRequest("PATCH", c.accountURL+"/scim/v2/Groups/"+groupID, bytes.NewReader(body))
// ...
}
28