Sha256: ff5f6a38a494a6bf27f2bd329d7668616448d5d0d34d4c49db408ca2b37c8a05

Contents?: true

Size: 889 Bytes

Versions: 2

Compression:

Stored size: 889 Bytes

Contents

# frozen_string_literal: true

$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
require "awesome_print"
require "archivesspace/client"

# official sandbox
config = ArchivesSpace::Configuration.new(
  {
    base_uri: "https://sandbox.archivesspace.org/api",
    base_repo: "",
    username: "admin",
    password: "admin",
    page_size: 50,
    throttle: 0,
    verify_ssl: false
  }
)

client = ArchivesSpace::Client.new(config).login

user_data = {
  username: "bde",
  name: "BDE",
  is_admin: false
}

client.post(
  "users",
  ArchivesSpace::Template.process("user.json.erb", user_data),
  {password: "123456"}
)

users_with_roles = {
  "bde" => ["repository-basic-data-entry"]
}

begin
  client.config.base_repo = "repositories/2"
  results = client.group_user_assignment users_with_roles
  ap results.map(&:parsed)
rescue ArchivesSpace::RequestError => e
  puts e.message
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
archivesspace-client-0.4.1 examples/user_groups.rb
archivesspace-client-0.4.0 examples/user_groups.rb