shotgun_api_ruby 0.0.7 → 0.0.8

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: 331b2df4f527205c4803c47cb3a80373578aa740d56fe79c092930881afb9a01
4
- data.tar.gz: '09a83792f0f2b93d3b877cb10501d27c0049ef23c928e34ec65b90b9db956900'
3
+ metadata.gz: 3ae703829a60a9216ec532dd7d90c627bc15cab08a766ba245a90f67f7bff696
4
+ data.tar.gz: b7dfe8b5ecfe096ea87986eb5c4e292919503133e8baea2d115405ae52d349bb
5
5
  SHA512:
6
- metadata.gz: f47383023c6a67909c1eb1a54c8acc55880ba978bd20292633fb77362fdfd2e216d5b70869e1da88f1286a8640cec180fa12ef8b7d67351d8815b6b86d3d0e2e
7
- data.tar.gz: db5f9915dd9d40558d627efc6ed1860d254ef0f324e40a30aaa4f2e1cf8d78ea10baab866572a82444e40f4b12c3d18da537474fecd7e1a3c839ce0faa4900e9
6
+ metadata.gz: 9b9463f3e579cd14c74036e25691ccb73a296268a2729b188dd52453f459287c5c212ed357a48c06b6e41376a018fe7a79c5f88e9ff8b577abaa1bcc1b9b852b
7
+ data.tar.gz: 972f60041a6f0025c3691d4ed44ae08991b1b544030a59cbba61bbcbadf55ff6061032826a483572d37e3e23a12deddf6005d78870de9b84429fbdcceb5fc550
@@ -0,0 +1,23 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [0.0.8] - 2020-12-16
10
+ ### Added
11
+ - Schema: read
12
+ - Schema: read fields
13
+
14
+ ## [0.0.7] - 2020-12-16
15
+ ### Added
16
+ - Entities: update
17
+ - Entities: create
18
+ - Entities: delete
19
+ - Entities: revive
20
+
21
+ [Unreleased]: https://github.com/shotgunsoftware/shotgun_api_ruby/compare/v0.0.8...HEAD
22
+ [0.0.8]: https://github.com/shotgunsoftware/shotgun_api_ruby/releases/tag/v0.0.8
23
+ [0.0.7]: https://github.com/shotgunsoftware/shotgun_api_ruby/releases/tag/v0.0.7
data/README.md CHANGED
@@ -340,6 +340,26 @@ Will try to revive the entity referenced by the id. Will return true if successf
340
340
  client.assets.revive(1226)
341
341
  ```
342
342
 
343
+ ### Schema
344
+
345
+ Those calls allow to inspect the schema for a shotgun site.
346
+
347
+ #### Entity
348
+
349
+ ```ruby
350
+ client.assets.schema
351
+ ```
352
+
353
+ #### Entity fields
354
+
355
+ Fetch the different fields available on an entity type and their definition.
356
+
357
+ ```ruby
358
+ fields = client.assets.fields
359
+ fields.code.name # => "Asset Name"
360
+ fields.code.properties.summary_default # => "none"
361
+ ```
362
+
343
363
  ### Non implemented calls
344
364
 
345
365
  All calls which are not yet implemented can be done through the `connection` method. This method will still take care of the authentication for you.
@@ -5,6 +5,7 @@ module ShotgunApiRuby
5
5
  def initialize(connection, type)
6
6
  @connection = connection.dup
7
7
  @type = type
8
+ @base_url_prefix = @connection.url_prefix
8
9
  @connection.url_prefix = "#{@connection.url_prefix}/entity/#{type}"
9
10
  end
10
11
 
@@ -220,7 +221,6 @@ module ShotgunApiRuby
220
221
  req.headers['Content-Type'] = 'application/vnd+shotgun.api3_hash+json'
221
222
  end
222
223
  req.body = params.to_h.merge(filters: filter).to_json
223
- pp JSON.parse(req.body)
224
224
  end
225
225
  resp_body = JSON.parse(resp.body)
226
226
 
@@ -239,6 +239,18 @@ module ShotgunApiRuby
239
239
  end
240
240
  end
241
241
 
242
+ def schema_client
243
+ @schema_client ||= Schema.new(connection, type, @base_url_prefix)
244
+ end
245
+
246
+ def schema
247
+ schema_client.read
248
+ end
249
+
250
+ def fields
251
+ schema_client.fields
252
+ end
253
+
242
254
  private
243
255
 
244
256
  def filters_are_simple?(filters)
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ShotgunApiRuby
4
+ class Entities
5
+ class Schema
6
+ def initialize(connection, type, base_url_prefix)
7
+ @connection = connection.dup
8
+ @type = type
9
+ @connection.url_prefix = "#{base_url_prefix}/schema/#{type}"
10
+ end
11
+ attr_reader :type, :connection
12
+
13
+ def read
14
+ resp = @connection.get('')
15
+
16
+ if resp.status >= 300
17
+ raise "Error while read schema for #{type}: #{resp.body}"
18
+ end
19
+
20
+ resp_body = JSON.parse(resp.body)
21
+
22
+ OpenStruct.new(
23
+ resp_body["data"].transform_values{ |v| v["value"] }
24
+ )
25
+ end
26
+
27
+ def fields
28
+ resp = @connection.get('fields')
29
+ resp_body = JSON.parse(resp.body)
30
+
31
+ if resp.status >= 300
32
+ raise "Error while read schema fields for #{type}: #{resp.body}"
33
+ end
34
+
35
+ OpenStruct.new(
36
+ resp_body["data"].transform_values do |value|
37
+ OpenStruct.new(
38
+ value.transform_values do |attribute|
39
+ attribute["value"]
40
+ end.merge(
41
+ properties: OpenStruct.new(value["properties"].transform_values{ |prop| prop["value"] })
42
+ )
43
+ )
44
+ end
45
+ )
46
+ end
47
+ end
48
+ end
49
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ShotgunApiRuby
4
- VERSION = "0.0.7"
4
+ VERSION = "0.0.8"
5
5
  end
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
 
19
19
  spec.metadata["homepage_uri"] = spec.homepage
20
20
  spec.metadata["source_code_uri"] = "https://github.com/shotgunsoftware/shotgun_api_ruby"
21
- # spec.metadata["changelog_uri"] = "http://none.yet.com"
21
+ spec.metadata['changelog_uri'] = "https://github.com/shotgunsoftware/shotgun_api_ruby/blob/main/CHANGELOG.md"
22
22
 
23
23
  # Specify which files should be added to the gem when it is released.
24
24
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shotgun_api_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis <Zaratan> Pasin
@@ -210,6 +210,7 @@ files:
210
210
  - ".ruby-gemset"
211
211
  - ".ruby-version"
212
212
  - ".travis.yml"
213
+ - CHANGELOG.md
213
214
  - Gemfile
214
215
  - Gemfile.lock
215
216
  - LICENSE.txt
@@ -222,6 +223,7 @@ files:
222
223
  - lib/shotgun_api_ruby/client.rb
223
224
  - lib/shotgun_api_ruby/entities.rb
224
225
  - lib/shotgun_api_ruby/entities/params.rb
226
+ - lib/shotgun_api_ruby/entities/schema.rb
225
227
  - lib/shotgun_api_ruby/entity.rb
226
228
  - lib/shotgun_api_ruby/preferences.rb
227
229
  - lib/shotgun_api_ruby/server_info.rb
@@ -233,6 +235,7 @@ licenses:
233
235
  metadata:
234
236
  homepage_uri: https://github.com/shotgunsoftware/shotgun_api_ruby
235
237
  source_code_uri: https://github.com/shotgunsoftware/shotgun_api_ruby
238
+ changelog_uri: https://github.com/shotgunsoftware/shotgun_api_ruby/blob/main/CHANGELOG.md
236
239
  post_install_message:
237
240
  rdoc_options: []
238
241
  require_paths: