runapi-topaz 0.2.6 → 0.2.7

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: 8bb62f2b5c763e463433c6a31953baaf2f0f6fe9d2586898149e759b2b7a4544
4
- data.tar.gz: 2890b5d76de93833bb898c9d2ad25eee601dc3597db7d35e1f332f3d3499b199
3
+ metadata.gz: 52dc7160d3ead033cba7dcfd96c3e5b8d2155a76c2f2a7a0ff43b5525a4e6f38
4
+ data.tar.gz: e2ccac89059ab9e7c30353e2ec249a22957fc15eba0dc25d2818d52d703ebf46
5
5
  SHA512:
6
- metadata.gz: 52ede417926cb5fffe3af6af0dd5e5a9e00ccb2cbb73ca86be7b963a94ee1dd04c913b4c05817a0ab34c9eafcca34c90bf936fef8fa21ef8f575d3ed03abaf34
7
- data.tar.gz: 4d0496f468fd8c1277420c461cb7856e61efe269dc17614836c25da379104f42e9574b4b04f8d69885e458956ab60b52e3d1febaf3e62bf22edddc40f3192bf9
6
+ metadata.gz: 1de31db31fd7c9740230ad62de53cc32e07211e3914e6e0ec3acd45871f3055c0bcb0fd7423b1ba4364796d5f9a120cd1bd07948a7d6f3ceb34ad1ae35864f21
7
+ data.tar.gz: d635d7b485ffe75a77cb1999a4ecbf98310d9f5ae6f745a3035ef1d469b87f5838c9bc0a01d2b4052f12e23787ae4ac0ab4c82443a0a22c03c3aa91ce97344b0
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
- # Topaz API Ruby SDK for RunAPI
1
+ # Topaz Ruby SDK for RunAPI
2
2
 
3
- The topaz api Ruby SDK is the language-specific package for Topaz on RunAPI. Use this topaz api package for image upscale, video upscale, restoration, and production cleanup flows when your application needs JSON request bodies, task status lookup, and consistent RunAPI errors in Ruby.
3
+ The Topaz Ruby SDK is the language-specific package for Topaz on RunAPI. Use this package for image upscale, video upscale, restoration, and production cleanup workflows when your application needs request bodies, task status lookup, and consistent RunAPI errors in Ruby.
4
4
 
5
- This topaz api README is the Ruby package guide inside the public `topaz-sdk` repository. For the repository overview, start at `../README.md`; for model details, use https://runapi.ai/models/topaz; for API reference, use https://runapi.ai/docs#topaz; for SDK docs, use https://runapi.ai/docs#sdk-topaz.
5
+ This README is the Ruby package guide inside the public `topaz-sdk` repository. For the repository overview, start at `../README.md`; for model details, use https://runapi.ai/models/topaz; for API reference, use https://runapi.ai/docs#topaz; for SDK docs, use https://runapi.ai/docs#sdk-topaz.
6
6
 
7
7
  ## Install
8
8
 
@@ -16,10 +16,10 @@ gem install runapi-topaz
16
16
  require "runapi-topaz"
17
17
 
18
18
  client = RunApi::Topaz::Client.new
19
- task = client.image_upscales.create(
19
+ task = client.upscale_image.create(
20
20
  # Pass the Topaz JSON request body from https://runapi.ai/docs#topaz.
21
21
  )
22
- status = client.image_upscales.get(task.id)
22
+ status = client.upscale_image.get(task.id)
23
23
  ```
24
24
 
25
25
  Use `create` when you want to submit a task and return quickly, `get` when you need the latest task state, and `run` when a script should create and poll until completion. In web request handlers, prefer `create` plus webhook or later `get` polling so a worker is not held open.
@@ -28,7 +28,7 @@ RunAPI-generated file URLs are temporary. Download and store generated images, v
28
28
 
29
29
  ## Language notes
30
30
 
31
- Use Ruby keyword arguments and the `RunApi::Topaz` error classes when building upscaling jobs, Rails workers, or scripts. The available resources include image upscales, and video upscales. Keep `RUNAPI_API_KEY` in the environment or your secret manager; never commit API keys or callback secrets.
31
+ Use Ruby keyword arguments and the `RunApi::Topaz` error classes when building upscaling jobs, Rails workers, or scripts. The available resources are `upscale_image` and `upscale_video`. Keep `RUNAPI_API_KEY` in the environment or your secret manager; never commit API keys or callback secrets.
32
32
 
33
33
  ## Links
34
34
 
@@ -8,7 +8,7 @@ module RunApi
8
8
  # client = RunApi::Topaz::Client.new(api_key: "sk-...")
9
9
  # result = client.upscale_image.run(
10
10
  # model: "topaz-upscale-image",
11
- # source_image_url: "https://example.com/photo.jpg",
11
+ # source_image_url: "https://cdn.runapi.ai/public/samples/image.jpg",
12
12
  # upscale_factor: 2
13
13
  # )
14
14
  # puts result.images.first.url
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RunApi
4
+ module Topaz
5
+ CONTRACT = {
6
+ "upscale-image" => {
7
+ "models" => ["topaz-upscale-image"],
8
+ "fields_by_model" => {
9
+ "topaz-upscale-image" => {
10
+ "source_image_url" => {
11
+ "required" => true
12
+ },
13
+ "upscale_factor" => {
14
+ "enum" => [1, 2, 4, 8],
15
+ "required" => true,
16
+ "type" => "integer"
17
+ }
18
+ }
19
+ }
20
+ },
21
+ "upscale-video" => {
22
+ "models" => ["topaz-upscale-video"],
23
+ "fields_by_model" => {
24
+ "topaz-upscale-video" => {
25
+ "source_video_url" => {
26
+ "required" => true
27
+ },
28
+ "upscale_factor" => {
29
+ "enum" => [1, 2, 4],
30
+ "type" => "integer"
31
+ }
32
+ }
33
+ }
34
+ }
35
+ }.freeze
36
+ end
37
+ end
@@ -24,26 +24,13 @@ module RunApi
24
24
 
25
25
  def create(**params)
26
26
  params = compact_params(params)
27
- validate_params!(params)
27
+ validate_contract!(CONTRACT["upscale-image"], params)
28
28
  request(:post, ENDPOINT, body: params)
29
29
  end
30
30
 
31
31
  def get(id)
32
32
  request(:get, "#{ENDPOINT}/#{id}")
33
33
  end
34
-
35
- private
36
-
37
- def validate_params!(params)
38
- raise Core::ValidationError, "model is required" unless param(params, :model) == Types::UPSCALE_IMAGE_MODEL
39
- raise Core::ValidationError, "source_image_url is required" unless param(params, :source_image_url)
40
-
41
- factor = param(params, :upscale_factor)
42
- raise Core::ValidationError, "upscale_factor is required" unless factor
43
- return if Types::UPSCALE_IMAGE_FACTORS.include?(factor)
44
-
45
- raise Core::ValidationError, "upscale_factor must be one of: #{Types::UPSCALE_IMAGE_FACTORS.join(", ")}"
46
- end
47
34
  end
48
35
  end
49
36
  end
@@ -24,25 +24,13 @@ module RunApi
24
24
 
25
25
  def create(**params)
26
26
  params = compact_params(params)
27
- validate_params!(params)
27
+ validate_contract!(CONTRACT["upscale-video"], params)
28
28
  request(:post, ENDPOINT, body: params)
29
29
  end
30
30
 
31
31
  def get(id)
32
32
  request(:get, "#{ENDPOINT}/#{id}")
33
33
  end
34
-
35
- private
36
-
37
- def validate_params!(params)
38
- raise Core::ValidationError, "model is required" unless param(params, :model) == Types::UPSCALE_VIDEO_MODEL
39
- raise Core::ValidationError, "source_video_url is required" unless param(params, :source_video_url)
40
-
41
- factor = param(params, :upscale_factor)
42
- return unless factor && !Types::UPSCALE_VIDEO_FACTORS.include?(factor)
43
-
44
- raise Core::ValidationError, "upscale_factor must be one of: #{Types::UPSCALE_VIDEO_FACTORS.join(", ")}"
45
- end
46
34
  end
47
35
  end
48
36
  end
@@ -2,17 +2,8 @@
2
2
 
3
3
  module RunApi
4
4
  module Topaz
5
- # Type definitions and constants for the Topaz upscaling API.
5
+ # Response models for the Topaz upscaling API.
6
6
  module Types
7
- # Image upscaling model slug.
8
- UPSCALE_IMAGE_MODEL = "topaz-upscale-image"
9
- # Video upscaling model slug.
10
- UPSCALE_VIDEO_MODEL = "topaz-upscale-video"
11
- # Allowed image upscale factors. Higher factors produce larger output but take longer.
12
- UPSCALE_IMAGE_FACTORS = [1, 2, 4, 8].freeze
13
- # Allowed video upscale factors. Max 4x (8x is not supported for video).
14
- UPSCALE_VIDEO_FACTORS = [1, 2, 4].freeze
15
-
16
7
  # URL to an upscaled image.
17
8
  class Image < RunApi::Core::BaseModel
18
9
  optional :url, String
data/lib/runapi/topaz.rb CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "runapi/core"
4
4
  require_relative "topaz/types"
5
+ require_relative "topaz/contract_gen"
5
6
  require_relative "topaz/resources/upscale_image"
6
7
  require_relative "topaz/resources/upscale_video"
7
8
  require_relative "topaz/client"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runapi-topaz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - RunAPI
@@ -15,18 +15,18 @@ dependencies:
15
15
  requirements:
16
16
  - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: 0.2.6
18
+ version: 0.2.7
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - "~>"
24
24
  - !ruby/object:Gem::Version
25
- version: 0.2.6
26
- description: The topaz api Ruby SDK is the language-specific package for Topaz on
27
- RunAPI. Use this topaz api package for image upscale, video upscale, restoration,
28
- and production cleanup flows when your application needs JSON request bodies, task
29
- status lookup, and consistent RunAPI errors in Ruby.
25
+ version: 0.2.7
26
+ description: The Topaz Ruby SDK is the language-specific package for Topaz on RunAPI.
27
+ Use this package for image upscale, video upscale, restoration, and production cleanup
28
+ workflows when your application needs request bodies, task status lookup, and consistent
29
+ RunAPI errors in Ruby.
30
30
  email:
31
31
  - contact@runapi.ai
32
32
  executables: []
@@ -39,6 +39,7 @@ files:
39
39
  - lib/runapi-topaz.rb
40
40
  - lib/runapi/topaz.rb
41
41
  - lib/runapi/topaz/client.rb
42
+ - lib/runapi/topaz/contract_gen.rb
42
43
  - lib/runapi/topaz/resources/upscale_image.rb
43
44
  - lib/runapi/topaz/resources/upscale_video.rb
44
45
  - lib/runapi/topaz/types.rb
@@ -46,9 +47,11 @@ homepage: https://runapi.ai/models/topaz
46
47
  licenses:
47
48
  - Apache-2.0
48
49
  metadata:
50
+ runapi_slug: topaz
49
51
  homepage_uri: https://runapi.ai/models/topaz
50
52
  documentation_uri: https://github.com/runapi-ai/topaz-sdk/blob/main/ruby/README.md
51
53
  source_code_uri: https://github.com/runapi-ai/topaz-sdk
54
+ bug_tracker_uri: https://github.com/runapi-ai/topaz-sdk/issues
52
55
  changelog_uri: https://github.com/runapi-ai/topaz-sdk/blob/main/CHANGELOG.md
53
56
  rdoc_options: []
54
57
  require_paths:
@@ -66,5 +69,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
69
  requirements: []
67
70
  rubygems_version: 4.0.10
68
71
  specification_version: 4
69
- summary: Topaz API Ruby SDK for RunAPI
72
+ summary: Topaz Ruby SDK for RunAPI
70
73
  test_files: []