atlas_rb 0.0.88 → 0.0.91
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.version +1 -1
- data/Gemfile.lock +2 -2
- data/lib/atlas_rb/collection.rb +35 -0
- data/lib/atlas_rb/community.rb +35 -0
- data/lib/atlas_rb/faraday_helper.rb +13 -9
- data/lib/atlas_rb/user.rb +44 -0
- data/lib/atlas_rb/work.rb +35 -0
- data/lib/atlas_rb.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: aa8cb5bbcea60e8d4d85a3a8f3f71ec7e798a811221a53292f9481ab844f6047
|
|
4
|
+
data.tar.gz: 9d72d547fe715ba4c9cf168652b61606b3354ab1a7d929e221d9d7691be01db9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 951c36792f8fa9c3f767da1bea737df2165211402ca8c22577925c96c0af81bdaa24cdf77343d6d515625627550a5cebb4e02267e59e0e54ce2cb391e9000e52
|
|
7
|
+
data.tar.gz: 19e89a98c99c0819bcd3558ef27131c75a2510c57f318c9fe596a82b18abe866f24b1b69610a417f7d47b456de4dd275c88338bbacd43be8d3114e8993237582
|
data/.version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.0.
|
|
1
|
+
0.0.91
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
atlas_rb (0.0.
|
|
4
|
+
atlas_rb (0.0.91)
|
|
5
5
|
faraday (~> 2.7)
|
|
6
6
|
faraday-follow_redirects (~> 0.3.0)
|
|
7
7
|
faraday-multipart (~> 1)
|
|
@@ -23,7 +23,7 @@ GEM
|
|
|
23
23
|
net-http (~> 0.5)
|
|
24
24
|
hashie (5.1.0)
|
|
25
25
|
logger
|
|
26
|
-
json (2.19.
|
|
26
|
+
json (2.19.5)
|
|
27
27
|
logger (1.7.0)
|
|
28
28
|
multipart-post (2.4.1)
|
|
29
29
|
net-http (0.9.1)
|
data/lib/atlas_rb/collection.rb
CHANGED
|
@@ -60,6 +60,41 @@ module AtlasRb
|
|
|
60
60
|
connection({}).delete(ROUTE + id)
|
|
61
61
|
end
|
|
62
62
|
|
|
63
|
+
# Tombstone (withdraw) a Collection.
|
|
64
|
+
#
|
|
65
|
+
# The Collection remains in Atlas storage but is marked as withdrawn:
|
|
66
|
+
# search and show pages return a withdrawn stub for every user. Atlas
|
|
67
|
+
# rejects the request with `422 has_live_children` if the Collection
|
|
68
|
+
# still has live (non-tombstoned) Works.
|
|
69
|
+
#
|
|
70
|
+
# @param id [String] the Collection ID.
|
|
71
|
+
# @param nuid [String] the acting user's NUID, stamped on the resource
|
|
72
|
+
# as `tombstoned_by` for audit purposes.
|
|
73
|
+
# @return [Faraday::Response] the raw response. `200`/`204` on success;
|
|
74
|
+
# `422` with `{"code":"has_live_children"}` if the Collection is not empty.
|
|
75
|
+
#
|
|
76
|
+
# @example
|
|
77
|
+
# AtlasRb::Collection.tombstone("col-456", nuid: "000000002")
|
|
78
|
+
def self.tombstone(id, nuid:)
|
|
79
|
+
connection({}, nuid).post(ROUTE + id + '/tombstone')
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Restore a previously tombstoned Collection.
|
|
83
|
+
#
|
|
84
|
+
# **Operator-only.** Restoration is intentionally not exposed in any
|
|
85
|
+
# end-user UI; call this from a Rails console session (or a future
|
|
86
|
+
# admin panel) when the library has decided an object should come back.
|
|
87
|
+
#
|
|
88
|
+
# @param id [String] the Collection ID.
|
|
89
|
+
# @param nuid [String] the acting user's NUID.
|
|
90
|
+
# @return [Faraday::Response] the raw response.
|
|
91
|
+
#
|
|
92
|
+
# @example Operator restoring from `bundle exec rails console`
|
|
93
|
+
# AtlasRb::Collection.restore("col-456", nuid: "000000002")
|
|
94
|
+
def self.restore(id, nuid:)
|
|
95
|
+
connection({}, nuid).post(ROUTE + id + '/restore')
|
|
96
|
+
end
|
|
97
|
+
|
|
63
98
|
# List the Works in a Collection.
|
|
64
99
|
#
|
|
65
100
|
# The endpoint returns just the noids; resolve each through
|
data/lib/atlas_rb/community.rb
CHANGED
|
@@ -64,6 +64,41 @@ module AtlasRb
|
|
|
64
64
|
connection({}).delete(ROUTE + id)
|
|
65
65
|
end
|
|
66
66
|
|
|
67
|
+
# Tombstone (withdraw) a Community.
|
|
68
|
+
#
|
|
69
|
+
# The Community remains in Atlas storage but is marked as withdrawn:
|
|
70
|
+
# search and show pages return a withdrawn stub for every user. Atlas
|
|
71
|
+
# rejects the request with `422 has_live_children` if the Community
|
|
72
|
+
# still has live (non-tombstoned) members.
|
|
73
|
+
#
|
|
74
|
+
# @param id [String] the Community ID.
|
|
75
|
+
# @param nuid [String] the acting user's NUID, stamped on the resource
|
|
76
|
+
# as `tombstoned_by` for audit purposes.
|
|
77
|
+
# @return [Faraday::Response] the raw response. `200`/`204` on success;
|
|
78
|
+
# `422` with `{"code":"has_live_children"}` if the Community is not empty.
|
|
79
|
+
#
|
|
80
|
+
# @example
|
|
81
|
+
# AtlasRb::Community.tombstone("c-123", nuid: "000000002")
|
|
82
|
+
def self.tombstone(id, nuid:)
|
|
83
|
+
connection({}, nuid).post(ROUTE + id + '/tombstone')
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# Restore a previously tombstoned Community.
|
|
87
|
+
#
|
|
88
|
+
# **Operator-only.** Restoration is intentionally not exposed in any
|
|
89
|
+
# end-user UI; call this from a Rails console session (or a future
|
|
90
|
+
# admin panel) when the library has decided an object should come back.
|
|
91
|
+
#
|
|
92
|
+
# @param id [String] the Community ID.
|
|
93
|
+
# @param nuid [String] the acting user's NUID.
|
|
94
|
+
# @return [Faraday::Response] the raw response.
|
|
95
|
+
#
|
|
96
|
+
# @example Operator restoring from `bundle exec rails console`
|
|
97
|
+
# AtlasRb::Community.restore("c-123", nuid: "000000002")
|
|
98
|
+
def self.restore(id, nuid:)
|
|
99
|
+
connection({}, nuid).post(ROUTE + id + '/restore')
|
|
100
|
+
end
|
|
101
|
+
|
|
67
102
|
# List the immediate children (sub-Communities and Collections) of a Community.
|
|
68
103
|
#
|
|
69
104
|
# The endpoint returns just the noids; resolve each through
|
|
@@ -29,14 +29,16 @@ module AtlasRb
|
|
|
29
29
|
# @example Fetching a community
|
|
30
30
|
# AtlasRb::Community.connection({}).get('/communities/abc123')
|
|
31
31
|
def connection(params, nuid=nil)
|
|
32
|
+
headers = {
|
|
33
|
+
"Content-Type" => "application/json",
|
|
34
|
+
"Authorization" => "Bearer #{ENV.fetch("ATLAS_TOKEN", nil)}"
|
|
35
|
+
}
|
|
36
|
+
headers["User"] = "NUID #{nuid}" if nuid
|
|
37
|
+
|
|
32
38
|
Faraday.new(
|
|
33
39
|
url: ENV.fetch("ATLAS_URL", nil),
|
|
34
40
|
params: params,
|
|
35
|
-
headers:
|
|
36
|
-
"Content-Type" => "application/json",
|
|
37
|
-
"Authorization" => "Bearer #{ENV.fetch("ATLAS_TOKEN", nil)}",
|
|
38
|
-
"User" => "NUID #{nuid}"
|
|
39
|
-
}
|
|
41
|
+
headers: headers
|
|
40
42
|
) do |f|
|
|
41
43
|
f.response :follow_redirects
|
|
42
44
|
f.adapter Faraday.default_adapter
|
|
@@ -62,12 +64,14 @@ module AtlasRb
|
|
|
62
64
|
# }
|
|
63
65
|
# AtlasRb::Blob.multipart({}).post('/files/', payload)
|
|
64
66
|
def multipart(nuid=nil)
|
|
67
|
+
headers = {
|
|
68
|
+
"Authorization" => "Bearer #{ENV.fetch("ATLAS_TOKEN", nil)}"
|
|
69
|
+
}
|
|
70
|
+
headers["User"] = "NUID #{nuid}" if nuid
|
|
71
|
+
|
|
65
72
|
Faraday.new(
|
|
66
73
|
url: ENV.fetch("ATLAS_URL", nil),
|
|
67
|
-
headers:
|
|
68
|
-
"Authorization" => "Bearer #{ENV.fetch("ATLAS_TOKEN", nil)}",
|
|
69
|
-
"User" => "NUID #{nuid}"
|
|
70
|
-
}
|
|
74
|
+
headers: headers
|
|
71
75
|
) do |f|
|
|
72
76
|
f.request :multipart
|
|
73
77
|
f.request :url_encoded
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module AtlasRb
|
|
4
|
+
# System-user binding for Atlas's find-or-create + group-replace endpoint.
|
|
5
|
+
#
|
|
6
|
+
# Used by Cerberus on its SSO callback: given an NUID and the IdP-asserted
|
|
7
|
+
# group set, find-or-create the matching User row and replace its groups
|
|
8
|
+
# with the supplied array (full replace, not merge — the IdP's assertion
|
|
9
|
+
# is authoritative).
|
|
10
|
+
#
|
|
11
|
+
# The endpoint is system-only; {.find_or_create} sends bearer-token auth
|
|
12
|
+
# and no `User:` header. Atlas returns 403 if any `User:` header is
|
|
13
|
+
# present.
|
|
14
|
+
class User
|
|
15
|
+
extend AtlasRb::FaradayHelper
|
|
16
|
+
|
|
17
|
+
# Find-or-create the User keyed on NUID and replace its groups.
|
|
18
|
+
#
|
|
19
|
+
# Idempotent on `nuid`. Authoritative on `groups`.
|
|
20
|
+
#
|
|
21
|
+
# @param nuid [String] the Northeastern University ID.
|
|
22
|
+
# @param groups [Array<String>] full group set; replaces, not merges.
|
|
23
|
+
# @param name [String, nil] forwarded if the caller (e.g. Cerberus's
|
|
24
|
+
# SSO callback) has it; Atlas treats this field as optional.
|
|
25
|
+
# @param email [String, nil] forwarded if available; optional in Atlas.
|
|
26
|
+
# @return [AtlasRb::Mash] the resulting User record (`id`, `nuid`,
|
|
27
|
+
# `name`, `email`, `role`, `groups`).
|
|
28
|
+
#
|
|
29
|
+
# @example From Cerberus's SSO callback
|
|
30
|
+
# AtlasRb::User.find_or_create(nuid: "001234567",
|
|
31
|
+
# groups: ["northeastern:staff",
|
|
32
|
+
# "drs:editors"],
|
|
33
|
+
# name: "Jane Doe",
|
|
34
|
+
# email: "j.doe@example.edu")
|
|
35
|
+
def self.find_or_create(nuid:, groups:, name: nil, email: nil)
|
|
36
|
+
body = { groups: groups }
|
|
37
|
+
body[:name] = name if name
|
|
38
|
+
body[:email] = email if email
|
|
39
|
+
|
|
40
|
+
response = connection({}).put("/users/by_nuid/#{nuid}", body.to_json)
|
|
41
|
+
AtlasRb::Mash.new(JSON.parse(response.body))["user"]
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
data/lib/atlas_rb/work.rb
CHANGED
|
@@ -63,6 +63,41 @@ module AtlasRb
|
|
|
63
63
|
connection({}).delete(ROUTE + id)
|
|
64
64
|
end
|
|
65
65
|
|
|
66
|
+
# Tombstone (withdraw) a Work.
|
|
67
|
+
#
|
|
68
|
+
# The Work remains in Atlas storage along with its FileSets and Blobs,
|
|
69
|
+
# but is marked as withdrawn: search and show pages return a withdrawn
|
|
70
|
+
# stub for every user. Unlike Communities and Collections, Works are
|
|
71
|
+
# always tombstoneable regardless of how many files they hold — the
|
|
72
|
+
# FileSets and Blobs ride along.
|
|
73
|
+
#
|
|
74
|
+
# @param id [String] the Work ID.
|
|
75
|
+
# @param nuid [String] the acting user's NUID, stamped on the resource
|
|
76
|
+
# as `tombstoned_by` for audit purposes.
|
|
77
|
+
# @return [Faraday::Response] the raw response.
|
|
78
|
+
#
|
|
79
|
+
# @example
|
|
80
|
+
# AtlasRb::Work.tombstone("w-789", nuid: "000000002")
|
|
81
|
+
def self.tombstone(id, nuid:)
|
|
82
|
+
connection({}, nuid).post(ROUTE + id + '/tombstone')
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# Restore a previously tombstoned Work.
|
|
86
|
+
#
|
|
87
|
+
# **Operator-only.** Restoration is intentionally not exposed in any
|
|
88
|
+
# end-user UI; call this from a Rails console session (or a future
|
|
89
|
+
# admin panel) when the library has decided an object should come back.
|
|
90
|
+
#
|
|
91
|
+
# @param id [String] the Work ID.
|
|
92
|
+
# @param nuid [String] the acting user's NUID.
|
|
93
|
+
# @return [Faraday::Response] the raw response.
|
|
94
|
+
#
|
|
95
|
+
# @example Operator restoring from `bundle exec rails console`
|
|
96
|
+
# AtlasRb::Work.restore("w-789", nuid: "000000002")
|
|
97
|
+
def self.restore(id, nuid:)
|
|
98
|
+
connection({}, nuid).post(ROUTE + id + '/restore')
|
|
99
|
+
end
|
|
100
|
+
|
|
66
101
|
# Replace a Work's metadata by uploading a MODS XML document.
|
|
67
102
|
#
|
|
68
103
|
# @param id [String] the Work ID.
|
data/lib/atlas_rb.rb
CHANGED
|
@@ -13,6 +13,7 @@ require_relative "atlas_rb/collection"
|
|
|
13
13
|
require_relative "atlas_rb/work"
|
|
14
14
|
require_relative "atlas_rb/file_set"
|
|
15
15
|
require_relative "atlas_rb/blob"
|
|
16
|
+
require_relative "atlas_rb/user"
|
|
16
17
|
|
|
17
18
|
# Ruby client for the Atlas API — Northeastern University's institutional
|
|
18
19
|
# digital repository.
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: atlas_rb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.91
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- David Cliff
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-05-09 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|
|
@@ -122,6 +122,7 @@ files:
|
|
|
122
122
|
- lib/atlas_rb/file_set.rb
|
|
123
123
|
- lib/atlas_rb/mash.rb
|
|
124
124
|
- lib/atlas_rb/resource.rb
|
|
125
|
+
- lib/atlas_rb/user.rb
|
|
125
126
|
- lib/atlas_rb/version.rb
|
|
126
127
|
- lib/atlas_rb/work.rb
|
|
127
128
|
- sig/atlas_rb.rbs
|