stackshift-assets 0.2.0 → 0.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cdfe2efcf2a51f4c4bf71a687718adb1e79afc2e3a18f4366eda886635b1bd72
4
- data.tar.gz: 1c59b7c238b084196e80849fccfcfae8ef4430f88ae93af07d3999c679c36b01
3
+ metadata.gz: 2607cf398ae181f6643e452898d4a915770388274d566ff2beb5341c7221eaa7
4
+ data.tar.gz: 86acd19ea277884c2fd3fe8d3066d43511410e16fbf723818ee2f37fb0f6e335
5
5
  SHA512:
6
- metadata.gz: f3abe3f0304c97a80727e4ac7d362f0f33f7f6c76dc69ab2a64df9ed6c00ade142dbd4596056730b82cafb50a233adbc027dadb0de98bea8969ab13b5f55cb2e
7
- data.tar.gz: 55d9c68193000c748b9ddfd5adb86cfbebf7cfea41a80c83d36903947616d76ec1d9e912b91c94c3a537ef55d4efb0dda5fc85470d1b6757648bdae23e5f6880
6
+ metadata.gz: ff2f67172dbe00e43faac345fdff3f0aa5af0eddb0c7543475f964481e25d6aec018ec5709d719fc3da1844dedba1f17c7f6e2ae606fd0ac232a4856590dbd68
7
+ data.tar.gz: 10e3c6aad19b00999c0d7d6a341de658500494e1c7911afa9fe99f96e4dab4a57fea07d5bf3a040081596706f1c85dbe3e8f092c28b1a6e2ff67eb4e4776616c
data/README.md CHANGED
@@ -1,3 +1,12 @@
1
1
  # StackShift Assets for Ruby
2
2
 
3
3
  Require \`stackshift/assets_client\`. Rails applications can inject the client and use resumable upload sessions for direct uploads. Every mutating call takes the current revision and sends \`If-Match\`.
4
+
5
+ For Cloudinary or S3 imports, use `client.for_space(space_id)` to scope connection, storage, and migration calls. Run a dry inventory before transfer:
6
+
7
+ ```ruby
8
+ platform = client.for_space(space_id)
9
+ preview = platform.start_asset_migration({ source_connection_id: connection_id,
10
+ destination_bucket_id: bucket_id, source_prefix: "campaigns/2026", dry_run: true })
11
+ report = platform.asset_migration_report(preview.fetch("id"))
12
+ ```
@@ -5,9 +5,11 @@ require "digest"
5
5
  require "net/http"
6
6
  require "securerandom"
7
7
  require "uri"
8
+ require_relative "assets_platform"
8
9
 
9
10
  module StackShift
10
11
  class AssetsClient
12
+ include AssetsPlatform
11
13
  def initialize(api_key:, base_url: "https://api.stackshift.cloud/api/v1", cdn_base_url: "https://cdn.stackshift.cloud")
12
14
  raise ArgumentError, "StackShift SDK requires an API key" if api_key.to_s.strip.empty?
13
15
 
@@ -0,0 +1,82 @@
1
+ # frozen_string_literal: true
2
+
3
+ module StackShift
4
+ module AssetsPlatform
5
+ def for_space(space_id)
6
+ scoped = dup
7
+ scoped.instance_variable_set(:@asset_platform_space_id, space_id)
8
+ scoped
9
+ end
10
+
11
+ def list_asset_connections
12
+ platform_request(:get, "/assets/connections")
13
+ end
14
+
15
+ def get_asset_connection(id)
16
+ platform_request(:get, "/assets/connections/#{escape(id)}")
17
+ end
18
+
19
+ def create_asset_connection(input)
20
+ platform_request(:post, "/assets/connections", body: input)
21
+ end
22
+
23
+ def update_asset_connection(id, input)
24
+ platform_request(:patch, "/assets/connections/#{escape(id)}", body: input)
25
+ end
26
+
27
+ def verify_asset_connection(id)
28
+ platform_request(:post, "/assets/connections/#{escape(id)}/verify")
29
+ end
30
+
31
+ def delete_asset_connection(id)
32
+ platform_request(:delete, "/assets/connections/#{escape(id)}")
33
+ end
34
+
35
+ def configure_asset_storage(bucket_id, revision:, **input)
36
+ platform_request(:put, "/assets/buckets/#{escape(bucket_id)}/storage", body: input, headers: if_match(revision))
37
+ end
38
+
39
+ def list_asset_s2_buckets
40
+ platform_request(:get, "/assets/s2-buckets")
41
+ end
42
+
43
+ def create_asset_s2_bucket(input)
44
+ platform_request(:post, "/assets/s2-buckets", body: input)
45
+ end
46
+
47
+ def relocate_asset_bucket(bucket_id, input = {})
48
+ platform_request(:post, "/assets/buckets/#{escape(bucket_id)}/relocations", body: input)
49
+ end
50
+
51
+ def start_asset_migration(input)
52
+ platform_request(:post, "/assets/migrations", body: input)
53
+ end
54
+
55
+ def list_asset_migrations(limit: nil)
56
+ platform_request(:get, "/assets/migrations", query: limit ? { limit: limit } : nil)
57
+ end
58
+
59
+ def get_asset_migration(id)
60
+ platform_request(:get, "/assets/migrations/#{escape(id)}")
61
+ end
62
+
63
+ def cancel_asset_migration(id)
64
+ platform_request(:post, "/assets/migrations/#{escape(id)}/cancel")
65
+ end
66
+
67
+ def retry_asset_migration_item(migration_id, item_id)
68
+ platform_request(:post, "/assets/migrations/#{escape(migration_id)}/items/#{escape(item_id)}/retry")
69
+ end
70
+
71
+ def asset_migration_report(id)
72
+ platform_request(:get, "/assets/migrations/#{escape(id)}/report", query: { format: "json" })
73
+ end
74
+
75
+ private
76
+
77
+ def platform_request(method, path, body: nil, query: nil, headers: {})
78
+ headers = headers.merge("X-Asset-Space-ID" => @asset_platform_space_id) if @asset_platform_space_id && !@asset_platform_space_id.empty?
79
+ request(method, path, body: body, query: query, headers: headers)
80
+ end
81
+ end
82
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stackshift-assets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - StackShift
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-09-05 00:00:00.000000000 Z
11
+ date: 2026-10-01 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -20,6 +20,7 @@ files:
20
20
  - README.md
21
21
  - lib/stackshift/assets.rb
22
22
  - lib/stackshift/assets_client.rb
23
+ - lib/stackshift/assets_platform.rb
23
24
  - lib/stackshift/rails.rb
24
25
  homepage:
25
26
  licenses: []