diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..adb71c87 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,48 @@ +name: CI +on: + push: + branches-ignore: + - 'generated' + - 'codegen/**' + - 'integrated/**' + - 'stl-preview-head/**' + - 'stl-preview-base/**' + pull_request: + branches-ignore: + - 'stl-preview-head/**' + - 'stl-preview-base/**' + +jobs: + lint: + timeout-minutes: 10 + name: lint + runs-on: ${{ github.repository == 'stainless-sdks/imagekit-ruby' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork + + steps: + - uses: actions/checkout@v4 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + bundler-cache: false + - run: |- + bundle install + + - name: Run lints + run: ./scripts/lint + test: + timeout-minutes: 10 + name: test + runs-on: ${{ github.repository == 'stainless-sdks/imagekit-ruby' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork + steps: + - uses: actions/checkout@v4 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + bundler-cache: false + - run: |- + bundle install + + - name: Run tests + run: ./scripts/test diff --git a/.github/workflows/gempush.yml b/.github/workflows/gempush.yml deleted file mode 100644 index 6a3223fd..00000000 --- a/.github/workflows/gempush.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Ruby Gem -on: - release: - types: [published] - -jobs: - build: - name: Build + Publish - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Set up Ruby 2.6 - uses: ruby/setup-ruby@v1.126.0 - with: - ruby-version: 2.6.5 - bundler: 2.4.22 - - name: Run Test Cases - run: | - gem install bundler -v 2.4.22 - bundle install --jobs 4 --retry 3 - bundle exec rake - - - name: Publish to RubyGems - run: | - mkdir -p $HOME/.gem - touch $HOME/.gem/credentials - chmod 0600 $HOME/.gem/credentials - printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials - gem build *.gemspec - gem push *.gem - env: - GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}} diff --git a/.github/workflows/publish-gem.yml b/.github/workflows/publish-gem.yml new file mode 100644 index 00000000..a3de9dee --- /dev/null +++ b/.github/workflows/publish-gem.yml @@ -0,0 +1,31 @@ +# This workflow is triggered when a GitHub release is created. +# It can also be run manually to re-publish to rubygems.org in case it failed for some reason. +# You can run this workflow by navigating to https://www.github.com/imagekit-developer/imagekit-ruby/actions/workflows/publish-gem.yml +name: Publish Gem +on: + workflow_dispatch: + + release: + types: [published] + +jobs: + publish: + name: publish + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + bundler-cache: false + - run: |- + bundle install + + - name: Publish to RubyGems.org + run: | + bash ./bin/publish-gem + env: + # `RUBYGEMS_HOST` is only required for private gem repositories, not https://rubygems.org + RUBYGEMS_HOST: ${{ secrets.IMAGE_KIT_RUBYGEMS_HOST || secrets.RUBYGEMS_HOST }} + GEM_HOST_API_KEY: ${{ secrets.IMAGE_KIT_GEM_HOST_API_KEY || secrets.GEM_HOST_API_KEY }} diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml new file mode 100644 index 00000000..9d9c1e66 --- /dev/null +++ b/.github/workflows/release-doctor.yml @@ -0,0 +1,22 @@ +name: Release Doctor +on: + pull_request: + branches: + - master + workflow_dispatch: + +jobs: + release_doctor: + name: release doctor + runs-on: ubuntu-latest + if: github.repository == 'imagekit-developer/imagekit-ruby' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next') + + steps: + - uses: actions/checkout@v4 + + - name: Check release environment + run: | + bash ./bin/check-release-environment + env: + RUBYGEMS_HOST: ${{ secrets.IMAGE_KIT_RUBYGEMS_HOST || secrets.RUBYGEMS_HOST }} + GEM_HOST_API_KEY: ${{ secrets.IMAGE_KIT_GEM_HOST_API_KEY || secrets.GEM_HOST_API_KEY }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 8c68db1a..00000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Ruby Test - -on: [ push, pull_request ] - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Set up Ruby 2.6 - uses: ruby/setup-ruby@v1.126.0 - with: - ruby-version: 2.6.5 - bundler: 2.4.22 - - name: Build and test with Rake - run: | - gem install bundler -v 2.4.22 - bundle install --jobs 4 --retry 3 - bundle exec rake - # - name: Upload code coverage reports to codecov - # uses: codecov/codecov-action@v1 - # with: - # token: 58fd7bff-e88e-4f23-b940-811b12f20dcf # not required for public repos - # # file: ./coverage.xml # optional - # # files: ./coverage1.xml,./coverage2.xml # optional - # # flags: unittests # optional - # # name: codecov-umbrella # optional - # # fail_ci_if_error: true # optional (default = false) diff --git a/.gitignore b/.gitignore index 7500a4aa..3d26ceed 100644 --- a/.gitignore +++ b/.gitignore @@ -1,23 +1,10 @@ -.bundle/ -log/*.log -pkg/ -coverage/ -test/dummy/db/*.sqlite3 -test/dummy/db/*.sqlite3-journal -test/dummy/db/*.sqlite3-* -test/dummy/log/*.log -test/dummy/storage/ -test/dummy/tmp/ -.vscode -public/uploads/ -config/master.key -.DS_Store -Gemfile.lock -**/Gemfile.lock -.idea/* -.rakeTasks -.idea/.gitignore -.idea/imagekit-ruby.iml -.idea/misc.xml -.idea/modules.xml -.idea/vcs.xml +*.gem +.idea/ +.ignore +.prism.log +.ruby-lsp/ +.yardoc/ +bin/tapioca +Brewfile.lock.json +doc/ +sorbet/tapioca/* diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 00000000..c7159c1a --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "0.0.2" +} \ No newline at end of file diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 00000000..f79bc9ed --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,292 @@ +# yaml-language-server: $schema=https://www.rubyschema.org/rubocop.json +--- +# Explicitly disable pending cops for now. This is the default behaviour but +# this avoids a large warning every time we run it. +# Stop RuboCop nagging about rubocop-rake. +# Ensure that RuboCop validates according to the lowest version of Ruby that we support. +AllCops: + Exclude: + - "bin/*" + NewCops: enable + SuggestExtensions: false + TargetRubyVersion: 3.2 + +# Whether MFA is required or not should be left to the token configuration. +Gemspec/RequireMFA: + Enabled: false + +# Don't require this extra line break, it can be excessive. +Layout/EmptyLineAfterGuardClause: + Enabled: false + +# Don't leave complex assignment values hanging off to the right. +Layout/EndAlignment: + EnforcedStyleAlignWith: variable + +Layout/FirstArrayElementLineBreak: + Enabled: true + +Layout/FirstHashElementLineBreak: + Enabled: true + +Layout/FirstMethodArgumentLineBreak: + Enabled: true + +Layout/FirstMethodParameterLineBreak: + Enabled: true + +# Set a reasonable line length; rely on other cops to correct long lines. +Layout/LineLength: + AllowedPatterns: + - "^\\s*#.*$" + - ^require(_relative)? + - "Imagekit::Internal::Type::BaseModel$" + - "^\\s*[A-Z0-9_]+ = :" + - "Imagekit::(Models|Resources|Test)::" + Max: 110 + +Layout/MultilineArrayLineBreaks: + Enabled: true + +# Start the assignment on the same line variable is mentioned. +Layout/MultilineAssignmentLayout: + EnforcedStyle: same_line + +Layout/MultilineHashKeyLineBreaks: + Enabled: true + +Layout/MultilineMethodArgumentLineBreaks: + Enabled: true + +Layout/MultilineMethodParameterLineBreaks: + Enabled: true + +# Prefer compact hash literals. +Layout/SpaceInsideHashLiteralBraces: + EnforcedStyle: no_space + Exclude: + - "**/*.rbi" + +Lint/BooleanSymbol: + Enabled: false + +# This option occasionally mangles identifier names +Lint/DeprecatedConstants: + Exclude: + - "**/*.rbi" + +# We use pattern assertion in tests to ensure correctness. +Lint/DuplicateMatchPattern: + Exclude: + - "test/**/*" + +# Fairly useful in tests for pattern assertions. +Lint/EmptyInPattern: + Exclude: + - "test/**/*" + +Lint/MissingCopEnableDirective: + Exclude: + - "examples/**/*.rb" + +Lint/MissingSuper: + Exclude: + - "**/*.rbi" + +Lint/SymbolConversion: + Exclude: + - "**/*.rbi" + +# Disabled for safety reasons, this option changes code semantics. +Lint/UnusedMethodArgument: + AutoCorrect: false + +# This option is prone to causing accidental bugs. +Lint/UselessAssignment: + AutoCorrect: false + Exclude: + - "examples/**/*.rb" + +Metrics/AbcSize: + Enabled: false + +Metrics/BlockLength: + AllowedPatterns: + - assert_pattern + - type_alias + - define_sorbet_constant! + Exclude: + - "**/*.rbi" + +Metrics/ClassLength: + Enabled: false + +Metrics/CyclomaticComplexity: + Enabled: false + +Metrics/MethodLength: + Enabled: false + +Metrics/ModuleLength: + Enabled: false + +Metrics/ParameterLists: + Enabled: false + +Metrics/PerceivedComplexity: + Enabled: false + +Naming/AccessorMethodName: + Enabled: false + +# Need to preserve block identifier for documentation. +Naming/BlockForwarding: + Enabled: false + +# Underscores are generally useful for disambiguation. +Naming/ClassAndModuleCamelCase: + Enabled: false + +Naming/MethodParameterName: + Enabled: false + +Naming/PredicatePrefix: + Exclude: + - "**/*.rbi" + +Naming/VariableNumber: + Enabled: false + +# Nothing wrong with inline private methods. +Style/AccessModifierDeclarations: + Enabled: false + +Style/AccessorGrouping: + Exclude: + - "**/*.rbi" + +# Behaviour of alias_method is more predictable. +Style/Alias: + EnforcedStyle: prefer_alias_method + +# And/or have confusing precedence, avoid them. +Style/AndOr: + EnforcedStyle: always + +Style/ArgumentsForwarding: + Enabled: false + +Style/BisectedAttrAccessor: + Exclude: + - "**/*.rbi" + +# We prefer nested modules in lib/, but are currently using compact style for tests. +Style/ClassAndModuleChildren: + Exclude: + - "test/**/*" + +Style/CommentAnnotation: + Enabled: false + +# We should go back and add these docs, but ignore for now. +Style/Documentation: + Enabled: false + +# Allow explicit empty elses, for clarity. +Style/EmptyElse: + Enabled: false + +Style/EmptyMethod: + Exclude: + - "**/*.rbi" + +# We commonly use ENV['KEY'], it's OK. +Style/FetchEnvVar: + Enabled: false + +# Just to be safe, ensure nobody is mutating our internal strings. +Style/FrozenStringLiteralComment: + EnforcedStyle: always + Exclude: + - "**/*.rbi" + +# Nothing wrong with clear if statements. +Style/IfUnlessModifier: + Enabled: false + +# Rubocop is pretty bad about mangling single line lambdas. +Style/Lambda: + Enabled: false + +# Prefer consistency in method calling syntax. +Style/MethodCallWithArgsParentheses: + AllowedMethods: + - raise + Enabled: true + Exclude: + - "**/*.gemspec" + +Style/MultilineBlockChain: + Enabled: false + +# Perfectly fine. +Style/MultipleComparison: + Enabled: false + +Style/MutableConstant: + Exclude: + - "**/*.rbi" + +# Not all parameters should be named. +Style/NumberedParameters: + Enabled: false + +Style/NumberedParametersLimit: + Max: 2 + +# Reasonable to use brackets for errors with long messages. +Style/RaiseArgs: + Enabled: false + +# Be explicit about `RuntimeError`s. +Style/RedundantException: + Enabled: false + +Style/RedundantInitialize: + Exclude: + - "**/*.rbi" + +Style/RedundantParentheses: + Exclude: + - "**/*.rbi" + +# Prefer slashes for regex literals. +Style/RegexpLiteral: + EnforcedStyle: slashes + +# Allow explicit ifs, especially for imperative use. +Style/SafeNavigation: + Enabled: false + +Style/SignalException: + Exclude: + - Rakefile + - "**/*.rake" + +# We use these sparingly, where we anticipate future branches for the +# inner conditional. +Style/SoleNestedConditional: + Enabled: false + +# Prefer double quotes so that interpolation can be easily added. +Style/StringLiterals: + EnforcedStyle: double_quotes + +# Prefer explicit symbols for clarity; you can search for `:the_symbol`. +Style/SymbolArray: + EnforcedStyle: brackets + +# This option makes examples harder to read for ruby novices. +Style/SymbolProc: + Exclude: + - "examples/**/*.rb" diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 00000000..944880fa --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +3.2.0 diff --git a/.solargraph.yml b/.solargraph.yml new file mode 100644 index 00000000..b100d90f --- /dev/null +++ b/.solargraph.yml @@ -0,0 +1,11 @@ +--- +max_files: 0 +include: + - '*.gemspec' + - 'Rakefile' + - 'examples/**/*.rb' + - 'lib/**/*.rb' + - 'test/imagekit/resource_namespaces.rb' + - 'test/imagekit/test_helper.rb' +exclude: + - 'rbi/**/*' diff --git a/.stats.yml b/.stats.yml new file mode 100644 index 00000000..031fed99 --- /dev/null +++ b/.stats.yml @@ -0,0 +1,4 @@ +configured_endpoints: 42 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-d1a3e6dfc45ae832b6b14a0aef25878985c679fa9f48c1470df188b1578ba648.yml +openapi_spec_hash: 1d382866fce3284f26d341f112988d9d +config_hash: d57f3c7c581048428b41398f30da8b9b diff --git a/.yardopts b/.yardopts new file mode 100644 index 00000000..84c12f2a --- /dev/null +++ b/.yardopts @@ -0,0 +1,6 @@ +--type-name-tag generic:Generic +--default-return void +--markup markdown +--markup-provider redcarpet +--exclude /rbi +--exclude /sig diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..8ccad9d4 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,73 @@ +# Changelog + +## 0.0.2 (2025-09-21) + +Full Changelog: [v0.0.1...v0.0.2](https://github.com/imagekit-developer/imagekit-ruby/compare/v0.0.1...v0.0.2) + +### Features + +* **api:** add BaseWebhookEvent ([b4c2a83](https://github.com/imagekit-developer/imagekit-ruby/commit/b4c2a8398c1b8bfa1df7da222ede418b047fe0b1)) +* **api:** extract UpdateFileDetailsRequest to model ([9aaa659](https://github.com/imagekit-developer/imagekit-ruby/commit/9aaa6599d67f4d077d34d0afec3c08baef271b9b)) +* **api:** manual updates ([9604a8e](https://github.com/imagekit-developer/imagekit-ruby/commit/9604a8eb40f6e4947075d6ff80bf919062a1556f)) +* **api:** manual updates ([0682128](https://github.com/imagekit-developer/imagekit-ruby/commit/0682128a78d935ba01979783050d66aac099504a)) +* **api:** manual updates ([f9bee87](https://github.com/imagekit-developer/imagekit-ruby/commit/f9bee8789b20c3ae42a177e8e7adc086fd6b734a)) +* **api:** manual updates ([2f5a40a](https://github.com/imagekit-developer/imagekit-ruby/commit/2f5a40ab9e7c3ffc0755c8c8cbf26bcfe69ab5b0)) +* **api:** manual updates ([428829b](https://github.com/imagekit-developer/imagekit-ruby/commit/428829bb7d7a3e01621dcb6d9901a1b440481f7c)) +* **api:** manual updates ([54e5bdf](https://github.com/imagekit-developer/imagekit-ruby/commit/54e5bdf49a3a67eb494e7aecfd4f5300f8c07772)) +* **api:** manual updates ([8c970ed](https://github.com/imagekit-developer/imagekit-ruby/commit/8c970ed1b42cfb40e05cedf4f643096918097f67)) +* **api:** manual updates ([e33d6ed](https://github.com/imagekit-developer/imagekit-ruby/commit/e33d6ed379d8d298f049edcf5b5b4d2ecfdd82bd)) +* **api:** manual updates ([4c04de9](https://github.com/imagekit-developer/imagekit-ruby/commit/4c04de93766bb15aad1784f5a4a594036fdce827)) +* **api:** manual updates ([e9bad22](https://github.com/imagekit-developer/imagekit-ruby/commit/e9bad2213d947539b07f4c71622c6bee2e826274)) +* **api:** manual updates ([c0417fb](https://github.com/imagekit-developer/imagekit-ruby/commit/c0417fbd4286fb47cbdfc154a696fcd2d34b1b5d)) +* **api:** manual updates ([bddb2fa](https://github.com/imagekit-developer/imagekit-ruby/commit/bddb2faecc78b22888d44aeda6896bdeff0f7cf8)) +* **api:** manual updates ([24f9f11](https://github.com/imagekit-developer/imagekit-ruby/commit/24f9f11ca39e3611c621a1d5383d763a4acd87b4)) +* **api:** manual updates ([8ac0ad3](https://github.com/imagekit-developer/imagekit-ruby/commit/8ac0ad3ff00d4036d52ec31777d74cb19f8d4379)) +* **api:** manual updates ([c64d558](https://github.com/imagekit-developer/imagekit-ruby/commit/c64d558fc172b4c1768d59731dc2a0e2c71de2fb)) +* **api:** manual updates ([453e942](https://github.com/imagekit-developer/imagekit-ruby/commit/453e942ec2c25f3720305dcd564ca22b85815336)) +* **api:** remove Stainless attribution from readme ([45e7793](https://github.com/imagekit-developer/imagekit-ruby/commit/45e7793eae012f4fcd05a30aa1ff4ef695793792)) +* **api:** update api docs link ([03ecbdf](https://github.com/imagekit-developer/imagekit-ruby/commit/03ecbdffb5dddc16aeace01e5b86a7e525263d7b)) +* **api:** Update env var name ([db61f60](https://github.com/imagekit-developer/imagekit-ruby/commit/db61f6089520c631dccbc618453d018634e53e63)) +* expose response headers for both streams and errors ([72c02c3](https://github.com/imagekit-developer/imagekit-ruby/commit/72c02c37a42bddc4e191b43145a562fab9e01dc7)) + + +### Bug Fixes + +* carrierwave bump to rm mimemagic dep ([ab4c2cf](https://github.com/imagekit-developer/imagekit-ruby/commit/ab4c2cf5856de50a9cb9deb7fb2168d67258083d)) +* change to dev dep ([22b98f8](https://github.com/imagekit-developer/imagekit-ruby/commit/22b98f8a9f482f11c0e6c3cfe9650a75e62d7f17)) +* conflict resolving ([9014f4f](https://github.com/imagekit-developer/imagekit-ruby/commit/9014f4f876914ab73f12ff79b3dd11132cc0f8a4)) +* Gemfile.lock remove and added to .gitignore ([b1a3bd7](https://github.com/imagekit-developer/imagekit-ruby/commit/b1a3bd7850397668f49770e75636acc592547878)) +* import issue fixed ([3a49fc5](https://github.com/imagekit-developer/imagekit-ruby/commit/3a49fc55bd7032d65c72016dab7d5669f2e17227)) +* import related to issue ([83a3f5a](https://github.com/imagekit-developer/imagekit-ruby/commit/83a3f5a10559dc863b0f6e149f9edbea8a2793ee)) +* rails 5~6 conflict issue and version build updates ([47aaf01](https://github.com/imagekit-developer/imagekit-ruby/commit/47aaf01727ccf9600db945f75338c73509691319)) +* rails dependency as development ([3d90b7b](https://github.com/imagekit-developer/imagekit-ruby/commit/3d90b7bc435499535d427e7e20893c419b39ed8a)) +* README.md linking sections ([9101ca2](https://github.com/imagekit-developer/imagekit-ruby/commit/9101ca2f3676a28d92c84c3b1b2c1c78ab5d027d)) +* spelling typo ([8debe83](https://github.com/imagekit-developer/imagekit-ruby/commit/8debe8379dbebdc7aad334acd1d8ac69283b0f94)) +* upload dir issue ([ce5754b](https://github.com/imagekit-developer/imagekit-ruby/commit/ce5754b24330cd2beb47ac12bb11985f10a5b93b)) + + +### Chores + +* carrierwave rails implemented ([9e130d4](https://github.com/imagekit-developer/imagekit-ruby/commit/9e130d484421a11b45e6884b2780194ffcb59173)) +* constants added ([59b760d](https://github.com/imagekit-developer/imagekit-ruby/commit/59b760dbee284b981bb3cc793fad5e6ce87c98f6)) +* do not install brew dependencies in ./scripts/bootstrap by default ([14104e2](https://github.com/imagekit-developer/imagekit-ruby/commit/14104e2b691d586fe0e978a6c6e4232d2e6db650)) +* file operation added ([11f2685](https://github.com/imagekit-developer/imagekit-ruby/commit/11f2685bccf80730b6da2855c2362f7287800ea8)) +* samle ruby app added ([21f88b8](https://github.com/imagekit-developer/imagekit-ruby/commit/21f88b8be03339265dc32548be7fb394fdc057b4)) +* sample rails project added ([2bf0cbe](https://github.com/imagekit-developer/imagekit-ruby/commit/2bf0cbed22811bb7e600febd5cb88e524cc07d7b)) +* sync repo ([0200fb8](https://github.com/imagekit-developer/imagekit-ruby/commit/0200fb885ff82f4960f401169d728b48c9d900cf)) +* update SDK settings ([5ce5d1f](https://github.com/imagekit-developer/imagekit-ruby/commit/5ce5d1f2370b6b31c1d2927856bfeac5eb592a23)) +* url generation implemented ([dda02cd](https://github.com/imagekit-developer/imagekit-ruby/commit/dda02cdcb05846b870b530f23cd40e478028bad1)) + + +### Build System + +* **deps:** bump addressable from 2.7.0 to 2.8.0 in /samples/rails_app ([db074cc](https://github.com/imagekit-developer/imagekit-ruby/commit/db074cc81e5aa59fa962b5e26c25d327bb4cac87)) +* **deps:** bump carrierwave from 2.1.0 to 2.1.1 in /samples/rails_app ([c109b9b](https://github.com/imagekit-developer/imagekit-ruby/commit/c109b9bd0effff643b8062dbe9d1157dad0210d8)) +* **deps:** bump nokogiri from 1.10.10 to 1.11.4 in /samples/rails_app ([9497849](https://github.com/imagekit-developer/imagekit-ruby/commit/9497849e1caa72bc5bbc582da3fc5f6575f2b455)) +* **deps:** bump rack from 2.2.2 to 2.2.3 in /samples/rails_app ([50c7336](https://github.com/imagekit-developer/imagekit-ruby/commit/50c7336a5c568d7fcbae99b15c5a646f96ac74d3)) +* **deps:** bump websocket-extensions in /samples/rails_app ([07d8ffa](https://github.com/imagekit-developer/imagekit-ruby/commit/07d8ffa895f8ad5c6c52c0d7e58824de602da8e2)) +* gem server added ([8046ad2](https://github.com/imagekit-developer/imagekit-ruby/commit/8046ad2ae832a47dc270b7b7b8d41cad3dcaecda)) +* gem server added ([32dfe99](https://github.com/imagekit-developer/imagekit-ruby/commit/32dfe99fe44da450a1a800c04ce2e86151f407e0)) +* gemspec modification ([0a4d32d](https://github.com/imagekit-developer/imagekit-ruby/commit/0a4d32d6c2b1d663f3074d6fac8cdf3f8200096e)) +* imagekit-sdk to imagekitio changing ([ca8c01e](https://github.com/imagekit-developer/imagekit-ruby/commit/ca8c01eefd657016f74aad0053e51899702dcd87)) +* version 1.0.1 added ([3193eb7](https://github.com/imagekit-developer/imagekit-ruby/commit/3193eb7ea55fa1f75643ab07bc4f8c7698f62852)) +* version chinging to 1.0.3 ([fa54abb](https://github.com/imagekit-developer/imagekit-ruby/commit/fa54abbc34aba78a2e895323c2bd02548a25063f)) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..15b2dbaa --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,125 @@ +## Setting up the environment + +This repository contains a `.ruby-version` file, which should work with either [rbenv](https://github.com/rbenv/rbenv) or [asdf](https://github.com/asdf-vm/asdf) with the [ruby plugin](https://github.com/asdf-vm/asdf-ruby). + +Please follow the instructions for your preferred version manager to install the Ruby version specified in the `.ruby-version` file. + +To set up the repository, run: + +```bash +$ ./scripts/bootstrap +``` + +This will install all the required dependencies. + +## Modifying/Adding code + +Most of the SDK is generated code. Modifications to code will be persisted between generations, but may result in merge conflicts between manual patches and changes from the generator. The generator will never modify the contents of `lib/imagekit/helpers/` and `examples/` directory. + +## Adding and running examples + +All files in the `examples/` directory are not modified by the generator and can be freely edited or added to. + +```ruby +#!/usr/bin/env ruby +# frozen_string_literal: true + +require_relative "../lib/imagekit" + +# ... +``` + +```bash +$ chmod +x './examples/.rb' + +# run the example against your api +$ ruby './examples/.rb' +``` + +## Using the repository from source + +If you’d like to use the repository from source, you can either install from git or reference a cloned repository: + +To install via git in your `Gemfile`: + +```ruby +gem "imagekit", git: "https://www.github.com/imagekit-developer/imagekit-ruby" +``` + +Alternatively, reference local copy of the repo: + +```bash +$ git clone -- 'https://www.github.com/imagekit-developer/imagekit-ruby' '' +``` + +```ruby +gem "imagekit", path: "" +``` + +## Running commands + +Running `rake` by itself will show all runnable commands. + +```bash +$ bundle exec rake +``` + +## Running tests + +Most tests require you to [set up a mock server](https://github.com/stoplightio/prism) against the OpenAPI spec to run the tests. + +```bash +$ npx prism mock path/to/your/openapi.yml +``` + +```bash +$ bundle exec rake test +``` + +## Linting and formatting + +This repository uses [rubocop](https://github.com/rubocop/rubocop) for linting and formatting of `*.rb` files; And [syntax_tree](https://github.com/ruby-syntax-tree/syntax_tree) is used for formatting of both `*.rbi` and `*.rbs` files. + +There are two separate type checkers supported by this library: [sorbet](https://github.com/sorbet/sorbet) and [steep](https://github.com/soutaro/steep) are used for verifying `*.rbi` and `*.rbs` files respectively. + +To lint and typecheck: + +```bash +$ bundle exec rake lint +``` + +To format and fix all lint issues automatically: + +```bash +$ bundle exec rake format +``` + +## Editor Support + +### Ruby LSP + +[Ruby LSP](https://github.com/Shopify/ruby-lsp) has quite good support for go to definition, but not auto-completion. + +This can be installed along side Solargraph. + +### Solargraph + +[Solargraph](https://solargraph.org) has quite good support for auto-completion, but not go to definition. + +This can be installed along side Ruby LSP. + +### Sorbet + +[Sorbet](https://sorbet.org) should mostly work out of the box when editing this library directly. However, there are a some caveats due to the colocation of `*.rb` and `*.rbi` files in the same project. These issues should not otherwise manifest when this library is used as a dependency. + +1. For go to definition usages, sorbet might get confused and may not always navigate to the correct location. + +2. For each generic type in `*.rbi` files, a spurious "Duplicate type member" error is present. + +## Documentation Preview + +To preview the documentation, run: + +```bash +$ bundle exec rake docs:preview [PORT=8808] +``` diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md deleted file mode 100644 index 47e24cd9..00000000 --- a/DEVELOPMENT.md +++ /dev/null @@ -1,20 +0,0 @@ -# Development Guide - - -**1. To modify version open `lib/imagekit/sdk/version.rb` and change value of `VERSION`.** - -**2. Setup dependency for projects** -```shell -gem install bundler -bundle install -``` - -**2. Run test cases** -```shell -bundle exec rake -``` - -**3. To build gem** -```shell -gem build imagekitio.gemspec -``` diff --git a/Gemfile b/Gemfile index c5777000..0d76364b 100644 --- a/Gemfile +++ b/Gemfile @@ -1,27 +1,33 @@ -source 'https://rubygems.org' -git_source(:github) { |repo| "https://github.com/#{repo}.git" } +# frozen_string_literal: true + +source "https://rubygems.org" -# Declare your gem's dependencies in imagekit-sdk.gemspec. -# Bundler will treat runtime dependencies like base dependencies, and -# development dependencies will be added by default to the :development group. gemspec -# Declare any dependencies that are still in development here instead of in -# your gemspec. These might include edge Rails or gems from your path or -# Git. Remember to move these dependencies to your gemspec before releasing -# your gem to rubygems.org. +group :development do + gem "rake" + gem "rbs" + gem "rubocop" + gem "sorbet" + gem "steep" + gem "syntax_tree" + # TODO: using a fork for now, the prettier below has a bug + gem "syntax_tree-rbs", github: "stainless-api/syntax_tree-rbs", branch: "main" + gem "tapioca" +end -# To use a debugger -# gem 'byebug', group: [:development, :test] -# gem 'carrierwave', '~> 2.0' -# gem "rake", "~> 12.0" -# gem "rest-client", "~>2.1" +group :development, :test do + gem "async" + gem "minitest" + gem "minitest-focus" + gem "minitest-hooks" + gem "minitest-proveit" + gem "minitest-rg" + gem "webmock" +end -group :test do - gem "minitest", "~> 5.0" - gem "rspec" - gem 'simplecov' - # gem 'codecov' - gem 'webmock' - gem 'byebug' +group :development, :docs do + gem "redcarpet" + gem "webrick" + gem "yard" end diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 00000000..b85ec310 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,226 @@ +GIT + remote: https://github.com/stainless-api/syntax_tree-rbs.git + revision: c30b50219918be7cfe3ef803a00b59d1e77fcada + branch: main + specs: + syntax_tree-rbs (1.0.0) + prettier_print + rbs + syntax_tree (>= 2.0.1) + +PATH + remote: . + specs: + imagekit (0.0.2) + connection_pool + +GEM + remote: https://rubygems.org/ + specs: + activesupport (8.0.2.1) + base64 + benchmark (>= 0.3) + bigdecimal + concurrent-ruby (~> 1.0, >= 1.3.1) + connection_pool (>= 2.2.5) + drb + i18n (>= 1.6, < 2) + logger (>= 1.4.2) + minitest (>= 5.1) + securerandom (>= 0.3) + tzinfo (~> 2.0, >= 2.0.5) + uri (>= 0.13.1) + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) + ast (2.4.3) + async (2.27.3) + console (~> 1.29) + fiber-annotation + io-event (~> 1.11) + metrics (~> 0.12) + traces (~> 0.15) + base64 (0.3.0) + benchmark (0.4.1) + bigdecimal (3.2.2) + concurrent-ruby (1.3.5) + connection_pool (2.5.3) + console (1.33.0) + fiber-annotation + fiber-local (~> 1.1) + json + crack (1.0.0) + bigdecimal + rexml + csv (3.3.5) + drb (2.2.3) + erubi (1.13.1) + ffi (1.17.2-aarch64-linux-gnu) + ffi (1.17.2-aarch64-linux-musl) + ffi (1.17.2-arm64-darwin) + ffi (1.17.2-x86_64-darwin) + ffi (1.17.2-x86_64-linux-gnu) + ffi (1.17.2-x86_64-linux-musl) + fiber-annotation (0.2.0) + fiber-local (1.1.0) + fiber-storage + fiber-storage (1.0.1) + fileutils (1.7.3) + hashdiff (1.2.0) + i18n (1.14.7) + concurrent-ruby (~> 1.0) + io-event (1.11.2) + json (2.13.2) + language_server-protocol (3.17.0.5) + lint_roller (1.1.0) + listen (3.9.0) + rb-fsevent (~> 0.10, >= 0.10.3) + rb-inotify (~> 0.9, >= 0.9.10) + logger (1.7.0) + metrics (0.13.0) + minitest (5.25.5) + minitest-focus (1.4.0) + minitest (>= 4, < 6) + minitest-hooks (1.5.2) + minitest (> 5.3) + minitest-proveit (1.0.0) + minitest (> 5, < 7) + minitest-rg (5.3.0) + minitest (~> 5.0) + mutex_m (0.3.0) + netrc (0.11.0) + parallel (1.27.0) + parser (3.3.9.0) + ast (~> 2.4.1) + racc + prettier_print (1.2.1) + prism (1.4.0) + public_suffix (6.0.2) + racc (1.8.1) + rainbow (3.1.1) + rake (13.3.0) + rb-fsevent (0.11.2) + rb-inotify (0.11.1) + ffi (~> 1.0) + rbi (0.3.6) + prism (~> 1.0) + rbs (>= 3.4.4) + rbs (3.9.4) + logger + redcarpet (3.6.1) + regexp_parser (2.11.2) + rexml (3.4.1) + rubocop (1.79.2) + json (~> 2.3) + language_server-protocol (~> 3.17.0.2) + lint_roller (~> 1.1.0) + parallel (~> 1.10) + parser (>= 3.3.0.2) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 2.9.3, < 3.0) + rubocop-ast (>= 1.46.0, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 4.0) + rubocop-ast (1.46.0) + parser (>= 3.3.7.2) + prism (~> 1.4) + ruby-progressbar (1.13.0) + securerandom (0.4.1) + sorbet (0.5.12424) + sorbet-static (= 0.5.12424) + sorbet-runtime (0.5.12424) + sorbet-static (0.5.12424-aarch64-linux) + sorbet-static (0.5.12424-universal-darwin) + sorbet-static (0.5.12424-x86_64-linux) + sorbet-static-and-runtime (0.5.12424) + sorbet (= 0.5.12424) + sorbet-runtime (= 0.5.12424) + spoom (1.6.3) + erubi (>= 1.10.0) + prism (>= 0.28.0) + rbi (>= 0.3.3) + rexml (>= 3.2.6) + sorbet-static-and-runtime (>= 0.5.10187) + thor (>= 0.19.2) + steep (1.10.0) + activesupport (>= 5.1) + concurrent-ruby (>= 1.1.10) + csv (>= 3.0.9) + fileutils (>= 1.1.0) + json (>= 2.1.0) + language_server-protocol (>= 3.17.0.4, < 4.0) + listen (~> 3.0) + logger (>= 1.3.0) + mutex_m (>= 0.3.0) + parser (>= 3.1) + rainbow (>= 2.2.2, < 4.0) + rbs (~> 3.9) + securerandom (>= 0.1) + strscan (>= 1.0.0) + terminal-table (>= 2, < 5) + uri (>= 0.12.0) + strscan (3.1.5) + syntax_tree (6.3.0) + prettier_print (>= 1.2.0) + tapioca (0.16.11) + benchmark + bundler (>= 2.2.25) + netrc (>= 0.11.0) + parallel (>= 1.21.0) + rbi (~> 0.2) + sorbet-static-and-runtime (>= 0.5.11087) + spoom (>= 1.2.0) + thor (>= 1.2.0) + yard-sorbet + terminal-table (4.0.0) + unicode-display_width (>= 1.1.1, < 4) + thor (1.4.0) + traces (0.17.0) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) + unicode-display_width (3.1.5) + unicode-emoji (~> 4.0, >= 4.0.4) + unicode-emoji (4.0.4) + uri (1.0.3) + webmock (3.25.1) + addressable (>= 2.8.0) + crack (>= 0.3.2) + hashdiff (>= 0.4.0, < 2.0.0) + webrick (1.9.1) + yard (0.9.37) + yard-sorbet (0.9.0) + sorbet-runtime + yard + +PLATFORMS + aarch64-linux + aarch64-linux-gnu + aarch64-linux-musl + arm64-darwin + universal-darwin + x86_64-darwin + x86_64-linux-gnu + x86_64-linux-musl + +DEPENDENCIES + async + imagekit! + minitest + minitest-focus + minitest-hooks + minitest-proveit + minitest-rg + rake + rbs + redcarpet + rubocop + sorbet + steep + syntax_tree + syntax_tree-rbs! + tapioca + webmock + webrick + yard + +BUNDLED WITH + 2.4.1 diff --git a/LICENSE b/LICENSE index b767e540..e7a4d160 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,201 @@ -MIT License - -Copyright (c) 2020 Imagekit - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2025 Image Kit + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md index 20a7791d..0d7cf3f0 100644 --- a/README.md +++ b/README.md @@ -1,915 +1,280 @@ -[ImageKit.io](https://imagekit.io) - -# Imagekit Ruby and Rails SDK - -[![Ruby Test](https://github.com/imagekit-developer/imagekit-ruby/workflows/Ruby%20Test/badge.svg)](https://github.com/imagekit-developer/imagekit-ruby) -[![Gem Version](https://badge.fury.io/rb/imagekitio.svg)](https://badge.fury.io/rb/imagekitio) -[![codecov](https://codecov.io/gh/imagekit-developer/imagekit-ruby/branch/master/graph/badge.svg)](https://codecov.io/gh/imagekit-developer/imagekit-ruby) -[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) -[![Twitter Follow](https://img.shields.io/twitter/follow/imagekitio?label=Follow&style=social)](https://twitter.com/ImagekitIo) - -Ruby on Rails gem for [ImageKit](https://imagekit.io/) implements the new APIs and interface for different file operations. - -ImageKit is complete media storage, optimization, and transformation solution that comes with an [image and video CDN](https://imagekit.io/features/imagekit-infrastructure). It can be integrated with your existing infrastructure - storage like AWS S3, web servers, your CDN, and custom domain names, allowing you to deliver optimized images in minutes with minimal code changes. - -Table of contents - - * [Changelog](#changelog) - * [Installation](#installation) - * [Initialization](#initialization) - - [CarrierWave](#carrierwave) - - [ActiveStorage](#activestorage) - * [URL Generation](#url-generation) - * [File Upload](#file-upload) - * [File Management](#file-management) - * [Utility Functions](#utility-functions) - * [Sample applications](#sample-application) - * [Upgrade to 2.x](#upgrade-to-2x) - * [Support](#support) - * [Links](#links) - - -# Quick start guide -Get started with [official quick start guide](https://docs.imagekit.io/getting-started/quickstart-guides/ruby-guides) for integrating ImageKit in Ruby on Rails. - -## Changelog -### SDK Version 3.0.0 -#### Breaking changes -**1. Overlay syntax update** -* In version 3.0.0, we've removed the old overlay syntax parameters for transformations, such as `oi`, `ot`, `obg`, and [more](https://docs.imagekit.io/features/image-transformations/overlay). These parameters are deprecated and will start returning errors when used in URLs. Please migrate to the new layers syntax that supports overlay nesting, provides better positional control, and allows more transformations at the layer level. You can start with [examples](https://docs.imagekit.io/features/image-transformations/overlay-using-layers#examples) to learn quickly. -* You can migrate to the new layers syntax using the `raw` transformation parameter. +# Image Kit Ruby API library -## Installation - -Add `imagekitio` dependency to your application's Gemfile: - -```ruby -gem 'imagekitio' -``` - -And then execute: -``` -$ bundle install -``` - -Or install it yourself: -``` -$ gem install imagekitio -``` - -## Initialization - -Create a new file `config/initializers/imagekitio.rb` then add the configuration. -```ruby -ImageKitIo.configure do |config| - if Rails.env.development? - config.public_key = 'your_public_api_key' - config.private_key = 'your_private_api_key' - config.url_endpoint = 'https://ik.imagekit.io/your_imagekit_id/' - end - config.service = :carrierwave - #config.service = :active_storage - #config.constants.MISSING_PRIVATE_KEY = 'custom error message' -end -``` -#### CarrierWave -You can create a CarrierWave uploader to attach pictures to your database objects as their attributes. Skip to [this section](https://github.com/imagekit-developer/imagekit-ruby#file-upload) to upload images without designating them as database attributes. Make sure to add service `:carrierwave` as shown in [initialization section](#initialization). - -```bash -rails g uploader -# For example, if you want to create an uploader for Avatar attribute, then use -rails g uploader Avatar -# Generated uploader's path will be app/uploaders/avatar_uploader.rb -``` - -After that, you need to edit your generated uploader and make the following changes: -```ruby -# include this module inside the top of the uploader class -include ImageKitIo::CarrierWave - -# If you want to add uploading options, then create this method inside the uploader file as an example - -def options - options={ - response_fields: 'isPrivateFile, tags', - tags: %w[abc def], - use_unique_file_name: false, - folder: "your_directory/" - } -end - -# If you want to set upload dir, then you can use the following method, or you can also use the options method. -# This method should return a string -def store_dir - "your_directory/" -end -``` - -Then you need to modify your model. for example- if your model name is employee, then do these changes. - -```ruby -class Employee < ApplicationRecord - attr_accessor :avatar - mount_uploader :avatar, AvatarUploader -end -``` +The Image Kit Ruby library provides convenient access to the Image Kit REST API from any Ruby 3.2.0+ application. It ships with comprehensive types & docstrings in Yard, RBS, and RBI – [see below](https://github.com/imagekit-developer/imagekit-ruby#Sorbet) for usage with Sorbet. The standard library's `net/http` is used as the HTTP transport, with connection pooling via the `connection_pool` gem. -Get image url: -```ruby -# If @employee is an object of your model that has data. - -# To get the original image url, use -@employee.avatar.url +## Documentation -# To get the file metadata -@employee.avatar.metadata +Documentation for releases of this gem can be found [on RubyDoc](https://gemdocs.org/gems/imagekit). +The REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). -# And to get transformed url use -# options is a transformation options -@employee.avatar.url_with(options) -``` - -#### ActiveStorage +## Installation -Once you [install](https://guides.rubyonrails.org/active_storage_overview.html#setup) the active_storage gem, then any model can have the attachment using `has_one_attached` or `has_many_attached` like below: +To use this gem, install via Bundler by adding the following to your application's `Gemfile`: -```ruby -class Employee < ApplicationRecord - has_one_attached :avatar -end -``` + -Get image url: ```ruby -# If @employee is an object of your model that has data. - -# To get the original image url, use -@employee.avatar.url -``` - -Now, let's configure active_storage as a service for the imagekitio. - -First add `:active_storage` in initializer file. - -```ruby -config.service = :active_storage -``` - -Then add the imagekitio service in the `storage.yml` file: - -```ruby -imagekitio: - service: ImageKitIo +gem "imagekit", "~> 0.0.2" ``` + ## Usage -You can use this Ruby SDK for three different methods - URL generation, file upload, and media management operations. The usage of the SDK has been explained below. - -* `URL Generation` -* `File Upload` -* `File Management` - -## URL generation - -**1. Using Image path and image hostname or endpoint** - -This method allows you to create an URL to access a file using the relative file path and the ImageKit URL endpoint (`urlEndpoint`). The file can be an image, video or any other static file supported by ImageKit. - ```ruby -imagekitio = ImageKitIo.client -image_url = imagekitio.url({ - path: "/default-image.jpg", - url_endpoint: "https://ik.imagekit.io/your_imagekit_id/endpoint/", - transformation: [{height: "300", width: "400", raw: "ar-4-3,q-40"}] -}) -``` - -The result in a URL like -``` -https://ik.imagekit.io/your_imagekit_id/endpoint/tr:h-300,w-400,ar-4-3,q-40/default-image.jpg -``` - -**2.Using full image URL** -This method allows you to add transformation parameters to an absolute URL. For example, if you have configured a custom CNAME and have absolute asset URLs in your database or CMS, you will often need this. - - -```ruby -image_url = imagekitio.url({ - src: "https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg", - transformation: [{height: "300", width: "400"}], -}) -``` - -The results in a URL like - -``` -https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg?tr=h-300%2Cw-400 -``` - - -The `.url()` method accepts the following parameters - -| Option | Description | -| :---------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| url_endpoint | Optional. The base URL to be appended before the path of the image. If not specified, the URL Endpoint specified at the time of SDK initialization is used. For example, https://ik.imagekit.io/your_imagekit_id/endpoint/ | -| path | Conditional. This is the path at which the image exists. For example, `/path/to/image.jpg`. Either the `path` or `src` parameter needs to be specified for URL generation. | -| src | Conditional. This is the complete URL of an image already mapped to ImageKit. For example, `https://ik.imagekit.io/your_imagekit_id/endpoint/path/to/image.jpg`. Either the `path` or `src` parameter needs to be specified for URL generation. | -| transformation | Optional. An array of objects specifying the transformation to be applied in the URL. The transformation name and the value should be specified as a key-value pair in the object. Different steps of a [chained transformation](https://docs.imagekit.io/features/image-transformations/chained-transformations) can be specified as different objects of the array. The complete list of supported transformations in the SDK and some examples of using them are given later. If you use a transformation name that is not specified in the SDK, it gets applied as it is in the URL. | -| transformation_position | Optional. The default value is `path` that places the transformation string as a path parameter in the URL. It can also be specified as `query`, which adds the transformation string as the query parameter `tr` in the URL. If you use `src` parameter to create the URL, then the transformation string is always added as a query parameter. | -| query_parameters | Optional. These are the other query parameters that you want to add to the final URL. These can be any query parameters and not necessarily related to ImageKit. Especially useful if you want to add some versioning parameters to your URLs. | -| signed | Optional. Boolean. Default is `false`. If set to `true`, the SDK generates a signed image URL adding the image signature to the image URL. This can only be used if you are creating the URL with the `url_endpoint` and `path` parameters and not with the `src` parameter. | -| expire_seconds | Optional. Integer. Meant to be used along with the `signed` parameter to specify the time in seconds from now when the URL should expire. If specified, the URL contains the expiry timestamp in the URL, and the image signature is modified accordingly. | - - -## Examples of generating URLs -**1. Chained Transformations as a query parameter** - -```ruby -image_url = imagekitio.url({ - path: "/default-image.jpg", - url_endpoint: "https://ik.imagekit.io/your_imagekit_id/endpoint/", - transformation: [{ - height: "300", - width: "400" - },{ - rotation: 90 - }], - transformation_position: "query" -}) -``` -Sample Result URL - -``` -https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg?tr=h-300%2Cw-400%3Art-90 -``` - -**2. Sharpening and contrast transforms and a progressive JPG image** - -There are some transforms like [Sharpening](https://docs.imagekit.io/features/image-transformations/image-enhancement-and-color-manipulation) -that can be added to the URL with or without any other value. To use such transforms without specifying a value, specify -the value as "-" in the transformation object. Otherwise, specify the value that you want to be -added to this transformation. - - -```ruby -image_url = imagekitio.url({ - src: "https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg", - transformation: [{ - format: "jpg", - progressive: "true", - effect_sharpen: "-", - effect_contrast: "1" - }] -}) -``` - -``` -//Note that because `src` parameter was used, the transformation string gets added as a query parameter `tr` -https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg?tr=f-jpg%2Cpr-true%2Ce-sharpen%2Ce-contrast-1 -``` - -**3. Signed URL that expires in 300 seconds with the default URL endpoint and other query parameters** - -```ruby -image_url = imagekit.url({ - path: "/default-image", - query_parameters: { - "v": "123" - }, - transformation: [{ - height: "300", - width: "400" - }], - signed: True, - expire_seconds: 300 -}) -``` -**Sample Result URL** -``` -https://ik.imagekit.io/your_imagekit_id/tr:h-300,w-400/default-image.jpg?v=123&ik-t=1567358667&ik-s=f2c7cdacbe7707b71a83d49cf1c6110e3d701054 -``` - -**4. Adding overlays** - -ImageKit.io enables you to apply overlays to [images](https://docs.imagekit.io/features/image-transformations/overlay-using-layers) and [videos](https://docs.imagekit.io/features/video-transformation/overlay) using the raw parameter with the concept of [layers](https://docs.imagekit.io/features/image-transformations/overlay-using-layers#layers). The raw parameter facilitates incorporating transformations directly in the URL. A layer is a distinct type of transformation that allows you to define an asset to serve as an overlay, along with its positioning and additional transformations. - -**Text as overlays** - -You can add any text string over a base video or image using a text layer (l-text). - -For example: - -```ruby -image_url = imagekit.url({ - path: "/default-image", - url_endpoint: "https://ik.imagekit.io/your_imagekit_id/endpoint/", - transformation: [{ - height: "300", - width: "400", - raw: "l-text,i-Imagekit,fs-50,l-end" - }], -}) -``` -**Sample Result URL** -``` -https://ik.imagekit.io/your_imagekit_id/tr:h-300,w-400,l-text,i-Imagekit,fs-50,l-end/default-image.jpg -``` - -**Image as overlays** - -You can add an image over a base video or image using an image layer (l-image). - -For example: - -```ruby -image_url = imagekit.url({ - path: "/default-image", - url_endpoint: "https://ik.imagekit.io/your_imagekit_id/endpoint/", - transformation: [{ - height: "300", - width: "400", - raw: "l-image,i-default-image.jpg,w-100,b-10_CDDC39,l-end" - }], -}) -``` -**Sample Result URL** -``` -https://ik.imagekit.io/your_imagekit_id/tr:h-300,w-400,l-image,i-default-image.jpg,w-100,b-10_CDDC39,l-end/default-image.jpg -``` - -**Solid color blocks as overlays** - -You can add solid color blocks over a base video or image using an image layer (l-image). - -For example: - -```ruby -image_url = imagekit.url({ - path: "/img/sample-video", - url_endpoint: "https://ik.imagekit.io/your_imagekit_id/endpoint/", - transformation: [{ - height: "300", - width: "400", - raw: "l-image,i-ik_canvas,bg-FF0000,w-300,h-100,l-end" - }], -}) -``` -**Sample Result URL** -``` -https://ik.imagekit.io/your_imagekit_id/tr:h-300,w-400,l-image,i-ik_canvas,bg-FF0000,w-300,h-100,l-end/img/sample-video.mp4 -``` - -**5. Arithmetic expressions in transformations** - -ImageKit allows use of [arithmetic expressions](https://docs.imagekit.io/features/arithmetic-expressions-in-transformations) in certain dimension and position-related parameters, making media transformations more flexible and dynamic. - -For example: - -```ruby -image_url = imagekit.url({ - path: "/default-image.jpg", - url_endpoint: "https://ik.imagekit.io/your_imagekit_id/endpoint/", - transformation: [{ - width: "iw_div_4", - height: "ih_div_2", - border: "cw_mul_0.05_yellow" - }] -}); -``` +require "bundler/setup" +require "imagekit" -**Sample Result URL** -``` -https://ik.imagekit.io/your_imagekit_id/default-image.jpg?tr=w-iw_div_4,h-ih_div_2,b-cw_mul_0.05_yellow -``` - -**List of transformations** - -The complete list of transformations supported and their usage in ImageKit can be found [here](https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations). The SDK gives a name to each transformation parameter, making the code simpler, making the code simpler, and readable. - -If a transformation is supported in ImageKit, but a name for it cannot be found in the table below, then use the transformation code from ImageKit docs as the name when using the `url` function. - -If you want to generate transformations in your application and add them to the URL as it is, use the `raw` parameter. - -| Supported Transformation Name | Translates to parameter | -|-------------------------------|-------------------------| -| height | h | -| width | w | -| aspect_ratio | ar | -| quality | q | -| crop | c | -| crop_mode | cm | -| x | x | -| y | y | -| focus | fo | -| format | f | -| radius | r | -| background | bg | -| border | b | -| rotation | rt | -| blur | bl | -| named | n | -| progressive | pr | -| lossless | lo | -| trim | t | -| metadata | md | -| color_profile | cp | -| default_image | di | -| dpr | dpr | -| effect_sharpen | e-sharpen | -| effect_usm | e-usm | -| effect_contrast | e-contrast | -| effect_gray | e-grayscale | -| effect_shadow | e-shadow | -| effect_gradient | e-gradient | -| original | orig | -| raw | `replaced by the parameter value` | - -## File Upload -This method can be used to directly upload images to your ImageKit Media Library without giving it the designation of an attribute of any database object. - -The SDK provides a simple interface using the `.upload()` method to upload files to the ImageKit Media library. It -accepts all the parameters supported by the [ImageKit Upload API](https://docs.imagekit.io/api-reference/upload-file-api/server-side-file-upload). - -The `upload()` method requires at least the `file` and the `file_name` parameter to upload a file and returns -a callback with the `error` and `result` as arguments. You can pass other parameters supported by the -ImageKit upload API using the same parameter name as specified in the upload API documentation. For example, to specify tags for a file at the time of upload, use the `tags` parameter as specified in the [documentation here](https://docs.imagekit.io/api-reference/upload-file-api/server-side-file-upload). - -Simple usage +image_kit = Imagekit::Client.new( + private_key: ENV["IMAGEKIT_PRIVATE_KEY"], # This is the default and can be omitted + password: ENV["OPTIONAL_IMAGEKIT_IGNORES_THIS"] # This is the default and can be omitted +) -```ruby -imagekitio.upload_file( - file: "", # required - file_name: "my_file_name.jpg", # required - response_fields: 'isPrivateFile, tags', - tags: %w[abc def], - use_unique_file_name: true, - transformation: { - pre: 'l-text,i-Imagekit,fs-50,l-end', - post: [ - { - type: 'transformation', - value: 'w-100' - } - ] - }, - checks: "'request.folder' : '/'" # To run server side checks before uploading files. Notice the quotes around file.size and 1mb. - is_published: true +response = image_kit.files.upload( + file: StringIO.new("https://www.example.com/public-url.jpg"), + file_name: "file-name.jpg" ) +puts(response.videoCodec) ``` -If the upload is succeeded, `error` will be `None`, and the result will be the same as what is received from ImageKit's -servers. If the upload fails, `error` will be the same as what is received from ImageKit's servers, and the result will -be `None`. - -## File Management - -The SDK provides a simple interface for all the [media APIs mentioned here](https://docs.imagekit.io/api-reference/media-api) -to manage your files. This also returns `error` and `result`. The `error` will be `None` if API succeeds. - -**List & Search Files** +### File uploads -Accepts an object specifying the parameters to be used to list and search files. All parameters specified -in the [documentation here](https://docs.imagekit.io/api-reference/media-api/list-and-search-files#list-and-search-file-api) can be passed with the -correct values to get the results. +Request parameters that correspond to file uploads can be passed as raw contents, a [`Pathname`](https://rubyapi.org/3.2/o/pathname) instance, [`StringIO`](https://rubyapi.org/3.2/o/stringio), or more. ```ruby -imagekitio.list_files( - skip: 0, - limit: 5 -) -``` -**Get File Details** +require "pathname" -Accepts the file ID and fetches the details as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/get-file-details) +# Use `Pathname` to send the filename and/or avoid paging a large file into memory: +response = image_kit.files.upload(file: Pathname("/path/to/file")) -```ruby -imagekitio.get_file_details( - file_id: '598821f949c0a938d57563bd' -) -``` +# Alternatively, pass file contents or a `StringIO` directly: +response = image_kit.files.upload(file: File.read("/path/to/file")) -**Get File Metadata** +# Or, to control the filename and/or content type: +file = Imagekit::FilePart.new(File.read("/path/to/file"), filename: "/path/to/file", content_type: "…") +response = image_kit.files.upload(file: file) -Accepts the file ID and fetches the metadata as per the [API documentation here](https://docs.imagekit.io/api-reference/metadata-api/get-image-metadata-for-uploaded-media-files) -```ruby -imagekit.get_file_metadata( - file_id: '598821f949c0a938d57563bd' -) +puts(response.videoCodec) ``` -**Get File Metadata from remote url** +Note that you can also pass a raw `IO` descriptor, but this disables retries, as the library can't be sure if the descriptor is a file or pipe (which cannot be rewound). -Accepts the remote file url and fetches the metadata as per the [API documentation here](https://docs.imagekit.io/api-reference/metadata-api/get-image-metadata-from-remote-url) +### Handling errors -```ruby -imagekit.get_remote_file_url_metadata( - remote_file_url: "https://ik.imagekit.io/demo/tr:w-100/default-image.jpg" -) -``` - -**Update File Details** - -Update parameters associated with the file as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/update-file-details). -The first argument to the `update_field_details` method is the file ID, and a second argument is an object with the -parameters to be updated. +When the library is unable to connect to the API, or if the API returns a non-success status code (i.e., 4xx or 5xx response), a subclass of `Imagekit::Errors::APIError` will be thrown: ```ruby -imagekitio.update_file_details( - file_id: '598821f949c0a938d57563bd', - tags: ["image_tag"], - custom_coordinates: "10,10,100, 100" -) +begin + file = image_kit.files.upload( + file: StringIO.new("https://www.example.com/public-url.jpg"), + file_name: "file-name.jpg" + ) +rescue Imagekit::Errors::APIConnectionError => e + puts("The server could not be reached") + puts(e.cause) # an underlying Exception, likely raised within `net/http` +rescue Imagekit::Errors::RateLimitError => e + puts("A 429 status code was received; we should back off a bit.") +rescue Imagekit::Errors::APIStatusError => e + puts("Another non-200-range status code was received") + puts(e.status) +end ``` +Error codes are as follows: -**Update publish status** +| Cause | Error Type | +| ---------------- | -------------------------- | +| HTTP 400 | `BadRequestError` | +| HTTP 401 | `AuthenticationError` | +| HTTP 403 | `PermissionDeniedError` | +| HTTP 404 | `NotFoundError` | +| HTTP 409 | `ConflictError` | +| HTTP 422 | `UnprocessableEntityError` | +| HTTP 429 | `RateLimitError` | +| HTTP >= 500 | `InternalServerError` | +| Other HTTP error | `APIStatusError` | +| Timeout | `APITimeoutError` | +| Network error | `APIConnectionError` | -If `publish` is included in the update options, no other parameters are allowed. If any are present, an error will be returned: `Your request cannot contain any other parameters when publish is present`. +### Retries -```ruby -imagekitio.update_file_details( - file_id: '598821f949c0a938d57563bd', - publish:{ - isPublished: true, - includeFileVersions: true - } -) -``` +Certain errors will be automatically retried 2 times by default, with a short exponential backoff. -**Copy File** +Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict, 429 Rate Limit, >=500 Internal errors, and timeouts will all be retried by default. -Copy file from one path to another path using the source file path and the destination path as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/copy-file) +You can use the `max_retries` option to configure or disable this: ```ruby -imagekitio.copy_file( - source_file_path: '/path/to/file.jpg', - destination_path: '/folder/to/copy/into', - include_file_versions: true #default false +# Configure the default for all requests: +image_kit = Imagekit::Client.new( + max_retries: 0 # default is 2 ) -``` - -**Move File** -Move file from one folder to another folder using the source file path and destination path as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/move-file) - -```ruby -imagekitio.move_file( - source_file_path: '/path/to/file.jpg', - destination_path: '/folder/to/move/into/' +# Or, configure per-request: +image_kit.files.upload( + file: StringIO.new("https://www.example.com/public-url.jpg"), + file_name: "file-name.jpg", + request_options: {max_retries: 5} ) ``` -**Rename File** +### Timeouts -Rename file as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/rename-file) +By default, requests will time out after 60 seconds. You can use the timeout option to configure or disable this: ```ruby -imagekitio.rename_file( - file_path: '/path/to/old-file-name.jpg', - new_file_name: 'new-file-name.jpg', - purge_cache: true #optional +# Configure the default for all requests: +image_kit = Imagekit::Client.new( + timeout: nil # default is 60 ) -``` -**Delete File** - -Delete a file as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/delete-file). The method accepts the file ID of the file that has to be deleted. - -```ruby -imagekitio.delete_file( - file_id: '598821f949c0a938d57563bd' -) -``` -**File versions** - -Get all file versions as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/get-file-versions). The method accepts the file ID of the file. - -```ruby -imagekitio.file_versions( - file_id: '598821f949c0a938d57563bd' +# Or, configure per-request: +image_kit.files.upload( + file: StringIO.new("https://www.example.com/public-url.jpg"), + file_name: "file-name.jpg", + request_options: {timeout: 5} ) ``` -**File version details** - -Get all file version detail as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/get-file-version-details). The method accepts the file ID and version ID of the file. - -```ruby -imagekitio.file_version_detail( - file_id: '598821f949c0a938d57563bd', - version_id: '846321f949c0a938d57567ty' -) -``` - -**Delete file version** - -Delete file version as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/delete-file-version). The method accepts the file ID and version ID of the file. -```ruby -imagekitio.delete_file_version( - file_id: '598821f949c0a938d57563bd', - version_id: '846321f949c0a938d57567ty' -) -``` +On timeout, `Imagekit::Errors::APITimeoutError` is raised. -**Restore file version** +Note that requests that time out are retried by default. -Restore deleted file version as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/restore-file-version). The method accepts the file ID and version ID of the file. +## Advanced concepts -```ruby -imagekitio.restore_file_version( - file_id: '598821f949c0a938d57563bd', - version_id: '846321f949c0a938d57567ty' -) -``` +### BaseModel -**Bulk File Delete by IDs** +All parameter and response objects inherit from `Imagekit::Internal::Type::BaseModel`, which provides several conveniences, including: -Delete a file as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/delete-files-bulk). The method accepts a list of file IDs of files that has to be -deleted. +1. All fields, including unknown ones, are accessible with `obj[:prop]` syntax, and can be destructured with `obj => {prop: prop}` or pattern-matching syntax. -```ruby -imagekitio.delete_bulk_files( - file_ids: ["598821f949c0a938d57563bd", "598821f949c0a938d57543bd"] -) -``` +2. Structural equivalence for equality; if two API calls return the same values, comparing the responses with == will return true. -**Purge Cache** -Programmatically issue a clear cache request as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/purge-cache). -Accepts the full URL of the file for which the cache has to be cleared. +3. Both instances and the classes themselves can be pretty-printed. -```ruby -imagekitio.purge_file_cache( - file_url: 'https://ik.imagekit.io/demo/logo-white_SJwqB4Nfe.png' -) -``` -**Purge Cache Status** +4. Helpers such as `#to_h`, `#deep_to_h`, `#to_json`, and `#to_yaml`. -Get the purge cache request status using the request ID returned when a purge cache request gets submitted as per the -[API documentation here](https://docs.imagekit.io/api-reference/media-api/purge-cache-status) +### Making custom or undocumented requests -```ruby -imagekitio.purge_file_cache_status( - request_id: '598821f949c0a938d57543bd' -) -``` +#### Undocumented properties -**Add Bulk Tags** +You can send undocumented parameters to any endpoint, and read undocumented response properties, like so: -Add multiple tags on multiple files using an array of file ids and an array of tags as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/add-tags-bulk) +Note: the `extra_` parameters of the same name overrides the documented parameters. ```ruby -imagekitio.add_bulk_tags( - file_ids: ['598821f949c0a938d57543bd', '598921f949c0a938d57543bd'], - tags: ['custom_tags', 'image', 'favourite'] -) -``` - -**Delete Bulk Tags** - -Remove multiple tags from multiple files using an array of file ids and an array of tags as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/remove-tags-bulk) +response = + image_kit.files.upload( + file: StringIO.new("https://www.example.com/public-url.jpg"), + file_name: "file-name.jpg", + request_options: { + extra_query: {my_query_parameter: value}, + extra_body: {my_body_parameter: value}, + extra_headers: {"my-header": value} + } + ) -```ruby -imagekitio.delete_bulk_tags( - file_ids: ['598821f949c0a938d57543bd', '598921f949c0a938d57543bd'], - tags: ['custom_tags', 'image'] -) +puts(response[:my_undocumented_property]) ``` -**Delete Bulk AI Tags** +#### Undocumented request params -Delete bulk ai tags as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/remove-aitags-bulk) - -```ruby -imagekitio.delete_bulk_ai_tags( - file_ids: ['598821f949c0a938d57543bd', '598921f949c0a938d57543bd'], - ai_tags: ['custom_ai_tags'] -) -``` +If you want to explicitly send an extra param, you can do so with the `extra_query`, `extra_body`, and `extra_headers` under the `request_options:` parameter when making a request, as seen in the examples above. -**Create Folder** +#### Undocumented endpoints -Create folder as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/create-folder) +To make requests to undocumented endpoints while retaining the benefit of auth, retries, and so on, you can make requests using `client.request`, like so: ```ruby -imagekitio.create_folder( - folder_name: 'new_folder', - parent_folder_path: 'source/folder/path' #optional +response = client.request( + method: :post, + path: '/undocumented/endpoint', + query: {"dog": "woof"}, + headers: {"useful-header": "interesting-value"}, + body: {"hello": "world"} ) ``` +### Concurrency & connection pooling -**Copy Folder** +The `Imagekit::Client` instances are threadsafe, but are only are fork-safe when there are no in-flight HTTP requests. -Copy folder as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/copy-folder) +Each instance of `Imagekit::Client` has its own HTTP connection pool with a default size of 99. As such, we recommend instantiating the client once per application in most settings. -```ruby -imagekitio.copy_folder( - source_folder_path: '/folder/to/copy', - destination_path: '/folder/to/copy/into', - include_file_versions: true #default false -) -``` +When all available connections from the pool are checked out, requests wait for a new connection to become available, with queue time counting towards the request timeout. -**Move Folder** +Unless otherwise specified, other classes in the SDK do not have locks protecting their underlying data structure. -Move folder as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/move-folder) +## Sorbet -```ruby -imagekitio.move_folder( - source_folder_path: '/folder/to/move', - destination_path: '/folder/to/move/into/' -) -``` +This library provides comprehensive [RBI](https://sorbet.org/docs/rbi) definitions, and has no dependency on sorbet-runtime. -**Delete Folder** - -Delete folder as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/delete-folder) +You can provide typesafe request parameters like so: ```ruby -imagekitio.delete_folder( - folder_path: 'folder/to/delete' +image_kit.files.upload( + file: StringIO.new("https://www.example.com/public-url.jpg"), + file_name: "file-name.jpg" ) ``` -**Bulk Job Status** - -Get the bulk job status as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/copy-move-folder-status) +Or, equivalently: ```ruby -imagekitio.bulk_job_status( - job_id: '5e21880d5efe355febd4cccd' +# Hashes work, but are not typesafe: +image_kit.files.upload( + file: StringIO.new("https://www.example.com/public-url.jpg"), + file_name: "file-name.jpg" ) -``` - -**Create a custom metadata field** -Create custom metadata fields as per the [API documentation here](https://docs.imagekit.io/api-reference/custom-metadata-fields-api/create-custom-metadata-field) - -```ruby - -imagekitio.create_custom_metadata_field( - name: 'price', - label: 'price_label', - schema: { - 'type': 'Number', - 'minValue': 100, - 'maxValue': 300 - } +# You can also splat a full Params class: +params = Imagekit::FileUploadParams.new( + file: StringIO.new("https://www.example.com/public-url.jpg"), + file_name: "file-name.jpg" ) +image_kit.files.upload(**params) ``` -**Get Custom Metadata Fields** +### Enums -Get the custom metadata fields as per the [API documentation here](https://docs.imagekit.io/api-reference/custom-metadata-fields-api/get-custom-metadata-field) +Since this library does not depend on `sorbet-runtime`, it cannot provide [`T::Enum`](https://sorbet.org/docs/tenum) instances. Instead, we provide "tagged symbols" instead, which is always a primitive at runtime: ```ruby -imagekitio.get_custom_metadata_fields( - include_deleted: true #optional -) -``` - -**Update Custom Metadata Fields** - -Update custom metadata fields as per the [API documentation here](https://docs.imagekit.io/api-reference/custom-metadata-fields-api/update-custom-metadata-field) +# :all +puts(Imagekit::AssetListParams::FileType::ALL) -```ruby -imagekitio.update_custom_metadata_field( - id: '5e21880d5efe355febd4bccd', #field_id - label: 'custom-price', #Either label or schema or both should be given - schema: nil -) +# Revealed type: `T.all(Imagekit::AssetListParams::FileType, Symbol)` +T.reveal_type(Imagekit::AssetListParams::FileType::ALL) ``` -**Delete Custom Metadata Fields** - -Delete custom metadata fields as per the [API documentation here](https://docs.imagekit.io/api-reference/custom-metadata-fields-api/delete-custom-metadata-field) +Enum parameters have a "relaxed" type, so you can either pass in enum constants or their literal value: ```ruby -imagekitio.delete_custom_metadata_field( - id: '5e21880d5efe355febd4bccd' #field_id +# Using the enum constants preserves the tagged type information: +image_kit.assets.list( + file_type: Imagekit::AssetListParams::FileType::ALL, + # … ) -``` - -## Access request-id, other response headers and HTTP status code -Each media management function returns a hash with `response`, `error`, `status_code`, `headers`, `raw_body` keys with respective values. - -```ruby -upload = imagekitio.upload_file( - file: file, - file_name: "default.jpg", - folder: '/test', - response_fields: 'tags,customCoordinates,isPrivateFile,metadata', - tags: %w[abc def], - use_unique_file_name: false, - is_private_file: true +# Literal values are also permissible: +image_kit.assets.list( + file_type: :all, + # … ) -puts upload[:status_code] # 200 -puts upload[:headers] - -# { -# "access-control-allow-origin"=>["*"], -# "x-ik-requestid"=>["6963194e-014f-8945-b05a-bdb0e088f1bd"], -# "content-type"=>["application/json; charset=utf-8"], -# "content-length"=>["611"], -# "etag"=>["W/\"859-GOeZiRFGOZERjHBgRUhG0EGcODs\""], -# "date"=>["Wed, 29 Jun 2022 07:04:33 GMT"], -# "x-request-id"=>["6963194e-014f-8945-b05a-bdb0e088f1bd"], -# "connection"=>["close"] -# } - - -puts upload[:raw_body] -# "{\"fileId\":\"62bjf980rb886bd691b86760\",\"name\":\"default.jpg\",\"size\":102117,\"versionInfo\":{\"id\":\"62bjf980rb886bd691b86760\",\"name\":\"Version 1\"},\"filePath\":\"/test/default.jpg\",\"url\":\"https://ik.imagekit.io/46865sdf6sdf/test/default.jpg\",\"fileType\":\"image\",\"height\":700,\"width\":1050,\"thumbnailUrl\":\"https://ik.imagekit.io/46865sdf6sdf/tr:n-ik_ml_thumbnail/test/default.jpg\",\"tags\":[\"abc\",\"def\"],\"AITags\":null,\"isPrivateFile\":true,\"customCoordinates\":null,\"metadata\":{\"height\":700,\"width\":1050,\"size\":102117,\"format\":\"jpg\",\"hasColorProfile\":true,\"quality\":0,\"density\":72,\"hasTransparency\":false,\"exif\":{},\"pHash\":\"90249d9b1fc74367\"}}" -``` - -## Utility functions - -We have included the following commonly used utility functions in this package. - -**Authentication parameter generation** - -If you are looking to implement client-side file upload, you will need a `token`, `expiry` timestamp, and a valid `signature` for that upload. The SDK provides a simple method that you can use in your code to generate these authentication parameters for you. - -_Note: The Private API Key should never be exposed in any client-side code. You must always generate these authentication parameters on the server-side_ - -`authentication_parameters = imagekit.get_authentication_parameters(token, expire)` - -Returns - -```ruby -{ - "token": "unique_token", - "expire": "valid_expiry_timestamp", - "signature": "generated_signature" -} -``` - -Both the `token` and `expire` parameters are optional. If not specified, the SDK uses the uuid to generate a random token and also generates a valid expiry timestamp internally. The value of the `token` and `expire` used to generate the signature is always returned in the response, no matter if they are provided as an input to this method or not. - -**Distance calculation between two pHash values** - -Perceptual hashing allows you to construct a hash value that uniquely identifies an input image based on the contents -of an image. [imagekit.io metadata API](https://docs.imagekit.io/api-reference/metadata-api) returns the pHash -value of an image in the response. You can use this value to find a duplicate near the duplicate(similar) image by calculating -the distance between the two images. - - -This SDK exposes the `phash_distance` function to calculate the distance between two pHash values. It accepts two pHash hexadecimal -strings and returns a numeric value indicative of the level of difference between the two images. - -```ruby -def calculate_distance(): - # fetch metadata of two uploaded image files - ... - # extract pHash strings from both: say 'first_hash' and 'second_hash.' - ... - # calculate the distance between them: - - distance = imagekitio.phash_distance(first_hash, second_hash) - return distance ``` -**Distance calculation examples** - -```ruby -imagekitio.phash_distance('f06830ca9f1e3e90', 'f06830ca9f1e3e90') -# output: 0 (ame image) - -imagekitio.phash_distance('2d5ad3936d2e015b', '2d6ed293db36a4fb') -# output: 17 (similar images) - -imagekitio.phash_distance('a4a65595ac94518b', '7838873e791f8400') -# output: 37 (dissimilar images) -``` - -## Sample Application -There are three sample apps: - -* Rails application using Carrierwave -* Rails application using ActiveStorage -* Plain ruby application - -Please see the sample applications in [here](https://github.com/imagekit-samples/quickstart). +## Versioning -## Upgrade to 2.x +This package follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions. As the library is in initial development and has a major version of `0`, APIs may change at any time. -If you are upgrading to 2.x from version 1.x, make the following changes in your application: +This package considers improvements to the (non-runtime) `*.rbi` and `*.rbs` type definitions to be non-breaking changes. -- Remove config from environment file to initializer file as described [here](#Initialization). -- Include `ImageKitIo::CarrierWave` in uploader class(for Carrierwave). -- Remove `storage :imagekit_store` config from uploader. -- Rename class `ImageKit::ImageKitClient` to `ImageKitIo::Client` -- Rename class `ImageKitIo::ImageKitRequest` to `ImageKitIo::Request` +## Requirements -## Support -For any feedback or to report any issues or general implementation support, please reach out to [support@imagekit.io](mailto:support@imagekit.io) +Ruby 3.2.0 or higher. -## Links -- [Documentation](https://docs.imagekit.io) -- [Main website](https://imagekit.io) +## Contributing -## License -Released under the MIT license. +See [the contributing documentation](https://github.com/imagekit-developer/imagekit-ruby/tree/master/CONTRIBUTING.md). diff --git a/Rakefile b/Rakefile index 7457939a..6b5be685 100644 --- a/Rakefile +++ b/Rakefile @@ -1,27 +1,160 @@ -begin - require 'bundler/setup' -rescue LoadError - puts 'You must `gem install bundler` and `bundle install` to run rake tasks' +# frozen_string_literal: true + +require "pathname" +require "securerandom" +require "shellwords" + +require "minitest/test_task" +require "rake/clean" +require "rubocop/rake_task" + +tapioca = "sorbet/tapioca" +examples = "examples" +ignore_file = ".ignore" + +CLEAN.push(*%w[.idea/ .ruby-lsp/ .yardoc/ doc/], *FileList["*.gem"], ignore_file) + +CLOBBER.push(*%w[sorbet/rbi/annotations/ sorbet/rbi/gems/], tapioca) + +multitask(:default) do + sh(*%w[rake --tasks]) +end + +desc("Preview docs; use `PORT=` to change the port") +multitask(:"docs:preview") do + sh(*%w[yard server --reload --quiet --bind [::] --port], ENV.fetch("PORT", "8808")) +end + +desc("Run test suites; use `TEST=path/to/test.rb` to run a specific test file") +multitask(:test) do + rb = + FileList[ENV.fetch("TEST", "./test/**/*_test.rb")] + .map { "require_relative(#{_1.dump});" } + .join + + ruby(*%w[-w -e], rb, verbose: false) { fail unless _1 } +end + +xargs = %w[xargs --no-run-if-empty --null --max-procs=0 --max-args=300 --] +ruby_opt = {"RUBYOPT" => [ENV["RUBYOPT"], "--encoding=UTF-8"].compact.join(" ")} + +desc("Lint `*.rb(i)`") +multitask(:"lint:rubocop") do + find = %w[find ./lib ./test ./rbi ./examples -type f -and ( -name *.rb -or -name *.rbi ) -print0] + + rubocop = %w[rubocop] + rubocop += %w[--format github] if ENV.key?("CI") + + # some lines cannot be shortened + rubocop += %w[--except Lint/RedundantCopDisableDirective,Layout/LineLength] + + lint = xargs + rubocop + sh("#{find.shelljoin} | #{lint.shelljoin}") +end + +desc("Format `*.rb`") +multitask(:"format:rb") do + # while `syntax_tree` is much faster than `rubocop`, `rubocop` is the only formatter with full syntax support + find = %w[find ./lib ./test ./examples -type f -and -name *.rb -print0] + fmt = xargs + %w[rubocop --fail-level F --autocorrect --format simple --] + sh("#{find.shelljoin} | #{fmt.shelljoin}") end -require 'rdoc/task' +desc("Format `*.rbi`") +multitask(:"format:rbi") do + find = %w[find ./rbi -type f -and -name *.rbi -print0] + fmt = xargs + %w[stree write --] + sh(ruby_opt, "#{find.shelljoin} | #{fmt.shelljoin}") +end + +desc("Format `*.rbs`") +multitask(:"format:rbs") do + find = %w[find ./sig -type f -name *.rbs -print0] + inplace = /darwin|bsd/ =~ RUBY_PLATFORM ? ["-i", ""] : %w[-i] + uuid = SecureRandom.uuid + + # `syntax_tree` has trouble with `rbs`'s class & module aliases + + sed_bin = /darwin/ =~ RUBY_PLATFORM ? "/usr/bin/sed" : "sed" + sed = xargs + [sed_bin, "-E", *inplace, "-e"] + # annotate unprocessable aliases with a unique comment + pre = sed + ["s/(class|module) ([^ ]+) = (.+$)/# \\1 #{uuid}\\n\\2: \\3/", "--"] + fmt = xargs + %w[stree write --plugin=rbs --] + # remove the unique comment and unprocessable aliases to type aliases + subst = <<~SED + s/# (class|module) #{uuid}/\\1/ + t l1 + b + + : l1 + N + s/\\n *([^:]+): (.+)$/ \\1 = \\2/ + SED + # for each line: + # 1. try transform the unique comment into `class | module`, if successful, branch to label `l1`. + # 2. at label `l1`, join previously annotated line with `class | module` information. + pst = sed + [subst, "--"] -RDoc::Task.new(:rdoc) do |rdoc| - rdoc.rdoc_dir = 'rdoc' - rdoc.title = 'ImageKitIo::Sdk' - rdoc.options << '--line-numbers' - rdoc.rdoc_files.include('README.md') - rdoc.rdoc_files.include('lib/**/*.rb') + success = false + + # transform class aliases to type aliases, which syntax tree has no trouble with + sh("#{find.shelljoin} | #{pre.shelljoin}") + # run syntax tree to format `*.rbs` files + sh(ruby_opt, "#{find.shelljoin} | #{fmt.shelljoin}") do + success = _1 + end + # transform type aliases back to class aliases + sh("#{find.shelljoin} | #{pst.shelljoin}") + + # always run post-processing to remove comment marker + fail unless success end -require 'bundler/gem_tasks' +desc("Format everything") +multitask(format: [:"format:rb", :"format:rbi", :"format:rbs"]) -require 'rake/testtask' +desc("Typecheck `*.rbs`") +multitask(:"typecheck:steep") do + sh(*%w[steep check]) +end -Rake::TestTask.new(:test) do |t| - t.libs << 'test' - t.pattern = 'test/**/*_test.rb' - t.verbose = false +directory(examples) + +desc("Typecheck `*.rbi`") +multitask("typecheck:sorbet": examples) do + sh(*%w[srb typecheck --dir], examples) end -task default: :test +directory(tapioca) do + sh(*%w[tapioca init]) +end + +desc("Typecheck everything") +multitask(typecheck: [:"typecheck:steep", :"typecheck:sorbet"]) + +desc("Lint and typecheck") +multitask(lint: [:"lint:rubocop", :typecheck]) + +desc("Build yard docs") +multitask(:"build:docs") do + sh(*%w[yard]) +end + +desc("Build ruby gem") +multitask(:"build:gem") do + # optimizing for grepping through the gem bundle: many tools honour `.ignore` files, including VSCode + # + # both `rbi` and `sig` directories are navigable by their respective tool chains and therefore can be ignored by tools such as `rg` + Pathname(ignore_file).write(<<~GLOB) + rbi/* + sig/* + GLOB + + sh(*%w[gem build -- imagekit.gemspec]) + rm_rf(ignore_file) +end + +desc("Release ruby gem") +multitask(release: [:"build:gem"]) do + sh(*%w[gem push], *FileList["*.gem"]) +end diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 00000000..8e64327a --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,27 @@ +# Security Policy + +## Reporting Security Issues + +This SDK is generated by [Stainless Software Inc](http://stainless.com). Stainless takes security seriously, and encourages you to report any security vulnerability promptly so that appropriate action can be taken. + +To report a security issue, please contact the Stainless team at security@stainless.com. + +## Responsible Disclosure + +We appreciate the efforts of security researchers and individuals who help us maintain the security of +SDKs we generate. If you believe you have found a security vulnerability, please adhere to responsible +disclosure practices by allowing us a reasonable amount of time to investigate and address the issue +before making any information public. + +## Reporting Non-SDK Related Security Issues + +If you encounter security issues that are not directly related to SDKs but pertain to the services +or products provided by Image Kit, please follow the respective company's security reporting guidelines. + +### Image Kit Terms and Policies + +Please contact developer@imagekit.io for any questions or concerns regarding the security of our services. + +--- + +Thank you for helping us keep the SDKs and systems they interact with secure. diff --git a/Steepfile b/Steepfile new file mode 100644 index 00000000..528b48c3 --- /dev/null +++ b/Steepfile @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require "yaml" + +target(:lib) do + configure_code_diagnostics(Steep::Diagnostic::Ruby.strict) + + signature("sig") + + YAML.safe_load_file("./manifest.yaml", symbolize_names: true) => {dependencies:} + # currently these libraries lack the `*.rbs` annotations required by `steep` + stdlibs = dependencies - %w[English etc net/http rbconfig set stringio] + + stdlibs.each { library(_1) } +end diff --git a/bin/check-release-environment b/bin/check-release-environment new file mode 100644 index 00000000..c05436e8 --- /dev/null +++ b/bin/check-release-environment @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +errors=() + +if [ -z "${GEM_HOST_API_KEY}" ]; then + errors+=("The GEM_HOST_API_KEY secret has not been set. Please set it in either this repository's secrets or your organization secrets") +fi + +lenErrors=${#errors[@]} + +if [[ lenErrors -gt 0 ]]; then + echo -e "Found the following errors in the release environment:\n" + + for error in "${errors[@]}"; do + echo -e "- $error\n" + done + + exit 1 +fi + +echo "The environment is ready to push releases!" diff --git a/bin/publish-gem b/bin/publish-gem new file mode 100644 index 00000000..8444af20 --- /dev/null +++ b/bin/publish-gem @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -Eeuo pipefail + +cd -- "$(dirname -- "$0")/.." + +bundle +find . -maxdepth 1 -type f -name "*.gem" -delete +rake release \ No newline at end of file diff --git a/bin/test b/bin/test deleted file mode 100755 index 5516a12b..00000000 --- a/bin/test +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env ruby -$: << File.expand_path("../test", __dir__) - -require "bundler/setup" -require "rails/plugin/test" diff --git a/codecov.yml b/codecov.yml deleted file mode 100644 index 6e19fffc..00000000 --- a/codecov.yml +++ /dev/null @@ -1,22 +0,0 @@ -codecov: - require_ci_to_pass: yes - -coverage: - status: - patch: off - precision: 2 - round: down - range: "70...100" - -parsers: - gcov: - branch_detection: - conditional: yes - loop: yes - method: no - macro: no - -comment: - layout: "reach,diff,flags,tree" - behavior: default - require_changes: no diff --git a/examples/.keep b/examples/.keep new file mode 100644 index 00000000..d8c73e93 --- /dev/null +++ b/examples/.keep @@ -0,0 +1,4 @@ +File generated from our OpenAPI spec by Stainless. + +This directory can be used to store example files demonstrating usage of this SDK. +It is ignored by Stainless code generation and its content (other than this keep file) won't be touched. \ No newline at end of file diff --git a/imagekit.gemspec b/imagekit.gemspec new file mode 100644 index 00000000..f094efa0 --- /dev/null +++ b/imagekit.gemspec @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +require_relative "lib/imagekit/version" + +Gem::Specification.new do |s| + s.name = "imagekit" + s.version = Imagekit::VERSION + s.summary = "Ruby library to access the Image Kit API" + s.authors = ["Image Kit"] + s.email = "developer@imagekit.io" + s.homepage = "https://gemdocs.org/gems/imagekit" + s.metadata["homepage_uri"] = s.homepage + s.metadata["source_code_uri"] = "https://github.com/imagekit-developer/imagekit-ruby" + s.metadata["rubygems_mfa_required"] = false.to_s + s.required_ruby_version = ">= 3.2.0" + + s.files = Dir[ + "lib/**/*.rb", + "rbi/**/*.rbi", + "sig/**/*.rbs", + "manifest.yaml", + "SECURITY.md", + "CHANGELOG.md", + ".ignore" + ] + s.extra_rdoc_files = ["README.md"] + s.add_dependency "connection_pool" +end diff --git a/imagekitio.gemspec b/imagekitio.gemspec deleted file mode 100644 index e44548d9..00000000 --- a/imagekitio.gemspec +++ /dev/null @@ -1,34 +0,0 @@ -$:.push File.expand_path("lib", __dir__) - -# Maintain your gem's version: -require "imagekitio/sdk/version" - -# Describe your gem and declare its dependencies: -Gem::Specification.new do |spec| - spec.name = "imagekitio" - spec.version = ImageKitIo::Sdk::VERSION - spec.authors = ["ImageKit.io team"] - spec.email = ["developer@imagekit.io"] - spec.homepage = "https://imagekit.io" - spec.summary = "Automate image optimization on rails platforms." - spec.description = "Automate image optimization on rails platforms." - spec.license = "MIT" - - # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host' - # to allow pushing to a single host or delete this section to allow pushing to any host. - if spec.respond_to?(:metadata) - spec.metadata["allowed_push_host"] = "https://rubygems.org" - else - raise "RubyGems 2.0 or newer is required to protect against " \ - "public gem pushes." - end - - spec.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"] - - spec.add_dependency "addressable", "~> 2.8" - spec.add_dependency "multipart-post", ">= 2.1.0" - spec.add_dependency "rest-client", "~> 2.1", ">=2.1" - spec.add_development_dependency "activestorage", ">= 5.2.0" - spec.add_development_dependency "carrierwave", ">= 0.7", "<= 2.2.1" - spec.add_development_dependency "rails", "~> 5.2.0", ">= 5.2.0" -end diff --git a/lib/active_storage/active_storage.rb b/lib/active_storage/active_storage.rb deleted file mode 100644 index 67565d12..00000000 --- a/lib/active_storage/active_storage.rb +++ /dev/null @@ -1,7 +0,0 @@ -begin - require 'active_storage' - rescue LoadError - puts "Add gem 'activestorage' to use this service" - end - require_relative './service/ik_file' - require_relative './service/image_kit_io_service' diff --git a/lib/active_storage/service/ik_file.rb b/lib/active_storage/service/ik_file.rb deleted file mode 100644 index 9b2b8f08..00000000 --- a/lib/active_storage/service/ik_file.rb +++ /dev/null @@ -1,115 +0,0 @@ -module ImageKiIo - module ActiveStorage - class IKFile - attr_accessor :identifier - - def initialize(identifier) - @identifier = identifier - @imagekit = ImageKitIo.client - end - - def url - identifier['url'] - end - - def delete - begin - @imagekit.delete_file(file_id: file_id) - rescue - file_id - end - end - - def file_type - identifier['fileType'] - end - - def thumbnail_url - identifier['thumbnail'] - end - - def filename - identifier['name'] - end - - def size - identifier['size'] - end - - def path - identifier['filePath'] - end - - def height - identifier['height'] - end - - def width - identifier['width'] - end - - def file_id - identifier['fileId'] - end - - def exist? - details = @imagekit.get_file_details(file_id: file_id) - return false if details[:error].present? - - true - end - - def type - identifier['type'] - end - - def tags - identifier['tags'] - end - - def ai_tags - identifier['AITags'] - end - - def is_private? - identifier['isPrivateFile'] - end - - def custom_coordinates - identifier['customCoordinates'] - end - - def mime - identifier['mime'] - end - - def alpha? - identifier['hasAlpha'] - end - - def custom_metadata - identifier['customMetadata'] - end - - def embedded_metadata - identifier['embeddedMetadata'] - end - - def created_at - identifier['createdAt'] - end - - def updated_at - identifier['updatedAt'] - end - - def extension_status - identifier['extensionStatus'] - end - - def transformation - identifier['transformation'] - end - end - end -end diff --git a/lib/active_storage/service/image_kit_io_service.rb b/lib/active_storage/service/image_kit_io_service.rb deleted file mode 100644 index 41a6390b..00000000 --- a/lib/active_storage/service/image_kit_io_service.rb +++ /dev/null @@ -1,188 +0,0 @@ -require_relative './ik_file' - -if defined? Rails - # Overwrite the ActiveStorage::Downloader's open method and remove the file integrity check constraint method verify_integrity_of - class DownloaderExtension < ::ActiveStorage::Downloader - def open(key, checksum:, name: "ActiveStorage-", tmpdir: nil, **options) - open_tempfile(name, tmpdir) do |file| - download key, file - # verify_integrity_of file, checksum: checksum - yield file - end - end - end - - module ActiveStorageBlobExtension - def self.included(base) - base.class_eval do - before_update :check_metadata - before_destroy :remove_imagekit_file - # ActiveRecord::Blob class first destroy the record data and then calls the service.delete method with key - # as an argument. But the imagekit.io needs fileId to destroy the file which can be get from the metadata. - # So first destroy the remote file and then destroy the local blob record. - def remove_imagekit_file - service.class.delete_ik_file(self) - end - - def remote_file_exist? - service.exist?(self.key) - end - - def remote_file - return false unless remote_file_exist? - - service.class.remote_file(self) - end - - # Needs to reload the record to reflect updated remote meta data. - def check_metadata - self.reload - end - end - end - end - - Rails.application.config.to_prepare do - ActiveStorage::Blob.send :include, ::ActiveStorageBlobExtension - end - - module ActiveStorage - class Service::ImageKitIoService < Service - include ImageKitIo::Constantable - - class << self - def delete_ik_file(blob) - ik_file(blob).delete - end - - def remote_file(blob) - ik_file(blob) - end - - def ik_file(blob) - self.new.send(:ik_file).new(blob.metadata) - end - end - - def initialize(**options) - @options = options - end - - def upload(key, io, checksum: nil, **options) - instrument :upload, key: key, checksum: checksum do - blob = storage_blob(key) - response = client.upload_file(file: io, file_name: blob.filename.to_s, content_type: blob.content_type) - if response[:error].nil? - blob.update_columns(metadata: response[:response].transform_keys(&:to_sym)) - else - raise Exception.new response[:error] - end - end - end - - def download(key, &block) - if block_given? - instrument :stream_file, key: key do - stream_file(key, &block) - end - else - instrument :download, key: key do - image_kit_file(key) - end - end - end - - def download_chunk(key, range) - puts 'Not implemented download_chunk' - end - - def delete(key) - instrument :delete, key: key do - # image kit file is already deleted on before blob destroy callback - key - end - end - - def delete_prefixed(prefix) - # delete the variants files - puts 'Not implemented delete_prefixed' - end - - def exist?(key) - image_kit_file(key).exist? - end - - def url_for_direct_upload(key, **options) - instrument :url, key: key do |payload| - options.delete(:content_length) - options.delete(:checksum) - url = "#{constants.BASE_URL}#{constants.UPLOAD}" - generated_url = client.url(src: url) - payload[:url] = generated_url - generated_url - end - end - - def headers_for_direct_upload(key, content_type:, checksum:, **options) - { - 'Content-Type' => content_type - } - end - - def path_for(key) - image_kit_file(key).path - end - - def url(key, filename: nil, content_type: '', **options) - generate_url(key, filename: filename, content_type: content_type, path: image_kit_file(key).path, **options) - end - - def open(*args, **options, &block) - DownloaderExtension.new(self).open(*args, **options, &block) - end - - private - - def private_url(key, expires_in:, filename:, disposition:, content_type:, **options) - generate_url(key, expires_in: expires_in, filename: filename, disposition: disposition, content_type: content_type, path: image_kit_file(key).path, **options) - end - - def generate_url(key, expires_in:, filename:, content_type:, disposition:, **options) - # filename = filename.to_s if filename.is_a? ActiveStorage::Filename - # options[:filename] = filename if filename - client.url(url_endpoint: config.url_endpoint, **options) - end - - def client - ImageKitIo.client - end - - def config - ImageKitIo.config - end - - def storage_blob(key) - ActiveStorage::Blob.find_by_key(key) - end - - def image_kit_file(key) - blob = storage_blob(key) - ik_file.new(blob.metadata) - end - - def ik_file - ImageKiIo::ActiveStorage::IKFile - end - - def stream_file(key, &download_block) - file_obj = image_kit_file(key) - block = proc { |response| - response.read_body do |chunk| - download_block.call(chunk) if download_block.present? - end - } - client.stream_file(file_url: file_obj.url, &block) - end - end - end -end diff --git a/lib/carrierwave/carrierwave.rb b/lib/carrierwave/carrierwave.rb deleted file mode 100644 index 1c589da4..00000000 --- a/lib/carrierwave/carrierwave.rb +++ /dev/null @@ -1,83 +0,0 @@ -begin - require 'carrierwave' -rescue LoadError - puts "Add gem 'carrierwave' to use this service" -end -require_relative './storage/imagekit_store' -require_relative './storage/ik_file' -require_relative './support/uri_filename' - -module ImageKitIo - module CarrierWave - def self.included(base) - base.include InstanceMethods - base.class_eval do - configure do |config| - config.storage_engines[:imagekit_store] = 'ImageKitIo::CarrierWave::Storage::ImageKitStore' - end - end - base.storage :imagekit_store - end - - module InstanceMethods - def initialize(*) - @imagekit = ImageKitIo.client - @options = {} - end - - def filename - if options != nil - @options = options - end - folder = nil - begin - folder = store_dir - rescue - end - - if folder != nil - @options[:folder] = folder - end - - if self.file != nil - resp = @imagekit.upload_file(file: open(self.file.file, 'rb'), file_name: self.file.filename, **@options) - # ::File.delete(self.file.file) - res = resp[:response].to_json - if res != "null" - res - else - "{\"filePath\":\"\",\"url\":\"\",\"name\":\"\"}" - end - else - "{\"filePath\":\"\",\"url\":\"\",\"name\":\"\"}" - end - end - - def fileId - JSON.parse(self.identifier)['fileId'] - end - - def blob - JSON.parse(self.identifier) - end - - def url_with(opt) - path = JSON.parse(self.identifier)['filePath'] - opt[:path] = path - url = @imagekit.url(opt) - end - - def url - JSON.parse(self.identifier)['url'] - end - - def options - options = {} - end - - def store_dir - store_dir = nil - end - end - end -end diff --git a/lib/carrierwave/storage/ik_file.rb b/lib/carrierwave/storage/ik_file.rb deleted file mode 100644 index f76811bf..00000000 --- a/lib/carrierwave/storage/ik_file.rb +++ /dev/null @@ -1,51 +0,0 @@ -module ImageKitIo - module CarrierWave - module Storage - class IKFile - # Initialize as required. - - def initialize(identifier) - @identifier=JSON.parse(identifier) - @imagekit = ImageKitIo.client - end - - # Duck-type methods for CarrierWave::SanitizedFile. - def content_type - "image/jpg" - end - def public_url - @identifier['url'] - end - def url(options = {}) - @identifier['url'] - end - - def fileId - @identifier['fileId'] - end - def filename(options = {}) - @identifier['name'] - end - def read - end - def size - end - def delete - # file_id=@identifier['fileId'] - begin - @imagekit.delete_file(file_id: fileId) - rescue - fileId - end - # binding.pry - # return nil - end - def exists? - end - # Others... ? - end - - end - - end -end diff --git a/lib/carrierwave/storage/imagekit_store.rb b/lib/carrierwave/storage/imagekit_store.rb deleted file mode 100644 index 5d00c74b..00000000 --- a/lib/carrierwave/storage/imagekit_store.rb +++ /dev/null @@ -1,68 +0,0 @@ -require 'uri' -require 'net/http' -require 'base64' - -module ImageKitIo - module CarrierWave - module Storage - class ImageKitStore < ::CarrierWave::Storage::Abstract - - def initialize(*) - super - @cache_called = nil - end - - def store!(file) - file.delete - end - - def retrieve!(identifier) - - IKFile.new(identifier) - end - - def cache!(new_file) - new_file.move_to(::File.expand_path(uploader.cache_path, uploader.root), uploader.permissions, uploader.directory_permissions, true) - rescue Errno::EMLINK, Errno::ENOSPC => e - raise(e) if @cache_called - @cache_called = true - - # NOTE: Remove cached files older than 10 minutes - clean_cache!(600) - - cache!(new_file) - end - - def retrieve_from_cache!(identifier) - CarrierWave::SanitizedFile.new(::File.expand_path(uploader.cache_path(identifier), uploader.root)) - end - - def delete_dir!(path) - if path - begin - Dir.rmdir(::File.expand_path(path, uploader.root)) - rescue Errno::ENOENT - # Ignore: path does not exist - rescue Errno::ENOTDIR - # Ignore: path is not a dir - rescue Errno::ENOTEMPTY, Errno::EEXIST - # Ignore: dir is not empty - end - end - end - - def clean_cache!(seconds) - Dir.glob(::File.expand_path(::File.join(uploader.cache_dir, '*'), CarrierWave.root)).each do |dir| - # generate_cache_id returns key formated TIMEINT-PID(-COUNTER)-RND - time = dir.scan(/(\d+)-\d+-\d+(?:-\d+)?/).first.map(&:to_i) - time = Time.at(*time) - if time < (Time.now.utc - seconds) - FileUtils.rm_rf(dir) - end - end - end - - end - end - end -end diff --git a/lib/carrierwave/support/uri_filename.rb b/lib/carrierwave/support/uri_filename.rb deleted file mode 100644 index f5d45430..00000000 --- a/lib/carrierwave/support/uri_filename.rb +++ /dev/null @@ -1,12 +0,0 @@ -module ImageKitIo - module CarrierWave - module Support - module UriFilename - def self.filename(url) - path = url.split('?').first - URI.decode(path).gsub(%r{.*/(.*?$)}, '\1') - end - end - end - end -end diff --git a/lib/imagekit.rb b/lib/imagekit.rb new file mode 100644 index 00000000..a6f92b0c --- /dev/null +++ b/lib/imagekit.rb @@ -0,0 +1,177 @@ +# frozen_string_literal: true + +# Standard libraries. +# rubocop:disable Lint/RedundantRequireStatement +require "English" +require "cgi" +require "date" +require "erb" +require "etc" +require "json" +require "net/http" +require "pathname" +require "rbconfig" +require "securerandom" +require "set" +require "stringio" +require "time" +require "uri" +# rubocop:enable Lint/RedundantRequireStatement + +# We already ship the preferred sorbet manifests in the package itself. +# `tapioca` currently does not offer us a way to opt out of unnecessary compilation. +if Object.const_defined?(:Tapioca) && + caller.chain([$PROGRAM_NAME]).chain(ARGV).any?(/tapioca/) && + ARGV.none?(/dsl/) + return +end + +# Gems. +require "connection_pool" + +# Package files. +require_relative "imagekit/version" +require_relative "imagekit/internal/util" +require_relative "imagekit/internal/type/converter" +require_relative "imagekit/internal/type/unknown" +require_relative "imagekit/internal/type/boolean" +require_relative "imagekit/internal/type/file_input" +require_relative "imagekit/internal/type/enum" +require_relative "imagekit/internal/type/union" +require_relative "imagekit/internal/type/array_of" +require_relative "imagekit/internal/type/hash_of" +require_relative "imagekit/internal/type/base_model" +require_relative "imagekit/internal/type/base_page" +require_relative "imagekit/internal/type/request_parameters" +require_relative "imagekit/internal" +require_relative "imagekit/request_options" +require_relative "imagekit/file_part" +require_relative "imagekit/errors" +require_relative "imagekit/internal/transport/base_client" +require_relative "imagekit/internal/transport/pooled_net_requester" +require_relative "imagekit/client" +require_relative "imagekit/models/accounts/origin_request" +require_relative "imagekit/models/accounts/url_endpoint_request" +require_relative "imagekit/models/update_file_request" +require_relative "imagekit/models/file" +require_relative "imagekit/models/base_overlay" +require_relative "imagekit/models/base_webhook_event" +require_relative "imagekit/models/accounts/origin_create_params" +require_relative "imagekit/models/accounts/origin_delete_params" +require_relative "imagekit/models/accounts/origin_get_params" +require_relative "imagekit/models/accounts/origin_list_params" +require_relative "imagekit/models/accounts/origin_list_response" +require_relative "imagekit/models/accounts/origin_response" +require_relative "imagekit/models/accounts/origin_update_params" +require_relative "imagekit/models/accounts/url_endpoint_create_params" +require_relative "imagekit/models/accounts/url_endpoint_delete_params" +require_relative "imagekit/models/accounts/url_endpoint_get_params" +require_relative "imagekit/models/accounts/url_endpoint_list_params" +require_relative "imagekit/models/accounts/url_endpoint_list_response" +require_relative "imagekit/models/accounts/url_endpoint_response" +require_relative "imagekit/models/accounts/url_endpoint_update_params" +require_relative "imagekit/models/accounts/usage_get_params" +require_relative "imagekit/models/accounts/usage_get_response" +require_relative "imagekit/models/asset_list_params" +require_relative "imagekit/models/asset_list_response" +require_relative "imagekit/models/beta/v2/file_upload_params" +require_relative "imagekit/models/beta/v2/file_upload_response" +require_relative "imagekit/models/cache/invalidation_create_params" +require_relative "imagekit/models/cache/invalidation_create_response" +require_relative "imagekit/models/cache/invalidation_get_params" +require_relative "imagekit/models/cache/invalidation_get_response" +require_relative "imagekit/models/custom_metadata_field" +require_relative "imagekit/models/custom_metadata_field_create_params" +require_relative "imagekit/models/custom_metadata_field_delete_params" +require_relative "imagekit/models/custom_metadata_field_delete_response" +require_relative "imagekit/models/custom_metadata_field_list_params" +require_relative "imagekit/models/custom_metadata_field_list_response" +require_relative "imagekit/models/custom_metadata_field_update_params" +require_relative "imagekit/models/extensions" +require_relative "imagekit/models/file_copy_params" +require_relative "imagekit/models/file_copy_response" +require_relative "imagekit/models/file_delete_params" +require_relative "imagekit/models/file_get_params" +require_relative "imagekit/models/file_move_params" +require_relative "imagekit/models/file_move_response" +require_relative "imagekit/models/file_rename_params" +require_relative "imagekit/models/file_rename_response" +require_relative "imagekit/models/files/bulk_add_tags_params" +require_relative "imagekit/models/files/bulk_add_tags_response" +require_relative "imagekit/models/files/bulk_delete_params" +require_relative "imagekit/models/files/bulk_delete_response" +require_relative "imagekit/models/files/bulk_remove_ai_tags_params" +require_relative "imagekit/models/files/bulk_remove_ai_tags_response" +require_relative "imagekit/models/files/bulk_remove_tags_params" +require_relative "imagekit/models/files/bulk_remove_tags_response" +require_relative "imagekit/models/files/metadata_get_from_url_params" +require_relative "imagekit/models/files/metadata_get_params" +require_relative "imagekit/models/files/version_delete_params" +require_relative "imagekit/models/files/version_delete_response" +require_relative "imagekit/models/files/version_get_params" +require_relative "imagekit/models/files/version_list_params" +require_relative "imagekit/models/files/version_list_response" +require_relative "imagekit/models/files/version_restore_params" +require_relative "imagekit/models/file_update_params" +require_relative "imagekit/models/file_update_response" +require_relative "imagekit/models/file_upload_params" +require_relative "imagekit/models/file_upload_response" +require_relative "imagekit/models/folder" +require_relative "imagekit/models/folder_copy_params" +require_relative "imagekit/models/folder_copy_response" +require_relative "imagekit/models/folder_create_params" +require_relative "imagekit/models/folder_create_response" +require_relative "imagekit/models/folder_delete_params" +require_relative "imagekit/models/folder_delete_response" +require_relative "imagekit/models/folder_move_params" +require_relative "imagekit/models/folder_move_response" +require_relative "imagekit/models/folder_rename_params" +require_relative "imagekit/models/folder_rename_response" +require_relative "imagekit/models/folders/job_get_params" +require_relative "imagekit/models/folders/job_get_response" +require_relative "imagekit/models/image_overlay" +require_relative "imagekit/models/metadata" +require_relative "imagekit/models/overlay" +require_relative "imagekit/models/overlay_position" +require_relative "imagekit/models/overlay_timing" +require_relative "imagekit/models/solid_color_overlay" +require_relative "imagekit/models/solid_color_overlay_transformation" +require_relative "imagekit/models/src_options" +require_relative "imagekit/models/streaming_resolution" +require_relative "imagekit/models/subtitle_overlay" +require_relative "imagekit/models/subtitle_overlay_transformation" +require_relative "imagekit/models/text_overlay" +require_relative "imagekit/models/text_overlay_transformation" +require_relative "imagekit/models/transformation" +require_relative "imagekit/models/transformation_position" +require_relative "imagekit/models/unsafe_unwrap_webhook_event" +require_relative "imagekit/models/unwrap_webhook_event" +require_relative "imagekit/models/upload_post_transform_error_event" +require_relative "imagekit/models/upload_post_transform_success_event" +require_relative "imagekit/models/upload_pre_transform_error_event" +require_relative "imagekit/models/upload_pre_transform_success_event" +require_relative "imagekit/models/video_overlay" +require_relative "imagekit/models/video_transformation_accepted_event" +require_relative "imagekit/models/video_transformation_error_event" +require_relative "imagekit/models/video_transformation_ready_event" +require_relative "imagekit/models/webhook_unsafe_unwrap_params" +require_relative "imagekit/models/webhook_unwrap_params" +require_relative "imagekit/models" +require_relative "imagekit/resources/accounts" +require_relative "imagekit/resources/accounts/origins" +require_relative "imagekit/resources/accounts/url_endpoints" +require_relative "imagekit/resources/accounts/usage" +require_relative "imagekit/resources/assets" +require_relative "imagekit/resources/beta" +require_relative "imagekit/resources/beta/v2" +require_relative "imagekit/resources/beta/v2/files" +require_relative "imagekit/resources/cache" +require_relative "imagekit/resources/cache/invalidation" +require_relative "imagekit/resources/custom_metadata_fields" +require_relative "imagekit/resources/files" +require_relative "imagekit/resources/files/bulk" +require_relative "imagekit/resources/files/metadata" +require_relative "imagekit/resources/files/versions" +require_relative "imagekit/resources/folders" +require_relative "imagekit/resources/folders/job" +require_relative "imagekit/resources/webhooks" diff --git a/lib/imagekit/client.rb b/lib/imagekit/client.rb new file mode 100644 index 00000000..e3f5f7c3 --- /dev/null +++ b/lib/imagekit/client.rb @@ -0,0 +1,125 @@ +# frozen_string_literal: true + +module Imagekit + class Client < Imagekit::Internal::Transport::BaseClient + # Default max number of retries to attempt after a failed retryable request. + DEFAULT_MAX_RETRIES = 2 + + # Default per-request timeout. + DEFAULT_TIMEOUT_IN_SECONDS = 60.0 + + # Default initial retry delay in seconds. + # Overall delay is calculated using exponential backoff + jitter. + DEFAULT_INITIAL_RETRY_DELAY = 0.5 + + # Default max retry delay in seconds. + DEFAULT_MAX_RETRY_DELAY = 8.0 + + # Your ImageKit private API key (starts with `private_`). You can find this in the + # [ImageKit dashboard](https://imagekit.io/dashboard/developer/api-keys). + # @return [String] + attr_reader :private_key + + # ImageKit uses your API key as username and ignores the password. The SDK sets a + # dummy value. You can ignore this field. + # @return [String, nil] + attr_reader :password + + # @return [Imagekit::Resources::CustomMetadataFields] + attr_reader :custom_metadata_fields + + # @return [Imagekit::Resources::Files] + attr_reader :files + + # @return [Imagekit::Resources::Assets] + attr_reader :assets + + # @return [Imagekit::Resources::Cache] + attr_reader :cache + + # @return [Imagekit::Resources::Folders] + attr_reader :folders + + # @return [Imagekit::Resources::Accounts] + attr_reader :accounts + + # @return [Imagekit::Resources::Beta] + attr_reader :beta + + # @return [Imagekit::Resources::Webhooks] + attr_reader :webhooks + + # @api private + # + # @return [Hash{String=>String}] + private def auth_headers + return {} if @private_key.nil? || @password.nil? + + base64_credentials = ["#{@private_key}:#{@password}"].pack("m0") + {"authorization" => "Basic #{base64_credentials}"} + end + + # @api private + # + # @return [Boolean] + def base_url_overridden? = @base_url_overridden + + # Creates and returns a new client for interacting with the API. + # + # @param private_key [String, nil] Your ImageKit private API key (starts with `private_`). You can find this in the + # [ImageKit dashboard](https://imagekit.io/dashboard/developer/api-keys). Defaults + # to `ENV["IMAGEKIT_PRIVATE_KEY"]` + # + # @param password [String, nil] ImageKit uses your API key as username and ignores the password. The SDK sets a + # dummy value. You can ignore this field. Defaults to + # `ENV["OPTIONAL_IMAGEKIT_IGNORES_THIS"]` + # + # @param base_url [String, nil] Override the default base URL for the API, e.g., + # `"https://api.example.com/v2/"`. Defaults to `ENV["IMAGE_KIT_BASE_URL"]` + # + # @param max_retries [Integer] Max number of retries to attempt after a failed retryable request. + # + # @param timeout [Float] + # + # @param initial_retry_delay [Float] + # + # @param max_retry_delay [Float] + def initialize( + private_key: ENV["IMAGEKIT_PRIVATE_KEY"], + password: ENV.fetch("OPTIONAL_IMAGEKIT_IGNORES_THIS", "do_not_set"), + base_url: ENV["IMAGE_KIT_BASE_URL"], + max_retries: self.class::DEFAULT_MAX_RETRIES, + timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS, + initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY, + max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY + ) + @base_url_overridden = !base_url.nil? + + base_url ||= "https://api.imagekit.io" + + if private_key.nil? + raise ArgumentError.new("private_key is required, and can be set via environ: \"IMAGEKIT_PRIVATE_KEY\"") + end + + @private_key = private_key.to_s + @password = password.to_s + + super( + base_url: base_url, + timeout: timeout, + max_retries: max_retries, + initial_retry_delay: initial_retry_delay, + max_retry_delay: max_retry_delay + ) + + @custom_metadata_fields = Imagekit::Resources::CustomMetadataFields.new(client: self) + @files = Imagekit::Resources::Files.new(client: self) + @assets = Imagekit::Resources::Assets.new(client: self) + @cache = Imagekit::Resources::Cache.new(client: self) + @folders = Imagekit::Resources::Folders.new(client: self) + @accounts = Imagekit::Resources::Accounts.new(client: self) + @beta = Imagekit::Resources::Beta.new(client: self) + @webhooks = Imagekit::Resources::Webhooks.new(client: self) + end + end +end diff --git a/lib/imagekit/errors.rb b/lib/imagekit/errors.rb new file mode 100644 index 00000000..354509a3 --- /dev/null +++ b/lib/imagekit/errors.rb @@ -0,0 +1,228 @@ +# frozen_string_literal: true + +module Imagekit + module Errors + class Error < StandardError + # @!attribute cause + # + # @return [StandardError, nil] + end + + class ConversionError < Imagekit::Errors::Error + # @return [StandardError, nil] + def cause = @cause.nil? ? super : @cause + + # @api private + # + # @param on [Class] + # @param method [Symbol] + # @param target [Object] + # @param value [Object] + # @param cause [StandardError, nil] + def initialize(on:, method:, target:, value:, cause: nil) + cls = on.name.split("::").last + + message = [ + "Failed to parse #{cls}.#{method} from #{value.class} to #{target.inspect}.", + "To get the unparsed API response, use #{cls}[#{method.inspect}].", + cause && "Cause: #{cause.message}" + ].filter(&:itself).join(" ") + + @cause = cause + super(message) + end + end + + class APIError < Imagekit::Errors::Error + # @return [URI::Generic] + attr_accessor :url + + # @return [Integer, nil] + attr_accessor :status + + # @return [Hash{String=>String}, nil] + attr_accessor :headers + + # @return [Object, nil] + attr_accessor :body + + # @api private + # + # @param url [URI::Generic] + # @param status [Integer, nil] + # @param headers [Hash{String=>String}, nil] + # @param body [Object, nil] + # @param request [nil] + # @param response [nil] + # @param message [String, nil] + def initialize(url:, status: nil, headers: nil, body: nil, request: nil, response: nil, message: nil) + @url = url + @status = status + @headers = headers + @body = body + @request = request + @response = response + super(message) + end + end + + class APIConnectionError < Imagekit::Errors::APIError + # @!attribute status + # + # @return [nil] + + # @!attribute body + # + # @return [nil] + + # @api private + # + # @param url [URI::Generic] + # @param status [nil] + # @param headers [Hash{String=>String}, nil] + # @param body [nil] + # @param request [nil] + # @param response [nil] + # @param message [String, nil] + def initialize( + url:, + status: nil, + headers: nil, + body: nil, + request: nil, + response: nil, + message: "Connection error." + ) + super + end + end + + class APITimeoutError < Imagekit::Errors::APIConnectionError + # @api private + # + # @param url [URI::Generic] + # @param status [nil] + # @param headers [Hash{String=>String}, nil] + # @param body [nil] + # @param request [nil] + # @param response [nil] + # @param message [String, nil] + def initialize( + url:, + status: nil, + headers: nil, + body: nil, + request: nil, + response: nil, + message: "Request timed out." + ) + super + end + end + + class APIStatusError < Imagekit::Errors::APIError + # @api private + # + # @param url [URI::Generic] + # @param status [Integer] + # @param headers [Hash{String=>String}, nil] + # @param body [Object, nil] + # @param request [nil] + # @param response [nil] + # @param message [String, nil] + # + # @return [self] + def self.for(url:, status:, headers:, body:, request:, response:, message: nil) + kwargs = + { + url: url, + status: status, + headers: headers, + body: body, + request: request, + response: response, + message: message + } + + case status + in 400 + Imagekit::Errors::BadRequestError.new(**kwargs) + in 401 + Imagekit::Errors::AuthenticationError.new(**kwargs) + in 403 + Imagekit::Errors::PermissionDeniedError.new(**kwargs) + in 404 + Imagekit::Errors::NotFoundError.new(**kwargs) + in 409 + Imagekit::Errors::ConflictError.new(**kwargs) + in 422 + Imagekit::Errors::UnprocessableEntityError.new(**kwargs) + in 429 + Imagekit::Errors::RateLimitError.new(**kwargs) + in (500..) + Imagekit::Errors::InternalServerError.new(**kwargs) + else + Imagekit::Errors::APIStatusError.new(**kwargs) + end + end + + # @!parse + # # @return [Integer] + # attr_accessor :status + + # @api private + # + # @param url [URI::Generic] + # @param status [Integer] + # @param headers [Hash{String=>String}, nil] + # @param body [Object, nil] + # @param request [nil] + # @param response [nil] + # @param message [String, nil] + def initialize(url:, status:, headers:, body:, request:, response:, message: nil) + message ||= {url: url.to_s, status: status, body: body} + super( + url: url, + status: status, + headers: headers, + body: body, + request: request, + response: response, + message: message&.to_s + ) + end + end + + class BadRequestError < Imagekit::Errors::APIStatusError + HTTP_STATUS = 400 + end + + class AuthenticationError < Imagekit::Errors::APIStatusError + HTTP_STATUS = 401 + end + + class PermissionDeniedError < Imagekit::Errors::APIStatusError + HTTP_STATUS = 403 + end + + class NotFoundError < Imagekit::Errors::APIStatusError + HTTP_STATUS = 404 + end + + class ConflictError < Imagekit::Errors::APIStatusError + HTTP_STATUS = 409 + end + + class UnprocessableEntityError < Imagekit::Errors::APIStatusError + HTTP_STATUS = 422 + end + + class RateLimitError < Imagekit::Errors::APIStatusError + HTTP_STATUS = 429 + end + + class InternalServerError < Imagekit::Errors::APIStatusError + HTTP_STATUS = (500..) + end + end +end diff --git a/lib/imagekit/file_part.rb b/lib/imagekit/file_part.rb new file mode 100644 index 00000000..7676aada --- /dev/null +++ b/lib/imagekit/file_part.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true + +module Imagekit + class FilePart + # @return [Pathname, StringIO, IO, String] + attr_reader :content + + # @return [String, nil] + attr_reader :content_type + + # @return [String, nil] + attr_reader :filename + + # @api private + # + # @return [String] + private def read + case content + in Pathname + content.read(binmode: true) + in StringIO + content.string + in IO + content.read + in String + content + end + end + + # @param a [Object] + # + # @return [String] + def to_json(*a) = read.to_json(*a) + + # @param a [Object] + # + # @return [String] + def to_yaml(*a) = read.to_yaml(*a) + + # @param content [Pathname, StringIO, IO, String] + # @param filename [String, nil] + # @param content_type [String, nil] + def initialize(content, filename: nil, content_type: nil) + @content = content + @filename = + case content + in Pathname + filename.nil? ? content.basename.to_path : ::File.basename(filename) + else + filename.nil? ? nil : ::File.basename(filename) + end + @content_type = content_type + end + end +end diff --git a/lib/imagekit/internal.rb b/lib/imagekit/internal.rb new file mode 100644 index 00000000..450d18b1 --- /dev/null +++ b/lib/imagekit/internal.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +module Imagekit + module Internal + extend Imagekit::Internal::Util::SorbetRuntimeSupport + + OMIT = + Object.new.tap do + _1.define_singleton_method(:inspect) { "#<#{Imagekit::Internal}::OMIT>" } + end + .freeze + + define_sorbet_constant!(:AnyHash) do + T.type_alias { T::Hash[Symbol, T.anything] } + end + define_sorbet_constant!(:FileInput) do + T.type_alias { T.any(Pathname, StringIO, IO, String, Imagekit::FilePart) } + end + end +end diff --git a/lib/imagekit/internal/transport/base_client.rb b/lib/imagekit/internal/transport/base_client.rb new file mode 100644 index 00000000..222a48cf --- /dev/null +++ b/lib/imagekit/internal/transport/base_client.rb @@ -0,0 +1,567 @@ +# frozen_string_literal: true + +module Imagekit + module Internal + module Transport + # @api private + # + # @abstract + class BaseClient + extend Imagekit::Internal::Util::SorbetRuntimeSupport + + # from whatwg fetch spec + MAX_REDIRECTS = 20 + + # rubocop:disable Style/MutableConstant + PLATFORM_HEADERS = + { + "x-stainless-arch" => Imagekit::Internal::Util.arch, + "x-stainless-lang" => "ruby", + "x-stainless-os" => Imagekit::Internal::Util.os, + "x-stainless-package-version" => Imagekit::VERSION, + "x-stainless-runtime" => ::RUBY_ENGINE, + "x-stainless-runtime-version" => ::RUBY_ENGINE_VERSION + } + # rubocop:enable Style/MutableConstant + + class << self + # @api private + # + # @param req [Hash{Symbol=>Object}] + # + # @raise [ArgumentError] + def validate!(req) + keys = [:method, :path, :query, :headers, :body, :unwrap, :page, :stream, :model, :options] + case req + in Hash + req.each_key do |k| + unless keys.include?(k) + raise ArgumentError.new("Request `req` keys must be one of #{keys}, got #{k.inspect}") + end + end + else + raise ArgumentError.new("Request `req` must be a Hash or RequestOptions, got #{req.inspect}") + end + end + + # @api private + # + # @param status [Integer] + # @param headers [Hash{String=>String}] + # + # @return [Boolean] + def should_retry?(status, headers:) + coerced = Imagekit::Internal::Util.coerce_boolean(headers["x-should-retry"]) + case [coerced, status] + in [true | false, _] + coerced + in [_, 408 | 409 | 429 | (500..)] + # retry on: + # 408: timeouts + # 409: locks + # 429: rate limits + # 500+: unknown errors + true + else + false + end + end + + # @api private + # + # @param request [Hash{Symbol=>Object}] . + # + # @option request [Symbol] :method + # + # @option request [URI::Generic] :url + # + # @option request [Hash{String=>String}] :headers + # + # @option request [Object] :body + # + # @option request [Integer] :max_retries + # + # @option request [Float] :timeout + # + # @param status [Integer] + # + # @param response_headers [Hash{String=>String}] + # + # @return [Hash{Symbol=>Object}] + def follow_redirect(request, status:, response_headers:) + method, url, headers = request.fetch_values(:method, :url, :headers) + location = + Kernel.then do + URI.join(url, response_headers["location"]) + rescue ArgumentError + message = "Server responded with status #{status} but no valid location header." + raise Imagekit::Errors::APIConnectionError.new( + url: url, + response: response_headers, + message: message + ) + end + + request = {**request, url: location} + + case [url.scheme, location.scheme] + in ["https", "http"] + message = "Tried to redirect to a insecure URL" + raise Imagekit::Errors::APIConnectionError.new( + url: url, + response: response_headers, + message: message + ) + else + nil + end + + # from whatwg fetch spec + case [status, method] + in [301 | 302, :post] | [303, _] + drop = %w[content-encoding content-language content-length content-location content-type] + request = { + **request, + method: method == :head ? :head : :get, + headers: headers.except(*drop), + body: nil + } + else + end + + # from undici + if Imagekit::Internal::Util.uri_origin(url) != Imagekit::Internal::Util.uri_origin(location) + drop = %w[authorization cookie host proxy-authorization] + request = {**request, headers: request.fetch(:headers).except(*drop)} + end + + request + end + + # @api private + # + # @param status [Integer, Imagekit::Errors::APIConnectionError] + # @param stream [Enumerable, nil] + def reap_connection!(status, stream:) + case status + in (..199) | (300..499) + stream&.each { next } + in Imagekit::Errors::APIConnectionError | (500..) + Imagekit::Internal::Util.close_fused!(stream) + else + end + end + end + + # @return [URI::Generic] + attr_reader :base_url + + # @return [Float] + attr_reader :timeout + + # @return [Integer] + attr_reader :max_retries + + # @return [Float] + attr_reader :initial_retry_delay + + # @return [Float] + attr_reader :max_retry_delay + + # @return [Hash{String=>String}] + attr_reader :headers + + # @return [String, nil] + attr_reader :idempotency_header + + # @api private + # @return [Imagekit::Internal::Transport::PooledNetRequester] + attr_reader :requester + + # @api private + # + # @param base_url [String] + # @param timeout [Float] + # @param max_retries [Integer] + # @param initial_retry_delay [Float] + # @param max_retry_delay [Float] + # @param headers [Hash{String=>String, Integer, Array, nil}] + # @param idempotency_header [String, nil] + def initialize( + base_url:, + timeout: 0.0, + max_retries: 0, + initial_retry_delay: 0.0, + max_retry_delay: 0.0, + headers: {}, + idempotency_header: nil + ) + @requester = Imagekit::Internal::Transport::PooledNetRequester.new + @headers = Imagekit::Internal::Util.normalized_headers( + self.class::PLATFORM_HEADERS, + { + "accept" => "application/json", + "content-type" => "application/json" + }, + headers + ) + @base_url_components = Imagekit::Internal::Util.parse_uri(base_url) + @base_url = Imagekit::Internal::Util.unparse_uri(@base_url_components) + @idempotency_header = idempotency_header&.to_s&.downcase + @timeout = timeout + @max_retries = max_retries + @initial_retry_delay = initial_retry_delay + @max_retry_delay = max_retry_delay + end + + # @api private + # + # @return [Hash{String=>String}] + private def auth_headers = {} + + # @api private + # + # @return [String] + private def generate_idempotency_key = "stainless-ruby-retry-#{SecureRandom.uuid}" + + # @api private + # + # @param req [Hash{Symbol=>Object}] . + # + # @option req [Symbol] :method + # + # @option req [String, Array] :path + # + # @option req [Hash{String=>Array, String, nil}, nil] :query + # + # @option req [Hash{String=>String, Integer, Array, nil}, nil] :headers + # + # @option req [Object, nil] :body + # + # @option req [Symbol, Integer, Array, Proc, nil] :unwrap + # + # @option req [Class, nil] :page + # + # @option req [Class, nil] :stream + # + # @option req [Imagekit::Internal::Type::Converter, Class, nil] :model + # + # @param opts [Hash{Symbol=>Object}] . + # + # @option opts [String, nil] :idempotency_key + # + # @option opts [Hash{String=>Array, String, nil}, nil] :extra_query + # + # @option opts [Hash{String=>String, nil}, nil] :extra_headers + # + # @option opts [Object, nil] :extra_body + # + # @option opts [Integer, nil] :max_retries + # + # @option opts [Float, nil] :timeout + # + # @return [Hash{Symbol=>Object}] + private def build_request(req, opts) + method, uninterpolated_path = req.fetch_values(:method, :path) + + path = Imagekit::Internal::Util.interpolate_path(uninterpolated_path) + + query = Imagekit::Internal::Util.deep_merge(req[:query].to_h, opts[:extra_query].to_h) + + headers = Imagekit::Internal::Util.normalized_headers( + @headers, + auth_headers, + req[:headers].to_h, + opts[:extra_headers].to_h + ) + + if @idempotency_header && + !headers.key?(@idempotency_header) && + (!Net::HTTP::IDEMPOTENT_METHODS_.include?(method.to_s.upcase) || opts.key?(:idempotency_key)) + headers[@idempotency_header] = opts.fetch(:idempotency_key) { generate_idempotency_key } + end + + unless headers.key?("x-stainless-retry-count") + headers["x-stainless-retry-count"] = "0" + end + + timeout = opts.fetch(:timeout, @timeout).to_f.clamp(0..) + unless headers.key?("x-stainless-timeout") || timeout.zero? + headers["x-stainless-timeout"] = timeout.to_s + end + + headers.reject! { |_, v| v.to_s.empty? } + + body = + case method + in :get | :head | :options | :trace + nil + else + Imagekit::Internal::Util.deep_merge(*[req[:body], opts[:extra_body]].compact) + end + + url = Imagekit::Internal::Util.join_parsed_uri( + @base_url_components, + {**req, path: path, query: query} + ) + headers, encoded = Imagekit::Internal::Util.encode_content(headers, body) + { + method: method, + url: url, + headers: headers, + body: encoded, + max_retries: opts.fetch(:max_retries, @max_retries), + timeout: timeout + } + end + + # @api private + # + # @param headers [Hash{String=>String}] + # @param retry_count [Integer] + # + # @return [Float] + private def retry_delay(headers, retry_count:) + # Non-standard extension + span = Float(headers["retry-after-ms"], exception: false)&.then { _1 / 1000 } + return span if span + + retry_header = headers["retry-after"] + return span if (span = Float(retry_header, exception: false)) + + span = retry_header&.then do + Time.httpdate(_1) - Time.now + rescue ArgumentError + nil + end + return span if span + + scale = retry_count**2 + jitter = 1 - (0.25 * rand) + (@initial_retry_delay * scale * jitter).clamp(0, @max_retry_delay) + end + + # @api private + # + # @param request [Hash{Symbol=>Object}] . + # + # @option request [Symbol] :method + # + # @option request [URI::Generic] :url + # + # @option request [Hash{String=>String}] :headers + # + # @option request [Object] :body + # + # @option request [Integer] :max_retries + # + # @option request [Float] :timeout + # + # @param redirect_count [Integer] + # + # @param retry_count [Integer] + # + # @param send_retry_header [Boolean] + # + # @raise [Imagekit::Errors::APIError] + # @return [Array(Integer, Net::HTTPResponse, Enumerable)] + def send_request(request, redirect_count:, retry_count:, send_retry_header:) + url, headers, max_retries, timeout = request.fetch_values(:url, :headers, :max_retries, :timeout) + input = {**request.except(:timeout), deadline: Imagekit::Internal::Util.monotonic_secs + timeout} + + if send_retry_header + headers["x-stainless-retry-count"] = retry_count.to_s + end + + begin + status, response, stream = @requester.execute(input) + rescue Imagekit::Errors::APIConnectionError => e + status = e + end + headers = Imagekit::Internal::Util.normalized_headers(response&.each_header&.to_h) + + case status + in ..299 + [status, response, stream] + in 300..399 if redirect_count >= self.class::MAX_REDIRECTS + self.class.reap_connection!(status, stream: stream) + + message = "Failed to complete the request within #{self.class::MAX_REDIRECTS} redirects." + raise Imagekit::Errors::APIConnectionError.new(url: url, response: response, message: message) + in 300..399 + self.class.reap_connection!(status, stream: stream) + + request = self.class.follow_redirect(request, status: status, response_headers: headers) + send_request( + request, + redirect_count: redirect_count + 1, + retry_count: retry_count, + send_retry_header: send_retry_header + ) + in Imagekit::Errors::APIConnectionError if retry_count >= max_retries + raise status + in (400..) if retry_count >= max_retries || !self.class.should_retry?(status, headers: headers) + decoded = Kernel.then do + Imagekit::Internal::Util.decode_content(headers, stream: stream, suppress_error: true) + ensure + self.class.reap_connection!(status, stream: stream) + end + + raise Imagekit::Errors::APIStatusError.for( + url: url, + status: status, + headers: headers, + body: decoded, + request: nil, + response: response + ) + in (400..) | Imagekit::Errors::APIConnectionError + self.class.reap_connection!(status, stream: stream) + + delay = retry_delay(response || {}, retry_count: retry_count) + sleep(delay) + + send_request( + request, + redirect_count: redirect_count, + retry_count: retry_count + 1, + send_retry_header: send_retry_header + ) + end + end + + # Execute the request specified by `req`. This is the method that all resource + # methods call into. + # + # @overload request(method, path, query: {}, headers: {}, body: nil, unwrap: nil, page: nil, stream: nil, model: Imagekit::Internal::Type::Unknown, options: {}) + # + # @param method [Symbol] + # + # @param path [String, Array] + # + # @param query [Hash{String=>Array, String, nil}, nil] + # + # @param headers [Hash{String=>String, Integer, Array, nil}, nil] + # + # @param body [Object, nil] + # + # @param unwrap [Symbol, Integer, Array, Proc, nil] + # + # @param page [Class, nil] + # + # @param stream [Class, nil] + # + # @param model [Imagekit::Internal::Type::Converter, Class, nil] + # + # @param options [Imagekit::RequestOptions, Hash{Symbol=>Object}, nil] . + # + # @option options [String, nil] :idempotency_key + # + # @option options [Hash{String=>Array, String, nil}, nil] :extra_query + # + # @option options [Hash{String=>String, nil}, nil] :extra_headers + # + # @option options [Object, nil] :extra_body + # + # @option options [Integer, nil] :max_retries + # + # @option options [Float, nil] :timeout + # + # @raise [Imagekit::Errors::APIError] + # @return [Object] + def request(req) + self.class.validate!(req) + model = req.fetch(:model) { Imagekit::Internal::Type::Unknown } + opts = req[:options].to_h + unwrap = req[:unwrap] + Imagekit::RequestOptions.validate!(opts) + request = build_request(req.except(:options), opts) + url = request.fetch(:url) + + # Don't send the current retry count in the headers if the caller modified the header defaults. + send_retry_header = request.fetch(:headers)["x-stainless-retry-count"] == "0" + status, response, stream = send_request( + request, + redirect_count: 0, + retry_count: 0, + send_retry_header: send_retry_header + ) + + headers = Imagekit::Internal::Util.normalized_headers(response.each_header.to_h) + decoded = Imagekit::Internal::Util.decode_content(headers, stream: stream) + case req + in {stream: Class => st} + st.new( + model: model, + url: url, + status: status, + headers: headers, + response: response, + unwrap: unwrap, + stream: decoded + ) + in {page: Class => page} + page.new(client: self, req: req, headers: headers, page_data: decoded) + else + unwrapped = Imagekit::Internal::Util.dig(decoded, unwrap) + Imagekit::Internal::Type::Converter.coerce(model, unwrapped) + end + end + + # @api private + # + # @return [String] + def inspect + # rubocop:disable Layout/LineLength + "#<#{self.class.name}:0x#{object_id.to_s(16)} base_url=#{@base_url} max_retries=#{@max_retries} timeout=#{@timeout}>" + # rubocop:enable Layout/LineLength + end + + define_sorbet_constant!(:RequestComponents) do + T.type_alias do + { + method: Symbol, + path: T.any(String, T::Array[String]), + query: T.nilable(T::Hash[String, T.nilable(T.any(T::Array[String], String))]), + headers: T.nilable( + T::Hash[String, + T.nilable( + T.any( + String, + Integer, + T::Array[T.nilable(T.any(String, Integer))] + ) + )] + ), + body: T.nilable(T.anything), + unwrap: T.nilable( + T.any( + Symbol, + Integer, + T::Array[T.any(Symbol, Integer)], + T.proc.params(arg0: T.anything).returns(T.anything) + ) + ), + page: T.nilable(T::Class[Imagekit::Internal::Type::BasePage[Imagekit::Internal::Type::BaseModel]]), + stream: T.nilable(T::Class[T.anything]), + model: T.nilable(Imagekit::Internal::Type::Converter::Input), + options: T.nilable(Imagekit::RequestOptions::OrHash) + } + end + end + define_sorbet_constant!(:RequestInput) do + T.type_alias do + { + method: Symbol, + url: URI::Generic, + headers: T::Hash[String, String], + body: T.anything, + max_retries: Integer, + timeout: Float + } + end + end + end + end + end +end diff --git a/lib/imagekit/internal/transport/pooled_net_requester.rb b/lib/imagekit/internal/transport/pooled_net_requester.rb new file mode 100644 index 00000000..365d5689 --- /dev/null +++ b/lib/imagekit/internal/transport/pooled_net_requester.rb @@ -0,0 +1,201 @@ +# frozen_string_literal: true + +module Imagekit + module Internal + module Transport + # @api private + class PooledNetRequester + extend Imagekit::Internal::Util::SorbetRuntimeSupport + + # from the golang stdlib + # https://github.com/golang/go/blob/c8eced8580028328fde7c03cbfcb720ce15b2358/src/net/http/transport.go#L49 + KEEP_ALIVE_TIMEOUT = 30 + + DEFAULT_MAX_CONNECTIONS = [Etc.nprocessors, 99].max + + class << self + # @api private + # + # @param url [URI::Generic] + # + # @return [Net::HTTP] + def connect(url) + port = + case [url.port, url.scheme] + in [Integer, _] + url.port + in [nil, "http" | "ws"] + Net::HTTP.http_default_port + in [nil, "https" | "wss"] + Net::HTTP.https_default_port + end + + Net::HTTP.new(url.host, port).tap do + _1.use_ssl = %w[https wss].include?(url.scheme) + _1.max_retries = 0 + end + end + + # @api private + # + # @param conn [Net::HTTP] + # @param deadline [Float] + def calibrate_socket_timeout(conn, deadline) + timeout = deadline - Imagekit::Internal::Util.monotonic_secs + conn.open_timeout = conn.read_timeout = conn.write_timeout = conn.continue_timeout = timeout + end + + # @api private + # + # @param request [Hash{Symbol=>Object}] . + # + # @option request [Symbol] :method + # + # @option request [URI::Generic] :url + # + # @option request [Hash{String=>String}] :headers + # + # @param blk [Proc] + # + # @yieldparam [String] + # @return [Array(Net::HTTPGenericRequest, Proc)] + def build_request(request, &blk) + method, url, headers, body = request.fetch_values(:method, :url, :headers, :body) + req = Net::HTTPGenericRequest.new( + method.to_s.upcase, + !body.nil?, + method != :head, + URI(url.to_s) # ensure we construct a URI class of the right scheme + ) + + headers.each { req[_1] = _2 } + + case body + in nil + nil + in String + req["content-length"] ||= body.bytesize.to_s unless req["transfer-encoding"] + req.body_stream = Imagekit::Internal::Util::ReadIOAdapter.new(body, &blk) + in StringIO + req["content-length"] ||= body.size.to_s unless req["transfer-encoding"] + req.body_stream = Imagekit::Internal::Util::ReadIOAdapter.new(body, &blk) + in Pathname | IO | Enumerator + req["transfer-encoding"] ||= "chunked" unless req["content-length"] + req.body_stream = Imagekit::Internal::Util::ReadIOAdapter.new(body, &blk) + end + + [req, req.body_stream&.method(:close)] + end + end + + # @api private + # + # @param url [URI::Generic] + # @param deadline [Float] + # @param blk [Proc] + # + # @raise [Timeout::Error] + # @yieldparam [Net::HTTP] + private def with_pool(url, deadline:, &blk) + origin = Imagekit::Internal::Util.uri_origin(url) + timeout = deadline - Imagekit::Internal::Util.monotonic_secs + pool = + @mutex.synchronize do + @pools[origin] ||= ConnectionPool.new(size: @size) do + self.class.connect(url) + end + end + + pool.with(timeout: timeout, &blk) + end + + # @api private + # + # @param request [Hash{Symbol=>Object}] . + # + # @option request [Symbol] :method + # + # @option request [URI::Generic] :url + # + # @option request [Hash{String=>String}] :headers + # + # @option request [Object] :body + # + # @option request [Float] :deadline + # + # @return [Array(Integer, Net::HTTPResponse, Enumerable)] + def execute(request) + url, deadline = request.fetch_values(:url, :deadline) + + req = nil + eof = false + finished = false + closing = nil + + # rubocop:disable Metrics/BlockLength + enum = Enumerator.new do |y| + with_pool(url, deadline: deadline) do |conn| + next if finished + + req, closing = self.class.build_request(request) do + self.class.calibrate_socket_timeout(conn, deadline) + end + + self.class.calibrate_socket_timeout(conn, deadline) + unless conn.started? + conn.keep_alive_timeout = self.class::KEEP_ALIVE_TIMEOUT + conn.start + end + + self.class.calibrate_socket_timeout(conn, deadline) + conn.request(req) do |rsp| + y << [conn, req, rsp] + break if finished + + rsp.read_body do |bytes| + y << bytes.force_encoding(Encoding::BINARY) + break if finished + + self.class.calibrate_socket_timeout(conn, deadline) + end + eof = true + end + end + rescue Timeout::Error + raise Imagekit::Errors::APITimeoutError.new(url: url, request: req) + rescue StandardError + raise Imagekit::Errors::APIConnectionError.new(url: url, request: req) + end + # rubocop:enable Metrics/BlockLength + + conn, _, response = enum.next + body = Imagekit::Internal::Util.fused_enum(enum, external: true) do + finished = true + tap do + enum.next + rescue StopIteration + nil + end + ensure + conn.finish if !eof && conn&.started? + closing&.call + end + [Integer(response.code), response, body] + end + + # @api private + # + # @param size [Integer] + def initialize(size: self.class::DEFAULT_MAX_CONNECTIONS) + @mutex = Mutex.new + @size = size + @pools = {} + end + + define_sorbet_constant!(:Request) do + T.type_alias { {method: Symbol, url: URI::Generic, headers: T::Hash[String, String], body: T.anything, deadline: Float} } + end + end + end + end +end diff --git a/lib/imagekit/internal/type/array_of.rb b/lib/imagekit/internal/type/array_of.rb new file mode 100644 index 00000000..7e21f934 --- /dev/null +++ b/lib/imagekit/internal/type/array_of.rb @@ -0,0 +1,168 @@ +# frozen_string_literal: true + +module Imagekit + module Internal + module Type + # @api private + # + # @abstract + # + # @generic Elem + # + # Array of items of a given type. + class ArrayOf + include Imagekit::Internal::Type::Converter + include Imagekit::Internal::Util::SorbetRuntimeSupport + + private_class_method :new + + # @overload [](type_info, spec = {}) + # + # @param type_info [Hash{Symbol=>Object}, Proc, Imagekit::Internal::Type::Converter, Class] + # + # @param spec [Hash{Symbol=>Object}] . + # + # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const + # + # @option spec [Proc] :enum + # + # @option spec [Proc] :union + # + # @option spec [Boolean] :"nil?" + # + # @return [self] + def self.[](...) = new(...) + + # @api public + # + # @param other [Object] + # + # @return [Boolean] + def ===(other) = other.is_a?(Array) && other.all?(item_type) + + # @api public + # + # @param other [Object] + # + # @return [Boolean] + def ==(other) + # rubocop:disable Layout/LineLength + other.is_a?(Imagekit::Internal::Type::ArrayOf) && other.nilable? == nilable? && other.item_type == item_type + # rubocop:enable Layout/LineLength + end + + # @api public + # + # @return [Integer] + def hash = [self.class, item_type].hash + + # @api private + # + # @param value [Array, Object] + # + # @param state [Hash{Symbol=>Object}] . + # + # @option state [Boolean] :translate_names + # + # @option state [Boolean] :strictness + # + # @option state [Hash{Symbol=>Object}] :exactness + # + # @option state [Class] :error + # + # @option state [Integer] :branched + # + # @return [Array, Object] + def coerce(value, state:) + exactness = state.fetch(:exactness) + + unless value.is_a?(Array) + exactness[:no] += 1 + state[:error] = TypeError.new("#{value.class} can't be coerced into #{Array}") + return value + end + + target = item_type + exactness[:yes] += 1 + value + .map do |item| + case [nilable?, item] + in [true, nil] + exactness[:yes] += 1 + nil + else + Imagekit::Internal::Type::Converter.coerce(target, item, state: state) + end + end + end + + # @api private + # + # @param value [Array, Object] + # + # @param state [Hash{Symbol=>Object}] . + # + # @option state [Boolean] :can_retry + # + # @return [Array, Object] + def dump(value, state:) + target = item_type + if value.is_a?(Array) + value.map do + Imagekit::Internal::Type::Converter.dump(target, _1, state: state) + end + else + super + end + end + + # @api private + # + # @return [Object] + def to_sorbet_type + T::Array[Imagekit::Internal::Util::SorbetRuntimeSupport.to_sorbet_type(item_type)] + end + + # @api private + # + # @return [generic] + protected def item_type = @item_type_fn.call + + # @api private + # + # @return [Boolean] + protected def nilable? = @nilable + + # @api private + # + # @param type_info [Hash{Symbol=>Object}, Proc, Imagekit::Internal::Type::Converter, Class] + # + # @param spec [Hash{Symbol=>Object}] . + # + # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const + # + # @option spec [Proc] :enum + # + # @option spec [Proc] :union + # + # @option spec [Boolean] :"nil?" + def initialize(type_info, spec = {}) + @item_type_fn = Imagekit::Internal::Type::Converter.type_info(type_info || spec) + @meta = Imagekit::Internal::Type::Converter.meta_info(type_info, spec) + @nilable = spec.fetch(:nil?, false) + end + + # @api private + # + # @param depth [Integer] + # + # @return [String] + def inspect(depth: 0) + items = Imagekit::Internal::Type::Converter.inspect(item_type, depth: depth.succ) + + "#{self.class}[#{[items, nilable? ? 'nil' : nil].compact.join(' | ')}]" + end + end + end + end +end diff --git a/lib/imagekit/internal/type/base_model.rb b/lib/imagekit/internal/type/base_model.rb new file mode 100644 index 00000000..10b423c5 --- /dev/null +++ b/lib/imagekit/internal/type/base_model.rb @@ -0,0 +1,530 @@ +# frozen_string_literal: true + +module Imagekit + module Internal + module Type + # @abstract + class BaseModel + extend Imagekit::Internal::Type::Converter + extend Imagekit::Internal::Util::SorbetRuntimeSupport + + class << self + # @api private + # + # Assumes superclass fields are totally defined before fields are accessed / + # defined on subclasses. + # + # @param child [Class] + def inherited(child) + super + child.known_fields.replace(known_fields.dup) + end + + # @api private + # + # @return [Hash{Symbol=>Hash{Symbol=>Object}}] + def known_fields = @known_fields ||= {} + + # @api private + # + # @return [Hash{Symbol=>Hash{Symbol=>Object}}] + def fields + known_fields.transform_values do |field| + {**field.except(:type_fn), type: field.fetch(:type_fn).call} + end + end + + # @api private + # + # @param name_sym [Symbol] + # + # @param required [Boolean] + # + # @param type_info [Hash{Symbol=>Object}, Proc, Imagekit::Internal::Type::Converter, Class] + # + # @param spec [Hash{Symbol=>Object}] . + # + # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const + # + # @option spec [Proc] :enum + # + # @option spec [Proc] :union + # + # @option spec [Boolean] :"nil?" + private def add_field(name_sym, required:, type_info:, spec:) + meta = Imagekit::Internal::Type::Converter.meta_info(type_info, spec) + type_fn, info = + case type_info + in Proc | Imagekit::Internal::Type::Converter | Class + [Imagekit::Internal::Type::Converter.type_info({**spec, union: type_info}), spec] + in Hash + [Imagekit::Internal::Type::Converter.type_info(type_info), type_info] + end + + setter = :"#{name_sym}=" + api_name = info.fetch(:api_name, name_sym) + nilable = info.fetch(:nil?, false) + const = required && !nilable ? info.fetch(:const, Imagekit::Internal::OMIT) : Imagekit::Internal::OMIT + + [name_sym, setter].each { undef_method(_1) } if known_fields.key?(name_sym) + + known_fields[name_sym] = + { + mode: @mode, + api_name: api_name, + required: required, + nilable: nilable, + const: const, + type_fn: type_fn, + meta: meta + } + + define_method(setter) do |value| + target = type_fn.call + state = Imagekit::Internal::Type::Converter.new_coerce_state(translate_names: false) + coerced = Imagekit::Internal::Type::Converter.coerce(target, value, state: state) + status = @coerced.store(name_sym, state.fetch(:error) || true) + stored = + case [target, status] + in [Imagekit::Internal::Type::Converter | Symbol, true] + coerced + else + value + end + @data.store(name_sym, stored) + end + + # rubocop:disable Style/CaseEquality + # rubocop:disable Metrics/BlockLength + define_method(name_sym) do + target = type_fn.call + + case @coerced[name_sym] + in true | false if Imagekit::Internal::Type::Converter === target + @data.fetch(name_sym) + in ::StandardError => e + raise Imagekit::Errors::ConversionError.new( + on: self.class, + method: __method__, + target: target, + value: @data.fetch(name_sym), + cause: e + ) + else + Kernel.then do + value = @data.fetch(name_sym) { const == Imagekit::Internal::OMIT ? nil : const } + state = Imagekit::Internal::Type::Converter.new_coerce_state(translate_names: false) + if (nilable || !required) && value.nil? + nil + else + Imagekit::Internal::Type::Converter.coerce( + target, value, state: state + ) + end + rescue StandardError => e + raise Imagekit::Errors::ConversionError.new( + on: self.class, + method: __method__, + target: target, + value: value, + cause: e + ) + end + end + end + # rubocop:enable Metrics/BlockLength + # rubocop:enable Style/CaseEquality + end + + # @api private + # + # @param name_sym [Symbol] + # + # @param type_info [Hash{Symbol=>Object}, Proc, Imagekit::Internal::Type::Converter, Class] + # + # @param spec [Hash{Symbol=>Object}] . + # + # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const + # + # @option spec [Proc] :enum + # + # @option spec [Proc] :union + # + # @option spec [Boolean] :"nil?" + def required(name_sym, type_info, spec = {}) + add_field(name_sym, required: true, type_info: type_info, spec: spec) + end + + # @api private + # + # @param name_sym [Symbol] + # + # @param type_info [Hash{Symbol=>Object}, Proc, Imagekit::Internal::Type::Converter, Class] + # + # @param spec [Hash{Symbol=>Object}] . + # + # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const + # + # @option spec [Proc] :enum + # + # @option spec [Proc] :union + # + # @option spec [Boolean] :"nil?" + def optional(name_sym, type_info, spec = {}) + add_field(name_sym, required: false, type_info: type_info, spec: spec) + end + + # @api private + # + # `request_only` attributes not excluded from `.#coerce` when receiving responses + # even if well behaved servers should not send them + # + # @param blk [Proc] + private def request_only(&blk) + @mode = :dump + blk.call + ensure + @mode = nil + end + + # @api private + # + # `response_only` attributes are omitted from `.#dump` when making requests + # + # @param blk [Proc] + private def response_only(&blk) + @mode = :coerce + blk.call + ensure + @mode = nil + end + + # @api public + # + # @param other [Object] + # + # @return [Boolean] + def ==(other) + other.is_a?(Class) && other <= Imagekit::Internal::Type::BaseModel && other.fields == fields + end + + # @api public + # + # @return [Integer] + def hash = fields.hash + end + + # @api public + # + # @param other [Object] + # + # @return [Boolean] + def ==(other) = self.class == other.class && @data == other.to_h + + # @api public + # + # @return [Integer] + def hash = [self.class, @data].hash + + class << self + # @api private + # + # @param value [Imagekit::Internal::Type::BaseModel, Hash{Object=>Object}, Object] + # + # @param state [Hash{Symbol=>Object}] . + # + # @option state [Boolean] :translate_names + # + # @option state [Boolean] :strictness + # + # @option state [Hash{Symbol=>Object}] :exactness + # + # @option state [Class] :error + # + # @option state [Integer] :branched + # + # @return [self, Object] + def coerce(value, state:) + exactness = state.fetch(:exactness) + + if value.is_a?(self) + exactness[:yes] += 1 + return value + end + + unless (val = Imagekit::Internal::Util.coerce_hash(value)).is_a?(Hash) + exactness[:no] += 1 + state[:error] = TypeError.new("#{value.class} can't be coerced into #{Hash}") + return value + end + exactness[:yes] += 1 + + keys = val.keys.to_set + instance = new + data = instance.to_h + status = instance.instance_variable_get(:@coerced) + + # rubocop:disable Metrics/BlockLength + fields.each do |name, field| + mode, required, target = field.fetch_values(:mode, :required, :type) + api_name, nilable, const = field.fetch_values(:api_name, :nilable, :const) + src_name = state.fetch(:translate_names) ? api_name : name + + unless val.key?(src_name) + if required && mode != :dump && const == Imagekit::Internal::OMIT + exactness[nilable ? :maybe : :no] += 1 + else + exactness[:yes] += 1 + end + next + end + + item = val.fetch(src_name) + keys.delete(src_name) + + state[:error] = nil + converted = + if item.nil? && (nilable || !required) + exactness[nilable ? :yes : :maybe] += 1 + nil + else + coerced = Imagekit::Internal::Type::Converter.coerce(target, item, state: state) + case target + in Imagekit::Internal::Type::Converter | Symbol + coerced + else + item + end + end + + status.store(name, state.fetch(:error) || true) + data.store(name, converted) + end + # rubocop:enable Metrics/BlockLength + + keys.each { data.store(_1, val.fetch(_1)) } + instance + end + + # @api private + # + # @param value [self, Object] + # + # @param state [Hash{Symbol=>Object}] . + # + # @option state [Boolean] :can_retry + # + # @return [Hash{Object=>Object}, Object] + def dump(value, state:) + unless (coerced = Imagekit::Internal::Util.coerce_hash(value)).is_a?(Hash) + return super + end + + acc = {} + + coerced.each do |key, val| + name = key.is_a?(String) ? key.to_sym : key + case (field = known_fields[name]) + in nil + acc.store(name, super(val, state: state)) + else + api_name, mode, type_fn = field.fetch_values(:api_name, :mode, :type_fn) + case mode + in :coerce + next + else + target = type_fn.call + acc.store(api_name, Imagekit::Internal::Type::Converter.dump(target, val, state: state)) + end + end + end + + known_fields.each_value do |field| + api_name, mode, const = field.fetch_values(:api_name, :mode, :const) + next if mode == :coerce || acc.key?(api_name) || const == Imagekit::Internal::OMIT + acc.store(api_name, const) + end + + acc + end + + # @api private + # + # @return [Object] + def to_sorbet_type + self + end + end + + class << self + # @api private + # + # @param model [Imagekit::Internal::Type::BaseModel] + # @param convert [Boolean] + # + # @return [Hash{Symbol=>Object}] + def recursively_to_h(model, convert:) + rec = ->(x) do + case x + in Imagekit::Internal::Type::BaseModel + if convert + fields = x.class.known_fields + x.to_h.to_h do |key, val| + [key, rec.call(fields.key?(key) ? x.public_send(key) : val)] + rescue Imagekit::Errors::ConversionError + [key, rec.call(val)] + end + else + rec.call(x.to_h) + end + in Hash + x.transform_values(&rec) + in Array + x.map(&rec) + else + x + end + end + rec.call(model) + end + end + + # @api public + # + # Returns the raw value associated with the given key, if found. Otherwise, nil is + # returned. + # + # It is valid to lookup keys that are not in the API spec, for example to access + # undocumented features. This method does not parse response data into + # higher-level types. Lookup by anything other than a Symbol is an ArgumentError. + # + # @param key [Symbol] + # + # @return [Object, nil] + def [](key) + unless key.instance_of?(Symbol) + raise ArgumentError.new("Expected symbol key for lookup, got #{key.inspect}") + end + + @data[key] + end + + # @api public + # + # Returns a Hash of the data underlying this object. O(1) + # + # Keys are Symbols and values are the raw values from the response. The return + # value indicates which values were ever set on the object. i.e. there will be a + # key in this hash if they ever were, even if the set value was nil. + # + # This method is not recursive. The returned value is shared by the object, so it + # should not be mutated. + # + # @return [Hash{Symbol=>Object}] + def to_h = @data + + alias_method :to_hash, :to_h + + # @api public + # + # In addition to the behaviour of `#to_h`, this method will recursively call + # `#to_h` on nested models. + # + # @return [Hash{Symbol=>Object}] + def deep_to_h = self.class.recursively_to_h(@data, convert: false) + + # @param keys [Array, nil] + # + # @return [Hash{Symbol=>Object}] + # + # @example + # # `base_overlay` is a `Imagekit::BaseOverlay` + # base_overlay => { + # position: position, + # timing: timing + # } + def deconstruct_keys(keys) + (keys || self.class.known_fields.keys) + .filter_map do |k| + unless self.class.known_fields.key?(k) + next + end + + [k, public_send(k)] + end + .to_h + end + + # @api public + # + # @param a [Object] + # + # @return [String] + def to_json(*a) = Imagekit::Internal::Type::Converter.dump(self.class, self).to_json(*a) + + # @api public + # + # @param a [Object] + # + # @return [String] + def to_yaml(*a) = Imagekit::Internal::Type::Converter.dump(self.class, self).to_yaml(*a) + + # Create a new instance of a model. + # + # @param data [Hash{Symbol=>Object}, self] + def initialize(data = {}) + @data = {} + @coerced = {} + Imagekit::Internal::Util.coerce_hash!(data).each do + if self.class.known_fields.key?(_1) + public_send(:"#{_1}=", _2) + else + @data.store(_1, _2) + @coerced.store(_1, false) + end + end + end + + class << self + # @api private + # + # @param depth [Integer] + # + # @return [String] + def inspect(depth: 0) + return super() if depth.positive? + + depth = depth.succ + deferred = fields.transform_values do |field| + type, required, nilable = field.fetch_values(:type, :required, :nilable) + inspected = [ + Imagekit::Internal::Type::Converter.inspect(type, depth: depth), + !required || nilable ? "nil" : nil + ].compact.join(" | ") + -> { inspected }.tap { _1.define_singleton_method(:inspect) { call } } + end + + "#{name}[#{deferred.inspect}]" + end + end + + # @api public + # + # @return [String] + def to_s = deep_to_h.to_s + + # @api private + # + # @return [String] + def inspect + converted = self.class.recursively_to_h(self, convert: true) + "#<#{self.class}:0x#{object_id.to_s(16)} #{converted}>" + end + + define_sorbet_constant!(:KnownField) do + T.type_alias { {mode: T.nilable(Symbol), required: T::Boolean, nilable: T::Boolean} } + end + end + end + end +end diff --git a/lib/imagekit/internal/type/base_page.rb b/lib/imagekit/internal/type/base_page.rb new file mode 100644 index 00000000..37df829b --- /dev/null +++ b/lib/imagekit/internal/type/base_page.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true + +module Imagekit + module Internal + module Type + # @api private + # + # @generic Elem + # + # This module provides a base implementation for paginated responses in the SDK. + module BasePage + # rubocop:disable Lint/UnusedMethodArgument + + # @api public + # + # @return [Boolean] + def next_page? = (raise NotImplementedError) + + # @api public + # + # @raise [Imagekit::Errors::APIError] + # @return [self] + def next_page = (raise NotImplementedError) + + # @api public + # + # @param blk [Proc] + # + # @yieldparam [generic] + # @return [void] + def auto_paging_each(&blk) = (raise NotImplementedError) + + # @return [Enumerable>] + def to_enum = super(:auto_paging_each) + + alias_method :enum_for, :to_enum + + # @api private + # + # @param client [Imagekit::Internal::Transport::BaseClient] + # @param req [Hash{Symbol=>Object}] + # @param headers [Hash{String=>String}] + # @param page_data [Object] + def initialize(client:, req:, headers:, page_data:) + @client = client + @req = req + @model = req.fetch(:model) + super() + end + + # rubocop:enable Lint/UnusedMethodArgument + end + end + end +end diff --git a/lib/imagekit/internal/type/boolean.rb b/lib/imagekit/internal/type/boolean.rb new file mode 100644 index 00000000..52ecc971 --- /dev/null +++ b/lib/imagekit/internal/type/boolean.rb @@ -0,0 +1,77 @@ +# frozen_string_literal: true + +module Imagekit + module Internal + module Type + # @api private + # + # @abstract + # + # Ruby has no Boolean class; this is something for models to refer to. + class Boolean + extend Imagekit::Internal::Type::Converter + extend Imagekit::Internal::Util::SorbetRuntimeSupport + + private_class_method :new + + # @api public + # + # @param other [Object] + # + # @return [Boolean] + def self.===(other) = other == true || other == false + + # @api public + # + # @param other [Object] + # + # @return [Boolean] + def self.==(other) = other.is_a?(Class) && other <= Imagekit::Internal::Type::Boolean + + class << self + # @api private + # + # Coerce value to Boolean if possible, otherwise return the original value. + # + # @param value [Boolean, Object] + # + # @param state [Hash{Symbol=>Object}] . + # + # @option state [Boolean] :translate_names + # + # @option state [Boolean] :strictness + # + # @option state [Hash{Symbol=>Object}] :exactness + # + # @option state [Class] :error + # + # @option state [Integer] :branched + # + # @return [Boolean, Object] + def coerce(value, state:) + state.fetch(:exactness)[value == true || value == false ? :yes : :no] += 1 + value + end + + # @!method dump(value, state:) + # @api private + # + # @param value [Boolean, Object] + # + # @param state [Hash{Symbol=>Object}] . + # + # @option state [Boolean] :can_retry + # + # @return [Boolean, Object] + + # @api private + # + # @return [Object] + def to_sorbet_type + T::Boolean + end + end + end + end + end +end diff --git a/lib/imagekit/internal/type/converter.rb b/lib/imagekit/internal/type/converter.rb new file mode 100644 index 00000000..90a839c6 --- /dev/null +++ b/lib/imagekit/internal/type/converter.rb @@ -0,0 +1,327 @@ +# frozen_string_literal: true + +module Imagekit + module Internal + module Type + # @api private + module Converter + extend Imagekit::Internal::Util::SorbetRuntimeSupport + + # rubocop:disable Lint/UnusedMethodArgument + + # @api private + # + # @param value [Object] + # + # @param state [Hash{Symbol=>Object}] . + # + # @option state [Boolean] :translate_names + # + # @option state [Boolean] :strictness + # + # @option state [Hash{Symbol=>Object}] :exactness + # + # @option state [Class] :error + # + # @option state [Integer] :branched + # + # @return [Object] + def coerce(value, state:) = (raise NotImplementedError) + + # @api private + # + # @param value [Object] + # + # @param state [Hash{Symbol=>Object}] . + # + # @option state [Boolean] :can_retry + # + # @return [Object] + def dump(value, state:) + case value + in Array + value.map { Imagekit::Internal::Type::Unknown.dump(_1, state: state) } + in Hash + value.transform_values { Imagekit::Internal::Type::Unknown.dump(_1, state: state) } + in Imagekit::Internal::Type::BaseModel + value.class.dump(value, state: state) + in StringIO + value.string + in Pathname | IO + state[:can_retry] = false if value.is_a?(IO) + Imagekit::FilePart.new(value) + in Imagekit::FilePart + state[:can_retry] = false if value.content.is_a?(IO) + value + else + value + end + end + + # @api private + # + # @param depth [Integer] + # + # @return [String] + def inspect(depth: 0) + super() + end + + # rubocop:enable Lint/UnusedMethodArgument + + class << self + # @api private + # + # @param spec [Hash{Symbol=>Object}, Proc, Imagekit::Internal::Type::Converter, Class] . + # + # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const + # + # @option spec [Proc] :enum + # + # @option spec [Proc] :union + # + # @option spec [Boolean] :"nil?" + # + # @return [Proc] + def type_info(spec) + case spec + in Proc + spec + in Hash + type_info(spec.slice(:const, :enum, :union).first&.last) + in true | false + -> { Imagekit::Internal::Type::Boolean } + in Imagekit::Internal::Type::Converter | Class | Symbol + -> { spec } + in NilClass | Integer | Float + -> { spec.class } + end + end + + # @api private + # + # @param type_info [Hash{Symbol=>Object}, Proc, Imagekit::Internal::Type::Converter, Class] . + # + # @option type_info [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const + # + # @option type_info [Proc] :enum + # + # @option type_info [Proc] :union + # + # @option type_info [Boolean] :"nil?" + # + # @param spec [Hash{Symbol=>Object}, Proc, Imagekit::Internal::Type::Converter, Class] . + # + # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const + # + # @option spec [Proc] :enum + # + # @option spec [Proc] :union + # + # @option spec [Boolean] :"nil?" + # + # @return [Hash{Symbol=>Object}] + def meta_info(type_info, spec) + [spec, type_info].grep(Hash).first.to_h.except(:const, :enum, :union, :nil?) + end + + # @api private + # + # @param translate_names [Boolean] + # + # @return [Hash{Symbol=>Object}] + def new_coerce_state(translate_names: true) + { + translate_names: translate_names, + strictness: true, + exactness: {yes: 0, no: 0, maybe: 0}, + error: nil, + branched: 0 + } + end + + # @api private + # + # Based on `target`, transform `value` into `target`, to the extent possible: + # + # 1. if the given `value` conforms to `target` already, return the given `value` + # 2. if it's possible and safe to convert the given `value` to `target`, then the + # converted value + # 3. otherwise, the given `value` unaltered + # + # The coercion process is subject to improvement between minor release versions. + # See https://docs.pydantic.dev/latest/concepts/unions/#smart-mode + # + # @param target [Imagekit::Internal::Type::Converter, Class] + # + # @param value [Object] + # + # @param state [Hash{Symbol=>Object}] The `strictness` is one of `true`, `false`. This informs the coercion strategy + # when we have to decide between multiple possible conversion targets: + # + # - `true`: the conversion must be exact, with minimum coercion. + # - `false`: the conversion can be approximate, with some coercion. + # + # The `exactness` is `Hash` with keys being one of `yes`, `no`, or `maybe`. For + # any given conversion attempt, the exactness will be updated based on how closely + # the value recursively matches the target type: + # + # - `yes`: the value can be converted to the target type with minimum coercion. + # - `maybe`: the value can be converted to the target type with some reasonable + # coercion. + # - `no`: the value cannot be converted to the target type. + # + # See implementation below for more details. + # + # @option state [Boolean] :translate_names + # + # @option state [Boolean] :strictness + # + # @option state [Hash{Symbol=>Object}] :exactness + # + # @option state [Class] :error + # + # @option state [Integer] :branched + # + # @return [Object] + def coerce(target, value, state: Imagekit::Internal::Type::Converter.new_coerce_state) + # rubocop:disable Metrics/BlockNesting + exactness = state.fetch(:exactness) + + case target + in Imagekit::Internal::Type::Converter + return target.coerce(value, state: state) + in Class + if value.is_a?(target) + exactness[:yes] += 1 + return value + end + + case target + in -> { _1 <= NilClass } + exactness[value.nil? ? :yes : :maybe] += 1 + return nil + in -> { _1 <= Integer } + case value + in Integer + exactness[:yes] += 1 + return value + else + Kernel.then do + return Integer(value).tap { exactness[:maybe] += 1 } + rescue ArgumentError, TypeError => e + state[:error] = e + end + end + in -> { _1 <= Float } + if value.is_a?(Numeric) + exactness[:yes] += 1 + return Float(value) + else + Kernel.then do + return Float(value).tap { exactness[:maybe] += 1 } + rescue ArgumentError, TypeError => e + state[:error] = e + end + end + in -> { _1 <= String } + case value + in String | Symbol | Numeric + exactness[value.is_a?(Numeric) ? :maybe : :yes] += 1 + return value.to_s + in StringIO + exactness[:yes] += 1 + return value.string + else + state[:error] = TypeError.new("#{value.class} can't be coerced into #{String}") + end + in -> { _1 <= Date || _1 <= Time } + Kernel.then do + return target.parse(value).tap { exactness[:yes] += 1 } + rescue ArgumentError, TypeError => e + state[:error] = e + end + in -> { _1 <= StringIO } if value.is_a?(String) + exactness[:yes] += 1 + return StringIO.new(value.b) + else + end + in Symbol + case value + in Symbol | String + if value.to_sym == target + exactness[:yes] += 1 + return target + else + exactness[:maybe] += 1 + return value + end + else + message = "cannot convert non-matching #{value.class} into #{target.inspect}" + state[:error] = ArgumentError.new(message) + end + else + end + + exactness[:no] += 1 + value + # rubocop:enable Metrics/BlockNesting + end + + # @api private + # + # @param target [Imagekit::Internal::Type::Converter, Class] + # + # @param value [Object] + # + # @param state [Hash{Symbol=>Object}] . + # + # @option state [Boolean] :can_retry + # + # @return [Object] + def dump(target, value, state: {can_retry: true}) + case target + in Imagekit::Internal::Type::Converter + target.dump(value, state: state) + else + Imagekit::Internal::Type::Unknown.dump(value, state: state) + end + end + + # @api private + # + # @param target [Object] + # @param depth [Integer] + # + # @return [String] + def inspect(target, depth:) + case target + in Imagekit::Internal::Type::Converter + target.inspect(depth: depth.succ) + else + target.inspect + end + end + end + + define_sorbet_constant!(:Input) do + T.type_alias { T.any(Imagekit::Internal::Type::Converter, T::Class[T.anything]) } + end + define_sorbet_constant!(:CoerceState) do + T.type_alias do + { + translate_names: T::Boolean, + strictness: T::Boolean, + exactness: {yes: Integer, no: Integer, maybe: Integer}, + error: T::Class[StandardError], + branched: Integer + } + end + end + define_sorbet_constant!(:DumpState) do + T.type_alias { {can_retry: T::Boolean} } + end + end + end + end +end diff --git a/lib/imagekit/internal/type/enum.rb b/lib/imagekit/internal/type/enum.rb new file mode 100644 index 00000000..f8cfca79 --- /dev/null +++ b/lib/imagekit/internal/type/enum.rb @@ -0,0 +1,156 @@ +# frozen_string_literal: true + +module Imagekit + module Internal + module Type + # @api private + # + # A value from among a specified list of options. OpenAPI enum values map to Ruby + # values in the SDK as follows: + # + # 1. boolean => true | false + # 2. integer => Integer + # 3. float => Float + # 4. string => Symbol + # + # We can therefore convert string values to Symbols, but can't convert other + # values safely. + # + # @example + # # `streaming_resolution` is a `Imagekit::StreamingResolution` + # case streaming_resolution + # when Imagekit::StreamingResolution::STREAMING_RESOLUTION_240 + # # ... + # when Imagekit::StreamingResolution::STREAMING_RESOLUTION_360 + # # ... + # when Imagekit::StreamingResolution::STREAMING_RESOLUTION_480 + # # ... + # else + # puts(streaming_resolution) + # end + # + # @example + # case streaming_resolution + # in :"240" + # # ... + # in :"360" + # # ... + # in :"480" + # # ... + # else + # puts(streaming_resolution) + # end + module Enum + include Imagekit::Internal::Type::Converter + include Imagekit::Internal::Util::SorbetRuntimeSupport + + # All of the valid Symbol values for this enum. + # + # @return [Array] + def values = constants.map { const_get(_1) } + + # @api public + # + # @param other [Object] + # + # @return [Boolean] + def ===(other) = values.include?(other) + + # @api public + # + # @param other [Object] + # + # @return [Boolean] + def ==(other) + # rubocop:disable Style/CaseEquality + Imagekit::Internal::Type::Enum === other && other.values.to_set == values.to_set + # rubocop:enable Style/CaseEquality + end + + # @api public + # + # @return [Integer] + def hash = values.to_set.hash + + # @api private + # + # Unlike with primitives, `Enum` additionally validates that the value is a member + # of the enum. + # + # @param value [String, Symbol, Object] + # + # @param state [Hash{Symbol=>Object}] . + # + # @option state [Boolean] :translate_names + # + # @option state [Boolean] :strictness + # + # @option state [Hash{Symbol=>Object}] :exactness + # + # @option state [Class] :error + # + # @option state [Integer] :branched + # + # @return [Symbol, Object] + def coerce(value, state:) + exactness = state.fetch(:exactness) + val = value.is_a?(String) ? value.to_sym : value + + if values.include?(val) + exactness[:yes] += 1 + val + elsif values.first&.class == val.class + exactness[:maybe] += 1 + value + else + exactness[:no] += 1 + state[:error] = TypeError.new("#{value.class} can't be coerced into #{self}") + value + end + end + + # @!method dump(value, state:) + # @api private + # + # @param value [Symbol, Object] + # + # @param state [Hash{Symbol=>Object}] . + # + # @option state [Boolean] :can_retry + # + # @return [Symbol, Object] + + # @api private + # + # @return [Object] + def to_sorbet_type + types = values.map { Imagekit::Internal::Util::SorbetRuntimeSupport.to_sorbet_type(_1) }.uniq + case types + in [] + T.noreturn + in [type] + type + else + T.any(*types) + end + end + + # @api private + # + # @param depth [Integer] + # + # @return [String] + def inspect(depth: 0) + if depth.positive? + return is_a?(Module) ? super() : self.class.name + end + + members = values.map { Imagekit::Internal::Type::Converter.inspect(_1, depth: depth.succ) } + prefix = is_a?(Module) ? name : self.class.name + + "#{prefix}[#{members.join(' | ')}]" + end + end + end + end +end diff --git a/lib/imagekit/internal/type/file_input.rb b/lib/imagekit/internal/type/file_input.rb new file mode 100644 index 00000000..125add8f --- /dev/null +++ b/lib/imagekit/internal/type/file_input.rb @@ -0,0 +1,108 @@ +# frozen_string_literal: true + +module Imagekit + module Internal + module Type + # @api private + # + # @abstract + # + # Either `Pathname` or `StringIO`, or `IO`, or + # `Imagekit::Internal::Type::FileInput`. + # + # Note: when `IO` is used, all retries are disabled, since many IO` streams are + # not rewindable. + class FileInput + extend Imagekit::Internal::Type::Converter + + private_class_method :new + + # @api public + # + # @param other [Object] + # + # @return [Boolean] + def self.===(other) + case other + in Pathname | StringIO | IO | String | Imagekit::FilePart + true + else + false + end + end + + # @api public + # + # @param other [Object] + # + # @return [Boolean] + def self.==(other) = other.is_a?(Class) && other <= Imagekit::Internal::Type::FileInput + + class << self + # @api private + # + # @param value [StringIO, String, Object] + # + # @param state [Hash{Symbol=>Object}] . + # + # @option state [Boolean] :translate_names + # + # @option state [Boolean] :strictness + # + # @option state [Hash{Symbol=>Object}] :exactness + # + # @option state [Class] :error + # + # @option state [Integer] :branched + # + # @return [StringIO, Object] + def coerce(value, state:) + exactness = state.fetch(:exactness) + case value + in String + exactness[:yes] += 1 + StringIO.new(value) + in StringIO + exactness[:yes] += 1 + value + else + state[:error] = TypeError.new("#{value.class} can't be coerced into #{StringIO}") + exactness[:no] += 1 + value + end + end + + # @api private + # + # @param value [Pathname, StringIO, IO, String, Object] + # + # @param state [Hash{Symbol=>Object}] . + # + # @option state [Boolean] :can_retry + # + # @return [Pathname, StringIO, IO, String, Object] + def dump(value, state:) + # rubocop:disable Lint/DuplicateBranch + case value + in IO + state[:can_retry] = false + in Imagekit::FilePart if value.content.is_a?(IO) + state[:can_retry] = false + else + end + # rubocop:enable Lint/DuplicateBranch + + value + end + + # @api private + # + # @return [Object] + def to_sorbet_type + T.any(Pathname, StringIO, IO, String, Imagekit::FilePart) + end + end + end + end + end +end diff --git a/lib/imagekit/internal/type/hash_of.rb b/lib/imagekit/internal/type/hash_of.rb new file mode 100644 index 00000000..20a0aa22 --- /dev/null +++ b/lib/imagekit/internal/type/hash_of.rb @@ -0,0 +1,188 @@ +# frozen_string_literal: true + +module Imagekit + module Internal + module Type + # @api private + # + # @abstract + # + # @generic Elem + # + # Hash of items of a given type. + class HashOf + include Imagekit::Internal::Type::Converter + include Imagekit::Internal::Util::SorbetRuntimeSupport + + private_class_method :new + + # @overload [](type_info, spec = {}) + # + # @param type_info [Hash{Symbol=>Object}, Proc, Imagekit::Internal::Type::Converter, Class] + # + # @param spec [Hash{Symbol=>Object}] . + # + # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const + # + # @option spec [Proc] :enum + # + # @option spec [Proc] :union + # + # @option spec [Boolean] :"nil?" + # + # @return [self] + def self.[](...) = new(...) + + # @api public + # + # @param other [Object] + # + # @return [Boolean] + def ===(other) + type = item_type + case other + in Hash + other.all? do |key, val| + case [key, val] + in [Symbol | String, ^type] + true + else + false + end + end + else + false + end + end + + # @api public + # + # @param other [Object] + # + # @return [Boolean] + def ==(other) + # rubocop:disable Layout/LineLength + other.is_a?(Imagekit::Internal::Type::HashOf) && other.nilable? == nilable? && other.item_type == item_type + # rubocop:enable Layout/LineLength + end + + # @api public + # + # @return [Integer] + def hash = [self.class, item_type].hash + + # @api private + # + # @param value [Hash{Object=>Object}, Object] + # + # @param state [Hash{Symbol=>Object}] . + # + # @option state [Boolean] :translate_names + # + # @option state [Boolean] :strictness + # + # @option state [Hash{Symbol=>Object}] :exactness + # + # @option state [Class] :error + # + # @option state [Integer] :branched + # + # @return [Hash{Symbol=>Object}, Object] + def coerce(value, state:) + exactness = state.fetch(:exactness) + + unless value.is_a?(Hash) + exactness[:no] += 1 + state[:error] = TypeError.new("#{value.class} can't be coerced into #{Hash}") + return value + end + + target = item_type + exactness[:yes] += 1 + value + .to_h do |key, val| + k = key.is_a?(String) ? key.to_sym : key + v = + case [nilable?, val] + in [true, nil] + exactness[:yes] += 1 + nil + else + Imagekit::Internal::Type::Converter.coerce(target, val, state: state) + end + + exactness[:no] += 1 unless k.is_a?(Symbol) + [k, v] + end + end + + # @api private + # + # @param value [Hash{Object=>Object}, Object] + # + # @param state [Hash{Symbol=>Object}] . + # + # @option state [Boolean] :can_retry + # + # @return [Hash{Symbol=>Object}, Object] + def dump(value, state:) + target = item_type + if value.is_a?(Hash) + value.transform_values do + Imagekit::Internal::Type::Converter.dump(target, _1, state: state) + end + else + super + end + end + + # @api private + # + # @return [Object] + def to_sorbet_type + T::Hash[Imagekit::Internal::Util::SorbetRuntimeSupport.to_sorbet_type(item_type)] + end + + # @api private + # + # @return [generic] + protected def item_type = @item_type_fn.call + + # @api private + # + # @return [Boolean] + protected def nilable? = @nilable + + # @api private + # + # @param type_info [Hash{Symbol=>Object}, Proc, Imagekit::Internal::Type::Converter, Class] + # + # @param spec [Hash{Symbol=>Object}] . + # + # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const + # + # @option spec [Proc] :enum + # + # @option spec [Proc] :union + # + # @option spec [Boolean] :"nil?" + def initialize(type_info, spec = {}) + @item_type_fn = Imagekit::Internal::Type::Converter.type_info(type_info || spec) + @meta = Imagekit::Internal::Type::Converter.meta_info(type_info, spec) + @nilable = spec.fetch(:nil?, false) + end + + # @api private + # + # @param depth [Integer] + # + # @return [String] + def inspect(depth: 0) + items = Imagekit::Internal::Type::Converter.inspect(item_type, depth: depth.succ) + + "#{self.class}[#{[items, nilable? ? 'nil' : nil].compact.join(' | ')}]" + end + end + end + end +end diff --git a/lib/imagekit/internal/type/request_parameters.rb b/lib/imagekit/internal/type/request_parameters.rb new file mode 100644 index 00000000..73dff299 --- /dev/null +++ b/lib/imagekit/internal/type/request_parameters.rb @@ -0,0 +1,42 @@ +# frozen_string_literal: true + +module Imagekit + module Internal + module Type + # @api private + module RequestParameters + # @!attribute request_options + # Options to specify HTTP behaviour for this request. + # + # @return [Imagekit::RequestOptions, Hash{Symbol=>Object}] + + # @param mod [Module] + def self.included(mod) + raise ArgumentError.new(mod) unless mod <= Imagekit::Internal::Type::BaseModel + + mod.optional(:request_options, Imagekit::RequestOptions) + end + + # @api private + module Converter + # @api private + # + # @param params [Object] + # + # @return [Array(Object, Hash{Symbol=>Object})] + def dump_request(params) + state = {can_retry: true} + case (dumped = dump(params, state: state)) + in Hash + options = Imagekit::Internal::Util.coerce_hash!(dumped[:request_options]).to_h + request_options = state.fetch(:can_retry) ? options : {**options, max_retries: 0} + [dumped.except(:request_options), request_options] + else + [dumped, nil] + end + end + end + end + end + end +end diff --git a/lib/imagekit/internal/type/union.rb b/lib/imagekit/internal/type/union.rb new file mode 100644 index 00000000..56cb34b1 --- /dev/null +++ b/lib/imagekit/internal/type/union.rb @@ -0,0 +1,250 @@ +# frozen_string_literal: true + +module Imagekit + module Internal + module Type + # @api private + # + # @example + # # `overlay` is a `Imagekit::Overlay` + # case overlay + # when Imagekit::TextOverlay + # # ... + # when Imagekit::ImageOverlay + # # ... + # when Imagekit::VideoOverlay + # # ... + # else + # puts(overlay) + # end + module Union + include Imagekit::Internal::Type::Converter + include Imagekit::Internal::Util::SorbetRuntimeSupport + + # @api private + # + # All of the specified variant info for this union. + # + # @return [ArrayObject})>] + private def known_variants = (@known_variants ||= []) + + # @api private + # + # @return [ArrayObject})>] + protected def derefed_variants + known_variants.map { |key, variant_fn, meta| [key, variant_fn.call, meta] } + end + + # All of the specified variants for this union. + # + # @return [Array] + def variants = derefed_variants.map { _2 } + + # @api private + # + # @param property [Symbol] + private def discriminator(property) + case property + in Symbol + @discriminator = property + end + end + + # @api private + # + # @param key [Symbol, Hash{Symbol=>Object}, Proc, Imagekit::Internal::Type::Converter, Class] + # + # @param spec [Hash{Symbol=>Object}, Proc, Imagekit::Internal::Type::Converter, Class] . + # + # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const + # + # @option spec [Proc] :enum + # + # @option spec [Proc] :union + # + # @option spec [Boolean] :"nil?" + private def variant(key, spec = nil) + meta = Imagekit::Internal::Type::Converter.meta_info(nil, spec) + variant_info = + case key + in Symbol + [key, Imagekit::Internal::Type::Converter.type_info(spec), meta] + in Proc | Imagekit::Internal::Type::Converter | Class | Hash + [nil, Imagekit::Internal::Type::Converter.type_info(key), meta] + end + + known_variants << variant_info + end + + # @api private + # + # @param value [Object] + # + # @return [Imagekit::Internal::Type::Converter, Class, nil] + private def resolve_variant(value) + case [@discriminator, value] + in [_, Imagekit::Internal::Type::BaseModel] + value.class + in [Symbol, Hash] + key = value.fetch(@discriminator) do + value.fetch(@discriminator.to_s, Imagekit::Internal::OMIT) + end + + return nil if key == Imagekit::Internal::OMIT + + key = key.to_sym if key.is_a?(String) + _, found = known_variants.find { |k,| k == key } + found&.call + else + nil + end + end + + # rubocop:disable Style/HashEachMethods + # rubocop:disable Style/CaseEquality + + # @api public + # + # @param other [Object] + # + # @return [Boolean] + def ===(other) + known_variants.any? do |_, variant_fn| + variant_fn.call === other + end + end + + # @api public + # + # @param other [Object] + # + # @return [Boolean] + def ==(other) + Imagekit::Internal::Type::Union === other && other.derefed_variants == derefed_variants + end + + # @api public + # + # @return [Integer] + def hash = variants.hash + + # @api private + # + # Tries to efficiently coerce the given value to one of the known variants. + # + # If the value cannot match any of the known variants, the coercion is considered + # non-viable and returns the original value. + # + # @param value [Object] + # + # @param state [Hash{Symbol=>Object}] . + # + # @option state [Boolean] :translate_names + # + # @option state [Boolean] :strictness + # + # @option state [Hash{Symbol=>Object}] :exactness + # + # @option state [Class] :error + # + # @option state [Integer] :branched + # + # @return [Object] + def coerce(value, state:) + if (target = resolve_variant(value)) + return Imagekit::Internal::Type::Converter.coerce(target, value, state: state) + end + + strictness = state.fetch(:strictness) + exactness = state.fetch(:exactness) + + alternatives = [] + known_variants.each do |_, variant_fn| + target = variant_fn.call + exact = state[:exactness] = {yes: 0, no: 0, maybe: 0} + state[:branched] += 1 + + coerced = Imagekit::Internal::Type::Converter.coerce(target, value, state: state) + yes, no, maybe = exact.values + if (no + maybe).zero? || (!strictness && yes.positive?) + exact.each { exactness[_1] += _2 } + state[:exactness] = exactness + return coerced + elsif maybe.positive? + alternatives << [[-yes, -maybe, no], exact, coerced] + end + end + + case alternatives.sort_by!(&:first) + in [] + exactness[:no] += 1 + state[:error] = ArgumentError.new("no matching variant for #{value.inspect}") + value + in [[_, exact, coerced], *] + exact.each { exactness[_1] += _2 } + coerced + end + .tap { state[:exactness] = exactness } + ensure + state[:strictness] = strictness + end + + # @api private + # + # @param value [Object] + # + # @param state [Hash{Symbol=>Object}] . + # + # @option state [Boolean] :can_retry + # + # @return [Object] + def dump(value, state:) + if (target = resolve_variant(value)) + return Imagekit::Internal::Type::Converter.dump(target, value, state: state) + end + + known_variants.each do + target = _2.call + return Imagekit::Internal::Type::Converter.dump(target, value, state: state) if target === value + end + + super + end + + # @api private + # + # @return [Object] + def to_sorbet_type + types = variants.map { Imagekit::Internal::Util::SorbetRuntimeSupport.to_sorbet_type(_1) }.uniq + case types + in [] + T.noreturn + in [type] + type + else + T.any(*types) + end + end + + # rubocop:enable Style/CaseEquality + # rubocop:enable Style/HashEachMethods + + # @api private + # + # @param depth [Integer] + # + # @return [String] + def inspect(depth: 0) + if depth.positive? + return is_a?(Module) ? super() : self.class.name + end + + members = variants.map { Imagekit::Internal::Type::Converter.inspect(_1, depth: depth.succ) } + prefix = is_a?(Module) ? name : self.class.name + + "#{prefix}[#{members.join(' | ')}]" + end + end + end + end +end diff --git a/lib/imagekit/internal/type/unknown.rb b/lib/imagekit/internal/type/unknown.rb new file mode 100644 index 00000000..43a4573a --- /dev/null +++ b/lib/imagekit/internal/type/unknown.rb @@ -0,0 +1,81 @@ +# frozen_string_literal: true + +module Imagekit + module Internal + module Type + # @api private + # + # @abstract + # + # When we don't know what to expect for the value. + class Unknown + extend Imagekit::Internal::Type::Converter + extend Imagekit::Internal::Util::SorbetRuntimeSupport + + # rubocop:disable Lint/UnusedMethodArgument + + private_class_method :new + + # @api public + # + # @param other [Object] + # + # @return [Boolean] + def self.===(other) = true + + # @api public + # + # @param other [Object] + # + # @return [Boolean] + def self.==(other) = other.is_a?(Class) && other <= Imagekit::Internal::Type::Unknown + + class << self + # @api private + # + # No coercion needed for Unknown type. + # + # @param value [Object] + # + # @param state [Hash{Symbol=>Object}] . + # + # @option state [Boolean] :translate_names + # + # @option state [Boolean] :strictness + # + # @option state [Hash{Symbol=>Object}] :exactness + # + # @option state [Class] :error + # + # @option state [Integer] :branched + # + # @return [Object] + def coerce(value, state:) + state.fetch(:exactness)[:yes] += 1 + value + end + + # @!method dump(value, state:) + # @api private + # + # @param value [Object] + # + # @param state [Hash{Symbol=>Object}] . + # + # @option state [Boolean] :can_retry + # + # @return [Object] + + # @api private + # + # @return [Object] + def to_sorbet_type + T.anything + end + end + + # rubocop:enable Lint/UnusedMethodArgument + end + end + end +end diff --git a/lib/imagekit/internal/util.rb b/lib/imagekit/internal/util.rb new file mode 100644 index 00000000..14ac714a --- /dev/null +++ b/lib/imagekit/internal/util.rb @@ -0,0 +1,914 @@ +# frozen_string_literal: true + +module Imagekit + module Internal + # @api private + module Util + # @api private + # + # @return [Float] + def self.monotonic_secs = Process.clock_gettime(Process::CLOCK_MONOTONIC) + + # @api private + # + # @param ns [Module, Class] + # + # @return [Enumerable] + def self.walk_namespaces(ns) + ns.constants(false).lazy.flat_map do + case (c = ns.const_get(_1, false)) + in Module | Class + walk_namespaces(c) + else + [] + end + end + .chain([ns]) + end + + class << self + # @api private + # + # @return [String] + def arch + case (arch = RbConfig::CONFIG["arch"])&.downcase + in nil + "unknown" + in /aarch64|arm64/ + "arm64" + in /x86_64/ + "x64" + in /arm/ + "arm" + else + "other:#{arch}" + end + end + + # @api private + # + # @return [String] + def os + case (host = RbConfig::CONFIG["host_os"])&.downcase + in nil + "Unknown" + in /linux/ + "Linux" + in /darwin/ + "MacOS" + in /freebsd/ + "FreeBSD" + in /openbsd/ + "OpenBSD" + in /mswin|mingw|cygwin|ucrt/ + "Windows" + else + "Other:#{host}" + end + end + end + + class << self + # @api private + # + # @param input [Object] + # + # @return [Boolean] + def primitive?(input) + case input + in true | false | Numeric | Symbol | String + true + else + false + end + end + + # @api private + # + # @param input [String, Boolean] + # + # @return [Boolean, Object] + def coerce_boolean(input) + case input.is_a?(String) ? input.downcase : input + in "true" + true + in "false" + false + else + input + end + end + + # @api private + # + # @param input [String, Boolean] + # + # @raise [ArgumentError] + # @return [Boolean, nil] + def coerce_boolean!(input) + case coerce_boolean(input) + in true | false | nil => coerced + coerced + else + raise ArgumentError.new("Unable to coerce #{input.inspect} into boolean value") + end + end + + # @api private + # + # @param input [String, Integer] + # + # @return [Integer, Object] + def coerce_integer(input) + Integer(input, exception: false) || input + end + + # @api private + # + # @param input [String, Integer, Float] + # + # @return [Float, Object] + def coerce_float(input) + Float(input, exception: false) || input + end + + # @api private + # + # @param input [Object] + # + # @return [Hash{Object=>Object}, Object] + def coerce_hash(input) + case input + in NilClass | Array | Set | Enumerator | StringIO | IO + input + else + input.respond_to?(:to_h) ? input.to_h : input + end + end + + # @api private + # + # @param input [Object] + # + # @raise [ArgumentError] + # @return [Hash{Object=>Object}, nil] + def coerce_hash!(input) + case coerce_hash(input) + in Hash | nil => coerced + coerced + else + message = "Expected a #{Hash} or #{Imagekit::Internal::Type::BaseModel}, got #{data.inspect}" + raise ArgumentError.new(message) + end + end + end + + class << self + # @api private + # + # @param lhs [Object] + # @param rhs [Object] + # @param concat [Boolean] + # + # @return [Object] + private def deep_merge_lr(lhs, rhs, concat: false) + case [lhs, rhs, concat] + in [Hash, Hash, _] + lhs.merge(rhs) { deep_merge_lr(_2, _3, concat: concat) } + in [Array, Array, true] + lhs.concat(rhs) + else + rhs + end + end + + # @api private + # + # Recursively merge one hash with another. If the values at a given key are not + # both hashes, just take the new value. + # + # @param values [Array] + # + # @param sentinel [Object, nil] the value to return if no values are provided. + # + # @param concat [Boolean] whether to merge sequences by concatenation. + # + # @return [Object] + def deep_merge(*values, sentinel: nil, concat: false) + case values + in [value, *values] + values.reduce(value) do |acc, val| + deep_merge_lr(acc, val, concat: concat) + end + else + sentinel + end + end + + # @api private + # + # @param data [Hash{Symbol=>Object}, Array, Object] + # @param pick [Symbol, Integer, Array, Proc, nil] + # @param blk [Proc, nil] + # + # @return [Object, nil] + def dig(data, pick, &blk) + case [data, pick] + in [_, nil] + data + in [Hash, Symbol] | [Array, Integer] + data.fetch(pick) { blk&.call } + in [Hash | Array, Array] + pick.reduce(data) do |acc, key| + case acc + in Hash if acc.key?(key) + acc.fetch(key) + in Array if key.is_a?(Integer) && key < acc.length + acc[key] + else + return blk&.call + end + end + in [_, Proc] + pick.call(data) + else + blk&.call + end + end + end + + class << self + # @api private + # + # @param uri [URI::Generic] + # + # @return [String] + def uri_origin(uri) + "#{uri.scheme}://#{uri.host}#{":#{uri.port}" unless uri.port == uri.default_port}" + end + + # @api private + # + # @param path [String, Array] + # + # @return [String] + def interpolate_path(path) + case path + in String + path + in [] + "" + in [String => p, *interpolations] + encoded = interpolations.map { ERB::Util.url_encode(_1) } + format(p, *encoded) + end + end + end + + class << self + # @api private + # + # @param query [String, nil] + # + # @return [Hash{String=>Array}] + def decode_query(query) + CGI.parse(query.to_s) + end + + # @api private + # + # @param query [Hash{String=>Array, String, nil}, nil] + # + # @return [String, nil] + def encode_query(query) + query.to_h.empty? ? nil : URI.encode_www_form(query) + end + end + + class << self + # @api private + # + # @param url [URI::Generic, String] + # + # @return [Hash{Symbol=>String, Integer, nil}] + def parse_uri(url) + parsed = URI::Generic.component.zip(URI.split(url)).to_h + {**parsed, query: decode_query(parsed.fetch(:query))} + end + + # @api private + # + # @param parsed [Hash{Symbol=>String, Integer, nil}] . + # + # @option parsed [String, nil] :scheme + # + # @option parsed [String, nil] :host + # + # @option parsed [Integer, nil] :port + # + # @option parsed [String, nil] :path + # + # @option parsed [Hash{String=>Array}] :query + # + # @return [URI::Generic] + def unparse_uri(parsed) + URI::Generic.build(**parsed, query: encode_query(parsed.fetch(:query))) + end + + # @api private + # + # @param lhs [Hash{Symbol=>String, Integer, nil}] . + # + # @option lhs [String, nil] :scheme + # + # @option lhs [String, nil] :host + # + # @option lhs [Integer, nil] :port + # + # @option lhs [String, nil] :path + # + # @option lhs [Hash{String=>Array}] :query + # + # @param rhs [Hash{Symbol=>String, Integer, nil}] . + # + # @option rhs [String, nil] :scheme + # + # @option rhs [String, nil] :host + # + # @option rhs [Integer, nil] :port + # + # @option rhs [String, nil] :path + # + # @option rhs [Hash{String=>Array}] :query + # + # @return [URI::Generic] + def join_parsed_uri(lhs, rhs) + base_path, base_query = lhs.fetch_values(:path, :query) + slashed = base_path.end_with?("/") ? base_path : "#{base_path}/" + + parsed_path, parsed_query = parse_uri(rhs.fetch(:path)).fetch_values(:path, :query) + override = URI::Generic.build(**rhs.slice(:scheme, :host, :port), path: parsed_path) + + joined = URI.join(URI::Generic.build(lhs.except(:path, :query)), slashed, override) + query = deep_merge( + joined.path == base_path ? base_query : {}, + parsed_query, + rhs[:query].to_h, + concat: true + ) + + joined.query = encode_query(query) + joined + end + end + + class << self + # @api private + # + # @param headers [Hash{String=>String, Integer, Array, nil}] + # + # @return [Hash{String=>String}] + def normalized_headers(*headers) + {}.merge(*headers.compact).to_h do |key, val| + value = + case val + in Array + val.filter_map { _1&.to_s&.strip }.join(", ") + else + val&.to_s&.strip + end + [key.downcase, value] + end + end + end + + # @api private + # + # An adapter that satisfies the IO interface required by `::IO.copy_stream` + class ReadIOAdapter + # @api private + # + # @return [Boolean, nil] + def close? = @closing + + # @api private + def close + case @stream + in Enumerator + Imagekit::Internal::Util.close_fused!(@stream) + in IO if close? + @stream.close + else + end + end + + # @api private + # + # @param max_len [Integer, nil] + # + # @return [String] + private def read_enum(max_len) + case max_len + in nil + @stream.to_a.join + in Integer + @buf << @stream.next while @buf.length < max_len + @buf.slice!(..max_len) + end + rescue StopIteration + @stream = nil + @buf.slice!(0..) + end + + # @api private + # + # @param max_len [Integer, nil] + # @param out_string [String, nil] + # + # @return [String, nil] + def read(max_len = nil, out_string = nil) + case @stream + in nil + nil + in IO | StringIO + @stream.read(max_len, out_string) + in Enumerator + read = read_enum(max_len) + case out_string + in String + out_string.replace(read) + in nil + read + end + end + .tap(&@blk) + end + + # @api private + # + # @param src [String, Pathname, StringIO, Enumerable] + # @param blk [Proc] + # + # @yieldparam [String] + def initialize(src, &blk) + @stream = + case src + in String + StringIO.new(src) + in Pathname + @closing = true + src.open(binmode: true) + else + src + end + @buf = String.new + @blk = blk + end + end + + class << self + # @param blk [Proc] + # + # @yieldparam [Enumerator::Yielder] + # @return [Enumerable] + def writable_enum(&blk) + Enumerator.new do |y| + buf = String.new + y.define_singleton_method(:write) do + self << buf.replace(_1) + buf.bytesize + end + + blk.call(y) + end + end + end + + # @type [Regexp] + JSON_CONTENT = %r{^application/(?:vnd(?:\.[^.]+)*\+)?json(?!l)} + # @type [Regexp] + JSONL_CONTENT = %r{^application/(:?x-(?:n|l)djson)|(:?(?:x-)?jsonl)} + + class << self + # @api private + # + # @param y [Enumerator::Yielder] + # @param val [Object] + # @param closing [Array] + # @param content_type [String, nil] + private def write_multipart_content(y, val:, closing:, content_type: nil) + content_line = "Content-Type: %s\r\n\r\n" + + case val + in Imagekit::FilePart + return write_multipart_content( + y, + val: val.content, + closing: closing, + content_type: val.content_type + ) + in Pathname + y << format(content_line, content_type || "application/octet-stream") + io = val.open(binmode: true) + closing << io.method(:close) + IO.copy_stream(io, y) + in IO + y << format(content_line, content_type || "application/octet-stream") + IO.copy_stream(val, y) + in StringIO + y << format(content_line, content_type || "application/octet-stream") + y << val.string + in -> { primitive?(_1) } + y << format(content_line, content_type || "text/plain") + y << val.to_s + else + y << format(content_line, content_type || "application/json") + y << JSON.generate(val) + end + y << "\r\n" + end + + # @api private + # + # @param y [Enumerator::Yielder] + # @param boundary [String] + # @param key [Symbol, String] + # @param val [Object] + # @param closing [Array] + private def write_multipart_chunk(y, boundary:, key:, val:, closing:) + y << "--#{boundary}\r\n" + y << "Content-Disposition: form-data" + + unless key.nil? + name = ERB::Util.url_encode(key.to_s) + y << "; name=\"#{name}\"" + end + + case val + in Imagekit::FilePart unless val.filename.nil? + filename = ERB::Util.url_encode(val.filename) + y << "; filename=\"#{filename}\"" + in Pathname | IO + filename = ERB::Util.url_encode(::File.basename(val.to_path)) + y << "; filename=\"#{filename}\"" + else + end + y << "\r\n" + + write_multipart_content(y, val: val, closing: closing) + end + + # @api private + # + # https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.1.md#special-considerations-for-multipart-content + # + # @param body [Object] + # + # @return [Array(String, Enumerable)] + private def encode_multipart_streaming(body) + boundary = SecureRandom.urlsafe_base64(60) + + closing = [] + strio = writable_enum do |y| + case body + in Hash + body.each do |key, val| + case val + in Array if val.all? { primitive?(_1) } + val.each do |v| + write_multipart_chunk(y, boundary: boundary, key: key, val: v, closing: closing) + end + else + write_multipart_chunk(y, boundary: boundary, key: key, val: val, closing: closing) + end + end + else + write_multipart_chunk(y, boundary: boundary, key: nil, val: body, closing: closing) + end + y << "--#{boundary}--\r\n" + end + + fused_io = fused_enum(strio) { closing.each(&:call) } + [boundary, fused_io] + end + + # @api private + # + # @param headers [Hash{String=>String}] + # @param body [Object] + # + # @return [Object] + def encode_content(headers, body) + # rubocop:disable Style/CaseEquality + # rubocop:disable Layout/LineLength + content_type = headers["content-type"] + case [content_type, body] + in [Imagekit::Internal::Util::JSON_CONTENT, Hash | Array | -> { primitive?(_1) }] + [headers, JSON.generate(body)] + in [Imagekit::Internal::Util::JSONL_CONTENT, Enumerable] unless Imagekit::Internal::Type::FileInput === body + [headers, body.lazy.map { JSON.generate(_1) }] + in [%r{^multipart/form-data}, Hash | Imagekit::Internal::Type::FileInput] + boundary, strio = encode_multipart_streaming(body) + headers = {**headers, "content-type" => "#{content_type}; boundary=#{boundary}"} + [headers, strio] + in [_, Symbol | Numeric] + [headers, body.to_s] + in [_, StringIO] + [headers, body.string] + in [_, Imagekit::FilePart] + [headers, body.content] + else + [headers, body] + end + # rubocop:enable Layout/LineLength + # rubocop:enable Style/CaseEquality + end + + # @api private + # + # https://www.iana.org/assignments/character-sets/character-sets.xhtml + # + # @param content_type [String] + # @param text [String] + def force_charset!(content_type, text:) + charset = /charset=([^;\s]+)/.match(content_type)&.captures&.first + + return unless charset + + begin + encoding = Encoding.find(charset) + text.force_encoding(encoding) + rescue ArgumentError + nil + end + end + + # @api private + # + # Assumes each chunk in stream has `Encoding::BINARY`. + # + # @param headers [Hash{String=>String}] + # @param stream [Enumerable] + # @param suppress_error [Boolean] + # + # @raise [JSON::ParserError] + # @return [Object] + def decode_content(headers, stream:, suppress_error: false) + case (content_type = headers["content-type"]) + in Imagekit::Internal::Util::JSON_CONTENT + json = stream.to_a.join + begin + JSON.parse(json, symbolize_names: true) + rescue JSON::ParserError => e + raise e unless suppress_error + json + end + in Imagekit::Internal::Util::JSONL_CONTENT + lines = decode_lines(stream) + chain_fused(lines) do |y| + lines.each { y << JSON.parse(_1, symbolize_names: true) } + end + in %r{^text/event-stream} + lines = decode_lines(stream) + decode_sse(lines) + else + text = stream.to_a.join + force_charset!(content_type, text: text) + StringIO.new(text) + end + end + end + + class << self + # @api private + # + # https://doc.rust-lang.org/std/iter/trait.FusedIterator.html + # + # @param enum [Enumerable] + # @param external [Boolean] + # @param close [Proc] + # + # @return [Enumerable] + def fused_enum(enum, external: false, &close) + fused = false + iter = Enumerator.new do |y| + next if fused + + fused = true + if external + loop { y << enum.next } + else + enum.each(&y) + end + ensure + close&.call + close = nil + end + + iter.define_singleton_method(:rewind) do + fused = true + self + end + iter + end + + # @api private + # + # @param enum [Enumerable, nil] + def close_fused!(enum) + return unless enum.is_a?(Enumerator) + + # rubocop:disable Lint/UnreachableLoop + enum.rewind.each { break } + # rubocop:enable Lint/UnreachableLoop + end + + # @api private + # + # @param enum [Enumerable, nil] + # @param blk [Proc] + # + # @yieldparam [Enumerator::Yielder] + # @return [Enumerable] + def chain_fused(enum, &blk) + iter = Enumerator.new { blk.call(_1) } + fused_enum(iter) { close_fused!(enum) } + end + end + + class << self + # @api private + # + # Assumes Strings have been forced into having `Encoding::BINARY`. + # + # This decoder is responsible for reassembling lines split across multiple + # fragments. + # + # @param enum [Enumerable] + # + # @return [Enumerable] + def decode_lines(enum) + re = /(\r\n|\r|\n)/ + buffer = String.new + cr_seen = nil + + chain_fused(enum) do |y| + enum.each do |row| + offset = buffer.bytesize + buffer << row + while (match = re.match(buffer, cr_seen&.to_i || offset)) + case [match.captures.first, cr_seen] + in ["\r", nil] + cr_seen = match.end(1) + next + in ["\r" | "\r\n", Integer] + y << buffer.slice!(..(cr_seen.pred)) + else + y << buffer.slice!(..(match.end(1).pred)) + end + offset = 0 + cr_seen = nil + end + end + + y << buffer.slice!(..(cr_seen.pred)) unless cr_seen.nil? + y << buffer unless buffer.empty? + end + end + + # @api private + # + # https://html.spec.whatwg.org/multipage/server-sent-events.html#parsing-an-event-stream + # + # Assumes that `lines` has been decoded with `#decode_lines`. + # + # @param lines [Enumerable] + # + # @return [EnumerableObject}>] + def decode_sse(lines) + # rubocop:disable Metrics/BlockLength + chain_fused(lines) do |y| + blank = {event: nil, data: nil, id: nil, retry: nil} + current = {} + + lines.each do |line| + case line.sub(/\R$/, "") + in "" + next if current.empty? + y << {**blank, **current} + current = {} + in /^:/ + next + in /^([^:]+):\s?(.*)$/ + field, value = Regexp.last_match.captures + case field + in "event" + current.merge!(event: value) + in "data" + (current[:data] ||= String.new) << (value << "\n") + in "id" unless value.include?("\0") + current.merge!(id: value) + in "retry" if /^\d+$/ =~ value + current.merge!(retry: Integer(value)) + else + end + else + end + end + # rubocop:enable Metrics/BlockLength + + y << {**blank, **current} unless current.empty? + end + end + end + + # @api private + module SorbetRuntimeSupport + class MissingSorbetRuntimeError < ::RuntimeError + end + + # @api private + # + # @return [Hash{Symbol=>Object}] + private def sorbet_runtime_constants = @sorbet_runtime_constants ||= {} + + # @api private + # + # @param name [Symbol] + def const_missing(name) + super unless sorbet_runtime_constants.key?(name) + + unless Object.const_defined?(:T) + message = "Trying to access a Sorbet constant #{name.inspect} without `sorbet-runtime`." + raise MissingSorbetRuntimeError.new(message) + end + + sorbet_runtime_constants.fetch(name).call + end + + # @api private + # + # @param name [Symbol] + # + # @return [Boolean] + def sorbet_constant_defined?(name) = sorbet_runtime_constants.key?(name) + + # @api private + # + # @param name [Symbol] + # @param blk [Proc] + def define_sorbet_constant!(name, &blk) = sorbet_runtime_constants.store(name, blk) + + # @api private + # + # @return [Object] + def to_sorbet_type = raise NotImplementedError + + class << self + # @api private + # + # @param type [Imagekit::Internal::Util::SorbetRuntimeSupport, Object] + # + # @return [Object] + def to_sorbet_type(type) + case type + in Imagekit::Internal::Util::SorbetRuntimeSupport + type.to_sorbet_type + in Class | Module + type + in true | false + T::Boolean + else + type.class + end + end + end + end + + extend Imagekit::Internal::Util::SorbetRuntimeSupport + + define_sorbet_constant!(:ParsedUri) do + T.type_alias do + { + scheme: T.nilable(String), + host: T.nilable(String), + port: T.nilable(Integer), + path: T.nilable(String), + query: T::Hash[String, T::Array[String]] + } + end + end + + define_sorbet_constant!(:ServerSentEvent) do + T.type_alias do + { + event: T.nilable(String), + data: T.nilable(String), + id: T.nilable(String), + retry: T.nilable(Integer) + } + end + end + end + end +end diff --git a/lib/imagekit/models.rb b/lib/imagekit/models.rb new file mode 100644 index 00000000..03ac79a0 --- /dev/null +++ b/lib/imagekit/models.rb @@ -0,0 +1,156 @@ +# frozen_string_literal: true + +module Imagekit + [Imagekit::Internal::Type::BaseModel, *Imagekit::Internal::Type::BaseModel.subclasses].each do |cls| + cls.define_sorbet_constant!(:OrHash) { T.type_alias { T.any(cls, Imagekit::Internal::AnyHash) } } + end + + Imagekit::Internal::Util.walk_namespaces(Imagekit::Models).each do |mod| + case mod + in Imagekit::Internal::Type::Enum | Imagekit::Internal::Type::Union + mod.constants.each do |name| + case mod.const_get(name) + in true | false + mod.define_sorbet_constant!(:TaggedBoolean) { T.type_alias { T::Boolean } } + mod.define_sorbet_constant!(:OrBoolean) { T.type_alias { T::Boolean } } + in Integer + mod.define_sorbet_constant!(:TaggedInteger) { T.type_alias { Integer } } + mod.define_sorbet_constant!(:OrInteger) { T.type_alias { Integer } } + in Float + mod.define_sorbet_constant!(:TaggedFloat) { T.type_alias { Float } } + mod.define_sorbet_constant!(:OrFloat) { T.type_alias { Float } } + in Symbol + mod.define_sorbet_constant!(:TaggedSymbol) { T.type_alias { Symbol } } + mod.define_sorbet_constant!(:OrSymbol) { T.type_alias { T.any(Symbol, String) } } + else + end + end + else + end + end + + Imagekit::Internal::Util.walk_namespaces(Imagekit::Models) + .lazy + .grep(Imagekit::Internal::Type::Union) + .each do |mod| + const = :Variants + next if mod.sorbet_constant_defined?(const) + + mod.define_sorbet_constant!(const) { T.type_alias { mod.to_sorbet_type } } + end + + Accounts = Imagekit::Models::Accounts + + AssetListParams = Imagekit::Models::AssetListParams + + BaseOverlay = Imagekit::Models::BaseOverlay + + BaseWebhookEvent = Imagekit::Models::BaseWebhookEvent + + Beta = Imagekit::Models::Beta + + Cache = Imagekit::Models::Cache + + CustomMetadataField = Imagekit::Models::CustomMetadataField + + CustomMetadataFieldCreateParams = Imagekit::Models::CustomMetadataFieldCreateParams + + CustomMetadataFieldDeleteParams = Imagekit::Models::CustomMetadataFieldDeleteParams + + CustomMetadataFieldListParams = Imagekit::Models::CustomMetadataFieldListParams + + CustomMetadataFieldUpdateParams = Imagekit::Models::CustomMetadataFieldUpdateParams + + ExtensionItem = Imagekit::Models::ExtensionItem + + # @type [Imagekit::Internal::Type::Converter] + Extensions = Imagekit::Models::Extensions + + File = Imagekit::Models::File + + FileCopyParams = Imagekit::Models::FileCopyParams + + FileDeleteParams = Imagekit::Models::FileDeleteParams + + FileGetParams = Imagekit::Models::FileGetParams + + FileMoveParams = Imagekit::Models::FileMoveParams + + FileRenameParams = Imagekit::Models::FileRenameParams + + Files = Imagekit::Models::Files + + FileUpdateParams = Imagekit::Models::FileUpdateParams + + FileUploadParams = Imagekit::Models::FileUploadParams + + Folder = Imagekit::Models::Folder + + FolderCopyParams = Imagekit::Models::FolderCopyParams + + FolderCreateParams = Imagekit::Models::FolderCreateParams + + FolderDeleteParams = Imagekit::Models::FolderDeleteParams + + FolderMoveParams = Imagekit::Models::FolderMoveParams + + FolderRenameParams = Imagekit::Models::FolderRenameParams + + Folders = Imagekit::Models::Folders + + ImageOverlay = Imagekit::Models::ImageOverlay + + Metadata = Imagekit::Models::Metadata + + Overlay = Imagekit::Models::Overlay + + OverlayPosition = Imagekit::Models::OverlayPosition + + OverlayTiming = Imagekit::Models::OverlayTiming + + SolidColorOverlay = Imagekit::Models::SolidColorOverlay + + SolidColorOverlayTransformation = Imagekit::Models::SolidColorOverlayTransformation + + SrcOptions = Imagekit::Models::SrcOptions + + StreamingResolution = Imagekit::Models::StreamingResolution + + SubtitleOverlay = Imagekit::Models::SubtitleOverlay + + SubtitleOverlayTransformation = Imagekit::Models::SubtitleOverlayTransformation + + TextOverlay = Imagekit::Models::TextOverlay + + TextOverlayTransformation = Imagekit::Models::TextOverlayTransformation + + Transformation = Imagekit::Models::Transformation + + TransformationPosition = Imagekit::Models::TransformationPosition + + UnsafeUnwrapWebhookEvent = Imagekit::Models::UnsafeUnwrapWebhookEvent + + UnwrapWebhookEvent = Imagekit::Models::UnwrapWebhookEvent + + UpdateFileRequest = Imagekit::Models::UpdateFileRequest + + UploadPostTransformErrorEvent = Imagekit::Models::UploadPostTransformErrorEvent + + UploadPostTransformSuccessEvent = Imagekit::Models::UploadPostTransformSuccessEvent + + UploadPreTransformErrorEvent = Imagekit::Models::UploadPreTransformErrorEvent + + UploadPreTransformSuccessEvent = Imagekit::Models::UploadPreTransformSuccessEvent + + VideoOverlay = Imagekit::Models::VideoOverlay + + VideoTransformationAcceptedEvent = Imagekit::Models::VideoTransformationAcceptedEvent + + VideoTransformationErrorEvent = Imagekit::Models::VideoTransformationErrorEvent + + VideoTransformationReadyEvent = Imagekit::Models::VideoTransformationReadyEvent + + WebhookUnsafeUnwrapParams = Imagekit::Models::WebhookUnsafeUnwrapParams + + WebhookUnwrapParams = Imagekit::Models::WebhookUnwrapParams +end diff --git a/lib/imagekit/models/accounts/origin_create_params.rb b/lib/imagekit/models/accounts/origin_create_params.rb new file mode 100644 index 00000000..120fed5d --- /dev/null +++ b/lib/imagekit/models/accounts/origin_create_params.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +module Imagekit + module Models + module Accounts + # @see Imagekit::Resources::Accounts::Origins#create + class OriginCreateParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + # @!attribute origin_request + # Schema for origin request resources. + # + # @return [Imagekit::Models::Accounts::OriginRequest::S3, Imagekit::Models::Accounts::OriginRequest::S3Compatible, Imagekit::Models::Accounts::OriginRequest::CloudinaryBackup, Imagekit::Models::Accounts::OriginRequest::WebFolder, Imagekit::Models::Accounts::OriginRequest::WebProxy, Imagekit::Models::Accounts::OriginRequest::Gcs, Imagekit::Models::Accounts::OriginRequest::AzureBlob, Imagekit::Models::Accounts::OriginRequest::AkeneoPim] + required :origin_request, union: -> { Imagekit::Accounts::OriginRequest } + + # @!method initialize(origin_request:, request_options: {}) + # @param origin_request [Imagekit::Models::Accounts::OriginRequest::S3, Imagekit::Models::Accounts::OriginRequest::S3Compatible, Imagekit::Models::Accounts::OriginRequest::CloudinaryBackup, Imagekit::Models::Accounts::OriginRequest::WebFolder, Imagekit::Models::Accounts::OriginRequest::WebProxy, Imagekit::Models::Accounts::OriginRequest::Gcs, Imagekit::Models::Accounts::OriginRequest::AzureBlob, Imagekit::Models::Accounts::OriginRequest::AkeneoPim] Schema for origin request resources. + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/imagekit/models/accounts/origin_delete_params.rb b/lib/imagekit/models/accounts/origin_delete_params.rb new file mode 100644 index 00000000..013eedd5 --- /dev/null +++ b/lib/imagekit/models/accounts/origin_delete_params.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module Imagekit + module Models + module Accounts + # @see Imagekit::Resources::Accounts::Origins#delete + class OriginDeleteParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + # @!method initialize(request_options: {}) + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/imagekit/models/accounts/origin_get_params.rb b/lib/imagekit/models/accounts/origin_get_params.rb new file mode 100644 index 00000000..97a63638 --- /dev/null +++ b/lib/imagekit/models/accounts/origin_get_params.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module Imagekit + module Models + module Accounts + # @see Imagekit::Resources::Accounts::Origins#get + class OriginGetParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + # @!method initialize(request_options: {}) + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/imagekit/models/accounts/origin_list_params.rb b/lib/imagekit/models/accounts/origin_list_params.rb new file mode 100644 index 00000000..8435e2f8 --- /dev/null +++ b/lib/imagekit/models/accounts/origin_list_params.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module Imagekit + module Models + module Accounts + # @see Imagekit::Resources::Accounts::Origins#list + class OriginListParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + # @!method initialize(request_options: {}) + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/imagekit/models/accounts/origin_list_response.rb b/lib/imagekit/models/accounts/origin_list_response.rb new file mode 100644 index 00000000..8f9e9da8 --- /dev/null +++ b/lib/imagekit/models/accounts/origin_list_response.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Imagekit + module Models + module Accounts + # @type [Imagekit::Internal::Type::Converter] + OriginListResponse = Imagekit::Internal::Type::ArrayOf[union: -> { Imagekit::Accounts::OriginResponse }] + end + end +end diff --git a/lib/imagekit/models/accounts/origin_request.rb b/lib/imagekit/models/accounts/origin_request.rb new file mode 100644 index 00000000..88b7782f --- /dev/null +++ b/lib/imagekit/models/accounts/origin_request.rb @@ -0,0 +1,547 @@ +# frozen_string_literal: true + +module Imagekit + module Models + module Accounts + # Schema for origin request resources. + module OriginRequest + extend Imagekit::Internal::Type::Union + + discriminator :type + + variant :S3, -> { Imagekit::Accounts::OriginRequest::S3 } + + variant :S3_COMPATIBLE, -> { Imagekit::Accounts::OriginRequest::S3Compatible } + + variant :CLOUDINARY_BACKUP, -> { Imagekit::Accounts::OriginRequest::CloudinaryBackup } + + variant :WEB_FOLDER, -> { Imagekit::Accounts::OriginRequest::WebFolder } + + variant :WEB_PROXY, -> { Imagekit::Accounts::OriginRequest::WebProxy } + + variant :GCS, -> { Imagekit::Accounts::OriginRequest::Gcs } + + variant :AZURE_BLOB, -> { Imagekit::Accounts::OriginRequest::AzureBlob } + + variant :AKENEO_PIM, -> { Imagekit::Accounts::OriginRequest::AkeneoPim } + + class S3 < Imagekit::Internal::Type::BaseModel + # @!attribute access_key + # Access key for the bucket. + # + # @return [String] + required :access_key, String, api_name: :accessKey + + # @!attribute bucket + # S3 bucket name. + # + # @return [String] + required :bucket, String + + # @!attribute name + # Display name of the origin. + # + # @return [String] + required :name, String + + # @!attribute secret_key + # Secret key for the bucket. + # + # @return [String] + required :secret_key, String, api_name: :secretKey + + # @!attribute type + # + # @return [Symbol, :S3] + required :type, const: :S3 + + # @!attribute base_url_for_canonical_header + # URL used in the Canonical header (if enabled). + # + # @return [String, nil] + optional :base_url_for_canonical_header, String, api_name: :baseUrlForCanonicalHeader + + # @!attribute include_canonical_header + # Whether to send a Canonical header. + # + # @return [Boolean, nil] + optional :include_canonical_header, + Imagekit::Internal::Type::Boolean, + api_name: :includeCanonicalHeader + + # @!attribute prefix + # Path prefix inside the bucket. + # + # @return [String, nil] + optional :prefix, String + + # @!method initialize(access_key:, bucket:, name:, secret_key:, base_url_for_canonical_header: nil, include_canonical_header: nil, prefix: nil, type: :S3) + # @param access_key [String] Access key for the bucket. + # + # @param bucket [String] S3 bucket name. + # + # @param name [String] Display name of the origin. + # + # @param secret_key [String] Secret key for the bucket. + # + # @param base_url_for_canonical_header [String] URL used in the Canonical header (if enabled). + # + # @param include_canonical_header [Boolean] Whether to send a Canonical header. + # + # @param prefix [String] Path prefix inside the bucket. + # + # @param type [Symbol, :S3] + end + + class S3Compatible < Imagekit::Internal::Type::BaseModel + # @!attribute access_key + # Access key for the bucket. + # + # @return [String] + required :access_key, String, api_name: :accessKey + + # @!attribute bucket + # S3 bucket name. + # + # @return [String] + required :bucket, String + + # @!attribute endpoint + # Custom S3-compatible endpoint. + # + # @return [String] + required :endpoint, String + + # @!attribute name + # Display name of the origin. + # + # @return [String] + required :name, String + + # @!attribute secret_key + # Secret key for the bucket. + # + # @return [String] + required :secret_key, String, api_name: :secretKey + + # @!attribute type + # + # @return [Symbol, :S3_COMPATIBLE] + required :type, const: :S3_COMPATIBLE + + # @!attribute base_url_for_canonical_header + # URL used in the Canonical header (if enabled). + # + # @return [String, nil] + optional :base_url_for_canonical_header, String, api_name: :baseUrlForCanonicalHeader + + # @!attribute include_canonical_header + # Whether to send a Canonical header. + # + # @return [Boolean, nil] + optional :include_canonical_header, + Imagekit::Internal::Type::Boolean, + api_name: :includeCanonicalHeader + + # @!attribute prefix + # Path prefix inside the bucket. + # + # @return [String, nil] + optional :prefix, String + + # @!attribute s3_force_path_style + # Use path-style S3 URLs? + # + # @return [Boolean, nil] + optional :s3_force_path_style, Imagekit::Internal::Type::Boolean, api_name: :s3ForcePathStyle + + # @!method initialize(access_key:, bucket:, endpoint:, name:, secret_key:, base_url_for_canonical_header: nil, include_canonical_header: nil, prefix: nil, s3_force_path_style: nil, type: :S3_COMPATIBLE) + # @param access_key [String] Access key for the bucket. + # + # @param bucket [String] S3 bucket name. + # + # @param endpoint [String] Custom S3-compatible endpoint. + # + # @param name [String] Display name of the origin. + # + # @param secret_key [String] Secret key for the bucket. + # + # @param base_url_for_canonical_header [String] URL used in the Canonical header (if enabled). + # + # @param include_canonical_header [Boolean] Whether to send a Canonical header. + # + # @param prefix [String] Path prefix inside the bucket. + # + # @param s3_force_path_style [Boolean] Use path-style S3 URLs? + # + # @param type [Symbol, :S3_COMPATIBLE] + end + + class CloudinaryBackup < Imagekit::Internal::Type::BaseModel + # @!attribute access_key + # Access key for the bucket. + # + # @return [String] + required :access_key, String, api_name: :accessKey + + # @!attribute bucket + # S3 bucket name. + # + # @return [String] + required :bucket, String + + # @!attribute name + # Display name of the origin. + # + # @return [String] + required :name, String + + # @!attribute secret_key + # Secret key for the bucket. + # + # @return [String] + required :secret_key, String, api_name: :secretKey + + # @!attribute type + # + # @return [Symbol, :CLOUDINARY_BACKUP] + required :type, const: :CLOUDINARY_BACKUP + + # @!attribute base_url_for_canonical_header + # URL used in the Canonical header (if enabled). + # + # @return [String, nil] + optional :base_url_for_canonical_header, String, api_name: :baseUrlForCanonicalHeader + + # @!attribute include_canonical_header + # Whether to send a Canonical header. + # + # @return [Boolean, nil] + optional :include_canonical_header, + Imagekit::Internal::Type::Boolean, + api_name: :includeCanonicalHeader + + # @!attribute prefix + # Path prefix inside the bucket. + # + # @return [String, nil] + optional :prefix, String + + # @!method initialize(access_key:, bucket:, name:, secret_key:, base_url_for_canonical_header: nil, include_canonical_header: nil, prefix: nil, type: :CLOUDINARY_BACKUP) + # @param access_key [String] Access key for the bucket. + # + # @param bucket [String] S3 bucket name. + # + # @param name [String] Display name of the origin. + # + # @param secret_key [String] Secret key for the bucket. + # + # @param base_url_for_canonical_header [String] URL used in the Canonical header (if enabled). + # + # @param include_canonical_header [Boolean] Whether to send a Canonical header. + # + # @param prefix [String] Path prefix inside the bucket. + # + # @param type [Symbol, :CLOUDINARY_BACKUP] + end + + class WebFolder < Imagekit::Internal::Type::BaseModel + # @!attribute base_url + # Root URL for the web folder origin. + # + # @return [String] + required :base_url, String, api_name: :baseUrl + + # @!attribute name + # Display name of the origin. + # + # @return [String] + required :name, String + + # @!attribute type + # + # @return [Symbol, :WEB_FOLDER] + required :type, const: :WEB_FOLDER + + # @!attribute base_url_for_canonical_header + # URL used in the Canonical header (if enabled). + # + # @return [String, nil] + optional :base_url_for_canonical_header, String, api_name: :baseUrlForCanonicalHeader + + # @!attribute forward_host_header_to_origin + # Forward the Host header to origin? + # + # @return [Boolean, nil] + optional :forward_host_header_to_origin, + Imagekit::Internal::Type::Boolean, + api_name: :forwardHostHeaderToOrigin + + # @!attribute include_canonical_header + # Whether to send a Canonical header. + # + # @return [Boolean, nil] + optional :include_canonical_header, + Imagekit::Internal::Type::Boolean, + api_name: :includeCanonicalHeader + + # @!method initialize(base_url:, name:, base_url_for_canonical_header: nil, forward_host_header_to_origin: nil, include_canonical_header: nil, type: :WEB_FOLDER) + # @param base_url [String] Root URL for the web folder origin. + # + # @param name [String] Display name of the origin. + # + # @param base_url_for_canonical_header [String] URL used in the Canonical header (if enabled). + # + # @param forward_host_header_to_origin [Boolean] Forward the Host header to origin? + # + # @param include_canonical_header [Boolean] Whether to send a Canonical header. + # + # @param type [Symbol, :WEB_FOLDER] + end + + class WebProxy < Imagekit::Internal::Type::BaseModel + # @!attribute name + # Display name of the origin. + # + # @return [String] + required :name, String + + # @!attribute type + # + # @return [Symbol, :WEB_PROXY] + required :type, const: :WEB_PROXY + + # @!attribute base_url_for_canonical_header + # URL used in the Canonical header (if enabled). + # + # @return [String, nil] + optional :base_url_for_canonical_header, String, api_name: :baseUrlForCanonicalHeader + + # @!attribute include_canonical_header + # Whether to send a Canonical header. + # + # @return [Boolean, nil] + optional :include_canonical_header, + Imagekit::Internal::Type::Boolean, + api_name: :includeCanonicalHeader + + # @!method initialize(name:, base_url_for_canonical_header: nil, include_canonical_header: nil, type: :WEB_PROXY) + # @param name [String] Display name of the origin. + # + # @param base_url_for_canonical_header [String] URL used in the Canonical header (if enabled). + # + # @param include_canonical_header [Boolean] Whether to send a Canonical header. + # + # @param type [Symbol, :WEB_PROXY] + end + + class Gcs < Imagekit::Internal::Type::BaseModel + # @!attribute bucket + # + # @return [String] + required :bucket, String + + # @!attribute client_email + # + # @return [String] + required :client_email, String, api_name: :clientEmail + + # @!attribute name + # Display name of the origin. + # + # @return [String] + required :name, String + + # @!attribute private_key + # + # @return [String] + required :private_key, String, api_name: :privateKey + + # @!attribute type + # + # @return [Symbol, :GCS] + required :type, const: :GCS + + # @!attribute base_url_for_canonical_header + # URL used in the Canonical header (if enabled). + # + # @return [String, nil] + optional :base_url_for_canonical_header, String, api_name: :baseUrlForCanonicalHeader + + # @!attribute include_canonical_header + # Whether to send a Canonical header. + # + # @return [Boolean, nil] + optional :include_canonical_header, + Imagekit::Internal::Type::Boolean, + api_name: :includeCanonicalHeader + + # @!attribute prefix + # + # @return [String, nil] + optional :prefix, String + + # @!method initialize(bucket:, client_email:, name:, private_key:, base_url_for_canonical_header: nil, include_canonical_header: nil, prefix: nil, type: :GCS) + # @param bucket [String] + # + # @param client_email [String] + # + # @param name [String] Display name of the origin. + # + # @param private_key [String] + # + # @param base_url_for_canonical_header [String] URL used in the Canonical header (if enabled). + # + # @param include_canonical_header [Boolean] Whether to send a Canonical header. + # + # @param prefix [String] + # + # @param type [Symbol, :GCS] + end + + class AzureBlob < Imagekit::Internal::Type::BaseModel + # @!attribute account_name + # + # @return [String] + required :account_name, String, api_name: :accountName + + # @!attribute container + # + # @return [String] + required :container, String + + # @!attribute name + # Display name of the origin. + # + # @return [String] + required :name, String + + # @!attribute sas_token + # + # @return [String] + required :sas_token, String, api_name: :sasToken + + # @!attribute type + # + # @return [Symbol, :AZURE_BLOB] + required :type, const: :AZURE_BLOB + + # @!attribute base_url_for_canonical_header + # URL used in the Canonical header (if enabled). + # + # @return [String, nil] + optional :base_url_for_canonical_header, String, api_name: :baseUrlForCanonicalHeader + + # @!attribute include_canonical_header + # Whether to send a Canonical header. + # + # @return [Boolean, nil] + optional :include_canonical_header, + Imagekit::Internal::Type::Boolean, + api_name: :includeCanonicalHeader + + # @!attribute prefix + # + # @return [String, nil] + optional :prefix, String + + # @!method initialize(account_name:, container:, name:, sas_token:, base_url_for_canonical_header: nil, include_canonical_header: nil, prefix: nil, type: :AZURE_BLOB) + # @param account_name [String] + # + # @param container [String] + # + # @param name [String] Display name of the origin. + # + # @param sas_token [String] + # + # @param base_url_for_canonical_header [String] URL used in the Canonical header (if enabled). + # + # @param include_canonical_header [Boolean] Whether to send a Canonical header. + # + # @param prefix [String] + # + # @param type [Symbol, :AZURE_BLOB] + end + + class AkeneoPim < Imagekit::Internal::Type::BaseModel + # @!attribute base_url + # Akeneo instance base URL. + # + # @return [String] + required :base_url, String, api_name: :baseUrl + + # @!attribute client_id + # Akeneo API client ID. + # + # @return [String] + required :client_id, String, api_name: :clientId + + # @!attribute client_secret + # Akeneo API client secret. + # + # @return [String] + required :client_secret, String, api_name: :clientSecret + + # @!attribute name + # Display name of the origin. + # + # @return [String] + required :name, String + + # @!attribute password + # Akeneo API password. + # + # @return [String] + required :password, String + + # @!attribute type + # + # @return [Symbol, :AKENEO_PIM] + required :type, const: :AKENEO_PIM + + # @!attribute username + # Akeneo API username. + # + # @return [String] + required :username, String + + # @!attribute base_url_for_canonical_header + # URL used in the Canonical header (if enabled). + # + # @return [String, nil] + optional :base_url_for_canonical_header, String, api_name: :baseUrlForCanonicalHeader + + # @!attribute include_canonical_header + # Whether to send a Canonical header. + # + # @return [Boolean, nil] + optional :include_canonical_header, + Imagekit::Internal::Type::Boolean, + api_name: :includeCanonicalHeader + + # @!method initialize(base_url:, client_id:, client_secret:, name:, password:, username:, base_url_for_canonical_header: nil, include_canonical_header: nil, type: :AKENEO_PIM) + # @param base_url [String] Akeneo instance base URL. + # + # @param client_id [String] Akeneo API client ID. + # + # @param client_secret [String] Akeneo API client secret. + # + # @param name [String] Display name of the origin. + # + # @param password [String] Akeneo API password. + # + # @param username [String] Akeneo API username. + # + # @param base_url_for_canonical_header [String] URL used in the Canonical header (if enabled). + # + # @param include_canonical_header [Boolean] Whether to send a Canonical header. + # + # @param type [Symbol, :AKENEO_PIM] + end + + # @!method self.variants + # @return [Array(Imagekit::Models::Accounts::OriginRequest::S3, Imagekit::Models::Accounts::OriginRequest::S3Compatible, Imagekit::Models::Accounts::OriginRequest::CloudinaryBackup, Imagekit::Models::Accounts::OriginRequest::WebFolder, Imagekit::Models::Accounts::OriginRequest::WebProxy, Imagekit::Models::Accounts::OriginRequest::Gcs, Imagekit::Models::Accounts::OriginRequest::AzureBlob, Imagekit::Models::Accounts::OriginRequest::AkeneoPim)] + end + end + end +end diff --git a/lib/imagekit/models/accounts/origin_response.rb b/lib/imagekit/models/accounts/origin_response.rb new file mode 100644 index 00000000..aa9aea71 --- /dev/null +++ b/lib/imagekit/models/accounts/origin_response.rb @@ -0,0 +1,567 @@ +# frozen_string_literal: true + +module Imagekit + module Models + module Accounts + # Origin object as returned by the API (sensitive fields removed). + # + # @see Imagekit::Resources::Accounts::Origins#create + module OriginResponse + extend Imagekit::Internal::Type::Union + + discriminator :type + + variant :S3, -> { Imagekit::Accounts::OriginResponse::S3 } + + variant :S3_COMPATIBLE, -> { Imagekit::Accounts::OriginResponse::S3Compatible } + + variant :CLOUDINARY_BACKUP, -> { Imagekit::Accounts::OriginResponse::CloudinaryBackup } + + variant :WEB_FOLDER, -> { Imagekit::Accounts::OriginResponse::WebFolder } + + variant :WEB_PROXY, -> { Imagekit::Accounts::OriginResponse::WebProxy } + + variant :GCS, -> { Imagekit::Accounts::OriginResponse::Gcs } + + variant :AZURE_BLOB, -> { Imagekit::Accounts::OriginResponse::AzureBlob } + + variant :AKENEO_PIM, -> { Imagekit::Accounts::OriginResponse::AkeneoPim } + + class S3 < Imagekit::Internal::Type::BaseModel + # @!attribute bucket + # S3 bucket name. + # + # @return [String] + required :bucket, String + + # @!attribute include_canonical_header + # Whether to send a Canonical header. + # + # @return [Boolean] + required :include_canonical_header, + Imagekit::Internal::Type::Boolean, + api_name: :includeCanonicalHeader + + # @!attribute name + # Display name of the origin. + # + # @return [String] + required :name, String + + # @!attribute prefix + # Path prefix inside the bucket. + # + # @return [String] + required :prefix, String + + # @!attribute type + # + # @return [Symbol, :S3] + required :type, const: :S3 + + # @!attribute base_url_for_canonical_header + # URL used in the Canonical header (if enabled). + # + # @return [String, nil] + optional :base_url_for_canonical_header, String, api_name: :baseUrlForCanonicalHeader + + response_only do + # @!attribute id + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + # + # @return [String] + required :id, String + end + + # @!method initialize(id:, bucket:, include_canonical_header:, name:, prefix:, base_url_for_canonical_header: nil, type: :S3) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Accounts::OriginResponse::S3} for more details. + # + # @param id [String] Unique identifier for the origin. This is generated by ImageKit when you create + # + # @param bucket [String] S3 bucket name. + # + # @param include_canonical_header [Boolean] Whether to send a Canonical header. + # + # @param name [String] Display name of the origin. + # + # @param prefix [String] Path prefix inside the bucket. + # + # @param base_url_for_canonical_header [String] URL used in the Canonical header (if enabled). + # + # @param type [Symbol, :S3] + end + + class S3Compatible < Imagekit::Internal::Type::BaseModel + # @!attribute bucket + # S3 bucket name. + # + # @return [String] + required :bucket, String + + # @!attribute endpoint + # Custom S3-compatible endpoint. + # + # @return [String] + required :endpoint, String + + # @!attribute include_canonical_header + # Whether to send a Canonical header. + # + # @return [Boolean] + required :include_canonical_header, + Imagekit::Internal::Type::Boolean, + api_name: :includeCanonicalHeader + + # @!attribute name + # Display name of the origin. + # + # @return [String] + required :name, String + + # @!attribute prefix + # Path prefix inside the bucket. + # + # @return [String] + required :prefix, String + + # @!attribute s3_force_path_style + # Use path-style S3 URLs? + # + # @return [Boolean] + required :s3_force_path_style, Imagekit::Internal::Type::Boolean, api_name: :s3ForcePathStyle + + # @!attribute type + # + # @return [Symbol, :S3_COMPATIBLE] + required :type, const: :S3_COMPATIBLE + + # @!attribute base_url_for_canonical_header + # URL used in the Canonical header (if enabled). + # + # @return [String, nil] + optional :base_url_for_canonical_header, String, api_name: :baseUrlForCanonicalHeader + + response_only do + # @!attribute id + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + # + # @return [String] + required :id, String + end + + # @!method initialize(id:, bucket:, endpoint:, include_canonical_header:, name:, prefix:, s3_force_path_style:, base_url_for_canonical_header: nil, type: :S3_COMPATIBLE) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Accounts::OriginResponse::S3Compatible} for more details. + # + # @param id [String] Unique identifier for the origin. This is generated by ImageKit when you create + # + # @param bucket [String] S3 bucket name. + # + # @param endpoint [String] Custom S3-compatible endpoint. + # + # @param include_canonical_header [Boolean] Whether to send a Canonical header. + # + # @param name [String] Display name of the origin. + # + # @param prefix [String] Path prefix inside the bucket. + # + # @param s3_force_path_style [Boolean] Use path-style S3 URLs? + # + # @param base_url_for_canonical_header [String] URL used in the Canonical header (if enabled). + # + # @param type [Symbol, :S3_COMPATIBLE] + end + + class CloudinaryBackup < Imagekit::Internal::Type::BaseModel + # @!attribute bucket + # S3 bucket name. + # + # @return [String] + required :bucket, String + + # @!attribute include_canonical_header + # Whether to send a Canonical header. + # + # @return [Boolean] + required :include_canonical_header, + Imagekit::Internal::Type::Boolean, + api_name: :includeCanonicalHeader + + # @!attribute name + # Display name of the origin. + # + # @return [String] + required :name, String + + # @!attribute prefix + # Path prefix inside the bucket. + # + # @return [String] + required :prefix, String + + # @!attribute type + # + # @return [Symbol, :CLOUDINARY_BACKUP] + required :type, const: :CLOUDINARY_BACKUP + + # @!attribute base_url_for_canonical_header + # URL used in the Canonical header (if enabled). + # + # @return [String, nil] + optional :base_url_for_canonical_header, String, api_name: :baseUrlForCanonicalHeader + + response_only do + # @!attribute id + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + # + # @return [String] + required :id, String + end + + # @!method initialize(id:, bucket:, include_canonical_header:, name:, prefix:, base_url_for_canonical_header: nil, type: :CLOUDINARY_BACKUP) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Accounts::OriginResponse::CloudinaryBackup} for more details. + # + # @param id [String] Unique identifier for the origin. This is generated by ImageKit when you create + # + # @param bucket [String] S3 bucket name. + # + # @param include_canonical_header [Boolean] Whether to send a Canonical header. + # + # @param name [String] Display name of the origin. + # + # @param prefix [String] Path prefix inside the bucket. + # + # @param base_url_for_canonical_header [String] URL used in the Canonical header (if enabled). + # + # @param type [Symbol, :CLOUDINARY_BACKUP] + end + + class WebFolder < Imagekit::Internal::Type::BaseModel + # @!attribute base_url + # Root URL for the web folder origin. + # + # @return [String] + required :base_url, String, api_name: :baseUrl + + # @!attribute forward_host_header_to_origin + # Forward the Host header to origin? + # + # @return [Boolean] + required :forward_host_header_to_origin, + Imagekit::Internal::Type::Boolean, + api_name: :forwardHostHeaderToOrigin + + # @!attribute include_canonical_header + # Whether to send a Canonical header. + # + # @return [Boolean] + required :include_canonical_header, + Imagekit::Internal::Type::Boolean, + api_name: :includeCanonicalHeader + + # @!attribute name + # Display name of the origin. + # + # @return [String] + required :name, String + + # @!attribute type + # + # @return [Symbol, :WEB_FOLDER] + required :type, const: :WEB_FOLDER + + # @!attribute base_url_for_canonical_header + # URL used in the Canonical header (if enabled). + # + # @return [String, nil] + optional :base_url_for_canonical_header, String, api_name: :baseUrlForCanonicalHeader + + response_only do + # @!attribute id + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + # + # @return [String] + required :id, String + end + + # @!method initialize(id:, base_url:, forward_host_header_to_origin:, include_canonical_header:, name:, base_url_for_canonical_header: nil, type: :WEB_FOLDER) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Accounts::OriginResponse::WebFolder} for more details. + # + # @param id [String] Unique identifier for the origin. This is generated by ImageKit when you create + # + # @param base_url [String] Root URL for the web folder origin. + # + # @param forward_host_header_to_origin [Boolean] Forward the Host header to origin? + # + # @param include_canonical_header [Boolean] Whether to send a Canonical header. + # + # @param name [String] Display name of the origin. + # + # @param base_url_for_canonical_header [String] URL used in the Canonical header (if enabled). + # + # @param type [Symbol, :WEB_FOLDER] + end + + class WebProxy < Imagekit::Internal::Type::BaseModel + # @!attribute include_canonical_header + # Whether to send a Canonical header. + # + # @return [Boolean] + required :include_canonical_header, + Imagekit::Internal::Type::Boolean, + api_name: :includeCanonicalHeader + + # @!attribute name + # Display name of the origin. + # + # @return [String] + required :name, String + + # @!attribute type + # + # @return [Symbol, :WEB_PROXY] + required :type, const: :WEB_PROXY + + # @!attribute base_url_for_canonical_header + # URL used in the Canonical header (if enabled). + # + # @return [String, nil] + optional :base_url_for_canonical_header, String, api_name: :baseUrlForCanonicalHeader + + response_only do + # @!attribute id + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + # + # @return [String] + required :id, String + end + + # @!method initialize(id:, include_canonical_header:, name:, base_url_for_canonical_header: nil, type: :WEB_PROXY) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Accounts::OriginResponse::WebProxy} for more details. + # + # @param id [String] Unique identifier for the origin. This is generated by ImageKit when you create + # + # @param include_canonical_header [Boolean] Whether to send a Canonical header. + # + # @param name [String] Display name of the origin. + # + # @param base_url_for_canonical_header [String] URL used in the Canonical header (if enabled). + # + # @param type [Symbol, :WEB_PROXY] + end + + class Gcs < Imagekit::Internal::Type::BaseModel + # @!attribute bucket + # + # @return [String] + required :bucket, String + + # @!attribute client_email + # + # @return [String] + required :client_email, String, api_name: :clientEmail + + # @!attribute include_canonical_header + # Whether to send a Canonical header. + # + # @return [Boolean] + required :include_canonical_header, + Imagekit::Internal::Type::Boolean, + api_name: :includeCanonicalHeader + + # @!attribute name + # Display name of the origin. + # + # @return [String] + required :name, String + + # @!attribute prefix + # + # @return [String] + required :prefix, String + + # @!attribute type + # + # @return [Symbol, :GCS] + required :type, const: :GCS + + # @!attribute base_url_for_canonical_header + # URL used in the Canonical header (if enabled). + # + # @return [String, nil] + optional :base_url_for_canonical_header, String, api_name: :baseUrlForCanonicalHeader + + response_only do + # @!attribute id + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + # + # @return [String] + required :id, String + end + + # @!method initialize(id:, bucket:, client_email:, include_canonical_header:, name:, prefix:, base_url_for_canonical_header: nil, type: :GCS) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Accounts::OriginResponse::Gcs} for more details. + # + # @param id [String] Unique identifier for the origin. This is generated by ImageKit when you create + # + # @param bucket [String] + # + # @param client_email [String] + # + # @param include_canonical_header [Boolean] Whether to send a Canonical header. + # + # @param name [String] Display name of the origin. + # + # @param prefix [String] + # + # @param base_url_for_canonical_header [String] URL used in the Canonical header (if enabled). + # + # @param type [Symbol, :GCS] + end + + class AzureBlob < Imagekit::Internal::Type::BaseModel + # @!attribute account_name + # + # @return [String] + required :account_name, String, api_name: :accountName + + # @!attribute container + # + # @return [String] + required :container, String + + # @!attribute include_canonical_header + # Whether to send a Canonical header. + # + # @return [Boolean] + required :include_canonical_header, + Imagekit::Internal::Type::Boolean, + api_name: :includeCanonicalHeader + + # @!attribute name + # Display name of the origin. + # + # @return [String] + required :name, String + + # @!attribute prefix + # + # @return [String] + required :prefix, String + + # @!attribute type + # + # @return [Symbol, :AZURE_BLOB] + required :type, const: :AZURE_BLOB + + # @!attribute base_url_for_canonical_header + # URL used in the Canonical header (if enabled). + # + # @return [String, nil] + optional :base_url_for_canonical_header, String, api_name: :baseUrlForCanonicalHeader + + response_only do + # @!attribute id + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + # + # @return [String] + required :id, String + end + + # @!method initialize(id:, account_name:, container:, include_canonical_header:, name:, prefix:, base_url_for_canonical_header: nil, type: :AZURE_BLOB) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Accounts::OriginResponse::AzureBlob} for more details. + # + # @param id [String] Unique identifier for the origin. This is generated by ImageKit when you create + # + # @param account_name [String] + # + # @param container [String] + # + # @param include_canonical_header [Boolean] Whether to send a Canonical header. + # + # @param name [String] Display name of the origin. + # + # @param prefix [String] + # + # @param base_url_for_canonical_header [String] URL used in the Canonical header (if enabled). + # + # @param type [Symbol, :AZURE_BLOB] + end + + class AkeneoPim < Imagekit::Internal::Type::BaseModel + # @!attribute base_url + # Akeneo instance base URL. + # + # @return [String] + required :base_url, String, api_name: :baseUrl + + # @!attribute include_canonical_header + # Whether to send a Canonical header. + # + # @return [Boolean] + required :include_canonical_header, + Imagekit::Internal::Type::Boolean, + api_name: :includeCanonicalHeader + + # @!attribute name + # Display name of the origin. + # + # @return [String] + required :name, String + + # @!attribute type + # + # @return [Symbol, :AKENEO_PIM] + required :type, const: :AKENEO_PIM + + # @!attribute base_url_for_canonical_header + # URL used in the Canonical header (if enabled). + # + # @return [String, nil] + optional :base_url_for_canonical_header, String, api_name: :baseUrlForCanonicalHeader + + response_only do + # @!attribute id + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + # + # @return [String] + required :id, String + end + + # @!method initialize(id:, base_url:, include_canonical_header:, name:, base_url_for_canonical_header: nil, type: :AKENEO_PIM) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Accounts::OriginResponse::AkeneoPim} for more details. + # + # @param id [String] Unique identifier for the origin. This is generated by ImageKit when you create + # + # @param base_url [String] Akeneo instance base URL. + # + # @param include_canonical_header [Boolean] Whether to send a Canonical header. + # + # @param name [String] Display name of the origin. + # + # @param base_url_for_canonical_header [String] URL used in the Canonical header (if enabled). + # + # @param type [Symbol, :AKENEO_PIM] + end + + # @!method self.variants + # @return [Array(Imagekit::Models::Accounts::OriginResponse::S3, Imagekit::Models::Accounts::OriginResponse::S3Compatible, Imagekit::Models::Accounts::OriginResponse::CloudinaryBackup, Imagekit::Models::Accounts::OriginResponse::WebFolder, Imagekit::Models::Accounts::OriginResponse::WebProxy, Imagekit::Models::Accounts::OriginResponse::Gcs, Imagekit::Models::Accounts::OriginResponse::AzureBlob, Imagekit::Models::Accounts::OriginResponse::AkeneoPim)] + end + end + end +end diff --git a/lib/imagekit/models/accounts/origin_update_params.rb b/lib/imagekit/models/accounts/origin_update_params.rb new file mode 100644 index 00000000..2cbe03a7 --- /dev/null +++ b/lib/imagekit/models/accounts/origin_update_params.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +module Imagekit + module Models + module Accounts + # @see Imagekit::Resources::Accounts::Origins#update + class OriginUpdateParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + # @!attribute origin_request + # Schema for origin request resources. + # + # @return [Imagekit::Models::Accounts::OriginRequest::S3, Imagekit::Models::Accounts::OriginRequest::S3Compatible, Imagekit::Models::Accounts::OriginRequest::CloudinaryBackup, Imagekit::Models::Accounts::OriginRequest::WebFolder, Imagekit::Models::Accounts::OriginRequest::WebProxy, Imagekit::Models::Accounts::OriginRequest::Gcs, Imagekit::Models::Accounts::OriginRequest::AzureBlob, Imagekit::Models::Accounts::OriginRequest::AkeneoPim] + required :origin_request, union: -> { Imagekit::Accounts::OriginRequest } + + # @!method initialize(origin_request:, request_options: {}) + # @param origin_request [Imagekit::Models::Accounts::OriginRequest::S3, Imagekit::Models::Accounts::OriginRequest::S3Compatible, Imagekit::Models::Accounts::OriginRequest::CloudinaryBackup, Imagekit::Models::Accounts::OriginRequest::WebFolder, Imagekit::Models::Accounts::OriginRequest::WebProxy, Imagekit::Models::Accounts::OriginRequest::Gcs, Imagekit::Models::Accounts::OriginRequest::AzureBlob, Imagekit::Models::Accounts::OriginRequest::AkeneoPim] Schema for origin request resources. + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/imagekit/models/accounts/url_endpoint_create_params.rb b/lib/imagekit/models/accounts/url_endpoint_create_params.rb new file mode 100644 index 00000000..5a065839 --- /dev/null +++ b/lib/imagekit/models/accounts/url_endpoint_create_params.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module Imagekit + module Models + module Accounts + # @see Imagekit::Resources::Accounts::URLEndpoints#create + class URLEndpointCreateParams < Imagekit::Models::Accounts::URLEndpointRequest + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + # @!method initialize(request_options: {}) + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/imagekit/models/accounts/url_endpoint_delete_params.rb b/lib/imagekit/models/accounts/url_endpoint_delete_params.rb new file mode 100644 index 00000000..484bea81 --- /dev/null +++ b/lib/imagekit/models/accounts/url_endpoint_delete_params.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module Imagekit + module Models + module Accounts + # @see Imagekit::Resources::Accounts::URLEndpoints#delete + class URLEndpointDeleteParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + # @!method initialize(request_options: {}) + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/imagekit/models/accounts/url_endpoint_get_params.rb b/lib/imagekit/models/accounts/url_endpoint_get_params.rb new file mode 100644 index 00000000..d5d4461b --- /dev/null +++ b/lib/imagekit/models/accounts/url_endpoint_get_params.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module Imagekit + module Models + module Accounts + # @see Imagekit::Resources::Accounts::URLEndpoints#get + class URLEndpointGetParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + # @!method initialize(request_options: {}) + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/imagekit/models/accounts/url_endpoint_list_params.rb b/lib/imagekit/models/accounts/url_endpoint_list_params.rb new file mode 100644 index 00000000..ec77107c --- /dev/null +++ b/lib/imagekit/models/accounts/url_endpoint_list_params.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module Imagekit + module Models + module Accounts + # @see Imagekit::Resources::Accounts::URLEndpoints#list + class URLEndpointListParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + # @!method initialize(request_options: {}) + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/imagekit/models/accounts/url_endpoint_list_response.rb b/lib/imagekit/models/accounts/url_endpoint_list_response.rb new file mode 100644 index 00000000..054376a9 --- /dev/null +++ b/lib/imagekit/models/accounts/url_endpoint_list_response.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Imagekit + module Models + module Accounts + # @type [Imagekit::Internal::Type::Converter] + URLEndpointListResponse = + Imagekit::Internal::Type::ArrayOf[-> { Imagekit::Accounts::URLEndpointResponse }] + end + end +end diff --git a/lib/imagekit/models/accounts/url_endpoint_request.rb b/lib/imagekit/models/accounts/url_endpoint_request.rb new file mode 100644 index 00000000..32c945fc --- /dev/null +++ b/lib/imagekit/models/accounts/url_endpoint_request.rb @@ -0,0 +1,110 @@ +# frozen_string_literal: true + +module Imagekit + module Models + module Accounts + class URLEndpointRequest < Imagekit::Internal::Type::BaseModel + # @!attribute description + # Description of the URL endpoint. + # + # @return [String] + required :description, String + + # @!attribute origins + # Ordered list of origin IDs to try when the file isn’t in the Media Library; + # ImageKit checks them in the sequence provided. Origin must be created before it + # can be used in a URL endpoint. + # + # @return [Array, nil] + optional :origins, Imagekit::Internal::Type::ArrayOf[String] + + # @!attribute url_prefix + # Path segment appended to your base URL to form the endpoint (letters, digits, + # and hyphens only — or empty for the default endpoint). + # + # @return [String, nil] + optional :url_prefix, String, api_name: :urlPrefix + + # @!attribute url_rewriter + # Configuration for third-party URL rewriting. + # + # @return [Imagekit::Models::Accounts::URLEndpointRequest::URLRewriter::Cloudinary, Imagekit::Models::Accounts::URLEndpointRequest::URLRewriter::Imgix, Imagekit::Models::Accounts::URLEndpointRequest::URLRewriter::Akamai, nil] + optional :url_rewriter, + union: -> { Imagekit::Accounts::URLEndpointRequest::URLRewriter }, + api_name: :urlRewriter + + # @!method initialize(description:, origins: nil, url_prefix: nil, url_rewriter: nil) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Accounts::URLEndpointRequest} for more details. + # + # Schema for URL endpoint resource. + # + # @param description [String] Description of the URL endpoint. + # + # @param origins [Array] Ordered list of origin IDs to try when the file isn’t in the Media Library; Imag + # + # @param url_prefix [String] Path segment appended to your base URL to form the endpoint (letters, digits, an + # + # @param url_rewriter [Imagekit::Models::Accounts::URLEndpointRequest::URLRewriter::Cloudinary, Imagekit::Models::Accounts::URLEndpointRequest::URLRewriter::Imgix, Imagekit::Models::Accounts::URLEndpointRequest::URLRewriter::Akamai] Configuration for third-party URL rewriting. + + # Configuration for third-party URL rewriting. + # + # @see Imagekit::Models::Accounts::URLEndpointRequest#url_rewriter + module URLRewriter + extend Imagekit::Internal::Type::Union + + discriminator :type + + variant :CLOUDINARY, -> { Imagekit::Accounts::URLEndpointRequest::URLRewriter::Cloudinary } + + variant :IMGIX, -> { Imagekit::Accounts::URLEndpointRequest::URLRewriter::Imgix } + + variant :AKAMAI, -> { Imagekit::Accounts::URLEndpointRequest::URLRewriter::Akamai } + + class Cloudinary < Imagekit::Internal::Type::BaseModel + # @!attribute type + # + # @return [Symbol, :CLOUDINARY] + required :type, const: :CLOUDINARY + + # @!attribute preserve_asset_delivery_types + # Whether to preserve `/` in the rewritten URL. + # + # @return [Boolean, nil] + optional :preserve_asset_delivery_types, + Imagekit::Internal::Type::Boolean, + api_name: :preserveAssetDeliveryTypes + + # @!method initialize(preserve_asset_delivery_types: nil, type: :CLOUDINARY) + # @param preserve_asset_delivery_types [Boolean] Whether to preserve `/` in the rewritten URL. + # + # @param type [Symbol, :CLOUDINARY] + end + + class Imgix < Imagekit::Internal::Type::BaseModel + # @!attribute type + # + # @return [Symbol, :IMGIX] + required :type, const: :IMGIX + + # @!method initialize(type: :IMGIX) + # @param type [Symbol, :IMGIX] + end + + class Akamai < Imagekit::Internal::Type::BaseModel + # @!attribute type + # + # @return [Symbol, :AKAMAI] + required :type, const: :AKAMAI + + # @!method initialize(type: :AKAMAI) + # @param type [Symbol, :AKAMAI] + end + + # @!method self.variants + # @return [Array(Imagekit::Models::Accounts::URLEndpointRequest::URLRewriter::Cloudinary, Imagekit::Models::Accounts::URLEndpointRequest::URLRewriter::Imgix, Imagekit::Models::Accounts::URLEndpointRequest::URLRewriter::Akamai)] + end + end + end + end +end diff --git a/lib/imagekit/models/accounts/url_endpoint_response.rb b/lib/imagekit/models/accounts/url_endpoint_response.rb new file mode 100644 index 00000000..3ea557dc --- /dev/null +++ b/lib/imagekit/models/accounts/url_endpoint_response.rb @@ -0,0 +1,123 @@ +# frozen_string_literal: true + +module Imagekit + module Models + module Accounts + # @see Imagekit::Resources::Accounts::URLEndpoints#create + class URLEndpointResponse < Imagekit::Internal::Type::BaseModel + # @!attribute description + # Description of the URL endpoint. + # + # @return [String] + required :description, String + + # @!attribute origins + # Ordered list of origin IDs to try when the file isn’t in the Media Library; + # ImageKit checks them in the sequence provided. Origin must be created before it + # can be used in a URL endpoint. + # + # @return [Array] + required :origins, Imagekit::Internal::Type::ArrayOf[String] + + # @!attribute url_prefix + # Path segment appended to your base URL to form the endpoint (letters, digits, + # and hyphens only — or empty for the default endpoint). + # + # @return [String] + required :url_prefix, String, api_name: :urlPrefix + + # @!attribute url_rewriter + # Configuration for third-party URL rewriting. + # + # @return [Imagekit::Models::Accounts::URLEndpointResponse::URLRewriter::Cloudinary, Imagekit::Models::Accounts::URLEndpointResponse::URLRewriter::Imgix, Imagekit::Models::Accounts::URLEndpointResponse::URLRewriter::Akamai, nil] + optional :url_rewriter, + union: -> { Imagekit::Accounts::URLEndpointResponse::URLRewriter }, + api_name: :urlRewriter + + response_only do + # @!attribute id + # Unique identifier for the URL-endpoint. This is generated by ImageKit when you + # create a new URL-endpoint. For the default URL-endpoint, this is always + # `default`. + # + # @return [String] + required :id, String + end + + # @!method initialize(id:, description:, origins:, url_prefix:, url_rewriter: nil) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Accounts::URLEndpointResponse} for more details. + # + # URL‑endpoint object as returned by the API. + # + # @param id [String] Unique identifier for the URL-endpoint. This is generated by ImageKit when you c + # + # @param description [String] Description of the URL endpoint. + # + # @param origins [Array] Ordered list of origin IDs to try when the file isn’t in the Media Library; Imag + # + # @param url_prefix [String] Path segment appended to your base URL to form the endpoint (letters, digits, an + # + # @param url_rewriter [Imagekit::Models::Accounts::URLEndpointResponse::URLRewriter::Cloudinary, Imagekit::Models::Accounts::URLEndpointResponse::URLRewriter::Imgix, Imagekit::Models::Accounts::URLEndpointResponse::URLRewriter::Akamai] Configuration for third-party URL rewriting. + + # Configuration for third-party URL rewriting. + # + # @see Imagekit::Models::Accounts::URLEndpointResponse#url_rewriter + module URLRewriter + extend Imagekit::Internal::Type::Union + + discriminator :type + + variant :CLOUDINARY, -> { Imagekit::Accounts::URLEndpointResponse::URLRewriter::Cloudinary } + + variant :IMGIX, -> { Imagekit::Accounts::URLEndpointResponse::URLRewriter::Imgix } + + variant :AKAMAI, -> { Imagekit::Accounts::URLEndpointResponse::URLRewriter::Akamai } + + class Cloudinary < Imagekit::Internal::Type::BaseModel + # @!attribute preserve_asset_delivery_types + # Whether to preserve `/` in the rewritten URL. + # + # @return [Boolean] + required :preserve_asset_delivery_types, + Imagekit::Internal::Type::Boolean, + api_name: :preserveAssetDeliveryTypes + + # @!attribute type + # + # @return [Symbol, :CLOUDINARY] + required :type, const: :CLOUDINARY + + # @!method initialize(preserve_asset_delivery_types:, type: :CLOUDINARY) + # @param preserve_asset_delivery_types [Boolean] Whether to preserve `/` in the rewritten URL. + # + # @param type [Symbol, :CLOUDINARY] + end + + class Imgix < Imagekit::Internal::Type::BaseModel + # @!attribute type + # + # @return [Symbol, :IMGIX] + required :type, const: :IMGIX + + # @!method initialize(type: :IMGIX) + # @param type [Symbol, :IMGIX] + end + + class Akamai < Imagekit::Internal::Type::BaseModel + # @!attribute type + # + # @return [Symbol, :AKAMAI] + required :type, const: :AKAMAI + + # @!method initialize(type: :AKAMAI) + # @param type [Symbol, :AKAMAI] + end + + # @!method self.variants + # @return [Array(Imagekit::Models::Accounts::URLEndpointResponse::URLRewriter::Cloudinary, Imagekit::Models::Accounts::URLEndpointResponse::URLRewriter::Imgix, Imagekit::Models::Accounts::URLEndpointResponse::URLRewriter::Akamai)] + end + end + end + end +end diff --git a/lib/imagekit/models/accounts/url_endpoint_update_params.rb b/lib/imagekit/models/accounts/url_endpoint_update_params.rb new file mode 100644 index 00000000..cb1bca4f --- /dev/null +++ b/lib/imagekit/models/accounts/url_endpoint_update_params.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module Imagekit + module Models + module Accounts + # @see Imagekit::Resources::Accounts::URLEndpoints#update + class URLEndpointUpdateParams < Imagekit::Models::Accounts::URLEndpointRequest + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + # @!method initialize(request_options: {}) + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/imagekit/models/accounts/usage_get_params.rb b/lib/imagekit/models/accounts/usage_get_params.rb new file mode 100644 index 00000000..61664b99 --- /dev/null +++ b/lib/imagekit/models/accounts/usage_get_params.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: true + +module Imagekit + module Models + module Accounts + # @see Imagekit::Resources::Accounts::Usage#get + class UsageGetParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + # @!attribute end_date + # Specify a `endDate` in `YYYY-MM-DD` format. It should be after the `startDate`. + # The difference between `startDate` and `endDate` should be less than 90 days. + # + # @return [Date] + required :end_date, Date + + # @!attribute start_date + # Specify a `startDate` in `YYYY-MM-DD` format. It should be before the `endDate`. + # The difference between `startDate` and `endDate` should be less than 90 days. + # + # @return [Date] + required :start_date, Date + + # @!method initialize(end_date:, start_date:, request_options: {}) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Accounts::UsageGetParams} for more details. + # + # @param end_date [Date] Specify a `endDate` in `YYYY-MM-DD` format. It should be after the `startDate`. + # + # @param start_date [Date] Specify a `startDate` in `YYYY-MM-DD` format. It should be before the `endDate`. + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/imagekit/models/accounts/usage_get_response.rb b/lib/imagekit/models/accounts/usage_get_response.rb new file mode 100644 index 00000000..7ac95137 --- /dev/null +++ b/lib/imagekit/models/accounts/usage_get_response.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true + +module Imagekit + module Models + module Accounts + # @see Imagekit::Resources::Accounts::Usage#get + class UsageGetResponse < Imagekit::Internal::Type::BaseModel + # @!attribute bandwidth_bytes + # Amount of bandwidth used in bytes. + # + # @return [Integer, nil] + optional :bandwidth_bytes, Integer, api_name: :bandwidthBytes + + # @!attribute extension_units_count + # Number of extension units used. + # + # @return [Integer, nil] + optional :extension_units_count, Integer, api_name: :extensionUnitsCount + + # @!attribute media_library_storage_bytes + # Storage used by media library in bytes. + # + # @return [Integer, nil] + optional :media_library_storage_bytes, Integer, api_name: :mediaLibraryStorageBytes + + # @!attribute original_cache_storage_bytes + # Storage used by the original cache in bytes. + # + # @return [Integer, nil] + optional :original_cache_storage_bytes, Integer, api_name: :originalCacheStorageBytes + + # @!attribute video_processing_units_count + # Number of video processing units used. + # + # @return [Integer, nil] + optional :video_processing_units_count, Integer, api_name: :videoProcessingUnitsCount + + # @!method initialize(bandwidth_bytes: nil, extension_units_count: nil, media_library_storage_bytes: nil, original_cache_storage_bytes: nil, video_processing_units_count: nil) + # @param bandwidth_bytes [Integer] Amount of bandwidth used in bytes. + # + # @param extension_units_count [Integer] Number of extension units used. + # + # @param media_library_storage_bytes [Integer] Storage used by media library in bytes. + # + # @param original_cache_storage_bytes [Integer] Storage used by the original cache in bytes. + # + # @param video_processing_units_count [Integer] Number of video processing units used. + end + end + end +end diff --git a/lib/imagekit/models/asset_list_params.rb b/lib/imagekit/models/asset_list_params.rb new file mode 100644 index 00000000..11eb0ea3 --- /dev/null +++ b/lib/imagekit/models/asset_list_params.rb @@ -0,0 +1,158 @@ +# frozen_string_literal: true + +module Imagekit + module Models + # @see Imagekit::Resources::Assets#list + class AssetListParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + # @!attribute file_type + # Filter results by file type. + # + # - `all` — include all file types + # - `image` — include only image files + # - `non-image` — include only non-image files (e.g., JS, CSS, video) + # + # @return [Symbol, Imagekit::Models::AssetListParams::FileType, nil] + optional :file_type, enum: -> { Imagekit::AssetListParams::FileType } + + # @!attribute limit + # The maximum number of results to return in response. + # + # @return [Integer, nil] + optional :limit, Integer + + # @!attribute path + # Folder path if you want to limit the search within a specific folder. For + # example, `/sales-banner/` will only search in folder sales-banner. + # + # Note : If your use case involves searching within a folder as well as its + # subfolders, you can use `path` parameter in `searchQuery` with appropriate + # operator. Checkout + # [Supported parameters](/docs/api-reference/digital-asset-management-dam/list-and-search-assets#supported-parameters) + # for more information. + # + # @return [String, nil] + optional :path, String + + # @!attribute search_query + # Query string in a Lucene-like query language e.g. `createdAt > "7d"`. + # + # Note : When the searchQuery parameter is present, the following query parameters + # will have no effect on the result: + # + # 1. `tags` + # 2. `type` + # 3. `name` + # + # [Learn more](/docs/api-reference/digital-asset-management-dam/list-and-search-assets#advanced-search-queries) + # from examples. + # + # @return [String, nil] + optional :search_query, String + + # @!attribute skip + # The number of results to skip before returning results. + # + # @return [Integer, nil] + optional :skip, Integer + + # @!attribute sort + # Sort the results by one of the supported fields in ascending or descending + # order. + # + # @return [Symbol, Imagekit::Models::AssetListParams::Sort, nil] + optional :sort, enum: -> { Imagekit::AssetListParams::Sort } + + # @!attribute type + # Filter results by asset type. + # + # - `file` — returns only files + # - `file-version` — returns specific file versions + # - `folder` — returns only folders + # - `all` — returns both files and folders (excludes `file-version`) + # + # @return [Symbol, Imagekit::Models::AssetListParams::Type, nil] + optional :type, enum: -> { Imagekit::AssetListParams::Type } + + # @!method initialize(file_type: nil, limit: nil, path: nil, search_query: nil, skip: nil, sort: nil, type: nil, request_options: {}) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::AssetListParams} for more details. + # + # @param file_type [Symbol, Imagekit::Models::AssetListParams::FileType] Filter results by file type. + # + # @param limit [Integer] The maximum number of results to return in response. + # + # @param path [String] Folder path if you want to limit the search within a specific folder. For exampl + # + # @param search_query [String] Query string in a Lucene-like query language e.g. `createdAt > "7d"`. + # + # @param skip [Integer] The number of results to skip before returning results. + # + # @param sort [Symbol, Imagekit::Models::AssetListParams::Sort] Sort the results by one of the supported fields in ascending or descending order + # + # @param type [Symbol, Imagekit::Models::AssetListParams::Type] Filter results by asset type. + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}] + + # Filter results by file type. + # + # - `all` — include all file types + # - `image` — include only image files + # - `non-image` — include only non-image files (e.g., JS, CSS, video) + module FileType + extend Imagekit::Internal::Type::Enum + + ALL = :all + IMAGE = :image + NON_IMAGE = :"non-image" + + # @!method self.values + # @return [Array] + end + + # Sort the results by one of the supported fields in ascending or descending + # order. + module Sort + extend Imagekit::Internal::Type::Enum + + ASC_NAME = :ASC_NAME + DESC_NAME = :DESC_NAME + ASC_CREATED = :ASC_CREATED + DESC_CREATED = :DESC_CREATED + ASC_UPDATED = :ASC_UPDATED + DESC_UPDATED = :DESC_UPDATED + ASC_HEIGHT = :ASC_HEIGHT + DESC_HEIGHT = :DESC_HEIGHT + ASC_WIDTH = :ASC_WIDTH + DESC_WIDTH = :DESC_WIDTH + ASC_SIZE = :ASC_SIZE + DESC_SIZE = :DESC_SIZE + ASC_RELEVANCE = :ASC_RELEVANCE + DESC_RELEVANCE = :DESC_RELEVANCE + + # @!method self.values + # @return [Array] + end + + # Filter results by asset type. + # + # - `file` — returns only files + # - `file-version` — returns specific file versions + # - `folder` — returns only folders + # - `all` — returns both files and folders (excludes `file-version`) + module Type + extend Imagekit::Internal::Type::Enum + + FILE = :file + FILE_VERSION = :"file-version" + FOLDER = :folder + ALL = :all + + # @!method self.values + # @return [Array] + end + end + end +end diff --git a/lib/imagekit/models/asset_list_response.rb b/lib/imagekit/models/asset_list_response.rb new file mode 100644 index 00000000..6477fc20 --- /dev/null +++ b/lib/imagekit/models/asset_list_response.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +module Imagekit + module Models + # Object containing details of a file or file version. + module AssetListResponseItem + extend Imagekit::Internal::Type::Union + + discriminator :type + + variant :folder, -> { Imagekit::Folder } + + # Object containing details of a file or file version. + variant -> { Imagekit::File } + + # @!method self.variants + # @return [Array(Imagekit::Models::Folder, Imagekit::Models::File)] + end + + # @type [Imagekit::Internal::Type::Converter] + AssetListResponse = + Imagekit::Internal::Type::ArrayOf[union: -> { Imagekit::Models::AssetListResponseItem }] + end +end diff --git a/lib/imagekit/models/base_overlay.rb b/lib/imagekit/models/base_overlay.rb new file mode 100644 index 00000000..44a3c8a8 --- /dev/null +++ b/lib/imagekit/models/base_overlay.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +module Imagekit + module Models + class BaseOverlay < Imagekit::Internal::Type::BaseModel + # @!attribute position + # + # @return [Imagekit::Models::OverlayPosition, nil] + optional :position, -> { Imagekit::OverlayPosition } + + # @!attribute timing + # + # @return [Imagekit::Models::OverlayTiming, nil] + optional :timing, -> { Imagekit::OverlayTiming } + + # @!method initialize(position: nil, timing: nil) + # @param position [Imagekit::Models::OverlayPosition] + # @param timing [Imagekit::Models::OverlayTiming] + end + end +end diff --git a/lib/imagekit/models/base_webhook_event.rb b/lib/imagekit/models/base_webhook_event.rb new file mode 100644 index 00000000..d34435b2 --- /dev/null +++ b/lib/imagekit/models/base_webhook_event.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +module Imagekit + module Models + class BaseWebhookEvent < Imagekit::Internal::Type::BaseModel + # @!attribute id + # Unique identifier for the event. + # + # @return [String] + required :id, String + + # @!attribute type + # The type of webhook event. + # + # @return [String] + required :type, String + + # @!method initialize(id:, type:) + # @param id [String] Unique identifier for the event. + # + # @param type [String] The type of webhook event. + end + end +end diff --git a/lib/imagekit/models/beta/v2/file_upload_params.rb b/lib/imagekit/models/beta/v2/file_upload_params.rb new file mode 100644 index 00000000..2b4cc97d --- /dev/null +++ b/lib/imagekit/models/beta/v2/file_upload_params.rb @@ -0,0 +1,444 @@ +# frozen_string_literal: true + +module Imagekit + module Models + module Beta + module V2 + # @see Imagekit::Resources::Beta::V2::Files#upload + class FileUploadParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + # @!attribute file + # The API accepts any of the following: + # + # - **Binary data** – send the raw bytes as `multipart/form-data`. + # - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can + # fetch. + # - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + # + # When supplying a URL, the server must receive the response headers within 8 + # seconds; otherwise the request fails with 400 Bad Request. + # + # @return [Pathname, StringIO, IO, String, Imagekit::FilePart] + required :file, Imagekit::Internal::Type::FileInput + + # @!attribute file_name + # The name with which the file has to be uploaded. + # + # @return [String] + required :file_name, String, api_name: :fileName + + # @!attribute token + # This is the client-generated JSON Web Token (JWT). The ImageKit.io server uses + # it to authenticate and check that the upload request parameters have not been + # tampered with after the token has been generated. Learn how to create the token + # on the page below. This field is only required for authentication when uploading + # a file from the client side. + # + # **Note**: Sending a JWT that has been used in the past will result in a + # validation error. Even if your previous request resulted in an error, you should + # always send a new token. + # + # **⚠️Warning**: JWT must be generated on the server-side because it is generated + # using your account's private API key. This field is required for authentication + # when uploading a file from the client-side. + # + # @return [String, nil] + optional :token, String + + # @!attribute checks + # Server-side checks to run on the asset. Read more about + # [Upload API checks](/docs/api-reference/upload-file/upload-file-v2#upload-api-checks). + # + # @return [String, nil] + optional :checks, String + + # @!attribute custom_coordinates + # Define an important area in the image. This is only relevant for image type + # files. + # + # - To be passed as a string with the x and y coordinates of the top-left corner, + # and width and height of the area of interest in the format `x,y,width,height`. + # For example - `10,10,100,100` + # - Can be used with fo-customtransformation. + # - If this field is not specified and the file is overwritten, then + # customCoordinates will be removed. + # + # @return [String, nil] + optional :custom_coordinates, String, api_name: :customCoordinates + + # @!attribute custom_metadata + # JSON key-value pairs to associate with the asset. Create the custom metadata + # fields before setting these values. + # + # @return [Hash{Symbol=>Object}, nil] + optional :custom_metadata, + Imagekit::Internal::Type::HashOf[Imagekit::Internal::Type::Unknown], + api_name: :customMetadata + + # @!attribute description + # Optional text to describe the contents of the file. + # + # @return [String, nil] + optional :description, String + + # @!attribute extensions + # Array of extensions to be applied to the asset. Each extension can be configured + # with specific parameters based on the extension type. + # + # @return [Array, nil] + optional :extensions, -> { Imagekit::Internal::Type::ArrayOf[union: Imagekit::ExtensionItem] } + + # @!attribute folder + # The folder path in which the image has to be uploaded. If the folder(s) didn't + # exist before, a new folder(s) is created. Using multiple `/` creates a nested + # folder. + # + # @return [String, nil] + optional :folder, String + + # @!attribute is_private_file + # Whether to mark the file as private or not. + # + # If `true`, the file is marked as private and is accessible only using named + # transformation or signed URL. + # + # @return [Boolean, nil] + optional :is_private_file, Imagekit::Internal::Type::Boolean, api_name: :isPrivateFile + + # @!attribute is_published + # Whether to upload file as published or not. + # + # If `false`, the file is marked as unpublished, which restricts access to the + # file only via the media library. Files in draft or unpublished state can only be + # publicly accessed after being published. + # + # The option to upload in draft state is only available in custom enterprise + # pricing plans. + # + # @return [Boolean, nil] + optional :is_published, Imagekit::Internal::Type::Boolean, api_name: :isPublished + + # @!attribute overwrite_ai_tags + # If set to `true` and a file already exists at the exact location, its AITags + # will be removed. Set `overwriteAITags` to `false` to preserve AITags. + # + # @return [Boolean, nil] + optional :overwrite_ai_tags, Imagekit::Internal::Type::Boolean, api_name: :overwriteAITags + + # @!attribute overwrite_custom_metadata + # If the request does not have `customMetadata`, and a file already exists at the + # exact location, existing customMetadata will be removed. + # + # @return [Boolean, nil] + optional :overwrite_custom_metadata, + Imagekit::Internal::Type::Boolean, + api_name: :overwriteCustomMetadata + + # @!attribute overwrite_file + # If `false` and `useUniqueFileName` is also `false`, and a file already exists at + # the exact location, upload API will return an error immediately. + # + # @return [Boolean, nil] + optional :overwrite_file, Imagekit::Internal::Type::Boolean, api_name: :overwriteFile + + # @!attribute overwrite_tags + # If the request does not have `tags`, and a file already exists at the exact + # location, existing tags will be removed. + # + # @return [Boolean, nil] + optional :overwrite_tags, Imagekit::Internal::Type::Boolean, api_name: :overwriteTags + + # @!attribute response_fields + # Array of response field keys to include in the API response body. + # + # @return [Array, nil] + optional :response_fields, + -> { + Imagekit::Internal::Type::ArrayOf[enum: Imagekit::Beta::V2::FileUploadParams::ResponseField] + }, + api_name: :responseFields + + # @!attribute tags + # Set the tags while uploading the file. Provide an array of tag strings (e.g. + # `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must not + # exceed 500, and the `%` character is not allowed. If this field is not specified + # and the file is overwritten, the existing tags will be removed. + # + # @return [Array, nil] + optional :tags, Imagekit::Internal::Type::ArrayOf[String] + + # @!attribute transformation + # Configure pre-processing (`pre`) and post-processing (`post`) transformations. + # + # - `pre` — applied before the file is uploaded to the Media Library. + # Useful for reducing file size or applying basic optimizations upfront (e.g., + # resize, compress). + # + # - `post` — applied immediately after upload. + # Ideal for generating transformed versions (like video encodes or thumbnails) + # in advance, so they're ready for delivery without delay. + # + # You can mix and match any combination of post-processing types. + # + # @return [Imagekit::Models::Beta::V2::FileUploadParams::Transformation, nil] + optional :transformation, -> { Imagekit::Beta::V2::FileUploadParams::Transformation } + + # @!attribute use_unique_file_name + # Whether to use a unique filename for this file or not. + # + # If `true`, ImageKit.io will add a unique suffix to the filename parameter to get + # a unique filename. + # + # If `false`, then the image is uploaded with the provided filename parameter, and + # any existing file with the same name is replaced. + # + # @return [Boolean, nil] + optional :use_unique_file_name, Imagekit::Internal::Type::Boolean, api_name: :useUniqueFileName + + # @!attribute webhook_url + # The final status of extensions after they have completed execution will be + # delivered to this endpoint as a POST request. + # [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + # about the webhook payload structure. + # + # @return [String, nil] + optional :webhook_url, String, api_name: :webhookUrl + + # @!method initialize(file:, file_name:, token: nil, checks: nil, custom_coordinates: nil, custom_metadata: nil, description: nil, extensions: nil, folder: nil, is_private_file: nil, is_published: nil, overwrite_ai_tags: nil, overwrite_custom_metadata: nil, overwrite_file: nil, overwrite_tags: nil, response_fields: nil, tags: nil, transformation: nil, use_unique_file_name: nil, webhook_url: nil, request_options: {}) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Beta::V2::FileUploadParams} for more details. + # + # @param file [Pathname, StringIO, IO, String, Imagekit::FilePart] The API accepts any of the following: + # + # @param file_name [String] The name with which the file has to be uploaded. + # + # @param token [String] This is the client-generated JSON Web Token (JWT). The ImageKit.io server uses i + # + # @param checks [String] Server-side checks to run on the asset. + # + # @param custom_coordinates [String] Define an important area in the image. This is only relevant for image type file + # + # @param custom_metadata [Hash{Symbol=>Object}] JSON key-value pairs to associate with the asset. Create the custom metadata fie + # + # @param description [String] Optional text to describe the contents of the file. + # + # @param extensions [Array] Array of extensions to be applied to the asset. Each extension can be configured + # + # @param folder [String] The folder path in which the image has to be uploaded. If the folder(s) didn't e + # + # @param is_private_file [Boolean] Whether to mark the file as private or not. + # + # @param is_published [Boolean] Whether to upload file as published or not. + # + # @param overwrite_ai_tags [Boolean] If set to `true` and a file already exists at the exact location, its AITags wil + # + # @param overwrite_custom_metadata [Boolean] If the request does not have `customMetadata`, and a file already exists at the + # + # @param overwrite_file [Boolean] If `false` and `useUniqueFileName` is also `false`, and a file already exists at + # + # @param overwrite_tags [Boolean] If the request does not have `tags`, and a file already exists at the exact loca + # + # @param response_fields [Array] Array of response field keys to include in the API response body. + # + # @param tags [Array] Set the tags while uploading the file. + # + # @param transformation [Imagekit::Models::Beta::V2::FileUploadParams::Transformation] Configure pre-processing (`pre`) and post-processing (`post`) transformations. + # + # @param use_unique_file_name [Boolean] Whether to use a unique filename for this file or not. + # + # @param webhook_url [String] The final status of extensions after they have completed execution will be deliv + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}] + + module ResponseField + extend Imagekit::Internal::Type::Enum + + TAGS = :tags + CUSTOM_COORDINATES = :customCoordinates + IS_PRIVATE_FILE = :isPrivateFile + EMBEDDED_METADATA = :embeddedMetadata + IS_PUBLISHED = :isPublished + CUSTOM_METADATA = :customMetadata + METADATA = :metadata + + # @!method self.values + # @return [Array] + end + + class Transformation < Imagekit::Internal::Type::BaseModel + # @!attribute post + # List of transformations to apply _after_ the file is uploaded. + # Each item must match one of the following types: `transformation`, + # `gif-to-video`, `thumbnail`, `abs`. + # + # @return [Array, nil] + optional :post, + -> { Imagekit::Internal::Type::ArrayOf[union: Imagekit::Beta::V2::FileUploadParams::Transformation::Post] } + + # @!attribute pre + # Transformation string to apply before uploading the file to the Media Library. + # Useful for optimizing files at ingestion. + # + # @return [String, nil] + optional :pre, String + + # @!method initialize(post: nil, pre: nil) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Beta::V2::FileUploadParams::Transformation} for more details. + # + # Configure pre-processing (`pre`) and post-processing (`post`) transformations. + # + # - `pre` — applied before the file is uploaded to the Media Library. + # Useful for reducing file size or applying basic optimizations upfront (e.g., + # resize, compress). + # + # - `post` — applied immediately after upload. + # Ideal for generating transformed versions (like video encodes or thumbnails) + # in advance, so they're ready for delivery without delay. + # + # You can mix and match any combination of post-processing types. + # + # @param post [Array] List of transformations to apply _after_ the file is uploaded. + # + # @param pre [String] Transformation string to apply before uploading the file to the Media Library. U + + module Post + extend Imagekit::Internal::Type::Union + + discriminator :type + + variant :transformation, -> { Imagekit::Beta::V2::FileUploadParams::Transformation::Post::Transformation } + + variant :"gif-to-video", -> { Imagekit::Beta::V2::FileUploadParams::Transformation::Post::GifToVideo } + + variant :thumbnail, -> { Imagekit::Beta::V2::FileUploadParams::Transformation::Post::Thumbnail } + + variant :abs, -> { Imagekit::Beta::V2::FileUploadParams::Transformation::Post::Abs } + + class Transformation < Imagekit::Internal::Type::BaseModel + # @!attribute type + # Transformation type. + # + # @return [Symbol, :transformation] + required :type, const: :transformation + + # @!attribute value + # Transformation string (e.g. `w-200,h-200`). + # Same syntax as ImageKit URL-based transformations. + # + # @return [String] + required :value, String + + # @!method initialize(value:, type: :transformation) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Beta::V2::FileUploadParams::Transformation::Post::Transformation} + # for more details. + # + # @param value [String] Transformation string (e.g. `w-200,h-200`). + # + # @param type [Symbol, :transformation] Transformation type. + end + + class GifToVideo < Imagekit::Internal::Type::BaseModel + # @!attribute type + # Converts an animated GIF into an MP4. + # + # @return [Symbol, :"gif-to-video"] + required :type, const: :"gif-to-video" + + # @!attribute value + # Optional transformation string to apply to the output video. + # **Example**: `q-80` + # + # @return [String, nil] + optional :value, String + + # @!method initialize(value: nil, type: :"gif-to-video") + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Beta::V2::FileUploadParams::Transformation::Post::GifToVideo} + # for more details. + # + # @param value [String] Optional transformation string to apply to the output video. + # + # @param type [Symbol, :"gif-to-video"] Converts an animated GIF into an MP4. + end + + class Thumbnail < Imagekit::Internal::Type::BaseModel + # @!attribute type + # Generates a thumbnail image. + # + # @return [Symbol, :thumbnail] + required :type, const: :thumbnail + + # @!attribute value + # Optional transformation string. + # **Example**: `w-150,h-150` + # + # @return [String, nil] + optional :value, String + + # @!method initialize(value: nil, type: :thumbnail) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Beta::V2::FileUploadParams::Transformation::Post::Thumbnail} + # for more details. + # + # @param value [String] Optional transformation string. + # + # @param type [Symbol, :thumbnail] Generates a thumbnail image. + end + + class Abs < Imagekit::Internal::Type::BaseModel + # @!attribute protocol + # Streaming protocol to use (`hls` or `dash`). + # + # @return [Symbol, Imagekit::Models::Beta::V2::FileUploadParams::Transformation::Post::Abs::Protocol] + required :protocol, enum: -> { Imagekit::Beta::V2::FileUploadParams::Transformation::Post::Abs::Protocol } + + # @!attribute type + # Adaptive Bitrate Streaming (ABS) setup. + # + # @return [Symbol, :abs] + required :type, const: :abs + + # @!attribute value + # List of different representations you want to create separated by an underscore. + # + # @return [String] + required :value, String + + # @!method initialize(protocol:, value:, type: :abs) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Beta::V2::FileUploadParams::Transformation::Post::Abs} for + # more details. + # + # @param protocol [Symbol, Imagekit::Models::Beta::V2::FileUploadParams::Transformation::Post::Abs::Protocol] Streaming protocol to use (`hls` or `dash`). + # + # @param value [String] List of different representations you want to create separated by an underscore. + # + # @param type [Symbol, :abs] Adaptive Bitrate Streaming (ABS) setup. + + # Streaming protocol to use (`hls` or `dash`). + # + # @see Imagekit::Models::Beta::V2::FileUploadParams::Transformation::Post::Abs#protocol + module Protocol + extend Imagekit::Internal::Type::Enum + + HLS = :hls + DASH = :dash + + # @!method self.values + # @return [Array] + end + end + + # @!method self.variants + # @return [Array(Imagekit::Models::Beta::V2::FileUploadParams::Transformation::Post::Transformation, Imagekit::Models::Beta::V2::FileUploadParams::Transformation::Post::GifToVideo, Imagekit::Models::Beta::V2::FileUploadParams::Transformation::Post::Thumbnail, Imagekit::Models::Beta::V2::FileUploadParams::Transformation::Post::Abs)] + end + end + end + end + end + end +end diff --git a/lib/imagekit/models/beta/v2/file_upload_response.rb b/lib/imagekit/models/beta/v2/file_upload_response.rb new file mode 100644 index 00000000..65cab1f9 --- /dev/null +++ b/lib/imagekit/models/beta/v2/file_upload_response.rb @@ -0,0 +1,397 @@ +# frozen_string_literal: true + +module Imagekit + module Models + module Beta + module V2 + # @see Imagekit::Resources::Beta::V2::Files#upload + class FileUploadResponse < Imagekit::Internal::Type::BaseModel + # @!attribute ai_tags + # An array of tags assigned to the uploaded file by auto tagging. + # + # @return [Array, nil] + optional :ai_tags, + -> { Imagekit::Internal::Type::ArrayOf[Imagekit::Models::Beta::V2::FileUploadResponse::AITag] }, + api_name: :AITags, + nil?: true + + # @!attribute audio_codec + # The audio codec used in the video (only for video). + # + # @return [String, nil] + optional :audio_codec, String, api_name: :audioCodec + + # @!attribute bit_rate + # The bit rate of the video in kbps (only for video). + # + # @return [Integer, nil] + optional :bit_rate, Integer, api_name: :bitRate + + # @!attribute custom_coordinates + # Value of custom coordinates associated with the image in the format + # `x,y,width,height`. If `customCoordinates` are not defined, then it is `null`. + # Send `customCoordinates` in `responseFields` in API request to get the value of + # this field. + # + # @return [String, nil] + optional :custom_coordinates, String, api_name: :customCoordinates, nil?: true + + # @!attribute custom_metadata + # A key-value data associated with the asset. Use `responseField` in API request + # to get `customMetadata` in the upload API response. Before setting any custom + # metadata on an asset, you have to create the field using custom metadata fields + # API. Send `customMetadata` in `responseFields` in API request to get the value + # of this field. + # + # @return [Hash{Symbol=>Object}, nil] + optional :custom_metadata, + Imagekit::Internal::Type::HashOf[Imagekit::Internal::Type::Unknown], + api_name: :customMetadata + + # @!attribute description + # Optional text to describe the contents of the file. Can be set by the user or + # the ai-auto-description extension. + # + # @return [String, nil] + optional :description, String + + # @!attribute duration + # The duration of the video in seconds (only for video). + # + # @return [Integer, nil] + optional :duration, Integer + + # @!attribute embedded_metadata + # Consolidated embedded metadata associated with the file. It includes exif, iptc, + # and xmp data. Send `embeddedMetadata` in `responseFields` in API request to get + # embeddedMetadata in the upload API response. + # + # @return [Hash{Symbol=>Object}, nil] + optional :embedded_metadata, + Imagekit::Internal::Type::HashOf[Imagekit::Internal::Type::Unknown], + api_name: :embeddedMetadata + + # @!attribute extension_status + # Extension names with their processing status at the time of completion of the + # request. It could have one of the following status values: + # + # `success`: The extension has been successfully applied. `failed`: The extension + # has failed and will not be retried. `pending`: The extension will finish + # processing in some time. On completion, the final status (success / failed) will + # be sent to the `webhookUrl` provided. + # + # If no extension was requested, then this parameter is not returned. + # + # @return [Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus, nil] + optional :extension_status, + -> { Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus }, + api_name: :extensionStatus + + # @!attribute file_id + # Unique fileId. Store this fileld in your database, as this will be used to + # perform update action on this file. + # + # @return [String, nil] + optional :file_id, String, api_name: :fileId + + # @!attribute file_path + # The relative path of the file in the media library e.g. + # `/marketing-assets/new-banner.jpg`. + # + # @return [String, nil] + optional :file_path, String, api_name: :filePath + + # @!attribute file_type + # Type of the uploaded file. Possible values are `image`, `non-image`. + # + # @return [String, nil] + optional :file_type, String, api_name: :fileType + + # @!attribute height + # Height of the image in pixels (Only for images) + # + # @return [Float, nil] + optional :height, Float + + # @!attribute is_private_file + # Is the file marked as private. It can be either `true` or `false`. Send + # `isPrivateFile` in `responseFields` in API request to get the value of this + # field. + # + # @return [Boolean, nil] + optional :is_private_file, Imagekit::Internal::Type::Boolean, api_name: :isPrivateFile + + # @!attribute is_published + # Is the file published or in draft state. It can be either `true` or `false`. + # Send `isPublished` in `responseFields` in API request to get the value of this + # field. + # + # @return [Boolean, nil] + optional :is_published, Imagekit::Internal::Type::Boolean, api_name: :isPublished + + # @!attribute metadata + # Legacy metadata. Send `metadata` in `responseFields` in API request to get + # metadata in the upload API response. + # + # @return [Imagekit::Models::Metadata, nil] + optional :metadata, -> { Imagekit::Metadata } + + # @!attribute name + # Name of the asset. + # + # @return [String, nil] + optional :name, String + + # @!attribute size + # Size of the image file in Bytes. + # + # @return [Float, nil] + optional :size, Float + + # @!attribute tags + # The array of tags associated with the asset. If no tags are set, it will be + # `null`. Send `tags` in `responseFields` in API request to get the value of this + # field. + # + # @return [Array, nil] + optional :tags, Imagekit::Internal::Type::ArrayOf[String], nil?: true + + # @!attribute thumbnail_url + # In the case of an image, a small thumbnail URL. + # + # @return [String, nil] + optional :thumbnail_url, String, api_name: :thumbnailUrl + + # @!attribute url + # A publicly accessible URL of the file. + # + # @return [String, nil] + optional :url, String + + # @!attribute version_info + # An object containing the file or file version's `id` (versionId) and `name`. + # + # @return [Imagekit::Models::Beta::V2::FileUploadResponse::VersionInfo, nil] + optional :version_info, + -> { Imagekit::Models::Beta::V2::FileUploadResponse::VersionInfo }, + api_name: :versionInfo + + # @!attribute video_codec + # The video codec used in the video (only for video). + # + # @return [String, nil] + optional :video_codec, String, api_name: :videoCodec + + # @!attribute width + # Width of the image in pixels (Only for Images) + # + # @return [Float, nil] + optional :width, Float + + # @!method initialize(ai_tags: nil, audio_codec: nil, bit_rate: nil, custom_coordinates: nil, custom_metadata: nil, description: nil, duration: nil, embedded_metadata: nil, extension_status: nil, file_id: nil, file_path: nil, file_type: nil, height: nil, is_private_file: nil, is_published: nil, metadata: nil, name: nil, size: nil, tags: nil, thumbnail_url: nil, url: nil, version_info: nil, video_codec: nil, width: nil) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Beta::V2::FileUploadResponse} for more details. + # + # Object containing details of a successful upload. + # + # @param ai_tags [Array, nil] An array of tags assigned to the uploaded file by auto tagging. + # + # @param audio_codec [String] The audio codec used in the video (only for video). + # + # @param bit_rate [Integer] The bit rate of the video in kbps (only for video). + # + # @param custom_coordinates [String, nil] Value of custom coordinates associated with the image in the format `x,y,width,h + # + # @param custom_metadata [Hash{Symbol=>Object}] A key-value data associated with the asset. Use `responseField` in API request t + # + # @param description [String] Optional text to describe the contents of the file. Can be set by the user or th + # + # @param duration [Integer] The duration of the video in seconds (only for video). + # + # @param embedded_metadata [Hash{Symbol=>Object}] Consolidated embedded metadata associated with the file. It includes exif, iptc, + # + # @param extension_status [Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus] Extension names with their processing status at the time of completion of the re + # + # @param file_id [String] Unique fileId. Store this fileld in your database, as this will be used to perfo + # + # @param file_path [String] The relative path of the file in the media library e.g. `/marketing-assets/new-b + # + # @param file_type [String] Type of the uploaded file. Possible values are `image`, `non-image`. + # + # @param height [Float] Height of the image in pixels (Only for images) + # + # @param is_private_file [Boolean] Is the file marked as private. It can be either `true` or `false`. Send `isPriva + # + # @param is_published [Boolean] Is the file published or in draft state. It can be either `true` or `false`. Sen + # + # @param metadata [Imagekit::Models::Metadata] Legacy metadata. Send `metadata` in `responseFields` in API request to get metad + # + # @param name [String] Name of the asset. + # + # @param size [Float] Size of the image file in Bytes. + # + # @param tags [Array, nil] The array of tags associated with the asset. If no tags are set, it will be `nul + # + # @param thumbnail_url [String] In the case of an image, a small thumbnail URL. + # + # @param url [String] A publicly accessible URL of the file. + # + # @param version_info [Imagekit::Models::Beta::V2::FileUploadResponse::VersionInfo] An object containing the file or file version's `id` (versionId) and `name`. + # + # @param video_codec [String] The video codec used in the video (only for video). + # + # @param width [Float] Width of the image in pixels (Only for Images) + + class AITag < Imagekit::Internal::Type::BaseModel + # @!attribute confidence + # Confidence score of the tag. + # + # @return [Float, nil] + optional :confidence, Float + + # @!attribute name + # Name of the tag. + # + # @return [String, nil] + optional :name, String + + # @!attribute source + # Array of `AITags` associated with the image. If no `AITags` are set, it will be + # null. These tags can be added using the `google-auto-tagging` or + # `aws-auto-tagging` extensions. + # + # @return [String, nil] + optional :source, String + + # @!method initialize(confidence: nil, name: nil, source: nil) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Beta::V2::FileUploadResponse::AITag} for more details. + # + # @param confidence [Float] Confidence score of the tag. + # + # @param name [String] Name of the tag. + # + # @param source [String] Array of `AITags` associated with the image. If no `AITags` are set, it will be + end + + # @see Imagekit::Models::Beta::V2::FileUploadResponse#extension_status + class ExtensionStatus < Imagekit::Internal::Type::BaseModel + # @!attribute ai_auto_description + # + # @return [Symbol, Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::AIAutoDescription, nil] + optional :ai_auto_description, + enum: -> { Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::AIAutoDescription }, + api_name: :"ai-auto-description" + + # @!attribute aws_auto_tagging + # + # @return [Symbol, Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::AwsAutoTagging, nil] + optional :aws_auto_tagging, + enum: -> { Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::AwsAutoTagging }, + api_name: :"aws-auto-tagging" + + # @!attribute google_auto_tagging + # + # @return [Symbol, Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::GoogleAutoTagging, nil] + optional :google_auto_tagging, + enum: -> { Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::GoogleAutoTagging }, + api_name: :"google-auto-tagging" + + # @!attribute remove_bg + # + # @return [Symbol, Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::RemoveBg, nil] + optional :remove_bg, + enum: -> { Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::RemoveBg }, + api_name: :"remove-bg" + + # @!method initialize(ai_auto_description: nil, aws_auto_tagging: nil, google_auto_tagging: nil, remove_bg: nil) + # Extension names with their processing status at the time of completion of the + # request. It could have one of the following status values: + # + # `success`: The extension has been successfully applied. `failed`: The extension + # has failed and will not be retried. `pending`: The extension will finish + # processing in some time. On completion, the final status (success / failed) will + # be sent to the `webhookUrl` provided. + # + # If no extension was requested, then this parameter is not returned. + # + # @param ai_auto_description [Symbol, Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::AIAutoDescription] + # @param aws_auto_tagging [Symbol, Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::AwsAutoTagging] + # @param google_auto_tagging [Symbol, Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::GoogleAutoTagging] + # @param remove_bg [Symbol, Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::RemoveBg] + + # @see Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus#ai_auto_description + module AIAutoDescription + extend Imagekit::Internal::Type::Enum + + SUCCESS = :success + PENDING = :pending + FAILED = :failed + + # @!method self.values + # @return [Array] + end + + # @see Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus#aws_auto_tagging + module AwsAutoTagging + extend Imagekit::Internal::Type::Enum + + SUCCESS = :success + PENDING = :pending + FAILED = :failed + + # @!method self.values + # @return [Array] + end + + # @see Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus#google_auto_tagging + module GoogleAutoTagging + extend Imagekit::Internal::Type::Enum + + SUCCESS = :success + PENDING = :pending + FAILED = :failed + + # @!method self.values + # @return [Array] + end + + # @see Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus#remove_bg + module RemoveBg + extend Imagekit::Internal::Type::Enum + + SUCCESS = :success + PENDING = :pending + FAILED = :failed + + # @!method self.values + # @return [Array] + end + end + + # @see Imagekit::Models::Beta::V2::FileUploadResponse#version_info + class VersionInfo < Imagekit::Internal::Type::BaseModel + # @!attribute id + # Unique identifier of the file version. + # + # @return [String, nil] + optional :id, String + + # @!attribute name + # Name of the file version. + # + # @return [String, nil] + optional :name, String + + # @!method initialize(id: nil, name: nil) + # An object containing the file or file version's `id` (versionId) and `name`. + # + # @param id [String] Unique identifier of the file version. + # + # @param name [String] Name of the file version. + end + end + end + end + end +end diff --git a/lib/imagekit/models/cache/invalidation_create_params.rb b/lib/imagekit/models/cache/invalidation_create_params.rb new file mode 100644 index 00000000..47e252a8 --- /dev/null +++ b/lib/imagekit/models/cache/invalidation_create_params.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +module Imagekit + module Models + module Cache + # @see Imagekit::Resources::Cache::Invalidation#create + class InvalidationCreateParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + # @!attribute url + # The full URL of the file to be purged. + # + # @return [String] + required :url, String + + # @!method initialize(url:, request_options: {}) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Cache::InvalidationCreateParams} for more details. + # + # @param url [String] The full URL of the file to be purged. + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/imagekit/models/cache/invalidation_create_response.rb b/lib/imagekit/models/cache/invalidation_create_response.rb new file mode 100644 index 00000000..ceb1f1d0 --- /dev/null +++ b/lib/imagekit/models/cache/invalidation_create_response.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +module Imagekit + module Models + module Cache + # @see Imagekit::Resources::Cache::Invalidation#create + class InvalidationCreateResponse < Imagekit::Internal::Type::BaseModel + # @!attribute request_id + # Unique identifier of the purge request. This can be used to check the status of + # the purge request. + # + # @return [String, nil] + optional :request_id, String, api_name: :requestId + + # @!method initialize(request_id: nil) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Cache::InvalidationCreateResponse} for more details. + # + # @param request_id [String] Unique identifier of the purge request. This can be used to check the status of + end + end + end +end diff --git a/lib/imagekit/models/cache/invalidation_get_params.rb b/lib/imagekit/models/cache/invalidation_get_params.rb new file mode 100644 index 00000000..d25ae6f5 --- /dev/null +++ b/lib/imagekit/models/cache/invalidation_get_params.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module Imagekit + module Models + module Cache + # @see Imagekit::Resources::Cache::Invalidation#get + class InvalidationGetParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + # @!method initialize(request_options: {}) + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/imagekit/models/cache/invalidation_get_response.rb b/lib/imagekit/models/cache/invalidation_get_response.rb new file mode 100644 index 00000000..0a5d99c0 --- /dev/null +++ b/lib/imagekit/models/cache/invalidation_get_response.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +module Imagekit + module Models + module Cache + # @see Imagekit::Resources::Cache::Invalidation#get + class InvalidationGetResponse < Imagekit::Internal::Type::BaseModel + # @!attribute status + # Status of the purge request. + # + # @return [Symbol, Imagekit::Models::Cache::InvalidationGetResponse::Status, nil] + optional :status, enum: -> { Imagekit::Models::Cache::InvalidationGetResponse::Status } + + # @!method initialize(status: nil) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Cache::InvalidationGetResponse} for more details. + # + # @param status [Symbol, Imagekit::Models::Cache::InvalidationGetResponse::Status] Status of the purge request. + + # Status of the purge request. + # + # @see Imagekit::Models::Cache::InvalidationGetResponse#status + module Status + extend Imagekit::Internal::Type::Enum + + PENDING = :Pending + COMPLETED = :Completed + + # @!method self.values + # @return [Array] + end + end + end + end +end diff --git a/lib/imagekit/models/custom_metadata_field.rb b/lib/imagekit/models/custom_metadata_field.rb new file mode 100644 index 00000000..c82382bc --- /dev/null +++ b/lib/imagekit/models/custom_metadata_field.rb @@ -0,0 +1,243 @@ +# frozen_string_literal: true + +module Imagekit + module Models + # @see Imagekit::Resources::CustomMetadataFields#create + class CustomMetadataField < Imagekit::Internal::Type::BaseModel + # @!attribute id + # Unique identifier for the custom metadata field. Use this to update the field. + # + # @return [String] + required :id, String + + # @!attribute label + # Human readable name of the custom metadata field. This name is displayed as form + # field label to the users while setting field value on the asset in the media + # library UI. + # + # @return [String] + required :label, String + + # @!attribute name + # API name of the custom metadata field. This becomes the key while setting + # `customMetadata` (key-value object) for an asset using upload or update API. + # + # @return [String] + required :name, String + + # @!attribute schema + # An object that describes the rules for the custom metadata field value. + # + # @return [Imagekit::Models::CustomMetadataField::Schema] + required :schema, -> { Imagekit::CustomMetadataField::Schema } + + # @!method initialize(id:, label:, name:, schema:) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::CustomMetadataField} for more details. + # + # Object containing details of a custom metadata field. + # + # @param id [String] Unique identifier for the custom metadata field. Use this to update the field. + # + # @param label [String] Human readable name of the custom metadata field. This name is displayed as form + # + # @param name [String] API name of the custom metadata field. This becomes the key while setting `custo + # + # @param schema [Imagekit::Models::CustomMetadataField::Schema] An object that describes the rules for the custom metadata field value. + + # @see Imagekit::Models::CustomMetadataField#schema + class Schema < Imagekit::Internal::Type::BaseModel + # @!attribute type + # Type of the custom metadata field. + # + # @return [Symbol, Imagekit::Models::CustomMetadataField::Schema::Type] + required :type, enum: -> { Imagekit::CustomMetadataField::Schema::Type } + + # @!attribute default_value + # The default value for this custom metadata field. Date type of default value + # depends on the field type. + # + # @return [String, Float, Boolean, Array, nil] + optional :default_value, + union: -> { Imagekit::CustomMetadataField::Schema::DefaultValue }, + api_name: :defaultValue + + # @!attribute is_value_required + # Specifies if the this custom metadata field is required or not. + # + # @return [Boolean, nil] + optional :is_value_required, Imagekit::Internal::Type::Boolean, api_name: :isValueRequired + + # @!attribute max_length + # Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. + # + # @return [Float, nil] + optional :max_length, Float, api_name: :maxLength + + # @!attribute max_value + # Maximum value of the field. Only set if field type is `Date` or `Number`. For + # `Date` type field, the value will be in ISO8601 string format. For `Number` type + # field, it will be a numeric value. + # + # @return [String, Float, nil] + optional :max_value, + union: -> { + Imagekit::CustomMetadataField::Schema::MaxValue + }, + api_name: :maxValue + + # @!attribute min_length + # Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. + # + # @return [Float, nil] + optional :min_length, Float, api_name: :minLength + + # @!attribute min_value + # Minimum value of the field. Only set if field type is `Date` or `Number`. For + # `Date` type field, the value will be in ISO8601 string format. For `Number` type + # field, it will be a numeric value. + # + # @return [String, Float, nil] + optional :min_value, + union: -> { + Imagekit::CustomMetadataField::Schema::MinValue + }, + api_name: :minValue + + # @!attribute select_options + # An array of allowed values when field type is `SingleSelect` or `MultiSelect`. + # + # @return [Array, nil] + optional :select_options, + -> { + Imagekit::Internal::Type::ArrayOf[union: Imagekit::CustomMetadataField::Schema::SelectOption] + }, + api_name: :selectOptions + + # @!method initialize(type:, default_value: nil, is_value_required: nil, max_length: nil, max_value: nil, min_length: nil, min_value: nil, select_options: nil) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::CustomMetadataField::Schema} for more details. + # + # An object that describes the rules for the custom metadata field value. + # + # @param type [Symbol, Imagekit::Models::CustomMetadataField::Schema::Type] Type of the custom metadata field. + # + # @param default_value [String, Float, Boolean, Array] The default value for this custom metadata field. Date type of default value dep + # + # @param is_value_required [Boolean] Specifies if the this custom metadata field is required or not. + # + # @param max_length [Float] Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. + # + # @param max_value [String, Float] Maximum value of the field. Only set if field type is `Date` or `Number`. For `D + # + # @param min_length [Float] Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. + # + # @param min_value [String, Float] Minimum value of the field. Only set if field type is `Date` or `Number`. For `D + # + # @param select_options [Array] An array of allowed values when field type is `SingleSelect` or `MultiSelect`. + + # Type of the custom metadata field. + # + # @see Imagekit::Models::CustomMetadataField::Schema#type + module Type + extend Imagekit::Internal::Type::Enum + + TEXT = :Text + TEXTAREA = :Textarea + NUMBER = :Number + DATE = :Date + BOOLEAN = :Boolean + SINGLE_SELECT = :SingleSelect + MULTI_SELECT = :MultiSelect + + # @!method self.values + # @return [Array] + end + + # The default value for this custom metadata field. Date type of default value + # depends on the field type. + # + # @see Imagekit::Models::CustomMetadataField::Schema#default_value + module DefaultValue + extend Imagekit::Internal::Type::Union + + variant String + + variant Float + + variant Imagekit::Internal::Type::Boolean + + # Default value should be of type array when custom metadata field type is set to `MultiSelect`. + variant -> { Imagekit::Models::CustomMetadataField::Schema::DefaultValue::MixedArray } + + module Mixed + extend Imagekit::Internal::Type::Union + + variant String + + variant Float + + variant Imagekit::Internal::Type::Boolean + + # @!method self.variants + # @return [Array(String, Float, Boolean)] + end + + # @!method self.variants + # @return [Array(String, Float, Boolean, Array)] + + # @type [Imagekit::Internal::Type::Converter] + MixedArray = + Imagekit::Internal::Type::ArrayOf[union: -> { + Imagekit::CustomMetadataField::Schema::DefaultValue::Mixed + }] + end + + # Maximum value of the field. Only set if field type is `Date` or `Number`. For + # `Date` type field, the value will be in ISO8601 string format. For `Number` type + # field, it will be a numeric value. + # + # @see Imagekit::Models::CustomMetadataField::Schema#max_value + module MaxValue + extend Imagekit::Internal::Type::Union + + variant String + + variant Float + + # @!method self.variants + # @return [Array(String, Float)] + end + + # Minimum value of the field. Only set if field type is `Date` or `Number`. For + # `Date` type field, the value will be in ISO8601 string format. For `Number` type + # field, it will be a numeric value. + # + # @see Imagekit::Models::CustomMetadataField::Schema#min_value + module MinValue + extend Imagekit::Internal::Type::Union + + variant String + + variant Float + + # @!method self.variants + # @return [Array(String, Float)] + end + + module SelectOption + extend Imagekit::Internal::Type::Union + + variant String + + variant Float + + variant Imagekit::Internal::Type::Boolean + + # @!method self.variants + # @return [Array(String, Float, Boolean)] + end + end + end + end +end diff --git a/lib/imagekit/models/custom_metadata_field_create_params.rb b/lib/imagekit/models/custom_metadata_field_create_params.rb new file mode 100644 index 00000000..58a2f328 --- /dev/null +++ b/lib/imagekit/models/custom_metadata_field_create_params.rb @@ -0,0 +1,238 @@ +# frozen_string_literal: true + +module Imagekit + module Models + # @see Imagekit::Resources::CustomMetadataFields#create + class CustomMetadataFieldCreateParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + # @!attribute label + # Human readable name of the custom metadata field. This should be unique across + # all non deleted custom metadata fields. This name is displayed as form field + # label to the users while setting field value on an asset in the media library + # UI. + # + # @return [String] + required :label, String + + # @!attribute name + # API name of the custom metadata field. This should be unique across all + # (including deleted) custom metadata fields. + # + # @return [String] + required :name, String + + # @!attribute schema + # + # @return [Imagekit::Models::CustomMetadataFieldCreateParams::Schema] + required :schema, -> { Imagekit::CustomMetadataFieldCreateParams::Schema } + + # @!method initialize(label:, name:, schema:, request_options: {}) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::CustomMetadataFieldCreateParams} for more details. + # + # @param label [String] Human readable name of the custom metadata field. This should be unique across a + # + # @param name [String] API name of the custom metadata field. This should be unique across all (includi + # + # @param schema [Imagekit::Models::CustomMetadataFieldCreateParams::Schema] + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}] + + class Schema < Imagekit::Internal::Type::BaseModel + # @!attribute type + # Type of the custom metadata field. + # + # @return [Symbol, Imagekit::Models::CustomMetadataFieldCreateParams::Schema::Type] + required :type, enum: -> { Imagekit::CustomMetadataFieldCreateParams::Schema::Type } + + # @!attribute default_value + # The default value for this custom metadata field. This property is only required + # if `isValueRequired` property is set to `true`. The value should match the + # `type` of custom metadata field. + # + # @return [String, Float, Boolean, Array, nil] + optional :default_value, + union: -> { Imagekit::CustomMetadataFieldCreateParams::Schema::DefaultValue }, + api_name: :defaultValue + + # @!attribute is_value_required + # Sets this custom metadata field as required. Setting custom metadata fields on + # an asset will throw error if the value for all required fields are not present + # in upload or update asset API request body. + # + # @return [Boolean, nil] + optional :is_value_required, Imagekit::Internal::Type::Boolean, api_name: :isValueRequired + + # @!attribute max_length + # Maximum length of string. Only set this property if `type` is set to `Text` or + # `Textarea`. + # + # @return [Float, nil] + optional :max_length, Float, api_name: :maxLength + + # @!attribute max_value + # Maximum value of the field. Only set this property if field type is `Date` or + # `Number`. For `Date` type field, set the minimum date in ISO8601 string format. + # For `Number` type field, set the minimum numeric value. + # + # @return [String, Float, nil] + optional :max_value, + union: -> { Imagekit::CustomMetadataFieldCreateParams::Schema::MaxValue }, + api_name: :maxValue + + # @!attribute min_length + # Minimum length of string. Only set this property if `type` is set to `Text` or + # `Textarea`. + # + # @return [Float, nil] + optional :min_length, Float, api_name: :minLength + + # @!attribute min_value + # Minimum value of the field. Only set this property if field type is `Date` or + # `Number`. For `Date` type field, set the minimum date in ISO8601 string format. + # For `Number` type field, set the minimum numeric value. + # + # @return [String, Float, nil] + optional :min_value, + union: -> { Imagekit::CustomMetadataFieldCreateParams::Schema::MinValue }, + api_name: :minValue + + # @!attribute select_options + # An array of allowed values. This property is only required if `type` property is + # set to `SingleSelect` or `MultiSelect`. + # + # @return [Array, nil] + optional :select_options, + -> { + Imagekit::Internal::Type::ArrayOf[union: Imagekit::CustomMetadataFieldCreateParams::Schema::SelectOption] + }, + api_name: :selectOptions + + # @!method initialize(type:, default_value: nil, is_value_required: nil, max_length: nil, max_value: nil, min_length: nil, min_value: nil, select_options: nil) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::CustomMetadataFieldCreateParams::Schema} for more details. + # + # @param type [Symbol, Imagekit::Models::CustomMetadataFieldCreateParams::Schema::Type] Type of the custom metadata field. + # + # @param default_value [String, Float, Boolean, Array] The default value for this custom metadata field. This property is only required + # + # @param is_value_required [Boolean] Sets this custom metadata field as required. Setting custom metadata fields on a + # + # @param max_length [Float] Maximum length of string. Only set this property if `type` is set to `Text` or ` + # + # @param max_value [String, Float] Maximum value of the field. Only set this property if field type is `Date` or `N + # + # @param min_length [Float] Minimum length of string. Only set this property if `type` is set to `Text` or ` + # + # @param min_value [String, Float] Minimum value of the field. Only set this property if field type is `Date` or `N + # + # @param select_options [Array] An array of allowed values. This property is only required if `type` property is + + # Type of the custom metadata field. + # + # @see Imagekit::Models::CustomMetadataFieldCreateParams::Schema#type + module Type + extend Imagekit::Internal::Type::Enum + + TEXT = :Text + TEXTAREA = :Textarea + NUMBER = :Number + DATE = :Date + BOOLEAN = :Boolean + SINGLE_SELECT = :SingleSelect + MULTI_SELECT = :MultiSelect + + # @!method self.values + # @return [Array] + end + + # The default value for this custom metadata field. This property is only required + # if `isValueRequired` property is set to `true`. The value should match the + # `type` of custom metadata field. + # + # @see Imagekit::Models::CustomMetadataFieldCreateParams::Schema#default_value + module DefaultValue + extend Imagekit::Internal::Type::Union + + variant String + + variant Float + + variant Imagekit::Internal::Type::Boolean + + # Default value should be of type array when custom metadata field type is set to `MultiSelect`. + variant -> { Imagekit::Models::CustomMetadataFieldCreateParams::Schema::DefaultValue::MixedArray } + + module Mixed + extend Imagekit::Internal::Type::Union + + variant String + + variant Float + + variant Imagekit::Internal::Type::Boolean + + # @!method self.variants + # @return [Array(String, Float, Boolean)] + end + + # @!method self.variants + # @return [Array(String, Float, Boolean, Array)] + + # @type [Imagekit::Internal::Type::Converter] + MixedArray = + Imagekit::Internal::Type::ArrayOf[union: -> { + Imagekit::CustomMetadataFieldCreateParams::Schema::DefaultValue::Mixed + }] + end + + # Maximum value of the field. Only set this property if field type is `Date` or + # `Number`. For `Date` type field, set the minimum date in ISO8601 string format. + # For `Number` type field, set the minimum numeric value. + # + # @see Imagekit::Models::CustomMetadataFieldCreateParams::Schema#max_value + module MaxValue + extend Imagekit::Internal::Type::Union + + variant String + + variant Float + + # @!method self.variants + # @return [Array(String, Float)] + end + + # Minimum value of the field. Only set this property if field type is `Date` or + # `Number`. For `Date` type field, set the minimum date in ISO8601 string format. + # For `Number` type field, set the minimum numeric value. + # + # @see Imagekit::Models::CustomMetadataFieldCreateParams::Schema#min_value + module MinValue + extend Imagekit::Internal::Type::Union + + variant String + + variant Float + + # @!method self.variants + # @return [Array(String, Float)] + end + + module SelectOption + extend Imagekit::Internal::Type::Union + + variant String + + variant Float + + variant Imagekit::Internal::Type::Boolean + + # @!method self.variants + # @return [Array(String, Float, Boolean)] + end + end + end + end +end diff --git a/lib/imagekit/models/custom_metadata_field_delete_params.rb b/lib/imagekit/models/custom_metadata_field_delete_params.rb new file mode 100644 index 00000000..21af3d9c --- /dev/null +++ b/lib/imagekit/models/custom_metadata_field_delete_params.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module Imagekit + module Models + # @see Imagekit::Resources::CustomMetadataFields#delete + class CustomMetadataFieldDeleteParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + # @!method initialize(request_options: {}) + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}] + end + end +end diff --git a/lib/imagekit/models/custom_metadata_field_delete_response.rb b/lib/imagekit/models/custom_metadata_field_delete_response.rb new file mode 100644 index 00000000..ec5f93b1 --- /dev/null +++ b/lib/imagekit/models/custom_metadata_field_delete_response.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Imagekit + module Models + # @see Imagekit::Resources::CustomMetadataFields#delete + class CustomMetadataFieldDeleteResponse < Imagekit::Internal::Type::BaseModel + # @!method initialize + end + end +end diff --git a/lib/imagekit/models/custom_metadata_field_list_params.rb b/lib/imagekit/models/custom_metadata_field_list_params.rb new file mode 100644 index 00000000..f2c94cec --- /dev/null +++ b/lib/imagekit/models/custom_metadata_field_list_params.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +module Imagekit + module Models + # @see Imagekit::Resources::CustomMetadataFields#list + class CustomMetadataFieldListParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + # @!attribute include_deleted + # Set it to `true` to include deleted field objects in the API response. + # + # @return [Boolean, nil] + optional :include_deleted, Imagekit::Internal::Type::Boolean + + # @!method initialize(include_deleted: nil, request_options: {}) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::CustomMetadataFieldListParams} for more details. + # + # @param include_deleted [Boolean] Set it to `true` to include deleted field objects in the API response. + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}] + end + end +end diff --git a/lib/imagekit/models/custom_metadata_field_list_response.rb b/lib/imagekit/models/custom_metadata_field_list_response.rb new file mode 100644 index 00000000..78a32292 --- /dev/null +++ b/lib/imagekit/models/custom_metadata_field_list_response.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +module Imagekit + module Models + # @type [Imagekit::Internal::Type::Converter] + CustomMetadataFieldListResponse = Imagekit::Internal::Type::ArrayOf[-> { Imagekit::CustomMetadataField }] + end +end diff --git a/lib/imagekit/models/custom_metadata_field_update_params.rb b/lib/imagekit/models/custom_metadata_field_update_params.rb new file mode 100644 index 00000000..f991da44 --- /dev/null +++ b/lib/imagekit/models/custom_metadata_field_update_params.rb @@ -0,0 +1,212 @@ +# frozen_string_literal: true + +module Imagekit + module Models + # @see Imagekit::Resources::CustomMetadataFields#update + class CustomMetadataFieldUpdateParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + # @!attribute label + # Human readable name of the custom metadata field. This should be unique across + # all non deleted custom metadata fields. This name is displayed as form field + # label to the users while setting field value on an asset in the media library + # UI. This parameter is required if `schema` is not provided. + # + # @return [String, nil] + optional :label, String + + # @!attribute schema + # An object that describes the rules for the custom metadata key. This parameter + # is required if `label` is not provided. Note: `type` cannot be updated and will + # be ignored if sent with the `schema`. The schema will be validated as per the + # existing `type`. + # + # @return [Imagekit::Models::CustomMetadataFieldUpdateParams::Schema, nil] + optional :schema, -> { Imagekit::CustomMetadataFieldUpdateParams::Schema } + + # @!method initialize(label: nil, schema: nil, request_options: {}) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::CustomMetadataFieldUpdateParams} for more details. + # + # @param label [String] Human readable name of the custom metadata field. This should be unique across a + # + # @param schema [Imagekit::Models::CustomMetadataFieldUpdateParams::Schema] An object that describes the rules for the custom metadata key. This parameter i + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}] + + class Schema < Imagekit::Internal::Type::BaseModel + # @!attribute default_value + # The default value for this custom metadata field. This property is only required + # if `isValueRequired` property is set to `true`. The value should match the + # `type` of custom metadata field. + # + # @return [String, Float, Boolean, Array, nil] + optional :default_value, + union: -> { Imagekit::CustomMetadataFieldUpdateParams::Schema::DefaultValue }, + api_name: :defaultValue + + # @!attribute is_value_required + # Sets this custom metadata field as required. Setting custom metadata fields on + # an asset will throw error if the value for all required fields are not present + # in upload or update asset API request body. + # + # @return [Boolean, nil] + optional :is_value_required, Imagekit::Internal::Type::Boolean, api_name: :isValueRequired + + # @!attribute max_length + # Maximum length of string. Only set this property if `type` is set to `Text` or + # `Textarea`. + # + # @return [Float, nil] + optional :max_length, Float, api_name: :maxLength + + # @!attribute max_value + # Maximum value of the field. Only set this property if field type is `Date` or + # `Number`. For `Date` type field, set the minimum date in ISO8601 string format. + # For `Number` type field, set the minimum numeric value. + # + # @return [String, Float, nil] + optional :max_value, + union: -> { Imagekit::CustomMetadataFieldUpdateParams::Schema::MaxValue }, + api_name: :maxValue + + # @!attribute min_length + # Minimum length of string. Only set this property if `type` is set to `Text` or + # `Textarea`. + # + # @return [Float, nil] + optional :min_length, Float, api_name: :minLength + + # @!attribute min_value + # Minimum value of the field. Only set this property if field type is `Date` or + # `Number`. For `Date` type field, set the minimum date in ISO8601 string format. + # For `Number` type field, set the minimum numeric value. + # + # @return [String, Float, nil] + optional :min_value, + union: -> { Imagekit::CustomMetadataFieldUpdateParams::Schema::MinValue }, + api_name: :minValue + + # @!attribute select_options + # An array of allowed values. This property is only required if `type` property is + # set to `SingleSelect` or `MultiSelect`. + # + # @return [Array, nil] + optional :select_options, + -> { + Imagekit::Internal::Type::ArrayOf[union: Imagekit::CustomMetadataFieldUpdateParams::Schema::SelectOption] + }, + api_name: :selectOptions + + # @!method initialize(default_value: nil, is_value_required: nil, max_length: nil, max_value: nil, min_length: nil, min_value: nil, select_options: nil) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::CustomMetadataFieldUpdateParams::Schema} for more details. + # + # An object that describes the rules for the custom metadata key. This parameter + # is required if `label` is not provided. Note: `type` cannot be updated and will + # be ignored if sent with the `schema`. The schema will be validated as per the + # existing `type`. + # + # @param default_value [String, Float, Boolean, Array] The default value for this custom metadata field. This property is only required + # + # @param is_value_required [Boolean] Sets this custom metadata field as required. Setting custom metadata fields on a + # + # @param max_length [Float] Maximum length of string. Only set this property if `type` is set to `Text` or ` + # + # @param max_value [String, Float] Maximum value of the field. Only set this property if field type is `Date` or `N + # + # @param min_length [Float] Minimum length of string. Only set this property if `type` is set to `Text` or ` + # + # @param min_value [String, Float] Minimum value of the field. Only set this property if field type is `Date` or `N + # + # @param select_options [Array] An array of allowed values. This property is only required if `type` property is + + # The default value for this custom metadata field. This property is only required + # if `isValueRequired` property is set to `true`. The value should match the + # `type` of custom metadata field. + # + # @see Imagekit::Models::CustomMetadataFieldUpdateParams::Schema#default_value + module DefaultValue + extend Imagekit::Internal::Type::Union + + variant String + + variant Float + + variant Imagekit::Internal::Type::Boolean + + # Default value should be of type array when custom metadata field type is set to `MultiSelect`. + variant -> { Imagekit::Models::CustomMetadataFieldUpdateParams::Schema::DefaultValue::MixedArray } + + module Mixed + extend Imagekit::Internal::Type::Union + + variant String + + variant Float + + variant Imagekit::Internal::Type::Boolean + + # @!method self.variants + # @return [Array(String, Float, Boolean)] + end + + # @!method self.variants + # @return [Array(String, Float, Boolean, Array)] + + # @type [Imagekit::Internal::Type::Converter] + MixedArray = + Imagekit::Internal::Type::ArrayOf[union: -> { + Imagekit::CustomMetadataFieldUpdateParams::Schema::DefaultValue::Mixed + }] + end + + # Maximum value of the field. Only set this property if field type is `Date` or + # `Number`. For `Date` type field, set the minimum date in ISO8601 string format. + # For `Number` type field, set the minimum numeric value. + # + # @see Imagekit::Models::CustomMetadataFieldUpdateParams::Schema#max_value + module MaxValue + extend Imagekit::Internal::Type::Union + + variant String + + variant Float + + # @!method self.variants + # @return [Array(String, Float)] + end + + # Minimum value of the field. Only set this property if field type is `Date` or + # `Number`. For `Date` type field, set the minimum date in ISO8601 string format. + # For `Number` type field, set the minimum numeric value. + # + # @see Imagekit::Models::CustomMetadataFieldUpdateParams::Schema#min_value + module MinValue + extend Imagekit::Internal::Type::Union + + variant String + + variant Float + + # @!method self.variants + # @return [Array(String, Float)] + end + + module SelectOption + extend Imagekit::Internal::Type::Union + + variant String + + variant Float + + variant Imagekit::Internal::Type::Boolean + + # @!method self.variants + # @return [Array(String, Float, Boolean)] + end + end + end + end +end diff --git a/lib/imagekit/models/extensions.rb b/lib/imagekit/models/extensions.rb new file mode 100644 index 00000000..d0b187c3 --- /dev/null +++ b/lib/imagekit/models/extensions.rb @@ -0,0 +1,136 @@ +# frozen_string_literal: true + +module Imagekit + module Models + module ExtensionItem + extend Imagekit::Internal::Type::Union + + discriminator :name + + variant :"remove-bg", -> { Imagekit::ExtensionItem::RemoveBg } + + variant :"ai-auto-description", -> { Imagekit::ExtensionItem::AIAutoDescription } + + variant -> { Imagekit::ExtensionItem::AutoTaggingExtension } + + class RemoveBg < Imagekit::Internal::Type::BaseModel + # @!attribute name + # Specifies the background removal extension. + # + # @return [Symbol, :"remove-bg"] + required :name, const: :"remove-bg" + + # @!attribute options + # + # @return [Imagekit::Models::ExtensionItem::RemoveBg::Options, nil] + optional :options, -> { Imagekit::ExtensionItem::RemoveBg::Options } + + # @!method initialize(options: nil, name: :"remove-bg") + # @param options [Imagekit::Models::ExtensionItem::RemoveBg::Options] + # + # @param name [Symbol, :"remove-bg"] Specifies the background removal extension. + + # @see Imagekit::Models::ExtensionItem::RemoveBg#options + class Options < Imagekit::Internal::Type::BaseModel + # @!attribute add_shadow + # Whether to add an artificial shadow to the result. Default is false. Note: + # Adding shadows is currently only supported for car photos. + # + # @return [Boolean, nil] + optional :add_shadow, Imagekit::Internal::Type::Boolean + + # @!attribute bg_color + # Specifies a solid color background using hex code (e.g., "81d4fa", "fff") or + # color name (e.g., "green"). If this parameter is set, `bg_image_url` must be + # empty. + # + # @return [String, nil] + optional :bg_color, String + + # @!attribute bg_image_url + # Sets a background image from a URL. If this parameter is set, `bg_color` must be + # empty. + # + # @return [String, nil] + optional :bg_image_url, String + + # @!attribute semitransparency + # Allows semi-transparent regions in the result. Default is true. Note: + # Semitransparency is currently only supported for car windows. + # + # @return [Boolean, nil] + optional :semitransparency, Imagekit::Internal::Type::Boolean + + # @!method initialize(add_shadow: nil, bg_color: nil, bg_image_url: nil, semitransparency: nil) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::ExtensionItem::RemoveBg::Options} for more details. + # + # @param add_shadow [Boolean] Whether to add an artificial shadow to the result. Default is false. Note: Addin + # + # @param bg_color [String] Specifies a solid color background using hex code (e.g., "81d4fa", "fff") or col + # + # @param bg_image_url [String] Sets a background image from a URL. If this parameter is set, `bg_color` must be + # + # @param semitransparency [Boolean] Allows semi-transparent regions in the result. Default is true. Note: Semitransp + end + end + + class AutoTaggingExtension < Imagekit::Internal::Type::BaseModel + # @!attribute max_tags + # Maximum number of tags to attach to the asset. + # + # @return [Integer] + required :max_tags, Integer, api_name: :maxTags + + # @!attribute min_confidence + # Minimum confidence level for tags to be considered valid. + # + # @return [Integer] + required :min_confidence, Integer, api_name: :minConfidence + + # @!attribute name + # Specifies the auto-tagging extension used. + # + # @return [Symbol, Imagekit::Models::ExtensionItem::AutoTaggingExtension::Name] + required :name, enum: -> { Imagekit::ExtensionItem::AutoTaggingExtension::Name } + + # @!method initialize(max_tags:, min_confidence:, name:) + # @param max_tags [Integer] Maximum number of tags to attach to the asset. + # + # @param min_confidence [Integer] Minimum confidence level for tags to be considered valid. + # + # @param name [Symbol, Imagekit::Models::ExtensionItem::AutoTaggingExtension::Name] Specifies the auto-tagging extension used. + + # Specifies the auto-tagging extension used. + # + # @see Imagekit::Models::ExtensionItem::AutoTaggingExtension#name + module Name + extend Imagekit::Internal::Type::Enum + + GOOGLE_AUTO_TAGGING = :"google-auto-tagging" + AWS_AUTO_TAGGING = :"aws-auto-tagging" + + # @!method self.values + # @return [Array] + end + end + + class AIAutoDescription < Imagekit::Internal::Type::BaseModel + # @!attribute name + # Specifies the auto description extension. + # + # @return [Symbol, :"ai-auto-description"] + required :name, const: :"ai-auto-description" + + # @!method initialize(name: :"ai-auto-description") + # @param name [Symbol, :"ai-auto-description"] Specifies the auto description extension. + end + + # @!method self.variants + # @return [Array(Imagekit::Models::ExtensionItem::RemoveBg, Imagekit::Models::ExtensionItem::AIAutoDescription, Imagekit::Models::ExtensionItem::AutoTaggingExtension)] + end + + # @type [Imagekit::Internal::Type::Converter] + Extensions = Imagekit::Internal::Type::ArrayOf[union: -> { Imagekit::ExtensionItem }] + end +end diff --git a/lib/imagekit/models/file.rb b/lib/imagekit/models/file.rb new file mode 100644 index 00000000..d1c2aacb --- /dev/null +++ b/lib/imagekit/models/file.rb @@ -0,0 +1,269 @@ +# frozen_string_literal: true + +module Imagekit + module Models + # @see Imagekit::Resources::Files#get + class File < Imagekit::Internal::Type::BaseModel + # @!attribute ai_tags + # An array of tags assigned to the file by auto tagging. + # + # @return [Array, nil] + optional :ai_tags, + -> { Imagekit::Internal::Type::ArrayOf[Imagekit::File::AITag] }, + api_name: :AITags, + nil?: true + + # @!attribute created_at + # Date and time when the file was uploaded. The date and time is in ISO8601 + # format. + # + # @return [Time, nil] + optional :created_at, Time, api_name: :createdAt + + # @!attribute custom_coordinates + # An string with custom coordinates of the file. + # + # @return [String, nil] + optional :custom_coordinates, String, api_name: :customCoordinates, nil?: true + + # @!attribute custom_metadata + # An object with custom metadata for the file. + # + # @return [Hash{Symbol=>Object}, nil] + optional :custom_metadata, + Imagekit::Internal::Type::HashOf[Imagekit::Internal::Type::Unknown], + api_name: :customMetadata + + # @!attribute description + # Optional text to describe the contents of the file. Can be set by the user or + # the ai-auto-description extension. + # + # @return [String, nil] + optional :description, String + + # @!attribute file_id + # Unique identifier of the asset. + # + # @return [String, nil] + optional :file_id, String, api_name: :fileId + + # @!attribute file_path + # Path of the file. This is the path you would use in the URL to access the file. + # For example, if the file is at the root of the media library, the path will be + # `/file.jpg`. If the file is inside a folder named `images`, the path will be + # `/images/file.jpg`. + # + # @return [String, nil] + optional :file_path, String, api_name: :filePath + + # @!attribute file_type + # Type of the file. Possible values are `image`, `non-image`. + # + # @return [String, nil] + optional :file_type, String, api_name: :fileType + + # @!attribute has_alpha + # Specifies if the image has an alpha channel. + # + # @return [Boolean, nil] + optional :has_alpha, Imagekit::Internal::Type::Boolean, api_name: :hasAlpha + + # @!attribute height + # Height of the file. + # + # @return [Float, nil] + optional :height, Float + + # @!attribute is_private_file + # Specifies if the file is private or not. + # + # @return [Boolean, nil] + optional :is_private_file, Imagekit::Internal::Type::Boolean, api_name: :isPrivateFile + + # @!attribute is_published + # Specifies if the file is published or not. + # + # @return [Boolean, nil] + optional :is_published, Imagekit::Internal::Type::Boolean, api_name: :isPublished + + # @!attribute mime + # MIME type of the file. + # + # @return [String, nil] + optional :mime, String + + # @!attribute name + # Name of the asset. + # + # @return [String, nil] + optional :name, String + + # @!attribute size + # Size of the file in bytes. + # + # @return [Float, nil] + optional :size, Float + + # @!attribute tags + # An array of tags assigned to the file. Tags are used to search files in the + # media library. + # + # @return [Array, nil] + optional :tags, Imagekit::Internal::Type::ArrayOf[String], nil?: true + + # @!attribute thumbnail + # URL of the thumbnail image. This URL is used to access the thumbnail image of + # the file in the media library. + # + # @return [String, nil] + optional :thumbnail, String + + # @!attribute type + # Type of the asset. + # + # @return [Symbol, Imagekit::Models::File::Type, nil] + optional :type, enum: -> { Imagekit::File::Type } + + # @!attribute updated_at + # Date and time when the file was last updated. The date and time is in ISO8601 + # format. + # + # @return [Time, nil] + optional :updated_at, Time, api_name: :updatedAt + + # @!attribute url + # URL of the file. + # + # @return [String, nil] + optional :url, String + + # @!attribute version_info + # An object with details of the file version. + # + # @return [Imagekit::Models::File::VersionInfo, nil] + optional :version_info, -> { Imagekit::File::VersionInfo }, api_name: :versionInfo + + # @!attribute width + # Width of the file. + # + # @return [Float, nil] + optional :width, Float + + # @!method initialize(ai_tags: nil, created_at: nil, custom_coordinates: nil, custom_metadata: nil, description: nil, file_id: nil, file_path: nil, file_type: nil, has_alpha: nil, height: nil, is_private_file: nil, is_published: nil, mime: nil, name: nil, size: nil, tags: nil, thumbnail: nil, type: nil, updated_at: nil, url: nil, version_info: nil, width: nil) + # Some parameter documentations has been truncated, see {Imagekit::Models::File} + # for more details. + # + # Object containing details of a file or file version. + # + # @param ai_tags [Array, nil] An array of tags assigned to the file by auto tagging. + # + # @param created_at [Time] Date and time when the file was uploaded. The date and time is in ISO8601 format + # + # @param custom_coordinates [String, nil] An string with custom coordinates of the file. + # + # @param custom_metadata [Hash{Symbol=>Object}] An object with custom metadata for the file. + # + # @param description [String] Optional text to describe the contents of the file. Can be set by the user or th + # + # @param file_id [String] Unique identifier of the asset. + # + # @param file_path [String] Path of the file. This is the path you would use in the URL to access the file. + # + # @param file_type [String] Type of the file. Possible values are `image`, `non-image`. + # + # @param has_alpha [Boolean] Specifies if the image has an alpha channel. + # + # @param height [Float] Height of the file. + # + # @param is_private_file [Boolean] Specifies if the file is private or not. + # + # @param is_published [Boolean] Specifies if the file is published or not. + # + # @param mime [String] MIME type of the file. + # + # @param name [String] Name of the asset. + # + # @param size [Float] Size of the file in bytes. + # + # @param tags [Array, nil] An array of tags assigned to the file. Tags are used to search files in the medi + # + # @param thumbnail [String] URL of the thumbnail image. This URL is used to access the thumbnail image of th + # + # @param type [Symbol, Imagekit::Models::File::Type] Type of the asset. + # + # @param updated_at [Time] Date and time when the file was last updated. The date and time is in ISO8601 fo + # + # @param url [String] URL of the file. + # + # @param version_info [Imagekit::Models::File::VersionInfo] An object with details of the file version. + # + # @param width [Float] Width of the file. + + class AITag < Imagekit::Internal::Type::BaseModel + # @!attribute confidence + # Confidence score of the tag. + # + # @return [Float, nil] + optional :confidence, Float + + # @!attribute name + # Name of the tag. + # + # @return [String, nil] + optional :name, String + + # @!attribute source + # Source of the tag. Possible values are `google-auto-tagging` and + # `aws-auto-tagging`. + # + # @return [String, nil] + optional :source, String + + # @!method initialize(confidence: nil, name: nil, source: nil) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::File::AITag} for more details. + # + # @param confidence [Float] Confidence score of the tag. + # + # @param name [String] Name of the tag. + # + # @param source [String] Source of the tag. Possible values are `google-auto-tagging` and `aws-auto-taggi + end + + # Type of the asset. + # + # @see Imagekit::Models::File#type + module Type + extend Imagekit::Internal::Type::Enum + + FILE = :file + FILE_VERSION = :"file-version" + + # @!method self.values + # @return [Array] + end + + # @see Imagekit::Models::File#version_info + class VersionInfo < Imagekit::Internal::Type::BaseModel + # @!attribute id + # Unique identifier of the file version. + # + # @return [String, nil] + optional :id, String + + # @!attribute name + # Name of the file version. + # + # @return [String, nil] + optional :name, String + + # @!method initialize(id: nil, name: nil) + # An object with details of the file version. + # + # @param id [String] Unique identifier of the file version. + # + # @param name [String] Name of the file version. + end + end + end +end diff --git a/lib/imagekit/models/file_copy_params.rb b/lib/imagekit/models/file_copy_params.rb new file mode 100644 index 00000000..3a481b8d --- /dev/null +++ b/lib/imagekit/models/file_copy_params.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +module Imagekit + module Models + # @see Imagekit::Resources::Files#copy + class FileCopyParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + # @!attribute destination_path + # Full path to the folder you want to copy the above file into. + # + # @return [String] + required :destination_path, String, api_name: :destinationPath + + # @!attribute source_file_path + # The full path of the file you want to copy. + # + # @return [String] + required :source_file_path, String, api_name: :sourceFilePath + + # @!attribute include_file_versions + # Option to copy all versions of a file. By default, only the current version of + # the file is copied. When set to true, all versions of the file will be copied. + # Default value - `false`. + # + # @return [Boolean, nil] + optional :include_file_versions, Imagekit::Internal::Type::Boolean, api_name: :includeFileVersions + + # @!method initialize(destination_path:, source_file_path:, include_file_versions: nil, request_options: {}) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::FileCopyParams} for more details. + # + # @param destination_path [String] Full path to the folder you want to copy the above file into. + # + # @param source_file_path [String] The full path of the file you want to copy. + # + # @param include_file_versions [Boolean] Option to copy all versions of a file. By default, only the current version of t + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}] + end + end +end diff --git a/lib/imagekit/models/file_copy_response.rb b/lib/imagekit/models/file_copy_response.rb new file mode 100644 index 00000000..b783f78a --- /dev/null +++ b/lib/imagekit/models/file_copy_response.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Imagekit + module Models + # @see Imagekit::Resources::Files#copy + class FileCopyResponse < Imagekit::Internal::Type::BaseModel + # @!method initialize + end + end +end diff --git a/lib/imagekit/models/file_delete_params.rb b/lib/imagekit/models/file_delete_params.rb new file mode 100644 index 00000000..7de513c4 --- /dev/null +++ b/lib/imagekit/models/file_delete_params.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module Imagekit + module Models + # @see Imagekit::Resources::Files#delete + class FileDeleteParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + # @!method initialize(request_options: {}) + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}] + end + end +end diff --git a/lib/imagekit/models/file_get_params.rb b/lib/imagekit/models/file_get_params.rb new file mode 100644 index 00000000..65525d6b --- /dev/null +++ b/lib/imagekit/models/file_get_params.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module Imagekit + module Models + # @see Imagekit::Resources::Files#get + class FileGetParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + # @!method initialize(request_options: {}) + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}] + end + end +end diff --git a/lib/imagekit/models/file_move_params.rb b/lib/imagekit/models/file_move_params.rb new file mode 100644 index 00000000..7af578f1 --- /dev/null +++ b/lib/imagekit/models/file_move_params.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +module Imagekit + module Models + # @see Imagekit::Resources::Files#move + class FileMoveParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + # @!attribute destination_path + # Full path to the folder you want to move the above file into. + # + # @return [String] + required :destination_path, String, api_name: :destinationPath + + # @!attribute source_file_path + # The full path of the file you want to move. + # + # @return [String] + required :source_file_path, String, api_name: :sourceFilePath + + # @!method initialize(destination_path:, source_file_path:, request_options: {}) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::FileMoveParams} for more details. + # + # @param destination_path [String] Full path to the folder you want to move the above file into. + # + # @param source_file_path [String] The full path of the file you want to move. + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}] + end + end +end diff --git a/lib/imagekit/models/file_move_response.rb b/lib/imagekit/models/file_move_response.rb new file mode 100644 index 00000000..69bb18b1 --- /dev/null +++ b/lib/imagekit/models/file_move_response.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Imagekit + module Models + # @see Imagekit::Resources::Files#move + class FileMoveResponse < Imagekit::Internal::Type::BaseModel + # @!method initialize + end + end +end diff --git a/lib/imagekit/models/file_rename_params.rb b/lib/imagekit/models/file_rename_params.rb new file mode 100644 index 00000000..692440d6 --- /dev/null +++ b/lib/imagekit/models/file_rename_params.rb @@ -0,0 +1,61 @@ +# frozen_string_literal: true + +module Imagekit + module Models + # @see Imagekit::Resources::Files#rename + class FileRenameParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + # @!attribute file_path + # The full path of the file you want to rename. + # + # @return [String] + required :file_path, String, api_name: :filePath + + # @!attribute new_file_name + # The new name of the file. A filename can contain: + # + # Alphanumeric Characters: `a-z`, `A-Z`, `0-9` (including Unicode letters, marks, + # and numerals in other languages). Special Characters: `.`, `_`, and `-`. + # + # Any other character, including space, will be replaced by `_`. + # + # @return [String] + required :new_file_name, String, api_name: :newFileName + + # @!attribute purge_cache + # Option to purge cache for the old file and its versions' URLs. + # + # When set to true, it will internally issue a purge cache request on CDN to + # remove cached content of old file and its versions. This purge request is + # counted against your monthly purge quota. + # + # Note: If the old file were accessible at + # `https://ik.imagekit.io/demo/old-filename.jpg`, a purge cache request would be + # issued against `https://ik.imagekit.io/demo/old-filename.jpg*` (with a wildcard + # at the end). It will remove the file and its versions' URLs and any + # transformations made using query parameters on this file or its versions. + # However, the cache for file transformations made using path parameters will + # persist. You can purge them using the purge API. For more details, refer to the + # purge API documentation. + # + # Default value - `false` + # + # @return [Boolean, nil] + optional :purge_cache, Imagekit::Internal::Type::Boolean, api_name: :purgeCache + + # @!method initialize(file_path:, new_file_name:, purge_cache: nil, request_options: {}) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::FileRenameParams} for more details. + # + # @param file_path [String] The full path of the file you want to rename. + # + # @param new_file_name [String] The new name of the file. A filename can contain: + # + # @param purge_cache [Boolean] Option to purge cache for the old file and its versions' URLs. + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}] + end + end +end diff --git a/lib/imagekit/models/file_rename_response.rb b/lib/imagekit/models/file_rename_response.rb new file mode 100644 index 00000000..96b9be0e --- /dev/null +++ b/lib/imagekit/models/file_rename_response.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +module Imagekit + module Models + # @see Imagekit::Resources::Files#rename + class FileRenameResponse < Imagekit::Internal::Type::BaseModel + # @!attribute purge_request_id + # Unique identifier of the purge request. This can be used to check the status of + # the purge request. + # + # @return [String, nil] + optional :purge_request_id, String, api_name: :purgeRequestId + + # @!method initialize(purge_request_id: nil) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::FileRenameResponse} for more details. + # + # @param purge_request_id [String] Unique identifier of the purge request. This can be used to check the status of + end + end +end diff --git a/lib/imagekit/models/file_update_params.rb b/lib/imagekit/models/file_update_params.rb new file mode 100644 index 00000000..1685dfad --- /dev/null +++ b/lib/imagekit/models/file_update_params.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +module Imagekit + module Models + # @see Imagekit::Resources::Files#update + class FileUpdateParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + # @!attribute update_file_request + # Schema for update file update request. + # + # @return [Imagekit::Models::UpdateFileRequest::UpdateFileDetails, Imagekit::Models::UpdateFileRequest::ChangePublicationStatus] + required :update_file_request, union: -> { Imagekit::UpdateFileRequest } + + # @!method initialize(update_file_request:, request_options: {}) + # @param update_file_request [Imagekit::Models::UpdateFileRequest::UpdateFileDetails, Imagekit::Models::UpdateFileRequest::ChangePublicationStatus] Schema for update file update request. + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}] + end + end +end diff --git a/lib/imagekit/models/file_update_response.rb b/lib/imagekit/models/file_update_response.rb new file mode 100644 index 00000000..916adbcf --- /dev/null +++ b/lib/imagekit/models/file_update_response.rb @@ -0,0 +1,104 @@ +# frozen_string_literal: true + +module Imagekit + module Models + # @see Imagekit::Resources::Files#update + class FileUpdateResponse < Imagekit::Models::File + # @!attribute extension_status + # + # @return [Imagekit::Models::FileUpdateResponse::ExtensionStatus, nil] + optional :extension_status, + -> { Imagekit::Models::FileUpdateResponse::ExtensionStatus }, + api_name: :extensionStatus + + # @!method initialize(extension_status: nil) + # Object containing details of a file or file version. + # + # @param extension_status [Imagekit::Models::FileUpdateResponse::ExtensionStatus] + + class ExtensionStatus < Imagekit::Internal::Type::BaseModel + # @!attribute ai_auto_description + # + # @return [Symbol, Imagekit::Models::FileUpdateResponse::ExtensionStatus::AIAutoDescription, nil] + optional :ai_auto_description, + enum: -> { Imagekit::Models::FileUpdateResponse::ExtensionStatus::AIAutoDescription }, + api_name: :"ai-auto-description" + + # @!attribute aws_auto_tagging + # + # @return [Symbol, Imagekit::Models::FileUpdateResponse::ExtensionStatus::AwsAutoTagging, nil] + optional :aws_auto_tagging, + enum: -> { Imagekit::Models::FileUpdateResponse::ExtensionStatus::AwsAutoTagging }, + api_name: :"aws-auto-tagging" + + # @!attribute google_auto_tagging + # + # @return [Symbol, Imagekit::Models::FileUpdateResponse::ExtensionStatus::GoogleAutoTagging, nil] + optional :google_auto_tagging, + enum: -> { Imagekit::Models::FileUpdateResponse::ExtensionStatus::GoogleAutoTagging }, + api_name: :"google-auto-tagging" + + # @!attribute remove_bg + # + # @return [Symbol, Imagekit::Models::FileUpdateResponse::ExtensionStatus::RemoveBg, nil] + optional :remove_bg, + enum: -> { Imagekit::Models::FileUpdateResponse::ExtensionStatus::RemoveBg }, + api_name: :"remove-bg" + + # @!method initialize(ai_auto_description: nil, aws_auto_tagging: nil, google_auto_tagging: nil, remove_bg: nil) + # @param ai_auto_description [Symbol, Imagekit::Models::FileUpdateResponse::ExtensionStatus::AIAutoDescription] + # @param aws_auto_tagging [Symbol, Imagekit::Models::FileUpdateResponse::ExtensionStatus::AwsAutoTagging] + # @param google_auto_tagging [Symbol, Imagekit::Models::FileUpdateResponse::ExtensionStatus::GoogleAutoTagging] + # @param remove_bg [Symbol, Imagekit::Models::FileUpdateResponse::ExtensionStatus::RemoveBg] + + # @see Imagekit::Models::FileUpdateResponse::ExtensionStatus#ai_auto_description + module AIAutoDescription + extend Imagekit::Internal::Type::Enum + + SUCCESS = :success + PENDING = :pending + FAILED = :failed + + # @!method self.values + # @return [Array] + end + + # @see Imagekit::Models::FileUpdateResponse::ExtensionStatus#aws_auto_tagging + module AwsAutoTagging + extend Imagekit::Internal::Type::Enum + + SUCCESS = :success + PENDING = :pending + FAILED = :failed + + # @!method self.values + # @return [Array] + end + + # @see Imagekit::Models::FileUpdateResponse::ExtensionStatus#google_auto_tagging + module GoogleAutoTagging + extend Imagekit::Internal::Type::Enum + + SUCCESS = :success + PENDING = :pending + FAILED = :failed + + # @!method self.values + # @return [Array] + end + + # @see Imagekit::Models::FileUpdateResponse::ExtensionStatus#remove_bg + module RemoveBg + extend Imagekit::Internal::Type::Enum + + SUCCESS = :success + PENDING = :pending + FAILED = :failed + + # @!method self.values + # @return [Array] + end + end + end + end +end diff --git a/lib/imagekit/models/file_upload_params.rb b/lib/imagekit/models/file_upload_params.rb new file mode 100644 index 00000000..282c8f74 --- /dev/null +++ b/lib/imagekit/models/file_upload_params.rb @@ -0,0 +1,477 @@ +# frozen_string_literal: true + +module Imagekit + module Models + # @see Imagekit::Resources::Files#upload + class FileUploadParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + # @!attribute file + # The API accepts any of the following: + # + # - **Binary data** – send the raw bytes as `multipart/form-data`. + # - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can + # fetch. + # - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + # + # When supplying a URL, the server must receive the response headers within 8 + # seconds; otherwise the request fails with 400 Bad Request. + # + # @return [Pathname, StringIO, IO, String, Imagekit::FilePart] + required :file, Imagekit::Internal::Type::FileInput + + # @!attribute file_name + # The name with which the file has to be uploaded. The file name can contain: + # + # - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. + # - Special Characters: `.`, `-` + # + # Any other character including space will be replaced by `_` + # + # @return [String] + required :file_name, String, api_name: :fileName + + # @!attribute token + # A unique value that the ImageKit.io server will use to recognize and prevent + # subsequent retries for the same request. We suggest using V4 UUIDs, or another + # random string with enough entropy to avoid collisions. This field is only + # required for authentication when uploading a file from the client side. + # + # **Note**: Sending a value that has been used in the past will result in a + # validation error. Even if your previous request resulted in an error, you should + # always send a new value for this field. + # + # @return [String, nil] + optional :token, String + + # @!attribute checks + # Server-side checks to run on the asset. Read more about + # [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). + # + # @return [String, nil] + optional :checks, String + + # @!attribute custom_coordinates + # Define an important area in the image. This is only relevant for image type + # files. + # + # - To be passed as a string with the x and y coordinates of the top-left corner, + # and width and height of the area of interest in the format `x,y,width,height`. + # For example - `10,10,100,100` + # - Can be used with fo-customtransformation. + # - If this field is not specified and the file is overwritten, then + # customCoordinates will be removed. + # + # @return [String, nil] + optional :custom_coordinates, String, api_name: :customCoordinates + + # @!attribute custom_metadata + # JSON key-value pairs to associate with the asset. Create the custom metadata + # fields before setting these values. + # + # @return [Hash{Symbol=>Object}, nil] + optional :custom_metadata, + Imagekit::Internal::Type::HashOf[Imagekit::Internal::Type::Unknown], + api_name: :customMetadata + + # @!attribute description + # Optional text to describe the contents of the file. + # + # @return [String, nil] + optional :description, String + + # @!attribute expire + # The time until your signature is valid. It must be a + # [Unix time](https://en.wikipedia.org/wiki/Unix_time) in less than 1 hour into + # the future. It should be in seconds. This field is only required for + # authentication when uploading a file from the client side. + # + # @return [Integer, nil] + optional :expire, Integer + + # @!attribute extensions + # Array of extensions to be applied to the asset. Each extension can be configured + # with specific parameters based on the extension type. + # + # @return [Array, nil] + optional :extensions, -> { Imagekit::Internal::Type::ArrayOf[union: Imagekit::ExtensionItem] } + + # @!attribute folder + # The folder path in which the image has to be uploaded. If the folder(s) didn't + # exist before, a new folder(s) is created. + # + # The folder name can contain: + # + # - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` + # - Special Characters: `/` , `_` , `-` + # + # Using multiple `/` creates a nested folder. + # + # @return [String, nil] + optional :folder, String + + # @!attribute is_private_file + # Whether to mark the file as private or not. + # + # If `true`, the file is marked as private and is accessible only using named + # transformation or signed URL. + # + # @return [Boolean, nil] + optional :is_private_file, Imagekit::Internal::Type::Boolean, api_name: :isPrivateFile + + # @!attribute is_published + # Whether to upload file as published or not. + # + # If `false`, the file is marked as unpublished, which restricts access to the + # file only via the media library. Files in draft or unpublished state can only be + # publicly accessed after being published. + # + # The option to upload in draft state is only available in custom enterprise + # pricing plans. + # + # @return [Boolean, nil] + optional :is_published, Imagekit::Internal::Type::Boolean, api_name: :isPublished + + # @!attribute overwrite_ai_tags + # If set to `true` and a file already exists at the exact location, its AITags + # will be removed. Set `overwriteAITags` to `false` to preserve AITags. + # + # @return [Boolean, nil] + optional :overwrite_ai_tags, Imagekit::Internal::Type::Boolean, api_name: :overwriteAITags + + # @!attribute overwrite_custom_metadata + # If the request does not have `customMetadata`, and a file already exists at the + # exact location, existing customMetadata will be removed. + # + # @return [Boolean, nil] + optional :overwrite_custom_metadata, + Imagekit::Internal::Type::Boolean, + api_name: :overwriteCustomMetadata + + # @!attribute overwrite_file + # If `false` and `useUniqueFileName` is also `false`, and a file already exists at + # the exact location, upload API will return an error immediately. + # + # @return [Boolean, nil] + optional :overwrite_file, Imagekit::Internal::Type::Boolean, api_name: :overwriteFile + + # @!attribute overwrite_tags + # If the request does not have `tags`, and a file already exists at the exact + # location, existing tags will be removed. + # + # @return [Boolean, nil] + optional :overwrite_tags, Imagekit::Internal::Type::Boolean, api_name: :overwriteTags + + # @!attribute public_key + # Your ImageKit.io public key. This field is only required for authentication when + # uploading a file from the client side. + # + # @return [String, nil] + optional :public_key, String, api_name: :publicKey + + # @!attribute response_fields + # Array of response field keys to include in the API response body. + # + # @return [Array, nil] + optional :response_fields, + -> { Imagekit::Internal::Type::ArrayOf[enum: Imagekit::FileUploadParams::ResponseField] }, + api_name: :responseFields + + # @!attribute signature + # HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a + # key. Learn how to create a signature on the page below. This should be in + # lowercase. + # + # Signature must be calculated on the server-side. This field is only required for + # authentication when uploading a file from the client side. + # + # @return [String, nil] + optional :signature, String + + # @!attribute tags + # Set the tags while uploading the file. Provide an array of tag strings (e.g. + # `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must not + # exceed 500, and the `%` character is not allowed. If this field is not specified + # and the file is overwritten, the existing tags will be removed. + # + # @return [Array, nil] + optional :tags, Imagekit::Internal::Type::ArrayOf[String] + + # @!attribute transformation + # Configure pre-processing (`pre`) and post-processing (`post`) transformations. + # + # - `pre` — applied before the file is uploaded to the Media Library. + # Useful for reducing file size or applying basic optimizations upfront (e.g., + # resize, compress). + # + # - `post` — applied immediately after upload. + # Ideal for generating transformed versions (like video encodes or thumbnails) + # in advance, so they're ready for delivery without delay. + # + # You can mix and match any combination of post-processing types. + # + # @return [Imagekit::Models::FileUploadParams::Transformation, nil] + optional :transformation, -> { Imagekit::FileUploadParams::Transformation } + + # @!attribute use_unique_file_name + # Whether to use a unique filename for this file or not. + # + # If `true`, ImageKit.io will add a unique suffix to the filename parameter to get + # a unique filename. + # + # If `false`, then the image is uploaded with the provided filename parameter, and + # any existing file with the same name is replaced. + # + # @return [Boolean, nil] + optional :use_unique_file_name, Imagekit::Internal::Type::Boolean, api_name: :useUniqueFileName + + # @!attribute webhook_url + # The final status of extensions after they have completed execution will be + # delivered to this endpoint as a POST request. + # [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + # about the webhook payload structure. + # + # @return [String, nil] + optional :webhook_url, String, api_name: :webhookUrl + + # @!method initialize(file:, file_name:, token: nil, checks: nil, custom_coordinates: nil, custom_metadata: nil, description: nil, expire: nil, extensions: nil, folder: nil, is_private_file: nil, is_published: nil, overwrite_ai_tags: nil, overwrite_custom_metadata: nil, overwrite_file: nil, overwrite_tags: nil, public_key: nil, response_fields: nil, signature: nil, tags: nil, transformation: nil, use_unique_file_name: nil, webhook_url: nil, request_options: {}) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::FileUploadParams} for more details. + # + # @param file [Pathname, StringIO, IO, String, Imagekit::FilePart] The API accepts any of the following: + # + # @param file_name [String] The name with which the file has to be uploaded. + # + # @param token [String] A unique value that the ImageKit.io server will use to recognize and prevent sub + # + # @param checks [String] Server-side checks to run on the asset. + # + # @param custom_coordinates [String] Define an important area in the image. This is only relevant for image type file + # + # @param custom_metadata [Hash{Symbol=>Object}] JSON key-value pairs to associate with the asset. Create the custom metadata fie + # + # @param description [String] Optional text to describe the contents of the file. + # + # @param expire [Integer] The time until your signature is valid. It must be a [Unix time](https://en.wiki + # + # @param extensions [Array] Array of extensions to be applied to the asset. Each extension can be configured + # + # @param folder [String] The folder path in which the image has to be uploaded. If the folder(s) didn't e + # + # @param is_private_file [Boolean] Whether to mark the file as private or not. + # + # @param is_published [Boolean] Whether to upload file as published or not. + # + # @param overwrite_ai_tags [Boolean] If set to `true` and a file already exists at the exact location, its AITags wil + # + # @param overwrite_custom_metadata [Boolean] If the request does not have `customMetadata`, and a file already exists at the + # + # @param overwrite_file [Boolean] If `false` and `useUniqueFileName` is also `false`, and a file already exists at + # + # @param overwrite_tags [Boolean] If the request does not have `tags`, and a file already exists at the exact loca + # + # @param public_key [String] Your ImageKit.io public key. This field is only required for authentication when + # + # @param response_fields [Array] Array of response field keys to include in the API response body. + # + # @param signature [String] HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a + # + # @param tags [Array] Set the tags while uploading the file. + # + # @param transformation [Imagekit::Models::FileUploadParams::Transformation] Configure pre-processing (`pre`) and post-processing (`post`) transformations. + # + # @param use_unique_file_name [Boolean] Whether to use a unique filename for this file or not. + # + # @param webhook_url [String] The final status of extensions after they have completed execution will be deliv + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}] + + module ResponseField + extend Imagekit::Internal::Type::Enum + + TAGS = :tags + CUSTOM_COORDINATES = :customCoordinates + IS_PRIVATE_FILE = :isPrivateFile + EMBEDDED_METADATA = :embeddedMetadata + IS_PUBLISHED = :isPublished + CUSTOM_METADATA = :customMetadata + METADATA = :metadata + + # @!method self.values + # @return [Array] + end + + class Transformation < Imagekit::Internal::Type::BaseModel + # @!attribute post + # List of transformations to apply _after_ the file is uploaded. + # Each item must match one of the following types: `transformation`, + # `gif-to-video`, `thumbnail`, `abs`. + # + # @return [Array, nil] + optional :post, + -> { Imagekit::Internal::Type::ArrayOf[union: Imagekit::FileUploadParams::Transformation::Post] } + + # @!attribute pre + # Transformation string to apply before uploading the file to the Media Library. + # Useful for optimizing files at ingestion. + # + # @return [String, nil] + optional :pre, String + + # @!method initialize(post: nil, pre: nil) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::FileUploadParams::Transformation} for more details. + # + # Configure pre-processing (`pre`) and post-processing (`post`) transformations. + # + # - `pre` — applied before the file is uploaded to the Media Library. + # Useful for reducing file size or applying basic optimizations upfront (e.g., + # resize, compress). + # + # - `post` — applied immediately after upload. + # Ideal for generating transformed versions (like video encodes or thumbnails) + # in advance, so they're ready for delivery without delay. + # + # You can mix and match any combination of post-processing types. + # + # @param post [Array] List of transformations to apply _after_ the file is uploaded. + # + # @param pre [String] Transformation string to apply before uploading the file to the Media Library. U + + module Post + extend Imagekit::Internal::Type::Union + + discriminator :type + + variant :transformation, -> { Imagekit::FileUploadParams::Transformation::Post::Transformation } + + variant :"gif-to-video", -> { Imagekit::FileUploadParams::Transformation::Post::GifToVideo } + + variant :thumbnail, -> { Imagekit::FileUploadParams::Transformation::Post::Thumbnail } + + variant :abs, -> { Imagekit::FileUploadParams::Transformation::Post::Abs } + + class Transformation < Imagekit::Internal::Type::BaseModel + # @!attribute type + # Transformation type. + # + # @return [Symbol, :transformation] + required :type, const: :transformation + + # @!attribute value + # Transformation string (e.g. `w-200,h-200`). + # Same syntax as ImageKit URL-based transformations. + # + # @return [String] + required :value, String + + # @!method initialize(value:, type: :transformation) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::FileUploadParams::Transformation::Post::Transformation} for + # more details. + # + # @param value [String] Transformation string (e.g. `w-200,h-200`). + # + # @param type [Symbol, :transformation] Transformation type. + end + + class GifToVideo < Imagekit::Internal::Type::BaseModel + # @!attribute type + # Converts an animated GIF into an MP4. + # + # @return [Symbol, :"gif-to-video"] + required :type, const: :"gif-to-video" + + # @!attribute value + # Optional transformation string to apply to the output video. + # **Example**: `q-80` + # + # @return [String, nil] + optional :value, String + + # @!method initialize(value: nil, type: :"gif-to-video") + # Some parameter documentations has been truncated, see + # {Imagekit::Models::FileUploadParams::Transformation::Post::GifToVideo} for more + # details. + # + # @param value [String] Optional transformation string to apply to the output video. + # + # @param type [Symbol, :"gif-to-video"] Converts an animated GIF into an MP4. + end + + class Thumbnail < Imagekit::Internal::Type::BaseModel + # @!attribute type + # Generates a thumbnail image. + # + # @return [Symbol, :thumbnail] + required :type, const: :thumbnail + + # @!attribute value + # Optional transformation string. + # **Example**: `w-150,h-150` + # + # @return [String, nil] + optional :value, String + + # @!method initialize(value: nil, type: :thumbnail) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::FileUploadParams::Transformation::Post::Thumbnail} for more + # details. + # + # @param value [String] Optional transformation string. + # + # @param type [Symbol, :thumbnail] Generates a thumbnail image. + end + + class Abs < Imagekit::Internal::Type::BaseModel + # @!attribute protocol + # Streaming protocol to use (`hls` or `dash`). + # + # @return [Symbol, Imagekit::Models::FileUploadParams::Transformation::Post::Abs::Protocol] + required :protocol, enum: -> { Imagekit::FileUploadParams::Transformation::Post::Abs::Protocol } + + # @!attribute type + # Adaptive Bitrate Streaming (ABS) setup. + # + # @return [Symbol, :abs] + required :type, const: :abs + + # @!attribute value + # List of different representations you want to create separated by an underscore. + # + # @return [String] + required :value, String + + # @!method initialize(protocol:, value:, type: :abs) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::FileUploadParams::Transformation::Post::Abs} for more + # details. + # + # @param protocol [Symbol, Imagekit::Models::FileUploadParams::Transformation::Post::Abs::Protocol] Streaming protocol to use (`hls` or `dash`). + # + # @param value [String] List of different representations you want to create separated by an underscore. + # + # @param type [Symbol, :abs] Adaptive Bitrate Streaming (ABS) setup. + + # Streaming protocol to use (`hls` or `dash`). + # + # @see Imagekit::Models::FileUploadParams::Transformation::Post::Abs#protocol + module Protocol + extend Imagekit::Internal::Type::Enum + + HLS = :hls + DASH = :dash + + # @!method self.values + # @return [Array] + end + end + + # @!method self.variants + # @return [Array(Imagekit::Models::FileUploadParams::Transformation::Post::Transformation, Imagekit::Models::FileUploadParams::Transformation::Post::GifToVideo, Imagekit::Models::FileUploadParams::Transformation::Post::Thumbnail, Imagekit::Models::FileUploadParams::Transformation::Post::Abs)] + end + end + end + end +end diff --git a/lib/imagekit/models/file_upload_response.rb b/lib/imagekit/models/file_upload_response.rb new file mode 100644 index 00000000..85ebf598 --- /dev/null +++ b/lib/imagekit/models/file_upload_response.rb @@ -0,0 +1,391 @@ +# frozen_string_literal: true + +module Imagekit + module Models + # @see Imagekit::Resources::Files#upload + class FileUploadResponse < Imagekit::Internal::Type::BaseModel + # @!attribute ai_tags + # An array of tags assigned to the uploaded file by auto tagging. + # + # @return [Array, nil] + optional :ai_tags, + -> { Imagekit::Internal::Type::ArrayOf[Imagekit::Models::FileUploadResponse::AITag] }, + api_name: :AITags, + nil?: true + + # @!attribute audio_codec + # The audio codec used in the video (only for video). + # + # @return [String, nil] + optional :audio_codec, String, api_name: :audioCodec + + # @!attribute bit_rate + # The bit rate of the video in kbps (only for video). + # + # @return [Integer, nil] + optional :bit_rate, Integer, api_name: :bitRate + + # @!attribute custom_coordinates + # Value of custom coordinates associated with the image in the format + # `x,y,width,height`. If `customCoordinates` are not defined, then it is `null`. + # Send `customCoordinates` in `responseFields` in API request to get the value of + # this field. + # + # @return [String, nil] + optional :custom_coordinates, String, api_name: :customCoordinates, nil?: true + + # @!attribute custom_metadata + # A key-value data associated with the asset. Use `responseField` in API request + # to get `customMetadata` in the upload API response. Before setting any custom + # metadata on an asset, you have to create the field using custom metadata fields + # API. Send `customMetadata` in `responseFields` in API request to get the value + # of this field. + # + # @return [Hash{Symbol=>Object}, nil] + optional :custom_metadata, + Imagekit::Internal::Type::HashOf[Imagekit::Internal::Type::Unknown], + api_name: :customMetadata + + # @!attribute description + # Optional text to describe the contents of the file. Can be set by the user or + # the ai-auto-description extension. + # + # @return [String, nil] + optional :description, String + + # @!attribute duration + # The duration of the video in seconds (only for video). + # + # @return [Integer, nil] + optional :duration, Integer + + # @!attribute embedded_metadata + # Consolidated embedded metadata associated with the file. It includes exif, iptc, + # and xmp data. Send `embeddedMetadata` in `responseFields` in API request to get + # embeddedMetadata in the upload API response. + # + # @return [Hash{Symbol=>Object}, nil] + optional :embedded_metadata, + Imagekit::Internal::Type::HashOf[Imagekit::Internal::Type::Unknown], + api_name: :embeddedMetadata + + # @!attribute extension_status + # Extension names with their processing status at the time of completion of the + # request. It could have one of the following status values: + # + # `success`: The extension has been successfully applied. `failed`: The extension + # has failed and will not be retried. `pending`: The extension will finish + # processing in some time. On completion, the final status (success / failed) will + # be sent to the `webhookUrl` provided. + # + # If no extension was requested, then this parameter is not returned. + # + # @return [Imagekit::Models::FileUploadResponse::ExtensionStatus, nil] + optional :extension_status, + -> { Imagekit::Models::FileUploadResponse::ExtensionStatus }, + api_name: :extensionStatus + + # @!attribute file_id + # Unique fileId. Store this fileld in your database, as this will be used to + # perform update action on this file. + # + # @return [String, nil] + optional :file_id, String, api_name: :fileId + + # @!attribute file_path + # The relative path of the file in the media library e.g. + # `/marketing-assets/new-banner.jpg`. + # + # @return [String, nil] + optional :file_path, String, api_name: :filePath + + # @!attribute file_type + # Type of the uploaded file. Possible values are `image`, `non-image`. + # + # @return [String, nil] + optional :file_type, String, api_name: :fileType + + # @!attribute height + # Height of the image in pixels (Only for images) + # + # @return [Float, nil] + optional :height, Float + + # @!attribute is_private_file + # Is the file marked as private. It can be either `true` or `false`. Send + # `isPrivateFile` in `responseFields` in API request to get the value of this + # field. + # + # @return [Boolean, nil] + optional :is_private_file, Imagekit::Internal::Type::Boolean, api_name: :isPrivateFile + + # @!attribute is_published + # Is the file published or in draft state. It can be either `true` or `false`. + # Send `isPublished` in `responseFields` in API request to get the value of this + # field. + # + # @return [Boolean, nil] + optional :is_published, Imagekit::Internal::Type::Boolean, api_name: :isPublished + + # @!attribute metadata + # Legacy metadata. Send `metadata` in `responseFields` in API request to get + # metadata in the upload API response. + # + # @return [Imagekit::Models::Metadata, nil] + optional :metadata, -> { Imagekit::Metadata } + + # @!attribute name + # Name of the asset. + # + # @return [String, nil] + optional :name, String + + # @!attribute size + # Size of the image file in Bytes. + # + # @return [Float, nil] + optional :size, Float + + # @!attribute tags + # The array of tags associated with the asset. If no tags are set, it will be + # `null`. Send `tags` in `responseFields` in API request to get the value of this + # field. + # + # @return [Array, nil] + optional :tags, Imagekit::Internal::Type::ArrayOf[String], nil?: true + + # @!attribute thumbnail_url + # In the case of an image, a small thumbnail URL. + # + # @return [String, nil] + optional :thumbnail_url, String, api_name: :thumbnailUrl + + # @!attribute url + # A publicly accessible URL of the file. + # + # @return [String, nil] + optional :url, String + + # @!attribute version_info + # An object containing the file or file version's `id` (versionId) and `name`. + # + # @return [Imagekit::Models::FileUploadResponse::VersionInfo, nil] + optional :version_info, -> { Imagekit::Models::FileUploadResponse::VersionInfo }, api_name: :versionInfo + + # @!attribute video_codec + # The video codec used in the video (only for video). + # + # @return [String, nil] + optional :video_codec, String, api_name: :videoCodec + + # @!attribute width + # Width of the image in pixels (Only for Images) + # + # @return [Float, nil] + optional :width, Float + + # @!method initialize(ai_tags: nil, audio_codec: nil, bit_rate: nil, custom_coordinates: nil, custom_metadata: nil, description: nil, duration: nil, embedded_metadata: nil, extension_status: nil, file_id: nil, file_path: nil, file_type: nil, height: nil, is_private_file: nil, is_published: nil, metadata: nil, name: nil, size: nil, tags: nil, thumbnail_url: nil, url: nil, version_info: nil, video_codec: nil, width: nil) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::FileUploadResponse} for more details. + # + # Object containing details of a successful upload. + # + # @param ai_tags [Array, nil] An array of tags assigned to the uploaded file by auto tagging. + # + # @param audio_codec [String] The audio codec used in the video (only for video). + # + # @param bit_rate [Integer] The bit rate of the video in kbps (only for video). + # + # @param custom_coordinates [String, nil] Value of custom coordinates associated with the image in the format `x,y,width,h + # + # @param custom_metadata [Hash{Symbol=>Object}] A key-value data associated with the asset. Use `responseField` in API request t + # + # @param description [String] Optional text to describe the contents of the file. Can be set by the user or th + # + # @param duration [Integer] The duration of the video in seconds (only for video). + # + # @param embedded_metadata [Hash{Symbol=>Object}] Consolidated embedded metadata associated with the file. It includes exif, iptc, + # + # @param extension_status [Imagekit::Models::FileUploadResponse::ExtensionStatus] Extension names with their processing status at the time of completion of the re + # + # @param file_id [String] Unique fileId. Store this fileld in your database, as this will be used to perfo + # + # @param file_path [String] The relative path of the file in the media library e.g. `/marketing-assets/new-b + # + # @param file_type [String] Type of the uploaded file. Possible values are `image`, `non-image`. + # + # @param height [Float] Height of the image in pixels (Only for images) + # + # @param is_private_file [Boolean] Is the file marked as private. It can be either `true` or `false`. Send `isPriva + # + # @param is_published [Boolean] Is the file published or in draft state. It can be either `true` or `false`. Sen + # + # @param metadata [Imagekit::Models::Metadata] Legacy metadata. Send `metadata` in `responseFields` in API request to get metad + # + # @param name [String] Name of the asset. + # + # @param size [Float] Size of the image file in Bytes. + # + # @param tags [Array, nil] The array of tags associated with the asset. If no tags are set, it will be `nul + # + # @param thumbnail_url [String] In the case of an image, a small thumbnail URL. + # + # @param url [String] A publicly accessible URL of the file. + # + # @param version_info [Imagekit::Models::FileUploadResponse::VersionInfo] An object containing the file or file version's `id` (versionId) and `name`. + # + # @param video_codec [String] The video codec used in the video (only for video). + # + # @param width [Float] Width of the image in pixels (Only for Images) + + class AITag < Imagekit::Internal::Type::BaseModel + # @!attribute confidence + # Confidence score of the tag. + # + # @return [Float, nil] + optional :confidence, Float + + # @!attribute name + # Name of the tag. + # + # @return [String, nil] + optional :name, String + + # @!attribute source + # Array of `AITags` associated with the image. If no `AITags` are set, it will be + # null. These tags can be added using the `google-auto-tagging` or + # `aws-auto-tagging` extensions. + # + # @return [String, nil] + optional :source, String + + # @!method initialize(confidence: nil, name: nil, source: nil) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::FileUploadResponse::AITag} for more details. + # + # @param confidence [Float] Confidence score of the tag. + # + # @param name [String] Name of the tag. + # + # @param source [String] Array of `AITags` associated with the image. If no `AITags` are set, it will be + end + + # @see Imagekit::Models::FileUploadResponse#extension_status + class ExtensionStatus < Imagekit::Internal::Type::BaseModel + # @!attribute ai_auto_description + # + # @return [Symbol, Imagekit::Models::FileUploadResponse::ExtensionStatus::AIAutoDescription, nil] + optional :ai_auto_description, + enum: -> { Imagekit::Models::FileUploadResponse::ExtensionStatus::AIAutoDescription }, + api_name: :"ai-auto-description" + + # @!attribute aws_auto_tagging + # + # @return [Symbol, Imagekit::Models::FileUploadResponse::ExtensionStatus::AwsAutoTagging, nil] + optional :aws_auto_tagging, + enum: -> { Imagekit::Models::FileUploadResponse::ExtensionStatus::AwsAutoTagging }, + api_name: :"aws-auto-tagging" + + # @!attribute google_auto_tagging + # + # @return [Symbol, Imagekit::Models::FileUploadResponse::ExtensionStatus::GoogleAutoTagging, nil] + optional :google_auto_tagging, + enum: -> { Imagekit::Models::FileUploadResponse::ExtensionStatus::GoogleAutoTagging }, + api_name: :"google-auto-tagging" + + # @!attribute remove_bg + # + # @return [Symbol, Imagekit::Models::FileUploadResponse::ExtensionStatus::RemoveBg, nil] + optional :remove_bg, + enum: -> { Imagekit::Models::FileUploadResponse::ExtensionStatus::RemoveBg }, + api_name: :"remove-bg" + + # @!method initialize(ai_auto_description: nil, aws_auto_tagging: nil, google_auto_tagging: nil, remove_bg: nil) + # Extension names with their processing status at the time of completion of the + # request. It could have one of the following status values: + # + # `success`: The extension has been successfully applied. `failed`: The extension + # has failed and will not be retried. `pending`: The extension will finish + # processing in some time. On completion, the final status (success / failed) will + # be sent to the `webhookUrl` provided. + # + # If no extension was requested, then this parameter is not returned. + # + # @param ai_auto_description [Symbol, Imagekit::Models::FileUploadResponse::ExtensionStatus::AIAutoDescription] + # @param aws_auto_tagging [Symbol, Imagekit::Models::FileUploadResponse::ExtensionStatus::AwsAutoTagging] + # @param google_auto_tagging [Symbol, Imagekit::Models::FileUploadResponse::ExtensionStatus::GoogleAutoTagging] + # @param remove_bg [Symbol, Imagekit::Models::FileUploadResponse::ExtensionStatus::RemoveBg] + + # @see Imagekit::Models::FileUploadResponse::ExtensionStatus#ai_auto_description + module AIAutoDescription + extend Imagekit::Internal::Type::Enum + + SUCCESS = :success + PENDING = :pending + FAILED = :failed + + # @!method self.values + # @return [Array] + end + + # @see Imagekit::Models::FileUploadResponse::ExtensionStatus#aws_auto_tagging + module AwsAutoTagging + extend Imagekit::Internal::Type::Enum + + SUCCESS = :success + PENDING = :pending + FAILED = :failed + + # @!method self.values + # @return [Array] + end + + # @see Imagekit::Models::FileUploadResponse::ExtensionStatus#google_auto_tagging + module GoogleAutoTagging + extend Imagekit::Internal::Type::Enum + + SUCCESS = :success + PENDING = :pending + FAILED = :failed + + # @!method self.values + # @return [Array] + end + + # @see Imagekit::Models::FileUploadResponse::ExtensionStatus#remove_bg + module RemoveBg + extend Imagekit::Internal::Type::Enum + + SUCCESS = :success + PENDING = :pending + FAILED = :failed + + # @!method self.values + # @return [Array] + end + end + + # @see Imagekit::Models::FileUploadResponse#version_info + class VersionInfo < Imagekit::Internal::Type::BaseModel + # @!attribute id + # Unique identifier of the file version. + # + # @return [String, nil] + optional :id, String + + # @!attribute name + # Name of the file version. + # + # @return [String, nil] + optional :name, String + + # @!method initialize(id: nil, name: nil) + # An object containing the file or file version's `id` (versionId) and `name`. + # + # @param id [String] Unique identifier of the file version. + # + # @param name [String] Name of the file version. + end + end + end +end diff --git a/lib/imagekit/models/files/bulk_add_tags_params.rb b/lib/imagekit/models/files/bulk_add_tags_params.rb new file mode 100644 index 00000000..9c85f747 --- /dev/null +++ b/lib/imagekit/models/files/bulk_add_tags_params.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +module Imagekit + module Models + module Files + # @see Imagekit::Resources::Files::Bulk#add_tags + class BulkAddTagsParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + # @!attribute file_ids + # An array of fileIds to which you want to add tags. + # + # @return [Array] + required :file_ids, Imagekit::Internal::Type::ArrayOf[String], api_name: :fileIds + + # @!attribute tags + # An array of tags that you want to add to the files. + # + # @return [Array] + required :tags, Imagekit::Internal::Type::ArrayOf[String] + + # @!method initialize(file_ids:, tags:, request_options: {}) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Files::BulkAddTagsParams} for more details. + # + # @param file_ids [Array] An array of fileIds to which you want to add tags. + # + # @param tags [Array] An array of tags that you want to add to the files. + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/imagekit/models/files/bulk_add_tags_response.rb b/lib/imagekit/models/files/bulk_add_tags_response.rb new file mode 100644 index 00000000..6bd30f2c --- /dev/null +++ b/lib/imagekit/models/files/bulk_add_tags_response.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +module Imagekit + module Models + module Files + # @see Imagekit::Resources::Files::Bulk#add_tags + class BulkAddTagsResponse < Imagekit::Internal::Type::BaseModel + # @!attribute successfully_updated_file_ids + # An array of fileIds that in which tags were successfully added. + # + # @return [Array, nil] + optional :successfully_updated_file_ids, + Imagekit::Internal::Type::ArrayOf[String], + api_name: :successfullyUpdatedFileIds + + # @!method initialize(successfully_updated_file_ids: nil) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Files::BulkAddTagsResponse} for more details. + # + # @param successfully_updated_file_ids [Array] An array of fileIds that in which tags were successfully added. + end + end + end +end diff --git a/lib/imagekit/models/files/bulk_delete_params.rb b/lib/imagekit/models/files/bulk_delete_params.rb new file mode 100644 index 00000000..02bffc69 --- /dev/null +++ b/lib/imagekit/models/files/bulk_delete_params.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +module Imagekit + module Models + module Files + # @see Imagekit::Resources::Files::Bulk#delete + class BulkDeleteParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + # @!attribute file_ids + # An array of fileIds which you want to delete. + # + # @return [Array] + required :file_ids, Imagekit::Internal::Type::ArrayOf[String], api_name: :fileIds + + # @!method initialize(file_ids:, request_options: {}) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Files::BulkDeleteParams} for more details. + # + # @param file_ids [Array] An array of fileIds which you want to delete. + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/imagekit/models/files/bulk_delete_response.rb b/lib/imagekit/models/files/bulk_delete_response.rb new file mode 100644 index 00000000..e2fabbfc --- /dev/null +++ b/lib/imagekit/models/files/bulk_delete_response.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +module Imagekit + module Models + module Files + # @see Imagekit::Resources::Files::Bulk#delete + class BulkDeleteResponse < Imagekit::Internal::Type::BaseModel + # @!attribute successfully_deleted_file_ids + # An array of fileIds that were successfully deleted. + # + # @return [Array, nil] + optional :successfully_deleted_file_ids, + Imagekit::Internal::Type::ArrayOf[String], + api_name: :successfullyDeletedFileIds + + # @!method initialize(successfully_deleted_file_ids: nil) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Files::BulkDeleteResponse} for more details. + # + # @param successfully_deleted_file_ids [Array] An array of fileIds that were successfully deleted. + end + end + end +end diff --git a/lib/imagekit/models/files/bulk_remove_ai_tags_params.rb b/lib/imagekit/models/files/bulk_remove_ai_tags_params.rb new file mode 100644 index 00000000..b050162f --- /dev/null +++ b/lib/imagekit/models/files/bulk_remove_ai_tags_params.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +module Imagekit + module Models + module Files + # @see Imagekit::Resources::Files::Bulk#remove_ai_tags + class BulkRemoveAITagsParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + # @!attribute ai_tags + # An array of AITags that you want to remove from the files. + # + # @return [Array] + required :ai_tags, Imagekit::Internal::Type::ArrayOf[String], api_name: :AITags + + # @!attribute file_ids + # An array of fileIds from which you want to remove AITags. + # + # @return [Array] + required :file_ids, Imagekit::Internal::Type::ArrayOf[String], api_name: :fileIds + + # @!method initialize(ai_tags:, file_ids:, request_options: {}) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Files::BulkRemoveAITagsParams} for more details. + # + # @param ai_tags [Array] An array of AITags that you want to remove from the files. + # + # @param file_ids [Array] An array of fileIds from which you want to remove AITags. + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/imagekit/models/files/bulk_remove_ai_tags_response.rb b/lib/imagekit/models/files/bulk_remove_ai_tags_response.rb new file mode 100644 index 00000000..49fb07de --- /dev/null +++ b/lib/imagekit/models/files/bulk_remove_ai_tags_response.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +module Imagekit + module Models + module Files + # @see Imagekit::Resources::Files::Bulk#remove_ai_tags + class BulkRemoveAITagsResponse < Imagekit::Internal::Type::BaseModel + # @!attribute successfully_updated_file_ids + # An array of fileIds that in which AITags were successfully removed. + # + # @return [Array, nil] + optional :successfully_updated_file_ids, + Imagekit::Internal::Type::ArrayOf[String], + api_name: :successfullyUpdatedFileIds + + # @!method initialize(successfully_updated_file_ids: nil) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Files::BulkRemoveAITagsResponse} for more details. + # + # @param successfully_updated_file_ids [Array] An array of fileIds that in which AITags were successfully removed. + end + end + end +end diff --git a/lib/imagekit/models/files/bulk_remove_tags_params.rb b/lib/imagekit/models/files/bulk_remove_tags_params.rb new file mode 100644 index 00000000..e5a2bbea --- /dev/null +++ b/lib/imagekit/models/files/bulk_remove_tags_params.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +module Imagekit + module Models + module Files + # @see Imagekit::Resources::Files::Bulk#remove_tags + class BulkRemoveTagsParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + # @!attribute file_ids + # An array of fileIds from which you want to remove tags. + # + # @return [Array] + required :file_ids, Imagekit::Internal::Type::ArrayOf[String], api_name: :fileIds + + # @!attribute tags + # An array of tags that you want to remove from the files. + # + # @return [Array] + required :tags, Imagekit::Internal::Type::ArrayOf[String] + + # @!method initialize(file_ids:, tags:, request_options: {}) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Files::BulkRemoveTagsParams} for more details. + # + # @param file_ids [Array] An array of fileIds from which you want to remove tags. + # + # @param tags [Array] An array of tags that you want to remove from the files. + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/imagekit/models/files/bulk_remove_tags_response.rb b/lib/imagekit/models/files/bulk_remove_tags_response.rb new file mode 100644 index 00000000..a36571e3 --- /dev/null +++ b/lib/imagekit/models/files/bulk_remove_tags_response.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +module Imagekit + module Models + module Files + # @see Imagekit::Resources::Files::Bulk#remove_tags + class BulkRemoveTagsResponse < Imagekit::Internal::Type::BaseModel + # @!attribute successfully_updated_file_ids + # An array of fileIds that in which tags were successfully removed. + # + # @return [Array, nil] + optional :successfully_updated_file_ids, + Imagekit::Internal::Type::ArrayOf[String], + api_name: :successfullyUpdatedFileIds + + # @!method initialize(successfully_updated_file_ids: nil) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Files::BulkRemoveTagsResponse} for more details. + # + # @param successfully_updated_file_ids [Array] An array of fileIds that in which tags were successfully removed. + end + end + end +end diff --git a/lib/imagekit/models/files/metadata_get_from_url_params.rb b/lib/imagekit/models/files/metadata_get_from_url_params.rb new file mode 100644 index 00000000..805ec5b6 --- /dev/null +++ b/lib/imagekit/models/files/metadata_get_from_url_params.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +module Imagekit + module Models + module Files + # @see Imagekit::Resources::Files::Metadata#get_from_url + class MetadataGetFromURLParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + # @!attribute url + # Should be a valid file URL. It should be accessible using your ImageKit.io + # account. + # + # @return [String] + required :url, String + + # @!method initialize(url:, request_options: {}) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Files::MetadataGetFromURLParams} for more details. + # + # @param url [String] Should be a valid file URL. It should be accessible using your ImageKit.io accou + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/imagekit/models/files/metadata_get_params.rb b/lib/imagekit/models/files/metadata_get_params.rb new file mode 100644 index 00000000..c95a81e5 --- /dev/null +++ b/lib/imagekit/models/files/metadata_get_params.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module Imagekit + module Models + module Files + # @see Imagekit::Resources::Files::Metadata#get + class MetadataGetParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + # @!method initialize(request_options: {}) + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/imagekit/models/files/version_delete_params.rb b/lib/imagekit/models/files/version_delete_params.rb new file mode 100644 index 00000000..e17425f1 --- /dev/null +++ b/lib/imagekit/models/files/version_delete_params.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +module Imagekit + module Models + module Files + # @see Imagekit::Resources::Files::Versions#delete + class VersionDeleteParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + # @!attribute file_id + # + # @return [String] + required :file_id, String + + # @!method initialize(file_id:, request_options: {}) + # @param file_id [String] + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/imagekit/models/files/version_delete_response.rb b/lib/imagekit/models/files/version_delete_response.rb new file mode 100644 index 00000000..7f044266 --- /dev/null +++ b/lib/imagekit/models/files/version_delete_response.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module Imagekit + module Models + module Files + # @see Imagekit::Resources::Files::Versions#delete + class VersionDeleteResponse < Imagekit::Internal::Type::BaseModel + # @!method initialize + end + end + end +end diff --git a/lib/imagekit/models/files/version_get_params.rb b/lib/imagekit/models/files/version_get_params.rb new file mode 100644 index 00000000..b4c7ae98 --- /dev/null +++ b/lib/imagekit/models/files/version_get_params.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +module Imagekit + module Models + module Files + # @see Imagekit::Resources::Files::Versions#get + class VersionGetParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + # @!attribute file_id + # + # @return [String] + required :file_id, String + + # @!method initialize(file_id:, request_options: {}) + # @param file_id [String] + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/imagekit/models/files/version_list_params.rb b/lib/imagekit/models/files/version_list_params.rb new file mode 100644 index 00000000..82bf2cc3 --- /dev/null +++ b/lib/imagekit/models/files/version_list_params.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module Imagekit + module Models + module Files + # @see Imagekit::Resources::Files::Versions#list + class VersionListParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + # @!method initialize(request_options: {}) + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/imagekit/models/files/version_list_response.rb b/lib/imagekit/models/files/version_list_response.rb new file mode 100644 index 00000000..b74454e4 --- /dev/null +++ b/lib/imagekit/models/files/version_list_response.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Imagekit + module Models + module Files + # @type [Imagekit::Internal::Type::Converter] + VersionListResponse = Imagekit::Internal::Type::ArrayOf[-> { Imagekit::File }] + end + end +end diff --git a/lib/imagekit/models/files/version_restore_params.rb b/lib/imagekit/models/files/version_restore_params.rb new file mode 100644 index 00000000..bf1e8c63 --- /dev/null +++ b/lib/imagekit/models/files/version_restore_params.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +module Imagekit + module Models + module Files + # @see Imagekit::Resources::Files::Versions#restore + class VersionRestoreParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + # @!attribute file_id + # + # @return [String] + required :file_id, String + + # @!method initialize(file_id:, request_options: {}) + # @param file_id [String] + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/imagekit/models/folder.rb b/lib/imagekit/models/folder.rb new file mode 100644 index 00000000..832ae2a1 --- /dev/null +++ b/lib/imagekit/models/folder.rb @@ -0,0 +1,76 @@ +# frozen_string_literal: true + +module Imagekit + module Models + class Folder < Imagekit::Internal::Type::BaseModel + # @!attribute created_at + # Date and time when the folder was created. The date and time is in ISO8601 + # format. + # + # @return [Time, nil] + optional :created_at, Time, api_name: :createdAt + + # @!attribute folder_id + # Unique identifier of the asset. + # + # @return [String, nil] + optional :folder_id, String, api_name: :folderId + + # @!attribute folder_path + # Path of the folder. This is the path you would use in the URL to access the + # folder. For example, if the folder is at the root of the media library, the path + # will be /folder. If the folder is inside another folder named images, the path + # will be /images/folder. + # + # @return [String, nil] + optional :folder_path, String, api_name: :folderPath + + # @!attribute name + # Name of the asset. + # + # @return [String, nil] + optional :name, String + + # @!attribute type + # Type of the asset. + # + # @return [Symbol, Imagekit::Models::Folder::Type, nil] + optional :type, enum: -> { Imagekit::Folder::Type } + + # @!attribute updated_at + # Date and time when the folder was last updated. The date and time is in ISO8601 + # format. + # + # @return [Time, nil] + optional :updated_at, Time, api_name: :updatedAt + + # @!method initialize(created_at: nil, folder_id: nil, folder_path: nil, name: nil, type: nil, updated_at: nil) + # Some parameter documentations has been truncated, see {Imagekit::Models::Folder} + # for more details. + # + # @param created_at [Time] Date and time when the folder was created. The date and time is in ISO8601 forma + # + # @param folder_id [String] Unique identifier of the asset. + # + # @param folder_path [String] Path of the folder. This is the path you would use in the URL to access the fold + # + # @param name [String] Name of the asset. + # + # @param type [Symbol, Imagekit::Models::Folder::Type] Type of the asset. + # + # @param updated_at [Time] Date and time when the folder was last updated. The date and time is in ISO8601 + + # Type of the asset. + # + # @see Imagekit::Models::Folder#type + module Type + extend Imagekit::Internal::Type::Enum + + FOLDER = :folder + + # @!method self.values + # @return [Array] + end + end + end +end diff --git a/lib/imagekit/models/folder_copy_params.rb b/lib/imagekit/models/folder_copy_params.rb new file mode 100644 index 00000000..fabc4272 --- /dev/null +++ b/lib/imagekit/models/folder_copy_params.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true + +module Imagekit + module Models + # @see Imagekit::Resources::Folders#copy + class FolderCopyParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + # @!attribute destination_path + # Full path to the destination folder where you want to copy the source folder + # into. + # + # @return [String] + required :destination_path, String, api_name: :destinationPath + + # @!attribute source_folder_path + # The full path to the source folder you want to copy. + # + # @return [String] + required :source_folder_path, String, api_name: :sourceFolderPath + + # @!attribute include_versions + # Option to copy all versions of files that are nested inside the selected folder. + # By default, only the current version of each file will be copied. When set to + # true, all versions of each file will be copied. Default value - `false`. + # + # @return [Boolean, nil] + optional :include_versions, Imagekit::Internal::Type::Boolean, api_name: :includeVersions + + # @!method initialize(destination_path:, source_folder_path:, include_versions: nil, request_options: {}) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::FolderCopyParams} for more details. + # + # @param destination_path [String] Full path to the destination folder where you want to copy the source folder int + # + # @param source_folder_path [String] The full path to the source folder you want to copy. + # + # @param include_versions [Boolean] Option to copy all versions of files that are nested inside the selected folder. + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}] + end + end +end diff --git a/lib/imagekit/models/folder_copy_response.rb b/lib/imagekit/models/folder_copy_response.rb new file mode 100644 index 00000000..a9deadc1 --- /dev/null +++ b/lib/imagekit/models/folder_copy_response.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +module Imagekit + module Models + # @see Imagekit::Resources::Folders#copy + class FolderCopyResponse < Imagekit::Internal::Type::BaseModel + # @!attribute job_id + # Unique identifier of the bulk job. This can be used to check the status of the + # bulk job. + # + # @return [String] + required :job_id, String, api_name: :jobId + + # @!method initialize(job_id:) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::FolderCopyResponse} for more details. + # + # Job submitted successfully. A `jobId` will be returned. + # + # @param job_id [String] Unique identifier of the bulk job. This can be used to check the status of the b + end + end +end diff --git a/lib/imagekit/models/folder_create_params.rb b/lib/imagekit/models/folder_create_params.rb new file mode 100644 index 00000000..05138b5b --- /dev/null +++ b/lib/imagekit/models/folder_create_params.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +module Imagekit + module Models + # @see Imagekit::Resources::Folders#create + class FolderCreateParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + # @!attribute folder_name + # The folder will be created with this name. + # + # All characters except alphabets and numbers (inclusive of unicode letters, + # marks, and numerals in other languages) will be replaced by an underscore i.e. + # `_`. + # + # @return [String] + required :folder_name, String, api_name: :folderName + + # @!attribute parent_folder_path + # The folder where the new folder should be created, for root use `/` else the + # path e.g. `containing/folder/`. + # + # Note: If any folder(s) is not present in the parentFolderPath parameter, it will + # be automatically created. For example, if you pass `/product/images/summer`, + # then `product`, `images`, and `summer` folders will be created if they don't + # already exist. + # + # @return [String] + required :parent_folder_path, String, api_name: :parentFolderPath + + # @!method initialize(folder_name:, parent_folder_path:, request_options: {}) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::FolderCreateParams} for more details. + # + # @param folder_name [String] The folder will be created with this name. + # + # @param parent_folder_path [String] The folder where the new folder should be created, for root use `/` else the pat + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}] + end + end +end diff --git a/lib/imagekit/models/folder_create_response.rb b/lib/imagekit/models/folder_create_response.rb new file mode 100644 index 00000000..6dab708e --- /dev/null +++ b/lib/imagekit/models/folder_create_response.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Imagekit + module Models + # @see Imagekit::Resources::Folders#create + class FolderCreateResponse < Imagekit::Internal::Type::BaseModel + # @!method initialize + end + end +end diff --git a/lib/imagekit/models/folder_delete_params.rb b/lib/imagekit/models/folder_delete_params.rb new file mode 100644 index 00000000..8f4480d7 --- /dev/null +++ b/lib/imagekit/models/folder_delete_params.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +module Imagekit + module Models + # @see Imagekit::Resources::Folders#delete + class FolderDeleteParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + # @!attribute folder_path + # Full path to the folder you want to delete. For example `/folder/to/delete/`. + # + # @return [String] + required :folder_path, String, api_name: :folderPath + + # @!method initialize(folder_path:, request_options: {}) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::FolderDeleteParams} for more details. + # + # @param folder_path [String] Full path to the folder you want to delete. For example `/folder/to/delete/`. + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}] + end + end +end diff --git a/lib/imagekit/models/folder_delete_response.rb b/lib/imagekit/models/folder_delete_response.rb new file mode 100644 index 00000000..c92e4aa9 --- /dev/null +++ b/lib/imagekit/models/folder_delete_response.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Imagekit + module Models + # @see Imagekit::Resources::Folders#delete + class FolderDeleteResponse < Imagekit::Internal::Type::BaseModel + # @!method initialize + end + end +end diff --git a/lib/imagekit/models/folder_move_params.rb b/lib/imagekit/models/folder_move_params.rb new file mode 100644 index 00000000..86d6ccc9 --- /dev/null +++ b/lib/imagekit/models/folder_move_params.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +module Imagekit + module Models + # @see Imagekit::Resources::Folders#move + class FolderMoveParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + # @!attribute destination_path + # Full path to the destination folder where you want to move the source folder + # into. + # + # @return [String] + required :destination_path, String, api_name: :destinationPath + + # @!attribute source_folder_path + # The full path to the source folder you want to move. + # + # @return [String] + required :source_folder_path, String, api_name: :sourceFolderPath + + # @!method initialize(destination_path:, source_folder_path:, request_options: {}) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::FolderMoveParams} for more details. + # + # @param destination_path [String] Full path to the destination folder where you want to move the source folder int + # + # @param source_folder_path [String] The full path to the source folder you want to move. + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}] + end + end +end diff --git a/lib/imagekit/models/folder_move_response.rb b/lib/imagekit/models/folder_move_response.rb new file mode 100644 index 00000000..8fa4b3ef --- /dev/null +++ b/lib/imagekit/models/folder_move_response.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +module Imagekit + module Models + # @see Imagekit::Resources::Folders#move + class FolderMoveResponse < Imagekit::Internal::Type::BaseModel + # @!attribute job_id + # Unique identifier of the bulk job. This can be used to check the status of the + # bulk job. + # + # @return [String] + required :job_id, String, api_name: :jobId + + # @!method initialize(job_id:) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::FolderMoveResponse} for more details. + # + # Job submitted successfully. A `jobId` will be returned. + # + # @param job_id [String] Unique identifier of the bulk job. This can be used to check the status of the b + end + end +end diff --git a/lib/imagekit/models/folder_rename_params.rb b/lib/imagekit/models/folder_rename_params.rb new file mode 100644 index 00000000..071d74c4 --- /dev/null +++ b/lib/imagekit/models/folder_rename_params.rb @@ -0,0 +1,59 @@ +# frozen_string_literal: true + +module Imagekit + module Models + # @see Imagekit::Resources::Folders#rename + class FolderRenameParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + # @!attribute folder_path + # The full path to the folder you want to rename. + # + # @return [String] + required :folder_path, String, api_name: :folderPath + + # @!attribute new_folder_name + # The new name for the folder. + # + # All characters except alphabets and numbers (inclusive of unicode letters, + # marks, and numerals in other languages) and `-` will be replaced by an + # underscore i.e. `_`. + # + # @return [String] + required :new_folder_name, String, api_name: :newFolderName + + # @!attribute purge_cache + # Option to purge cache for the old nested files and their versions' URLs. + # + # When set to true, it will internally issue a purge cache request on CDN to + # remove the cached content of the old nested files and their versions. There will + # only be one purge request for all the nested files, which will be counted + # against your monthly purge quota. + # + # Note: A purge cache request will be issued against + # `https://ik.imagekit.io/old/folder/path*` (with a wildcard at the end). This + # will remove all nested files, their versions' URLs, and any transformations made + # using query parameters on these files or their versions. However, the cache for + # file transformations made using path parameters will persist. You can purge them + # using the purge API. For more details, refer to the purge API documentation. + # + # Default value - `false` + # + # @return [Boolean, nil] + optional :purge_cache, Imagekit::Internal::Type::Boolean, api_name: :purgeCache + + # @!method initialize(folder_path:, new_folder_name:, purge_cache: nil, request_options: {}) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::FolderRenameParams} for more details. + # + # @param folder_path [String] The full path to the folder you want to rename. + # + # @param new_folder_name [String] The new name for the folder. + # + # @param purge_cache [Boolean] Option to purge cache for the old nested files and their versions' URLs. + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}] + end + end +end diff --git a/lib/imagekit/models/folder_rename_response.rb b/lib/imagekit/models/folder_rename_response.rb new file mode 100644 index 00000000..0ac8984b --- /dev/null +++ b/lib/imagekit/models/folder_rename_response.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +module Imagekit + module Models + # @see Imagekit::Resources::Folders#rename + class FolderRenameResponse < Imagekit::Internal::Type::BaseModel + # @!attribute job_id + # Unique identifier of the bulk job. This can be used to check the status of the + # bulk job. + # + # @return [String] + required :job_id, String, api_name: :jobId + + # @!method initialize(job_id:) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::FolderRenameResponse} for more details. + # + # Job submitted successfully. A `jobId` will be returned. + # + # @param job_id [String] Unique identifier of the bulk job. This can be used to check the status of the b + end + end +end diff --git a/lib/imagekit/models/folders/job_get_params.rb b/lib/imagekit/models/folders/job_get_params.rb new file mode 100644 index 00000000..916f9213 --- /dev/null +++ b/lib/imagekit/models/folders/job_get_params.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module Imagekit + module Models + module Folders + # @see Imagekit::Resources::Folders::Job#get + class JobGetParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + # @!method initialize(request_options: {}) + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/imagekit/models/folders/job_get_response.rb b/lib/imagekit/models/folders/job_get_response.rb new file mode 100644 index 00000000..efd0d528 --- /dev/null +++ b/lib/imagekit/models/folders/job_get_response.rb @@ -0,0 +1,74 @@ +# frozen_string_literal: true + +module Imagekit + module Models + module Folders + # @see Imagekit::Resources::Folders::Job#get + class JobGetResponse < Imagekit::Internal::Type::BaseModel + # @!attribute job_id + # Unique identifier of the bulk job. + # + # @return [String, nil] + optional :job_id, String, api_name: :jobId + + # @!attribute purge_request_id + # Unique identifier of the purge request. This will be present only if + # `purgeCache` is set to `true` in the rename folder API request. + # + # @return [String, nil] + optional :purge_request_id, String, api_name: :purgeRequestId + + # @!attribute status + # Status of the bulk job. + # + # @return [Symbol, Imagekit::Models::Folders::JobGetResponse::Status, nil] + optional :status, enum: -> { Imagekit::Models::Folders::JobGetResponse::Status } + + # @!attribute type + # Type of the bulk job. + # + # @return [Symbol, Imagekit::Models::Folders::JobGetResponse::Type, nil] + optional :type, enum: -> { Imagekit::Models::Folders::JobGetResponse::Type } + + # @!method initialize(job_id: nil, purge_request_id: nil, status: nil, type: nil) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Folders::JobGetResponse} for more details. + # + # @param job_id [String] Unique identifier of the bulk job. + # + # @param purge_request_id [String] Unique identifier of the purge request. This will be present only if `purgeCache + # + # @param status [Symbol, Imagekit::Models::Folders::JobGetResponse::Status] Status of the bulk job. + # + # @param type [Symbol, Imagekit::Models::Folders::JobGetResponse::Type] Type of the bulk job. + + # Status of the bulk job. + # + # @see Imagekit::Models::Folders::JobGetResponse#status + module Status + extend Imagekit::Internal::Type::Enum + + PENDING = :Pending + COMPLETED = :Completed + + # @!method self.values + # @return [Array] + end + + # Type of the bulk job. + # + # @see Imagekit::Models::Folders::JobGetResponse#type + module Type + extend Imagekit::Internal::Type::Enum + + COPY_FOLDER = :COPY_FOLDER + MOVE_FOLDER = :MOVE_FOLDER + RENAME_FOLDER = :RENAME_FOLDER + + # @!method self.values + # @return [Array] + end + end + end + end +end diff --git a/lib/imagekit/models/image_overlay.rb b/lib/imagekit/models/image_overlay.rb new file mode 100644 index 00000000..acd5bca8 --- /dev/null +++ b/lib/imagekit/models/image_overlay.rb @@ -0,0 +1,66 @@ +# frozen_string_literal: true + +module Imagekit + module Models + class ImageOverlay < Imagekit::Models::BaseOverlay + # @!attribute input + # Specifies the relative path to the image used as an overlay. + # + # @return [String] + required :input, String + + # @!attribute type + # + # @return [Symbol, :image] + required :type, const: :image + + # @!attribute encoding + # The input path can be included in the layer as either `i-{input}` or + # `ie-{base64_encoded_input}`. By default, the SDK determines the appropriate + # format automatically. To always use base64 encoding (`ie-{base64}`), set this + # parameter to `base64`. To always use plain text (`i-{input}`), set it to + # `plain`. + # + # @return [Symbol, Imagekit::Models::ImageOverlay::Encoding, nil] + optional :encoding, enum: -> { Imagekit::ImageOverlay::Encoding } + + # @!attribute transformation + # Array of transformations to be applied to the overlay image. Supported + # transformations depends on the base/parent asset. See overlays on + # [Images](https://imagekit.io/docs/add-overlays-on-images#list-of-supported-image-transformations-in-image-layers) + # and + # [Videos](https://imagekit.io/docs/add-overlays-on-videos#list-of-transformations-supported-on-image-overlay). + # + # @return [Array, nil] + optional :transformation, -> { Imagekit::Internal::Type::ArrayOf[Imagekit::Transformation] } + + # @!method initialize(input:, encoding: nil, transformation: nil, type: :image) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::ImageOverlay} for more details. + # + # @param input [String] Specifies the relative path to the image used as an overlay. + # + # @param encoding [Symbol, Imagekit::Models::ImageOverlay::Encoding] The input path can be included in the layer as either `i-{input}` or `ie-{base64 + # + # @param transformation [Array] Array of transformations to be applied to the overlay image. Supported transform + # + # @param type [Symbol, :image] + + # The input path can be included in the layer as either `i-{input}` or + # `ie-{base64_encoded_input}`. By default, the SDK determines the appropriate + # format automatically. To always use base64 encoding (`ie-{base64}`), set this + # parameter to `base64`. To always use plain text (`i-{input}`), set it to + # `plain`. + module Encoding + extend Imagekit::Internal::Type::Enum + + AUTO = :auto + PLAIN = :plain + BASE64 = :base64 + + # @!method self.values + # @return [Array] + end + end + end +end diff --git a/lib/imagekit/models/metadata.rb b/lib/imagekit/models/metadata.rb new file mode 100644 index 00000000..c02910dd --- /dev/null +++ b/lib/imagekit/models/metadata.rb @@ -0,0 +1,483 @@ +# frozen_string_literal: true + +module Imagekit + module Models + class Metadata < Imagekit::Internal::Type::BaseModel + # @!attribute audio_codec + # The audio codec used in the video (only for video). + # + # @return [String, nil] + optional :audio_codec, String, api_name: :audioCodec + + # @!attribute bit_rate + # The bit rate of the video in kbps (only for video). + # + # @return [Integer, nil] + optional :bit_rate, Integer, api_name: :bitRate + + # @!attribute density + # The density of the image in DPI. + # + # @return [Integer, nil] + optional :density, Integer + + # @!attribute duration + # The duration of the video in seconds (only for video). + # + # @return [Integer, nil] + optional :duration, Integer + + # @!attribute exif + # + # @return [Imagekit::Models::Metadata::Exif, nil] + optional :exif, -> { Imagekit::Metadata::Exif } + + # @!attribute format_ + # The format of the file (e.g., 'jpg', 'mp4'). + # + # @return [String, nil] + optional :format_, String, api_name: :format + + # @!attribute has_color_profile + # Indicates if the image has a color profile. + # + # @return [Boolean, nil] + optional :has_color_profile, Imagekit::Internal::Type::Boolean, api_name: :hasColorProfile + + # @!attribute has_transparency + # Indicates if the image contains transparent areas. + # + # @return [Boolean, nil] + optional :has_transparency, Imagekit::Internal::Type::Boolean, api_name: :hasTransparency + + # @!attribute height + # The height of the image or video in pixels. + # + # @return [Integer, nil] + optional :height, Integer + + # @!attribute p_hash + # Perceptual hash of the image. + # + # @return [String, nil] + optional :p_hash, String, api_name: :pHash + + # @!attribute quality + # The quality indicator of the image. + # + # @return [Integer, nil] + optional :quality, Integer + + # @!attribute size + # The file size in bytes. + # + # @return [Integer, nil] + optional :size, Integer + + # @!attribute video_codec + # The video codec used in the video (only for video). + # + # @return [String, nil] + optional :video_codec, String, api_name: :videoCodec + + # @!attribute width + # The width of the image or video in pixels. + # + # @return [Integer, nil] + optional :width, Integer + + # @!method initialize(audio_codec: nil, bit_rate: nil, density: nil, duration: nil, exif: nil, format_: nil, has_color_profile: nil, has_transparency: nil, height: nil, p_hash: nil, quality: nil, size: nil, video_codec: nil, width: nil) + # JSON object containing metadata. + # + # @param audio_codec [String] The audio codec used in the video (only for video). + # + # @param bit_rate [Integer] The bit rate of the video in kbps (only for video). + # + # @param density [Integer] The density of the image in DPI. + # + # @param duration [Integer] The duration of the video in seconds (only for video). + # + # @param exif [Imagekit::Models::Metadata::Exif] + # + # @param format_ [String] The format of the file (e.g., 'jpg', 'mp4'). + # + # @param has_color_profile [Boolean] Indicates if the image has a color profile. + # + # @param has_transparency [Boolean] Indicates if the image contains transparent areas. + # + # @param height [Integer] The height of the image or video in pixels. + # + # @param p_hash [String] Perceptual hash of the image. + # + # @param quality [Integer] The quality indicator of the image. + # + # @param size [Integer] The file size in bytes. + # + # @param video_codec [String] The video codec used in the video (only for video). + # + # @param width [Integer] The width of the image or video in pixels. + + # @see Imagekit::Models::Metadata#exif + class Exif < Imagekit::Internal::Type::BaseModel + # @!attribute exif + # Object containing Exif details. + # + # @return [Imagekit::Models::Metadata::Exif::Exif, nil] + optional :exif, -> { Imagekit::Metadata::Exif::Exif } + + # @!attribute gps + # Object containing GPS information. + # + # @return [Imagekit::Models::Metadata::Exif::Gps, nil] + optional :gps, -> { Imagekit::Metadata::Exif::Gps } + + # @!attribute image + # Object containing EXIF image information. + # + # @return [Imagekit::Models::Metadata::Exif::Image, nil] + optional :image, -> { Imagekit::Metadata::Exif::Image } + + # @!attribute interoperability + # JSON object. + # + # @return [Imagekit::Models::Metadata::Exif::Interoperability, nil] + optional :interoperability, -> { Imagekit::Metadata::Exif::Interoperability } + + # @!attribute makernote + # + # @return [Hash{Symbol=>Object}, nil] + optional :makernote, Imagekit::Internal::Type::HashOf[Imagekit::Internal::Type::Unknown] + + # @!attribute thumbnail + # Object containing Thumbnail information. + # + # @return [Imagekit::Models::Metadata::Exif::Thumbnail, nil] + optional :thumbnail, -> { Imagekit::Metadata::Exif::Thumbnail } + + # @!method initialize(exif: nil, gps: nil, image: nil, interoperability: nil, makernote: nil, thumbnail: nil) + # @param exif [Imagekit::Models::Metadata::Exif::Exif] Object containing Exif details. + # + # @param gps [Imagekit::Models::Metadata::Exif::Gps] Object containing GPS information. + # + # @param image [Imagekit::Models::Metadata::Exif::Image] Object containing EXIF image information. + # + # @param interoperability [Imagekit::Models::Metadata::Exif::Interoperability] JSON object. + # + # @param makernote [Hash{Symbol=>Object}] + # + # @param thumbnail [Imagekit::Models::Metadata::Exif::Thumbnail] Object containing Thumbnail information. + + # @see Imagekit::Models::Metadata::Exif#exif + class Exif < Imagekit::Internal::Type::BaseModel + # @!attribute aperture_value + # + # @return [Float, nil] + optional :aperture_value, Float, api_name: :ApertureValue + + # @!attribute color_space + # + # @return [Integer, nil] + optional :color_space, Integer, api_name: :ColorSpace + + # @!attribute create_date + # + # @return [String, nil] + optional :create_date, String, api_name: :CreateDate + + # @!attribute custom_rendered + # + # @return [Integer, nil] + optional :custom_rendered, Integer, api_name: :CustomRendered + + # @!attribute date_time_original + # + # @return [String, nil] + optional :date_time_original, String, api_name: :DateTimeOriginal + + # @!attribute exif_image_height + # + # @return [Integer, nil] + optional :exif_image_height, Integer, api_name: :ExifImageHeight + + # @!attribute exif_image_width + # + # @return [Integer, nil] + optional :exif_image_width, Integer, api_name: :ExifImageWidth + + # @!attribute exif_version + # + # @return [String, nil] + optional :exif_version, String, api_name: :ExifVersion + + # @!attribute exposure_compensation + # + # @return [Float, nil] + optional :exposure_compensation, Float, api_name: :ExposureCompensation + + # @!attribute exposure_mode + # + # @return [Integer, nil] + optional :exposure_mode, Integer, api_name: :ExposureMode + + # @!attribute exposure_program + # + # @return [Integer, nil] + optional :exposure_program, Integer, api_name: :ExposureProgram + + # @!attribute exposure_time + # + # @return [Float, nil] + optional :exposure_time, Float, api_name: :ExposureTime + + # @!attribute flash + # + # @return [Integer, nil] + optional :flash, Integer, api_name: :Flash + + # @!attribute flashpix_version + # + # @return [String, nil] + optional :flashpix_version, String, api_name: :FlashpixVersion + + # @!attribute f_number + # + # @return [Float, nil] + optional :f_number, Float, api_name: :FNumber + + # @!attribute focal_length + # + # @return [Integer, nil] + optional :focal_length, Integer, api_name: :FocalLength + + # @!attribute focal_plane_resolution_unit + # + # @return [Integer, nil] + optional :focal_plane_resolution_unit, Integer, api_name: :FocalPlaneResolutionUnit + + # @!attribute focal_plane_x_resolution + # + # @return [Float, nil] + optional :focal_plane_x_resolution, Float, api_name: :FocalPlaneXResolution + + # @!attribute focal_plane_y_resolution + # + # @return [Float, nil] + optional :focal_plane_y_resolution, Float, api_name: :FocalPlaneYResolution + + # @!attribute interop_offset + # + # @return [Integer, nil] + optional :interop_offset, Integer, api_name: :InteropOffset + + # @!attribute iso + # + # @return [Integer, nil] + optional :iso, Integer, api_name: :ISO + + # @!attribute metering_mode + # + # @return [Integer, nil] + optional :metering_mode, Integer, api_name: :MeteringMode + + # @!attribute scene_capture_type + # + # @return [Integer, nil] + optional :scene_capture_type, Integer, api_name: :SceneCaptureType + + # @!attribute shutter_speed_value + # + # @return [Float, nil] + optional :shutter_speed_value, Float, api_name: :ShutterSpeedValue + + # @!attribute sub_sec_time + # + # @return [String, nil] + optional :sub_sec_time, String, api_name: :SubSecTime + + # @!attribute white_balance + # + # @return [Integer, nil] + optional :white_balance, Integer, api_name: :WhiteBalance + + # @!method initialize(aperture_value: nil, color_space: nil, create_date: nil, custom_rendered: nil, date_time_original: nil, exif_image_height: nil, exif_image_width: nil, exif_version: nil, exposure_compensation: nil, exposure_mode: nil, exposure_program: nil, exposure_time: nil, flash: nil, flashpix_version: nil, f_number: nil, focal_length: nil, focal_plane_resolution_unit: nil, focal_plane_x_resolution: nil, focal_plane_y_resolution: nil, interop_offset: nil, iso: nil, metering_mode: nil, scene_capture_type: nil, shutter_speed_value: nil, sub_sec_time: nil, white_balance: nil) + # Object containing Exif details. + # + # @param aperture_value [Float] + # @param color_space [Integer] + # @param create_date [String] + # @param custom_rendered [Integer] + # @param date_time_original [String] + # @param exif_image_height [Integer] + # @param exif_image_width [Integer] + # @param exif_version [String] + # @param exposure_compensation [Float] + # @param exposure_mode [Integer] + # @param exposure_program [Integer] + # @param exposure_time [Float] + # @param flash [Integer] + # @param flashpix_version [String] + # @param f_number [Float] + # @param focal_length [Integer] + # @param focal_plane_resolution_unit [Integer] + # @param focal_plane_x_resolution [Float] + # @param focal_plane_y_resolution [Float] + # @param interop_offset [Integer] + # @param iso [Integer] + # @param metering_mode [Integer] + # @param scene_capture_type [Integer] + # @param shutter_speed_value [Float] + # @param sub_sec_time [String] + # @param white_balance [Integer] + end + + # @see Imagekit::Models::Metadata::Exif#gps + class Gps < Imagekit::Internal::Type::BaseModel + # @!attribute gps_version_id + # + # @return [Array, nil] + optional :gps_version_id, Imagekit::Internal::Type::ArrayOf[Integer], api_name: :GPSVersionID + + # @!method initialize(gps_version_id: nil) + # Object containing GPS information. + # + # @param gps_version_id [Array] + end + + # @see Imagekit::Models::Metadata::Exif#image + class Image < Imagekit::Internal::Type::BaseModel + # @!attribute exif_offset + # + # @return [Integer, nil] + optional :exif_offset, Integer, api_name: :ExifOffset + + # @!attribute gps_info + # + # @return [Integer, nil] + optional :gps_info, Integer, api_name: :GPSInfo + + # @!attribute make + # + # @return [String, nil] + optional :make, String, api_name: :Make + + # @!attribute model + # + # @return [String, nil] + optional :model, String, api_name: :Model + + # @!attribute modify_date + # + # @return [String, nil] + optional :modify_date, String, api_name: :ModifyDate + + # @!attribute orientation + # + # @return [Integer, nil] + optional :orientation, Integer, api_name: :Orientation + + # @!attribute resolution_unit + # + # @return [Integer, nil] + optional :resolution_unit, Integer, api_name: :ResolutionUnit + + # @!attribute software + # + # @return [String, nil] + optional :software, String, api_name: :Software + + # @!attribute x_resolution + # + # @return [Integer, nil] + optional :x_resolution, Integer, api_name: :XResolution + + # @!attribute y_cb_cr_positioning + # + # @return [Integer, nil] + optional :y_cb_cr_positioning, Integer, api_name: :YCbCrPositioning + + # @!attribute y_resolution + # + # @return [Integer, nil] + optional :y_resolution, Integer, api_name: :YResolution + + # @!method initialize(exif_offset: nil, gps_info: nil, make: nil, model: nil, modify_date: nil, orientation: nil, resolution_unit: nil, software: nil, x_resolution: nil, y_cb_cr_positioning: nil, y_resolution: nil) + # Object containing EXIF image information. + # + # @param exif_offset [Integer] + # @param gps_info [Integer] + # @param make [String] + # @param model [String] + # @param modify_date [String] + # @param orientation [Integer] + # @param resolution_unit [Integer] + # @param software [String] + # @param x_resolution [Integer] + # @param y_cb_cr_positioning [Integer] + # @param y_resolution [Integer] + end + + # @see Imagekit::Models::Metadata::Exif#interoperability + class Interoperability < Imagekit::Internal::Type::BaseModel + # @!attribute interop_index + # + # @return [String, nil] + optional :interop_index, String, api_name: :InteropIndex + + # @!attribute interop_version + # + # @return [String, nil] + optional :interop_version, String, api_name: :InteropVersion + + # @!method initialize(interop_index: nil, interop_version: nil) + # JSON object. + # + # @param interop_index [String] + # @param interop_version [String] + end + + # @see Imagekit::Models::Metadata::Exif#thumbnail + class Thumbnail < Imagekit::Internal::Type::BaseModel + # @!attribute compression + # + # @return [Integer, nil] + optional :compression, Integer, api_name: :Compression + + # @!attribute resolution_unit + # + # @return [Integer, nil] + optional :resolution_unit, Integer, api_name: :ResolutionUnit + + # @!attribute thumbnail_length + # + # @return [Integer, nil] + optional :thumbnail_length, Integer, api_name: :ThumbnailLength + + # @!attribute thumbnail_offset + # + # @return [Integer, nil] + optional :thumbnail_offset, Integer, api_name: :ThumbnailOffset + + # @!attribute x_resolution + # + # @return [Integer, nil] + optional :x_resolution, Integer, api_name: :XResolution + + # @!attribute y_resolution + # + # @return [Integer, nil] + optional :y_resolution, Integer, api_name: :YResolution + + # @!method initialize(compression: nil, resolution_unit: nil, thumbnail_length: nil, thumbnail_offset: nil, x_resolution: nil, y_resolution: nil) + # Object containing Thumbnail information. + # + # @param compression [Integer] + # @param resolution_unit [Integer] + # @param thumbnail_length [Integer] + # @param thumbnail_offset [Integer] + # @param x_resolution [Integer] + # @param y_resolution [Integer] + end + end + end + end +end diff --git a/lib/imagekit/models/overlay.rb b/lib/imagekit/models/overlay.rb new file mode 100644 index 00000000..3c1873ca --- /dev/null +++ b/lib/imagekit/models/overlay.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +module Imagekit + module Models + # Specifies an overlay to be applied on the parent image or video. ImageKit + # supports overlays including images, text, videos, subtitles, and solid colors. + # See + # [Overlay using layers](https://imagekit.io/docs/transformations#overlay-using-layers). + module Overlay + extend Imagekit::Internal::Type::Union + + discriminator :type + + variant :text, -> { Imagekit::TextOverlay } + + variant :image, -> { Imagekit::ImageOverlay } + + variant :video, -> { Imagekit::VideoOverlay } + + variant :subtitle, -> { Imagekit::SubtitleOverlay } + + variant :solidColor, -> { Imagekit::SolidColorOverlay } + + # @!method self.variants + # @return [Array(Imagekit::Models::TextOverlay, Imagekit::Models::ImageOverlay, Imagekit::Models::VideoOverlay, Imagekit::Models::SubtitleOverlay, Imagekit::Models::SolidColorOverlay)] + end + end +end diff --git a/lib/imagekit/models/overlay_position.rb b/lib/imagekit/models/overlay_position.rb new file mode 100644 index 00000000..1613fe15 --- /dev/null +++ b/lib/imagekit/models/overlay_position.rb @@ -0,0 +1,101 @@ +# frozen_string_literal: true + +module Imagekit + module Models + class OverlayPosition < Imagekit::Internal::Type::BaseModel + # @!attribute focus + # Specifies the position of the overlay relative to the parent image or video. + # Maps to `lfo` in the URL. + # + # @return [Symbol, Imagekit::Models::OverlayPosition::Focus, nil] + optional :focus, enum: -> { Imagekit::OverlayPosition::Focus } + + # @!attribute x + # Specifies the x-coordinate of the top-left corner of the base asset where the + # overlay's top-left corner will be positioned. It also accepts arithmetic + # expressions such as `bw_mul_0.4` or `bw_sub_cw`. Maps to `lx` in the URL. Learn + # about + # [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + # + # @return [Float, String, nil] + optional :x, union: -> { Imagekit::OverlayPosition::X } + + # @!attribute y_ + # Specifies the y-coordinate of the top-left corner of the base asset where the + # overlay's top-left corner will be positioned. It also accepts arithmetic + # expressions such as `bh_mul_0.4` or `bh_sub_ch`. Maps to `ly` in the URL. Learn + # about + # [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + # + # @return [Float, String, nil] + optional :y_, union: -> { Imagekit::OverlayPosition::Y }, api_name: :y + + # @!method initialize(focus: nil, x: nil, y_: nil) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::OverlayPosition} for more details. + # + # @param focus [Symbol, Imagekit::Models::OverlayPosition::Focus] Specifies the position of the overlay relative to the parent image or video. + # + # @param x [Float, String] Specifies the x-coordinate of the top-left corner of the base asset where the ov + # + # @param y_ [Float, String] Specifies the y-coordinate of the top-left corner of the base asset where the ov + + # Specifies the position of the overlay relative to the parent image or video. + # Maps to `lfo` in the URL. + # + # @see Imagekit::Models::OverlayPosition#focus + module Focus + extend Imagekit::Internal::Type::Enum + + CENTER = :center + TOP = :top + LEFT = :left + BOTTOM = :bottom + RIGHT = :right + TOP_LEFT = :top_left + TOP_RIGHT = :top_right + BOTTOM_LEFT = :bottom_left + BOTTOM_RIGHT = :bottom_right + + # @!method self.values + # @return [Array] + end + + # Specifies the x-coordinate of the top-left corner of the base asset where the + # overlay's top-left corner will be positioned. It also accepts arithmetic + # expressions such as `bw_mul_0.4` or `bw_sub_cw`. Maps to `lx` in the URL. Learn + # about + # [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + # + # @see Imagekit::Models::OverlayPosition#x + module X + extend Imagekit::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + end + + # Specifies the y-coordinate of the top-left corner of the base asset where the + # overlay's top-left corner will be positioned. It also accepts arithmetic + # expressions such as `bh_mul_0.4` or `bh_sub_ch`. Maps to `ly` in the URL. Learn + # about + # [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + # + # @see Imagekit::Models::OverlayPosition#y_ + module Y + extend Imagekit::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + end + end + end +end diff --git a/lib/imagekit/models/overlay_timing.rb b/lib/imagekit/models/overlay_timing.rb new file mode 100644 index 00000000..7e399421 --- /dev/null +++ b/lib/imagekit/models/overlay_timing.rb @@ -0,0 +1,97 @@ +# frozen_string_literal: true + +module Imagekit + module Models + class OverlayTiming < Imagekit::Internal::Type::BaseModel + # @!attribute duration + # Specifies the duration (in seconds) during which the overlay should appear on + # the base video. Accepts a positive number up to two decimal places (e.g., `20` + # or `20.50`) and arithmetic expressions such as `bdu_mul_0.4` or `bdu_sub_idu`. + # Applies only if the base asset is a video. Maps to `ldu` in the URL. + # + # @return [Float, String, nil] + optional :duration, union: -> { Imagekit::OverlayTiming::Duration } + + # @!attribute end_ + # Specifies the end time (in seconds) for when the overlay should disappear from + # the base video. If both end and duration are provided, duration is ignored. + # Accepts a positive number up to two decimal places (e.g., `20` or `20.50`) and + # arithmetic expressions such as `bdu_mul_0.4` or `bdu_sub_idu`. Applies only if + # the base asset is a video. Maps to `leo` in the URL. + # + # @return [Float, String, nil] + optional :end_, union: -> { Imagekit::OverlayTiming::End }, api_name: :end + + # @!attribute start + # Specifies the start time (in seconds) for when the overlay should appear on the + # base video. Accepts a positive number up to two decimal places (e.g., `20` or + # `20.50`) and arithmetic expressions such as `bdu_mul_0.4` or `bdu_sub_idu`. + # Applies only if the base asset is a video. Maps to `lso` in the URL. + # + # @return [Float, String, nil] + optional :start, union: -> { Imagekit::OverlayTiming::Start } + + # @!method initialize(duration: nil, end_: nil, start: nil) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::OverlayTiming} for more details. + # + # @param duration [Float, String] Specifies the duration (in seconds) during which the overlay should appear on th + # + # @param end_ [Float, String] Specifies the end time (in seconds) for when the overlay should disappear from t + # + # @param start [Float, String] Specifies the start time (in seconds) for when the overlay should appear on the + + # Specifies the duration (in seconds) during which the overlay should appear on + # the base video. Accepts a positive number up to two decimal places (e.g., `20` + # or `20.50`) and arithmetic expressions such as `bdu_mul_0.4` or `bdu_sub_idu`. + # Applies only if the base asset is a video. Maps to `ldu` in the URL. + # + # @see Imagekit::Models::OverlayTiming#duration + module Duration + extend Imagekit::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + end + + # Specifies the end time (in seconds) for when the overlay should disappear from + # the base video. If both end and duration are provided, duration is ignored. + # Accepts a positive number up to two decimal places (e.g., `20` or `20.50`) and + # arithmetic expressions such as `bdu_mul_0.4` or `bdu_sub_idu`. Applies only if + # the base asset is a video. Maps to `leo` in the URL. + # + # @see Imagekit::Models::OverlayTiming#end_ + module End + extend Imagekit::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + end + + # Specifies the start time (in seconds) for when the overlay should appear on the + # base video. Accepts a positive number up to two decimal places (e.g., `20` or + # `20.50`) and arithmetic expressions such as `bdu_mul_0.4` or `bdu_sub_idu`. + # Applies only if the base asset is a video. Maps to `lso` in the URL. + # + # @see Imagekit::Models::OverlayTiming#start + module Start + extend Imagekit::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + end + end + end +end diff --git a/lib/imagekit/models/solid_color_overlay.rb b/lib/imagekit/models/solid_color_overlay.rb new file mode 100644 index 00000000..e9851237 --- /dev/null +++ b/lib/imagekit/models/solid_color_overlay.rb @@ -0,0 +1,42 @@ +# frozen_string_literal: true + +module Imagekit + module Models + class SolidColorOverlay < Imagekit::Models::BaseOverlay + # @!attribute color + # Specifies the color of the block using an RGB hex code (e.g., `FF0000`), an RGBA + # code (e.g., `FFAABB50`), or a color name (e.g., `red`). If an 8-character value + # is provided, the last two characters represent the opacity level (from `00` for + # 0.00 to `99` for 0.99). + # + # @return [String] + required :color, String + + # @!attribute type + # + # @return [Symbol, :solidColor] + required :type, const: :solidColor + + # @!attribute transformation + # Control width and height of the solid color overlay. Supported transformations + # depend on the base/parent asset. See overlays on + # [Images](https://imagekit.io/docs/add-overlays-on-images#apply-transformation-on-solid-color-overlay) + # and + # [Videos](https://imagekit.io/docs/add-overlays-on-videos#apply-transformations-on-solid-color-block-overlay). + # + # @return [Array, nil] + optional :transformation, + -> { Imagekit::Internal::Type::ArrayOf[Imagekit::SolidColorOverlayTransformation] } + + # @!method initialize(color:, transformation: nil, type: :solidColor) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::SolidColorOverlay} for more details. + # + # @param color [String] Specifies the color of the block using an RGB hex code (e.g., `FF0000`), an RGBA + # + # @param transformation [Array] Control width and height of the solid color overlay. Supported transformations d + # + # @param type [Symbol, :solidColor] + end + end +end diff --git a/lib/imagekit/models/solid_color_overlay_transformation.rb b/lib/imagekit/models/solid_color_overlay_transformation.rb new file mode 100644 index 00000000..dacca6bb --- /dev/null +++ b/lib/imagekit/models/solid_color_overlay_transformation.rb @@ -0,0 +1,135 @@ +# frozen_string_literal: true + +module Imagekit + module Models + class SolidColorOverlayTransformation < Imagekit::Internal::Type::BaseModel + # @!attribute alpha + # Specifies the transparency level of the solid color overlay. Accepts integers + # from `1` to `9`. + # + # @return [Float, nil] + optional :alpha, Float + + # @!attribute background + # Specifies the background color of the solid color overlay. Accepts an RGB hex + # code (e.g., `FF0000`), an RGBA code (e.g., `FFAABB50`), or a color name. + # + # @return [String, nil] + optional :background, String + + # @!attribute gradient + # Creates a linear gradient with two colors. Pass `true` for a default gradient, + # or provide a string for a custom gradient. Only works if the base asset is an + # image. See + # [gradient](https://imagekit.io/docs/effects-and-enhancements#gradient---e-gradient). + # + # @return [Boolean, true, String, nil] + optional :gradient, union: -> { Imagekit::SolidColorOverlayTransformation::Gradient } + + # @!attribute height + # Controls the height of the solid color overlay. Accepts a numeric value or an + # arithmetic expression. Learn about + # [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + # + # @return [Float, String, nil] + optional :height, union: -> { Imagekit::SolidColorOverlayTransformation::Height } + + # @!attribute radius + # Specifies the corner radius of the solid color overlay. Set to `max` for + # circular or oval shape. See + # [radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). + # + # @return [Float, Symbol, :max, nil] + optional :radius, union: -> { Imagekit::SolidColorOverlayTransformation::Radius } + + # @!attribute width + # Controls the width of the solid color overlay. Accepts a numeric value or an + # arithmetic expression (e.g., `bw_mul_0.2` or `bh_div_2`). Learn about + # [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + # + # @return [Float, String, nil] + optional :width, union: -> { Imagekit::SolidColorOverlayTransformation::Width } + + # @!method initialize(alpha: nil, background: nil, gradient: nil, height: nil, radius: nil, width: nil) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::SolidColorOverlayTransformation} for more details. + # + # @param alpha [Float] Specifies the transparency level of the solid color overlay. Accepts integers fr + # + # @param background [String] Specifies the background color of the solid color overlay. Accepts an RGB hex co + # + # @param gradient [Boolean, true, String] Creates a linear gradient with two colors. Pass `true` for a default gradient, o + # + # @param height [Float, String] Controls the height of the solid color overlay. Accepts a numeric value or an ar + # + # @param radius [Float, Symbol, :max] Specifies the corner radius of the solid color overlay. Set to `max` for circula + # + # @param width [Float, String] Controls the width of the solid color overlay. Accepts a numeric value or an ari + + # Creates a linear gradient with two colors. Pass `true` for a default gradient, + # or provide a string for a custom gradient. Only works if the base asset is an + # image. See + # [gradient](https://imagekit.io/docs/effects-and-enhancements#gradient---e-gradient). + # + # @see Imagekit::Models::SolidColorOverlayTransformation#gradient + module Gradient + extend Imagekit::Internal::Type::Union + + variant const: true + + variant String + + # @!method self.variants + # @return [Array(Boolean, true, String)] + end + + # Controls the height of the solid color overlay. Accepts a numeric value or an + # arithmetic expression. Learn about + # [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + # + # @see Imagekit::Models::SolidColorOverlayTransformation#height + module Height + extend Imagekit::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + end + + # Specifies the corner radius of the solid color overlay. Set to `max` for + # circular or oval shape. See + # [radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). + # + # @see Imagekit::Models::SolidColorOverlayTransformation#radius + module Radius + extend Imagekit::Internal::Type::Union + + variant Float + + variant const: :max + + # @!method self.variants + # @return [Array(Float, Symbol, :max)] + end + + # Controls the width of the solid color overlay. Accepts a numeric value or an + # arithmetic expression (e.g., `bw_mul_0.2` or `bh_div_2`). Learn about + # [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + # + # @see Imagekit::Models::SolidColorOverlayTransformation#width + module Width + extend Imagekit::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + end + end + end +end diff --git a/lib/imagekit/models/src_options.rb b/lib/imagekit/models/src_options.rb new file mode 100644 index 00000000..ed73d6c7 --- /dev/null +++ b/lib/imagekit/models/src_options.rb @@ -0,0 +1,96 @@ +# frozen_string_literal: true + +module Imagekit + module Models + class SrcOptions < Imagekit::Internal::Type::BaseModel + # @!attribute src + # Accepts a relative or absolute path of the resource. If a relative path is + # provided, it is appended to the `urlEndpoint`. If an absolute path is provided, + # `urlEndpoint` is ignored. + # + # @return [String] + required :src, String + + # @!attribute url_endpoint + # Get your urlEndpoint from the + # [ImageKit dashboard](https://imagekit.io/dashboard/url-endpoints). + # + # @return [String] + required :url_endpoint, String, api_name: :urlEndpoint + + # @!attribute expires_in + # When you want the signed URL to expire, specified in seconds. If `expiresIn` is + # anything above 0, the URL will always be signed even if `signed` is set to + # false. If not specified and `signed` is `true`, the signed URL will not expire + # (valid indefinitely). + # + # Example: Setting `expiresIn: 3600` will make the URL expire 1 hour from + # generation time. After the expiry time, the signed URL will no longer be valid + # and ImageKit will return a 401 Unauthorized status code. + # + # [Learn more](https://imagekit.io/docs/media-delivery-basic-security#how-to-generate-signed-urls). + # + # @return [Float, nil] + optional :expires_in, Float, api_name: :expiresIn + + # @!attribute query_parameters + # These are additional query parameters that you want to add to the final URL. + # They can be any query parameters and not necessarily related to ImageKit. This + # is especially useful if you want to add a versioning parameter to your URLs. + # + # @return [Hash{Symbol=>String}, nil] + optional :query_parameters, Imagekit::Internal::Type::HashOf[String], api_name: :queryParameters + + # @!attribute signed + # Whether to sign the URL or not. Set this to `true` if you want to generate a + # signed URL. If `signed` is `true` and `expiresIn` is not specified, the signed + # URL will not expire (valid indefinitely). Note: If `expiresIn` is set to any + # value above 0, the URL will always be signed regardless of this setting. + # [Learn more](https://imagekit.io/docs/media-delivery-basic-security#how-to-generate-signed-urls). + # + # @return [Boolean, nil] + optional :signed, Imagekit::Internal::Type::Boolean + + # @!attribute transformation + # An array of objects specifying the transformations to be applied in the URL. If + # more than one transformation is specified, they are applied in the order they + # are specified as chained transformations. See + # [Chained transformations](https://imagekit.io/docs/transformations#chained-transformations). + # + # @return [Array, nil] + optional :transformation, -> { Imagekit::Internal::Type::ArrayOf[Imagekit::Transformation] } + + # @!attribute transformation_position + # By default, the transformation string is added as a query parameter in the URL, + # e.g., `?tr=w-100,h-100`. If you want to add the transformation string in the + # path of the URL, set this to `path`. Learn more in the + # [Transformations guide](https://imagekit.io/docs/transformations). + # + # @return [Symbol, Imagekit::Models::TransformationPosition, nil] + optional :transformation_position, + enum: -> { Imagekit::TransformationPosition }, + api_name: :transformationPosition + + # @!method initialize(src:, url_endpoint:, expires_in: nil, query_parameters: nil, signed: nil, transformation: nil, transformation_position: nil) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::SrcOptions} for more details. + # + # Options for generating ImageKit URLs with transformations. See the + # [Transformations guide](https://imagekit.io/docs/transformations). + # + # @param src [String] Accepts a relative or absolute path of the resource. If a relative path is provi + # + # @param url_endpoint [String] Get your urlEndpoint from the [ImageKit dashboard](https://imagekit.io/dashboard + # + # @param expires_in [Float] When you want the signed URL to expire, specified in seconds. If `expiresIn` is + # + # @param query_parameters [Hash{Symbol=>String}] These are additional query parameters that you want to add to the final URL. + # + # @param signed [Boolean] Whether to sign the URL or not. Set this to `true` if you want to generate a sig + # + # @param transformation [Array] An array of objects specifying the transformations to be applied in the URL. If + # + # @param transformation_position [Symbol, Imagekit::Models::TransformationPosition] By default, the transformation string is added as a query parameter in the URL, + end + end +end diff --git a/lib/imagekit/models/streaming_resolution.rb b/lib/imagekit/models/streaming_resolution.rb new file mode 100644 index 00000000..c30c25e1 --- /dev/null +++ b/lib/imagekit/models/streaming_resolution.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +module Imagekit + module Models + # Available streaming resolutions for + # [adaptive bitrate streaming](https://imagekit.io/docs/adaptive-bitrate-streaming) + module StreamingResolution + extend Imagekit::Internal::Type::Enum + + STREAMING_RESOLUTION_240 = :"240" + STREAMING_RESOLUTION_360 = :"360" + STREAMING_RESOLUTION_480 = :"480" + STREAMING_RESOLUTION_720 = :"720" + STREAMING_RESOLUTION_1080 = :"1080" + STREAMING_RESOLUTION_1440 = :"1440" + STREAMING_RESOLUTION_2160 = :"2160" + + # @!method self.values + # @return [Array] + end + end +end diff --git a/lib/imagekit/models/subtitle_overlay.rb b/lib/imagekit/models/subtitle_overlay.rb new file mode 100644 index 00000000..4fc0a96b --- /dev/null +++ b/lib/imagekit/models/subtitle_overlay.rb @@ -0,0 +1,64 @@ +# frozen_string_literal: true + +module Imagekit + module Models + class SubtitleOverlay < Imagekit::Models::BaseOverlay + # @!attribute input + # Specifies the relative path to the subtitle file used as an overlay. + # + # @return [String] + required :input, String + + # @!attribute type + # + # @return [Symbol, :subtitle] + required :type, const: :subtitle + + # @!attribute encoding + # The input path can be included in the layer as either `i-{input}` or + # `ie-{base64_encoded_input}`. By default, the SDK determines the appropriate + # format automatically. To always use base64 encoding (`ie-{base64}`), set this + # parameter to `base64`. To always use plain text (`i-{input}`), set it to + # `plain`. + # + # @return [Symbol, Imagekit::Models::SubtitleOverlay::Encoding, nil] + optional :encoding, enum: -> { Imagekit::SubtitleOverlay::Encoding } + + # @!attribute transformation + # Control styling of the subtitle. See + # [Styling subtitles](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer). + # + # @return [Array, nil] + optional :transformation, + -> { Imagekit::Internal::Type::ArrayOf[Imagekit::SubtitleOverlayTransformation] } + + # @!method initialize(input:, encoding: nil, transformation: nil, type: :subtitle) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::SubtitleOverlay} for more details. + # + # @param input [String] Specifies the relative path to the subtitle file used as an overlay. + # + # @param encoding [Symbol, Imagekit::Models::SubtitleOverlay::Encoding] The input path can be included in the layer as either `i-{input}` or `ie-{base64 + # + # @param transformation [Array] Control styling of the subtitle. See [Styling subtitles](https://imagekit.io/doc + # + # @param type [Symbol, :subtitle] + + # The input path can be included in the layer as either `i-{input}` or + # `ie-{base64_encoded_input}`. By default, the SDK determines the appropriate + # format automatically. To always use base64 encoding (`ie-{base64}`), set this + # parameter to `base64`. To always use plain text (`i-{input}`), set it to + # `plain`. + module Encoding + extend Imagekit::Internal::Type::Enum + + AUTO = :auto + PLAIN = :plain + BASE64 = :base64 + + # @!method self.values + # @return [Array] + end + end + end +end diff --git a/lib/imagekit/models/subtitle_overlay_transformation.rb b/lib/imagekit/models/subtitle_overlay_transformation.rb new file mode 100644 index 00000000..a2586ae2 --- /dev/null +++ b/lib/imagekit/models/subtitle_overlay_transformation.rb @@ -0,0 +1,113 @@ +# frozen_string_literal: true + +module Imagekit + module Models + class SubtitleOverlayTransformation < Imagekit::Internal::Type::BaseModel + # @!attribute background + # Specifies the subtitle background color using a standard color name, an RGB + # color code (e.g., FF0000), or an RGBA color code (e.g., FFAABB50). + # + # [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + # + # @return [String, nil] + optional :background, String + + # @!attribute color + # Sets the font color of the subtitle text using a standard color name, an RGB + # color code (e.g., FF0000), or an RGBA color code (e.g., FFAABB50). + # + # [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + # + # @return [String, nil] + optional :color, String + + # @!attribute font_family + # Font family for subtitles. Refer to the + # [supported fonts](https://imagekit.io/docs/add-overlays-on-images#supported-text-font-list). + # + # @return [String, nil] + optional :font_family, String, api_name: :fontFamily + + # @!attribute font_outline + # Sets the font outline of the subtitle text. Requires the outline width (an + # integer) and the outline color (as an RGB color code, RGBA color code, or + # standard web color name) separated by an underscore. Example: `fol-2_blue` + # (outline width of 2px and outline color blue), `fol-2_A1CCDD` (outline width of + # 2px and outline color `#A1CCDD`) and `fol-2_A1CCDD50` (outline width of 2px and + # outline color `#A1CCDD` at 50% opacity). + # + # [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + # + # @return [String, nil] + optional :font_outline, String, api_name: :fontOutline + + # @!attribute font_shadow + # Sets the font shadow for the subtitle text. Requires the shadow color (as an RGB + # color code, RGBA color code, or standard web color name) and shadow indent (an + # integer) separated by an underscore. Example: `fsh-blue_2` (shadow color blue, + # indent of 2px), `fsh-A1CCDD_3` (shadow color `#A1CCDD`, indent of 3px), + # `fsh-A1CCDD50_3` (shadow color `#A1CCDD` at 50% opacity, indent of 3px). + # + # [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + # + # @return [String, nil] + optional :font_shadow, String, api_name: :fontShadow + + # @!attribute font_size + # Sets the font size of subtitle text. + # + # [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + # + # @return [Float, nil] + optional :font_size, Float, api_name: :fontSize + + # @!attribute typography + # Sets the typography style of the subtitle text. Supports values are `b` for + # bold, `i` for italics, and `b_i` for bold with italics. + # + # [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + # + # @return [Symbol, Imagekit::Models::SubtitleOverlayTransformation::Typography, nil] + optional :typography, enum: -> { Imagekit::SubtitleOverlayTransformation::Typography } + + # @!method initialize(background: nil, color: nil, font_family: nil, font_outline: nil, font_shadow: nil, font_size: nil, typography: nil) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::SubtitleOverlayTransformation} for more details. + # + # Subtitle styling options. + # [Learn more](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + # from the docs. + # + # @param background [String] Specifies the subtitle background color using a standard color name, an RGB colo + # + # @param color [String] Sets the font color of the subtitle text using a standard color name, an RGB col + # + # @param font_family [String] Font family for subtitles. Refer to the [supported fonts](https://imagekit.io/do + # + # @param font_outline [String] Sets the font outline of the subtitle text. + # + # @param font_shadow [String] Sets the font shadow for the subtitle text. + # + # @param font_size [Float] Sets the font size of subtitle text. + # + # @param typography [Symbol, Imagekit::Models::SubtitleOverlayTransformation::Typography] Sets the typography style of the subtitle text. Supports values are `b` for bold + + # Sets the typography style of the subtitle text. Supports values are `b` for + # bold, `i` for italics, and `b_i` for bold with italics. + # + # [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + # + # @see Imagekit::Models::SubtitleOverlayTransformation#typography + module Typography + extend Imagekit::Internal::Type::Enum + + B = :b + I = :i + B_I = :b_i + + # @!method self.values + # @return [Array] + end + end + end +end diff --git a/lib/imagekit/models/text_overlay.rb b/lib/imagekit/models/text_overlay.rb new file mode 100644 index 00000000..523cf4ff --- /dev/null +++ b/lib/imagekit/models/text_overlay.rb @@ -0,0 +1,64 @@ +# frozen_string_literal: true + +module Imagekit + module Models + class TextOverlay < Imagekit::Models::BaseOverlay + # @!attribute text + # Specifies the text to be displayed in the overlay. The SDK automatically handles + # special characters and encoding. + # + # @return [String] + required :text, String + + # @!attribute type + # + # @return [Symbol, :text] + required :type, const: :text + + # @!attribute encoding + # Text can be included in the layer as either `i-{input}` (plain text) or + # `ie-{base64_encoded_input}` (base64). By default, the SDK selects the + # appropriate format based on the input text. To always use base64 + # (`ie-{base64}`), set this parameter to `base64`. To always use plain text + # (`i-{input}`), set it to `plain`. + # + # @return [Symbol, Imagekit::Models::TextOverlay::Encoding, nil] + optional :encoding, enum: -> { Imagekit::TextOverlay::Encoding } + + # @!attribute transformation + # Control styling of the text overlay. See + # [Text overlays](https://imagekit.io/docs/add-overlays-on-images#text-overlay). + # + # @return [Array, nil] + optional :transformation, -> { Imagekit::Internal::Type::ArrayOf[Imagekit::TextOverlayTransformation] } + + # @!method initialize(text:, encoding: nil, transformation: nil, type: :text) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::TextOverlay} for more details. + # + # @param text [String] Specifies the text to be displayed in the overlay. The SDK automatically handles + # + # @param encoding [Symbol, Imagekit::Models::TextOverlay::Encoding] Text can be included in the layer as either `i-{input}` (plain text) or `ie-{bas + # + # @param transformation [Array] Control styling of the text overlay. See [Text overlays](https://imagekit.io/doc + # + # @param type [Symbol, :text] + + # Text can be included in the layer as either `i-{input}` (plain text) or + # `ie-{base64_encoded_input}` (base64). By default, the SDK selects the + # appropriate format based on the input text. To always use base64 + # (`ie-{base64}`), set this parameter to `base64`. To always use plain text + # (`i-{input}`), set it to `plain`. + module Encoding + extend Imagekit::Internal::Type::Enum + + AUTO = :auto + PLAIN = :plain + BASE64 = :base64 + + # @!method self.values + # @return [Array] + end + end + end +end diff --git a/lib/imagekit/models/text_overlay_transformation.rb b/lib/imagekit/models/text_overlay_transformation.rb new file mode 100644 index 00000000..710ad972 --- /dev/null +++ b/lib/imagekit/models/text_overlay_transformation.rb @@ -0,0 +1,267 @@ +# frozen_string_literal: true + +module Imagekit + module Models + class TextOverlayTransformation < Imagekit::Internal::Type::BaseModel + # @!attribute alpha + # Specifies the transparency level of the text overlay. Accepts integers from `1` + # to `9`. + # + # @return [Float, nil] + optional :alpha, Float + + # @!attribute background + # Specifies the background color of the text overlay. Accepts an RGB hex code, an + # RGBA code, or a color name. + # + # @return [String, nil] + optional :background, String + + # @!attribute flip + # Flip the text overlay horizontally, vertically, or both. + # + # @return [Symbol, Imagekit::Models::TextOverlayTransformation::Flip, nil] + optional :flip, enum: -> { Imagekit::TextOverlayTransformation::Flip } + + # @!attribute font_color + # Specifies the font color of the overlaid text. Accepts an RGB hex code (e.g., + # `FF0000`), an RGBA code (e.g., `FFAABB50`), or a color name. + # + # @return [String, nil] + optional :font_color, String, api_name: :fontColor + + # @!attribute font_family + # Specifies the font family of the overlaid text. Choose from the supported fonts + # list or use a custom font. See + # [Supported fonts](https://imagekit.io/docs/add-overlays-on-images#supported-text-font-list) + # and + # [Custom font](https://imagekit.io/docs/add-overlays-on-images#change-font-family-in-text-overlay). + # + # @return [String, nil] + optional :font_family, String, api_name: :fontFamily + + # @!attribute font_size + # Specifies the font size of the overlaid text. Accepts a numeric value or an + # arithmetic expression. + # + # @return [Float, String, nil] + optional :font_size, union: -> { Imagekit::TextOverlayTransformation::FontSize }, api_name: :fontSize + + # @!attribute inner_alignment + # Specifies the inner alignment of the text when width is more than the text + # length. + # + # @return [Symbol, Imagekit::Models::TextOverlayTransformation::InnerAlignment, nil] + optional :inner_alignment, + enum: -> { Imagekit::TextOverlayTransformation::InnerAlignment }, + api_name: :innerAlignment + + # @!attribute line_height + # Specifies the line height of the text overlay. Accepts integer values + # representing line height in points. It can also accept + # [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations) + # such as `bw_mul_0.2`, or `bh_div_20`. + # + # @return [Float, String, nil] + optional :line_height, + union: -> { Imagekit::TextOverlayTransformation::LineHeight }, + api_name: :lineHeight + + # @!attribute padding + # Specifies the padding around the overlaid text. Can be provided as a single + # positive integer or multiple values separated by underscores (following CSS + # shorthand order). Arithmetic expressions are also accepted. + # + # @return [Float, String, nil] + optional :padding, union: -> { Imagekit::TextOverlayTransformation::Padding } + + # @!attribute radius + # Specifies the corner radius of the text overlay. Set to `max` to achieve a + # circular or oval shape. + # + # @return [Float, Symbol, :max, nil] + optional :radius, union: -> { Imagekit::TextOverlayTransformation::Radius } + + # @!attribute rotation + # Specifies the rotation angle of the text overlay. Accepts a numeric value for + # clockwise rotation or a string prefixed with "N" for counter-clockwise rotation. + # + # @return [Float, String, nil] + optional :rotation, union: -> { Imagekit::TextOverlayTransformation::Rotation } + + # @!attribute typography + # Specifies the typography style of the text. Supported values: + # + # - Single styles: `b` (bold), `i` (italic), `strikethrough`. + # - Combinations: Any combination separated by underscores, e.g., `b_i`, + # `b_i_strikethrough`. + # + # @return [String, nil] + optional :typography, String + + # @!attribute width + # Specifies the maximum width (in pixels) of the overlaid text. The text wraps + # automatically, and arithmetic expressions (e.g., `bw_mul_0.2` or `bh_div_2`) are + # supported. Useful when used in conjunction with the `background`. Learn about + # [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + # + # @return [Float, String, nil] + optional :width, union: -> { Imagekit::TextOverlayTransformation::Width } + + # @!method initialize(alpha: nil, background: nil, flip: nil, font_color: nil, font_family: nil, font_size: nil, inner_alignment: nil, line_height: nil, padding: nil, radius: nil, rotation: nil, typography: nil, width: nil) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::TextOverlayTransformation} for more details. + # + # @param alpha [Float] Specifies the transparency level of the text overlay. Accepts integers from `1` + # + # @param background [String] Specifies the background color of the text overlay. + # + # @param flip [Symbol, Imagekit::Models::TextOverlayTransformation::Flip] Flip the text overlay horizontally, vertically, or both. + # + # @param font_color [String] Specifies the font color of the overlaid text. Accepts an RGB hex code (e.g., `F + # + # @param font_family [String] Specifies the font family of the overlaid text. Choose from the supported fonts + # + # @param font_size [Float, String] Specifies the font size of the overlaid text. Accepts a numeric value or an arit + # + # @param inner_alignment [Symbol, Imagekit::Models::TextOverlayTransformation::InnerAlignment] Specifies the inner alignment of the text when width is more than the text lengt + # + # @param line_height [Float, String] Specifies the line height of the text overlay. + # + # @param padding [Float, String] Specifies the padding around the overlaid text. + # + # @param radius [Float, Symbol, :max] Specifies the corner radius of the text overlay. + # + # @param rotation [Float, String] Specifies the rotation angle of the text overlay. + # + # @param typography [String] Specifies the typography style of the text. + # + # @param width [Float, String] Specifies the maximum width (in pixels) of the overlaid text. The text wraps aut + + # Flip the text overlay horizontally, vertically, or both. + # + # @see Imagekit::Models::TextOverlayTransformation#flip + module Flip + extend Imagekit::Internal::Type::Enum + + H = :h + V = :v + H_V = :h_v + V_H = :v_h + + # @!method self.values + # @return [Array] + end + + # Specifies the font size of the overlaid text. Accepts a numeric value or an + # arithmetic expression. + # + # @see Imagekit::Models::TextOverlayTransformation#font_size + module FontSize + extend Imagekit::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + end + + # Specifies the inner alignment of the text when width is more than the text + # length. + # + # @see Imagekit::Models::TextOverlayTransformation#inner_alignment + module InnerAlignment + extend Imagekit::Internal::Type::Enum + + LEFT = :left + RIGHT = :right + CENTER = :center + + # @!method self.values + # @return [Array] + end + + # Specifies the line height of the text overlay. Accepts integer values + # representing line height in points. It can also accept + # [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations) + # such as `bw_mul_0.2`, or `bh_div_20`. + # + # @see Imagekit::Models::TextOverlayTransformation#line_height + module LineHeight + extend Imagekit::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + end + + # Specifies the padding around the overlaid text. Can be provided as a single + # positive integer or multiple values separated by underscores (following CSS + # shorthand order). Arithmetic expressions are also accepted. + # + # @see Imagekit::Models::TextOverlayTransformation#padding + module Padding + extend Imagekit::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + end + + # Specifies the corner radius of the text overlay. Set to `max` to achieve a + # circular or oval shape. + # + # @see Imagekit::Models::TextOverlayTransformation#radius + module Radius + extend Imagekit::Internal::Type::Union + + variant Float + + variant const: :max + + # @!method self.variants + # @return [Array(Float, Symbol, :max)] + end + + # Specifies the rotation angle of the text overlay. Accepts a numeric value for + # clockwise rotation or a string prefixed with "N" for counter-clockwise rotation. + # + # @see Imagekit::Models::TextOverlayTransformation#rotation + module Rotation + extend Imagekit::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + end + + # Specifies the maximum width (in pixels) of the overlaid text. The text wraps + # automatically, and arithmetic expressions (e.g., `bw_mul_0.2` or `bh_div_2`) are + # supported. Useful when used in conjunction with the `background`. Learn about + # [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + # + # @see Imagekit::Models::TextOverlayTransformation#width + module Width + extend Imagekit::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + end + end + end +end diff --git a/lib/imagekit/models/transformation.rb b/lib/imagekit/models/transformation.rb new file mode 100644 index 00000000..cd72bdb1 --- /dev/null +++ b/lib/imagekit/models/transformation.rb @@ -0,0 +1,1096 @@ +# frozen_string_literal: true + +module Imagekit + module Models + class Transformation < Imagekit::Internal::Type::BaseModel + # @!attribute ai_change_background + # Uses AI to change the background. Provide a text prompt or a base64-encoded + # prompt, e.g., `prompt-snow road` or `prompte-[urlencoded_base64_encoded_text]`. + # Not supported inside overlay. See + # [AI Change Background](https://imagekit.io/docs/ai-transformations#change-background-e-changebg). + # + # @return [String, nil] + optional :ai_change_background, String, api_name: :aiChangeBackground + + # @!attribute ai_drop_shadow + # Adds an AI-based drop shadow around a foreground object on a transparent or + # removed background. Optionally, control the direction, elevation, and saturation + # of the light source (e.g., `az-45` to change light direction). Pass `true` for + # the default drop shadow, or provide a string for a custom drop shadow. Supported + # inside overlay. See + # [AI Drop Shadow](https://imagekit.io/docs/ai-transformations#ai-drop-shadow-e-dropshadow). + # + # @return [Boolean, true, String, nil] + optional :ai_drop_shadow, union: -> { Imagekit::Transformation::AIDropShadow }, api_name: :aiDropShadow + + # @!attribute ai_edit + # Uses AI to edit images based on a text prompt. Provide a text prompt or a + # base64-encoded prompt, e.g., `prompt-snow road` or + # `prompte-[urlencoded_base64_encoded_text]`. Not supported inside overlay. + # See [AI Edit](https://imagekit.io/docs/ai-transformations#edit-image-e-edit). + # + # @return [String, nil] + optional :ai_edit, String, api_name: :aiEdit + + # @!attribute ai_remove_background + # Applies ImageKit's in-house background removal. Supported inside overlay. See + # [AI Background Removal](https://imagekit.io/docs/ai-transformations#imagekit-background-removal-e-bgremove). + # + # @return [Boolean, Imagekit::Models::Transformation::AIRemoveBackground, nil] + optional :ai_remove_background, + enum: -> { Imagekit::Transformation::AIRemoveBackground }, + api_name: :aiRemoveBackground + + # @!attribute ai_remove_background_external + # Uses third-party background removal. Note: It is recommended to use + # aiRemoveBackground, ImageKit's in-house solution, which is more cost-effective. + # Supported inside overlay. See + # [External Background Removal](https://imagekit.io/docs/ai-transformations#background-removal-e-removedotbg). + # + # @return [Boolean, Imagekit::Models::Transformation::AIRemoveBackgroundExternal, nil] + optional :ai_remove_background_external, + enum: -> { Imagekit::Transformation::AIRemoveBackgroundExternal }, + api_name: :aiRemoveBackgroundExternal + + # @!attribute ai_retouch + # Performs AI-based retouching to improve faces or product shots. Not supported + # inside overlay. See + # [AI Retouch](https://imagekit.io/docs/ai-transformations#retouch-e-retouch). + # + # @return [Boolean, Imagekit::Models::Transformation::AIRetouch, nil] + optional :ai_retouch, enum: -> { Imagekit::Transformation::AIRetouch }, api_name: :aiRetouch + + # @!attribute ai_upscale + # Upscales images beyond their original dimensions using AI. Not supported inside + # overlay. See + # [AI Upscale](https://imagekit.io/docs/ai-transformations#upscale-e-upscale). + # + # @return [Boolean, Imagekit::Models::Transformation::AIUpscale, nil] + optional :ai_upscale, enum: -> { Imagekit::Transformation::AIUpscale }, api_name: :aiUpscale + + # @!attribute ai_variation + # Generates a variation of an image using AI. This produces a new image with + # slight variations from the original, such as changes in color, texture, and + # other visual elements, while preserving the structure and essence of the + # original image. Not supported inside overlay. See + # [AI Generate Variations](https://imagekit.io/docs/ai-transformations#generate-variations-of-an-image-e-genvar). + # + # @return [Boolean, Imagekit::Models::Transformation::AIVariation, nil] + optional :ai_variation, enum: -> { Imagekit::Transformation::AIVariation }, api_name: :aiVariation + + # @!attribute aspect_ratio + # Specifies the aspect ratio for the output, e.g., "ar-4-3". Typically used with + # either width or height (but not both). For example: aspectRatio = `4:3`, `4_3`, + # or an expression like `iar_div_2`. See + # [Image resize and crop – Aspect ratio](https://imagekit.io/docs/image-resize-and-crop#aspect-ratio---ar). + # + # @return [Float, String, nil] + optional :aspect_ratio, union: -> { Imagekit::Transformation::AspectRatio }, api_name: :aspectRatio + + # @!attribute audio_codec + # Specifies the audio codec, e.g., `aac`, `opus`, or `none`. See + # [Audio codec](https://imagekit.io/docs/video-optimization#audio-codec---ac). + # + # @return [Symbol, Imagekit::Models::Transformation::AudioCodec, nil] + optional :audio_codec, enum: -> { Imagekit::Transformation::AudioCodec }, api_name: :audioCodec + + # @!attribute background + # Specifies the background to be used in conjunction with certain cropping + # strategies when resizing an image. + # + # - A solid color: e.g., `red`, `F3F3F3`, `AAFF0010`. See + # [Solid color background](https://imagekit.io/docs/effects-and-enhancements#solid-color-background). + # - A blurred background: e.g., `blurred`, `blurred_25_N15`, etc. See + # [Blurred background](https://imagekit.io/docs/effects-and-enhancements#blurred-background). + # - Expand the image boundaries using generative fill: `genfill`. Not supported + # inside overlay. Optionally, control the background scene by passing a text + # prompt: `genfill[:-prompt-${text}]` or + # `genfill[:-prompte-${urlencoded_base64_encoded_text}]`. See + # [Generative fill background](https://imagekit.io/docs/ai-transformations#generative-fill-bg-genfill). + # + # @return [String, nil] + optional :background, String + + # @!attribute blur + # Specifies the Gaussian blur level. Accepts an integer value between 1 and 100, + # or an expression like `bl-10`. See + # [Blur](https://imagekit.io/docs/effects-and-enhancements#blur---bl). + # + # @return [Float, nil] + optional :blur, Float + + # @!attribute border + # Adds a border to the output media. Accepts a string in the format + # `_` (e.g., `5_FFF000` for a 5px yellow border), or an + # expression like `ih_div_20_FF00FF`. See + # [Border](https://imagekit.io/docs/effects-and-enhancements#border---b). + # + # @return [String, nil] + optional :border, String + + # @!attribute color_profile + # Indicates whether the output image should retain the original color profile. See + # [Color profile](https://imagekit.io/docs/image-optimization#color-profile---cp). + # + # @return [Boolean, nil] + optional :color_profile, Imagekit::Internal::Type::Boolean, api_name: :colorProfile + + # @!attribute contrast_stretch + # Automatically enhances the contrast of an image (contrast stretch). See + # [Contrast Stretch](https://imagekit.io/docs/effects-and-enhancements#contrast-stretch---e-contrast). + # + # @return [Boolean, Imagekit::Models::Transformation::ContrastStretch, nil] + optional :contrast_stretch, + enum: -> { Imagekit::Transformation::ContrastStretch }, + api_name: :contrastStretch + + # @!attribute crop + # Crop modes for image resizing. See + # [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). + # + # @return [Symbol, Imagekit::Models::Transformation::Crop, nil] + optional :crop, enum: -> { Imagekit::Transformation::Crop } + + # @!attribute crop_mode + # Additional crop modes for image resizing. See + # [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). + # + # @return [Symbol, Imagekit::Models::Transformation::CropMode, nil] + optional :crop_mode, enum: -> { Imagekit::Transformation::CropMode }, api_name: :cropMode + + # @!attribute default_image + # Specifies a fallback image if the resource is not found, e.g., a URL or file + # path. See + # [Default image](https://imagekit.io/docs/image-transformation#default-image---di). + # + # @return [String, nil] + optional :default_image, String, api_name: :defaultImage + + # @!attribute dpr + # Accepts values between 0.1 and 5, or `auto` for automatic device pixel ratio + # (DPR) calculation. See + # [DPR](https://imagekit.io/docs/image-resize-and-crop#dpr---dpr). + # + # @return [Float, nil] + optional :dpr, Float + + # @!attribute duration + # Specifies the duration (in seconds) for trimming videos, e.g., `5` or `10.5`. + # Typically used with startOffset to indicate the length from the start offset. + # Arithmetic expressions are supported. See + # [Trim videos – Duration](https://imagekit.io/docs/trim-videos#duration---du). + # + # @return [Float, String, nil] + optional :duration, union: -> { Imagekit::Transformation::Duration } + + # @!attribute end_offset + # Specifies the end offset (in seconds) for trimming videos, e.g., `5` or `10.5`. + # Typically used with startOffset to define a time window. Arithmetic expressions + # are supported. See + # [Trim videos – End offset](https://imagekit.io/docs/trim-videos#end-offset---eo). + # + # @return [Float, String, nil] + optional :end_offset, union: -> { Imagekit::Transformation::EndOffset }, api_name: :endOffset + + # @!attribute flip + # Flips or mirrors an image either horizontally, vertically, or both. Acceptable + # values: `h` (horizontal), `v` (vertical), `h_v` (horizontal and vertical), or + # `v_h`. See [Flip](https://imagekit.io/docs/effects-and-enhancements#flip---fl). + # + # @return [Symbol, Imagekit::Models::Transformation::Flip, nil] + optional :flip, enum: -> { Imagekit::Transformation::Flip } + + # @!attribute focus + # Refines padding and cropping behavior for pad resize, maintain ratio, and + # extract crop modes. Supports manual positions and coordinate-based focus. With + # AI-based cropping, you can automatically keep key subjects in frame—such as + # faces or detected objects (e.g., `fo-face`, `fo-person`, `fo-car`)— while + # resizing. + # + # - See [Focus](https://imagekit.io/docs/image-resize-and-crop#focus---fo). + # - [Object aware cropping](https://imagekit.io/docs/image-resize-and-crop#object-aware-cropping---fo-object-name) + # + # @return [String, nil] + optional :focus, String + + # @!attribute format_ + # Specifies the output format for images or videos, e.g., `jpg`, `png`, `webp`, + # `mp4`, or `auto`. You can also pass `orig` for images to return the original + # format. ImageKit automatically delivers images and videos in the optimal format + # based on device support unless overridden by the dashboard settings or the + # format parameter. See + # [Image format](https://imagekit.io/docs/image-optimization#format---f) and + # [Video format](https://imagekit.io/docs/video-optimization#format---f). + # + # @return [Symbol, Imagekit::Models::Transformation::Format, nil] + optional :format_, enum: -> { Imagekit::Transformation::Format }, api_name: :format + + # @!attribute gradient + # Creates a linear gradient with two colors. Pass `true` for a default gradient, + # or provide a string for a custom gradient. See + # [Gradient](https://imagekit.io/docs/effects-and-enhancements#gradient---e-gradient). + # + # @return [Boolean, true, String, nil] + optional :gradient, union: -> { Imagekit::Transformation::Gradient } + + # @!attribute grayscale + # Enables a grayscale effect for images. See + # [Grayscale](https://imagekit.io/docs/effects-and-enhancements#grayscale---e-grayscale). + # + # @return [Boolean, Imagekit::Models::Transformation::Grayscale, nil] + optional :grayscale, enum: -> { Imagekit::Transformation::Grayscale } + + # @!attribute height + # Specifies the height of the output. If a value between 0 and 1 is provided, it + # is treated as a percentage (e.g., `0.5` represents 50% of the original height). + # You can also supply arithmetic expressions (e.g., `ih_mul_0.5`). Height + # transformation – + # [Images](https://imagekit.io/docs/image-resize-and-crop#height---h) · + # [Videos](https://imagekit.io/docs/video-resize-and-crop#height---h) + # + # @return [Float, String, nil] + optional :height, union: -> { Imagekit::Transformation::Height } + + # @!attribute lossless + # Specifies whether the output image (in JPEG or PNG) should be compressed + # losslessly. See + # [Lossless compression](https://imagekit.io/docs/image-optimization#lossless-webp-and-png---lo). + # + # @return [Boolean, nil] + optional :lossless, Imagekit::Internal::Type::Boolean + + # @!attribute metadata + # By default, ImageKit removes all metadata during automatic image compression. + # Set this to true to preserve metadata. See + # [Image metadata](https://imagekit.io/docs/image-optimization#image-metadata---md). + # + # @return [Boolean, nil] + optional :metadata, Imagekit::Internal::Type::Boolean + + # @!attribute named + # Named transformation reference. See + # [Named transformations](https://imagekit.io/docs/transformations#named-transformations). + # + # @return [String, nil] + optional :named, String + + # @!attribute opacity + # Specifies the opacity level of the output image. See + # [Opacity](https://imagekit.io/docs/effects-and-enhancements#opacity---o). + # + # @return [Float, nil] + optional :opacity, Float + + # @!attribute original + # If set to true, serves the original file without applying any transformations. + # See + # [Deliver original file as-is](https://imagekit.io/docs/core-delivery-features#deliver-original-file-as-is---orig-true). + # + # @return [Boolean, nil] + optional :original, Imagekit::Internal::Type::Boolean + + # @!attribute overlay + # Specifies an overlay to be applied on the parent image or video. ImageKit + # supports overlays including images, text, videos, subtitles, and solid colors. + # See + # [Overlay using layers](https://imagekit.io/docs/transformations#overlay-using-layers). + # + # @return [Imagekit::Models::Overlay, nil] + optional :overlay, union: -> { Imagekit::Overlay } + + # @!attribute page + # Extracts a specific page or frame from multi-page or layered files (PDF, PSD, + # AI). For example, specify by number (e.g., `2`), a range (e.g., `3-4` for the + # 2nd and 3rd layers), or by name (e.g., `name-layer-4` for a PSD layer). See + # [Thumbnail extraction](https://imagekit.io/docs/vector-and-animated-images#get-thumbnail-from-psd-pdf-ai-eps-and-animated-files). + # + # @return [Float, String, nil] + optional :page, union: -> { Imagekit::Transformation::Page } + + # @!attribute progressive + # Specifies whether the output JPEG image should be rendered progressively. + # Progressive loading begins with a low-quality, pixelated version of the full + # image, which gradually improves to provide a faster perceived load time. See + # [Progressive images](https://imagekit.io/docs/image-optimization#progressive-image---pr). + # + # @return [Boolean, nil] + optional :progressive, Imagekit::Internal::Type::Boolean + + # @!attribute quality + # Specifies the quality of the output image for lossy formats such as JPEG, WebP, + # and AVIF. A higher quality value results in a larger file size with better + # quality, while a lower value produces a smaller file size with reduced quality. + # See [Quality](https://imagekit.io/docs/image-optimization#quality---q). + # + # @return [Float, nil] + optional :quality, Float + + # @!attribute radius + # Specifies the corner radius for rounded corners (e.g., 20) or `max` for circular + # or oval shape. See + # [Radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). + # + # @return [Float, Symbol, :max, nil] + optional :radius, union: -> { Imagekit::Transformation::Radius } + + # @!attribute raw + # Pass any transformation not directly supported by the SDK. This transformation + # string is appended to the URL as provided. + # + # @return [String, nil] + optional :raw, String + + # @!attribute rotation + # Specifies the rotation angle in degrees. Positive values rotate the image + # clockwise; you can also use, for example, `N40` for counterclockwise rotation or + # `auto` to use the orientation specified in the image's EXIF data. For videos, + # only the following values are supported: 0, 90, 180, 270, or 360. See + # [Rotate](https://imagekit.io/docs/effects-and-enhancements#rotate---rt). + # + # @return [Float, String, nil] + optional :rotation, union: -> { Imagekit::Transformation::Rotation } + + # @!attribute shadow + # Adds a shadow beneath solid objects in an image with a transparent background. + # For AI-based drop shadows, refer to aiDropShadow. Pass `true` for a default + # shadow, or provide a string for a custom shadow. See + # [Shadow](https://imagekit.io/docs/effects-and-enhancements#shadow---e-shadow). + # + # @return [Boolean, true, String, nil] + optional :shadow, union: -> { Imagekit::Transformation::Shadow } + + # @!attribute sharpen + # Sharpens the input image, highlighting edges and finer details. Pass `true` for + # default sharpening, or provide a numeric value for custom sharpening. See + # [Sharpen](https://imagekit.io/docs/effects-and-enhancements#sharpen---e-sharpen). + # + # @return [Boolean, true, Float, nil] + optional :sharpen, union: -> { Imagekit::Transformation::Sharpen } + + # @!attribute start_offset + # Specifies the start offset (in seconds) for trimming videos, e.g., `5` or + # `10.5`. Arithmetic expressions are also supported. See + # [Trim videos – Start offset](https://imagekit.io/docs/trim-videos#start-offset---so). + # + # @return [Float, String, nil] + optional :start_offset, union: -> { Imagekit::Transformation::StartOffset }, api_name: :startOffset + + # @!attribute streaming_resolutions + # An array of resolutions for adaptive bitrate streaming, e.g., [`240`, `360`, + # `480`, `720`, `1080`]. See + # [Adaptive Bitrate Streaming](https://imagekit.io/docs/adaptive-bitrate-streaming). + # + # @return [Array, nil] + optional :streaming_resolutions, + -> { Imagekit::Internal::Type::ArrayOf[enum: Imagekit::StreamingResolution] }, + api_name: :streamingResolutions + + # @!attribute trim + # Useful for images with a solid or nearly solid background and a central object. + # This parameter trims the background, leaving only the central object in the + # output image. See + # [Trim edges](https://imagekit.io/docs/effects-and-enhancements#trim-edges---t). + # + # @return [Boolean, true, Float, nil] + optional :trim, union: -> { Imagekit::Transformation::Trim } + + # @!attribute unsharp_mask + # Applies Unsharp Masking (USM), an image sharpening technique. Pass `true` for a + # default unsharp mask, or provide a string for a custom unsharp mask. See + # [Unsharp Mask](https://imagekit.io/docs/effects-and-enhancements#unsharp-mask---e-usm). + # + # @return [Boolean, true, String, nil] + optional :unsharp_mask, union: -> { Imagekit::Transformation::UnsharpMask }, api_name: :unsharpMask + + # @!attribute video_codec + # Specifies the video codec, e.g., `h264`, `vp9`, `av1`, or `none`. See + # [Video codec](https://imagekit.io/docs/video-optimization#video-codec---vc). + # + # @return [Symbol, Imagekit::Models::Transformation::VideoCodec, nil] + optional :video_codec, enum: -> { Imagekit::Transformation::VideoCodec }, api_name: :videoCodec + + # @!attribute width + # Specifies the width of the output. If a value between 0 and 1 is provided, it is + # treated as a percentage (e.g., `0.4` represents 40% of the original width). You + # can also supply arithmetic expressions (e.g., `iw_div_2`). Width transformation + # – [Images](https://imagekit.io/docs/image-resize-and-crop#width---w) · + # [Videos](https://imagekit.io/docs/video-resize-and-crop#width---w) + # + # @return [Float, String, nil] + optional :width, union: -> { Imagekit::Transformation::Width } + + # @!attribute x + # Focus using cropped image coordinates - X coordinate. See + # [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). + # + # @return [Float, String, nil] + optional :x, union: -> { Imagekit::Transformation::X } + + # @!attribute x_center + # Focus using cropped image coordinates - X center coordinate. See + # [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). + # + # @return [Float, String, nil] + optional :x_center, union: -> { Imagekit::Transformation::XCenter }, api_name: :xCenter + + # @!attribute y_ + # Focus using cropped image coordinates - Y coordinate. See + # [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). + # + # @return [Float, String, nil] + optional :y_, union: -> { Imagekit::Transformation::Y }, api_name: :y + + # @!attribute y_center + # Focus using cropped image coordinates - Y center coordinate. See + # [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). + # + # @return [Float, String, nil] + optional :y_center, union: -> { Imagekit::Transformation::YCenter }, api_name: :yCenter + + # @!attribute zoom + # Accepts a numeric value that determines how much to zoom in or out of the + # cropped area. It should be used in conjunction with fo-face or fo-. + # See [Zoom](https://imagekit.io/docs/image-resize-and-crop#zoom---z). + # + # @return [Float, nil] + optional :zoom, Float + + # @!method initialize(ai_change_background: nil, ai_drop_shadow: nil, ai_edit: nil, ai_remove_background: nil, ai_remove_background_external: nil, ai_retouch: nil, ai_upscale: nil, ai_variation: nil, aspect_ratio: nil, audio_codec: nil, background: nil, blur: nil, border: nil, color_profile: nil, contrast_stretch: nil, crop: nil, crop_mode: nil, default_image: nil, dpr: nil, duration: nil, end_offset: nil, flip: nil, focus: nil, format_: nil, gradient: nil, grayscale: nil, height: nil, lossless: nil, metadata: nil, named: nil, opacity: nil, original: nil, overlay: nil, page: nil, progressive: nil, quality: nil, radius: nil, raw: nil, rotation: nil, shadow: nil, sharpen: nil, start_offset: nil, streaming_resolutions: nil, trim: nil, unsharp_mask: nil, video_codec: nil, width: nil, x: nil, x_center: nil, y_: nil, y_center: nil, zoom: nil) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Transformation} for more details. + # + # The SDK provides easy-to-use names for transformations. These names are + # converted to the corresponding transformation string before being added to the + # URL. SDKs are updated regularly to support new transformations. If you want to + # use a transformation that is not supported by the SDK, You can use the `raw` + # parameter to pass the transformation string directly. See the + # [Transformations documentation](https://imagekit.io/docs/transformations). + # + # @param ai_change_background [String] Uses AI to change the background. Provide a text prompt or a base64-encoded prom + # + # @param ai_drop_shadow [Boolean, true, String] Adds an AI-based drop shadow around a foreground object on a transparent or remo + # + # @param ai_edit [String] Uses AI to edit images based on a text prompt. Provide a text prompt or a base64 + # + # @param ai_remove_background [Boolean, Imagekit::Models::Transformation::AIRemoveBackground] Applies ImageKit's in-house background removal. + # + # @param ai_remove_background_external [Boolean, Imagekit::Models::Transformation::AIRemoveBackgroundExternal] Uses third-party background removal. + # + # @param ai_retouch [Boolean, Imagekit::Models::Transformation::AIRetouch] Performs AI-based retouching to improve faces or product shots. Not supported in + # + # @param ai_upscale [Boolean, Imagekit::Models::Transformation::AIUpscale] Upscales images beyond their original dimensions using AI. Not supported inside + # + # @param ai_variation [Boolean, Imagekit::Models::Transformation::AIVariation] Generates a variation of an image using AI. This produces a new image with sligh + # + # @param aspect_ratio [Float, String] Specifies the aspect ratio for the output, e.g., "ar-4-3". Typically used with e + # + # @param audio_codec [Symbol, Imagekit::Models::Transformation::AudioCodec] Specifies the audio codec, e.g., `aac`, `opus`, or `none`. See [Audio codec](htt + # + # @param background [String] Specifies the background to be used in conjunction with certain cropping strateg + # + # @param blur [Float] Specifies the Gaussian blur level. Accepts an integer value between 1 and 100, o + # + # @param border [String] Adds a border to the output media. Accepts a string in the format `] An array of resolutions for adaptive bitrate streaming, e.g., [`240`, `360`, `48 + # + # @param trim [Boolean, true, Float] Useful for images with a solid or nearly solid background and a central object. + # + # @param unsharp_mask [Boolean, true, String] Applies Unsharp Masking (USM), an image sharpening technique. + # + # @param video_codec [Symbol, Imagekit::Models::Transformation::VideoCodec] Specifies the video codec, e.g., `h264`, `vp9`, `av1`, or `none`. See [Video cod + # + # @param width [Float, String] Specifies the width of the output. If a value between 0 and 1 is provided, it is + # + # @param x [Float, String] Focus using cropped image coordinates - X coordinate. See [Focus using cropped c + # + # @param x_center [Float, String] Focus using cropped image coordinates - X center coordinate. See [Focus using cr + # + # @param y_ [Float, String] Focus using cropped image coordinates - Y coordinate. See [Focus using cropped c + # + # @param y_center [Float, String] Focus using cropped image coordinates - Y center coordinate. See [Focus using cr + # + # @param zoom [Float] Accepts a numeric value that determines how much to zoom in or out of the croppe + + # Adds an AI-based drop shadow around a foreground object on a transparent or + # removed background. Optionally, control the direction, elevation, and saturation + # of the light source (e.g., `az-45` to change light direction). Pass `true` for + # the default drop shadow, or provide a string for a custom drop shadow. Supported + # inside overlay. See + # [AI Drop Shadow](https://imagekit.io/docs/ai-transformations#ai-drop-shadow-e-dropshadow). + # + # @see Imagekit::Models::Transformation#ai_drop_shadow + module AIDropShadow + extend Imagekit::Internal::Type::Union + + variant const: true + + variant String + + # @!method self.variants + # @return [Array(Boolean, true, String)] + end + + # Applies ImageKit's in-house background removal. Supported inside overlay. See + # [AI Background Removal](https://imagekit.io/docs/ai-transformations#imagekit-background-removal-e-bgremove). + # + # @see Imagekit::Models::Transformation#ai_remove_background + module AIRemoveBackground + extend Imagekit::Internal::Type::Enum + + TRUE = true + + # @!method self.values + # @return [Array] + end + + # Uses third-party background removal. Note: It is recommended to use + # aiRemoveBackground, ImageKit's in-house solution, which is more cost-effective. + # Supported inside overlay. See + # [External Background Removal](https://imagekit.io/docs/ai-transformations#background-removal-e-removedotbg). + # + # @see Imagekit::Models::Transformation#ai_remove_background_external + module AIRemoveBackgroundExternal + extend Imagekit::Internal::Type::Enum + + TRUE = true + + # @!method self.values + # @return [Array] + end + + # Performs AI-based retouching to improve faces or product shots. Not supported + # inside overlay. See + # [AI Retouch](https://imagekit.io/docs/ai-transformations#retouch-e-retouch). + # + # @see Imagekit::Models::Transformation#ai_retouch + module AIRetouch + extend Imagekit::Internal::Type::Enum + + TRUE = true + + # @!method self.values + # @return [Array] + end + + # Upscales images beyond their original dimensions using AI. Not supported inside + # overlay. See + # [AI Upscale](https://imagekit.io/docs/ai-transformations#upscale-e-upscale). + # + # @see Imagekit::Models::Transformation#ai_upscale + module AIUpscale + extend Imagekit::Internal::Type::Enum + + TRUE = true + + # @!method self.values + # @return [Array] + end + + # Generates a variation of an image using AI. This produces a new image with + # slight variations from the original, such as changes in color, texture, and + # other visual elements, while preserving the structure and essence of the + # original image. Not supported inside overlay. See + # [AI Generate Variations](https://imagekit.io/docs/ai-transformations#generate-variations-of-an-image-e-genvar). + # + # @see Imagekit::Models::Transformation#ai_variation + module AIVariation + extend Imagekit::Internal::Type::Enum + + TRUE = true + + # @!method self.values + # @return [Array] + end + + # Specifies the aspect ratio for the output, e.g., "ar-4-3". Typically used with + # either width or height (but not both). For example: aspectRatio = `4:3`, `4_3`, + # or an expression like `iar_div_2`. See + # [Image resize and crop – Aspect ratio](https://imagekit.io/docs/image-resize-and-crop#aspect-ratio---ar). + # + # @see Imagekit::Models::Transformation#aspect_ratio + module AspectRatio + extend Imagekit::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + end + + # Specifies the audio codec, e.g., `aac`, `opus`, or `none`. See + # [Audio codec](https://imagekit.io/docs/video-optimization#audio-codec---ac). + # + # @see Imagekit::Models::Transformation#audio_codec + module AudioCodec + extend Imagekit::Internal::Type::Enum + + AAC = :aac + OPUS = :opus + NONE = :none + + # @!method self.values + # @return [Array] + end + + # Automatically enhances the contrast of an image (contrast stretch). See + # [Contrast Stretch](https://imagekit.io/docs/effects-and-enhancements#contrast-stretch---e-contrast). + # + # @see Imagekit::Models::Transformation#contrast_stretch + module ContrastStretch + extend Imagekit::Internal::Type::Enum + + TRUE = true + + # @!method self.values + # @return [Array] + end + + # Crop modes for image resizing. See + # [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). + # + # @see Imagekit::Models::Transformation#crop + module Crop + extend Imagekit::Internal::Type::Enum + + FORCE = :force + AT_MAX = :at_max + AT_MAX_ENLARGE = :at_max_enlarge + AT_LEAST = :at_least + MAINTAIN_RATIO = :maintain_ratio + + # @!method self.values + # @return [Array] + end + + # Additional crop modes for image resizing. See + # [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). + # + # @see Imagekit::Models::Transformation#crop_mode + module CropMode + extend Imagekit::Internal::Type::Enum + + PAD_RESIZE = :pad_resize + EXTRACT = :extract + PAD_EXTRACT = :pad_extract + + # @!method self.values + # @return [Array] + end + + # Specifies the duration (in seconds) for trimming videos, e.g., `5` or `10.5`. + # Typically used with startOffset to indicate the length from the start offset. + # Arithmetic expressions are supported. See + # [Trim videos – Duration](https://imagekit.io/docs/trim-videos#duration---du). + # + # @see Imagekit::Models::Transformation#duration + module Duration + extend Imagekit::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + end + + # Specifies the end offset (in seconds) for trimming videos, e.g., `5` or `10.5`. + # Typically used with startOffset to define a time window. Arithmetic expressions + # are supported. See + # [Trim videos – End offset](https://imagekit.io/docs/trim-videos#end-offset---eo). + # + # @see Imagekit::Models::Transformation#end_offset + module EndOffset + extend Imagekit::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + end + + # Flips or mirrors an image either horizontally, vertically, or both. Acceptable + # values: `h` (horizontal), `v` (vertical), `h_v` (horizontal and vertical), or + # `v_h`. See [Flip](https://imagekit.io/docs/effects-and-enhancements#flip---fl). + # + # @see Imagekit::Models::Transformation#flip + module Flip + extend Imagekit::Internal::Type::Enum + + H = :h + V = :v + H_V = :h_v + V_H = :v_h + + # @!method self.values + # @return [Array] + end + + # Specifies the output format for images or videos, e.g., `jpg`, `png`, `webp`, + # `mp4`, or `auto`. You can also pass `orig` for images to return the original + # format. ImageKit automatically delivers images and videos in the optimal format + # based on device support unless overridden by the dashboard settings or the + # format parameter. See + # [Image format](https://imagekit.io/docs/image-optimization#format---f) and + # [Video format](https://imagekit.io/docs/video-optimization#format---f). + # + # @see Imagekit::Models::Transformation#format_ + module Format + extend Imagekit::Internal::Type::Enum + + AUTO = :auto + WEBP = :webp + JPG = :jpg + JPEG = :jpeg + PNG = :png + GIF = :gif + SVG = :svg + MP4 = :mp4 + WEBM = :webm + AVIF = :avif + ORIG = :orig + + # @!method self.values + # @return [Array] + end + + # Creates a linear gradient with two colors. Pass `true` for a default gradient, + # or provide a string for a custom gradient. See + # [Gradient](https://imagekit.io/docs/effects-and-enhancements#gradient---e-gradient). + # + # @see Imagekit::Models::Transformation#gradient + module Gradient + extend Imagekit::Internal::Type::Union + + variant const: true + + variant String + + # @!method self.variants + # @return [Array(Boolean, true, String)] + end + + # Enables a grayscale effect for images. See + # [Grayscale](https://imagekit.io/docs/effects-and-enhancements#grayscale---e-grayscale). + # + # @see Imagekit::Models::Transformation#grayscale + module Grayscale + extend Imagekit::Internal::Type::Enum + + TRUE = true + + # @!method self.values + # @return [Array] + end + + # Specifies the height of the output. If a value between 0 and 1 is provided, it + # is treated as a percentage (e.g., `0.5` represents 50% of the original height). + # You can also supply arithmetic expressions (e.g., `ih_mul_0.5`). Height + # transformation – + # [Images](https://imagekit.io/docs/image-resize-and-crop#height---h) · + # [Videos](https://imagekit.io/docs/video-resize-and-crop#height---h) + # + # @see Imagekit::Models::Transformation#height + module Height + extend Imagekit::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + end + + # Extracts a specific page or frame from multi-page or layered files (PDF, PSD, + # AI). For example, specify by number (e.g., `2`), a range (e.g., `3-4` for the + # 2nd and 3rd layers), or by name (e.g., `name-layer-4` for a PSD layer). See + # [Thumbnail extraction](https://imagekit.io/docs/vector-and-animated-images#get-thumbnail-from-psd-pdf-ai-eps-and-animated-files). + # + # @see Imagekit::Models::Transformation#page + module Page + extend Imagekit::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + end + + # Specifies the corner radius for rounded corners (e.g., 20) or `max` for circular + # or oval shape. See + # [Radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). + # + # @see Imagekit::Models::Transformation#radius + module Radius + extend Imagekit::Internal::Type::Union + + variant Float + + variant const: :max + + # @!method self.variants + # @return [Array(Float, Symbol, :max)] + end + + # Specifies the rotation angle in degrees. Positive values rotate the image + # clockwise; you can also use, for example, `N40` for counterclockwise rotation or + # `auto` to use the orientation specified in the image's EXIF data. For videos, + # only the following values are supported: 0, 90, 180, 270, or 360. See + # [Rotate](https://imagekit.io/docs/effects-and-enhancements#rotate---rt). + # + # @see Imagekit::Models::Transformation#rotation + module Rotation + extend Imagekit::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + end + + # Adds a shadow beneath solid objects in an image with a transparent background. + # For AI-based drop shadows, refer to aiDropShadow. Pass `true` for a default + # shadow, or provide a string for a custom shadow. See + # [Shadow](https://imagekit.io/docs/effects-and-enhancements#shadow---e-shadow). + # + # @see Imagekit::Models::Transformation#shadow + module Shadow + extend Imagekit::Internal::Type::Union + + variant const: true + + variant String + + # @!method self.variants + # @return [Array(Boolean, true, String)] + end + + # Sharpens the input image, highlighting edges and finer details. Pass `true` for + # default sharpening, or provide a numeric value for custom sharpening. See + # [Sharpen](https://imagekit.io/docs/effects-and-enhancements#sharpen---e-sharpen). + # + # @see Imagekit::Models::Transformation#sharpen + module Sharpen + extend Imagekit::Internal::Type::Union + + variant const: true + + variant Float + + # @!method self.variants + # @return [Array(Boolean, true, Float)] + end + + # Specifies the start offset (in seconds) for trimming videos, e.g., `5` or + # `10.5`. Arithmetic expressions are also supported. See + # [Trim videos – Start offset](https://imagekit.io/docs/trim-videos#start-offset---so). + # + # @see Imagekit::Models::Transformation#start_offset + module StartOffset + extend Imagekit::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + end + + # Useful for images with a solid or nearly solid background and a central object. + # This parameter trims the background, leaving only the central object in the + # output image. See + # [Trim edges](https://imagekit.io/docs/effects-and-enhancements#trim-edges---t). + # + # @see Imagekit::Models::Transformation#trim + module Trim + extend Imagekit::Internal::Type::Union + + variant const: true + + variant Float + + # @!method self.variants + # @return [Array(Boolean, true, Float)] + end + + # Applies Unsharp Masking (USM), an image sharpening technique. Pass `true` for a + # default unsharp mask, or provide a string for a custom unsharp mask. See + # [Unsharp Mask](https://imagekit.io/docs/effects-and-enhancements#unsharp-mask---e-usm). + # + # @see Imagekit::Models::Transformation#unsharp_mask + module UnsharpMask + extend Imagekit::Internal::Type::Union + + variant const: true + + variant String + + # @!method self.variants + # @return [Array(Boolean, true, String)] + end + + # Specifies the video codec, e.g., `h264`, `vp9`, `av1`, or `none`. See + # [Video codec](https://imagekit.io/docs/video-optimization#video-codec---vc). + # + # @see Imagekit::Models::Transformation#video_codec + module VideoCodec + extend Imagekit::Internal::Type::Enum + + H264 = :h264 + VP9 = :vp9 + AV1 = :av1 + NONE = :none + + # @!method self.values + # @return [Array] + end + + # Specifies the width of the output. If a value between 0 and 1 is provided, it is + # treated as a percentage (e.g., `0.4` represents 40% of the original width). You + # can also supply arithmetic expressions (e.g., `iw_div_2`). Width transformation + # – [Images](https://imagekit.io/docs/image-resize-and-crop#width---w) · + # [Videos](https://imagekit.io/docs/video-resize-and-crop#width---w) + # + # @see Imagekit::Models::Transformation#width + module Width + extend Imagekit::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + end + + # Focus using cropped image coordinates - X coordinate. See + # [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). + # + # @see Imagekit::Models::Transformation#x + module X + extend Imagekit::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + end + + # Focus using cropped image coordinates - X center coordinate. See + # [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). + # + # @see Imagekit::Models::Transformation#x_center + module XCenter + extend Imagekit::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + end + + # Focus using cropped image coordinates - Y coordinate. See + # [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). + # + # @see Imagekit::Models::Transformation#y_ + module Y + extend Imagekit::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + end + + # Focus using cropped image coordinates - Y center coordinate. See + # [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). + # + # @see Imagekit::Models::Transformation#y_center + module YCenter + extend Imagekit::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + end + end + end +end diff --git a/lib/imagekit/models/transformation_position.rb b/lib/imagekit/models/transformation_position.rb new file mode 100644 index 00000000..e2281215 --- /dev/null +++ b/lib/imagekit/models/transformation_position.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +module Imagekit + module Models + # By default, the transformation string is added as a query parameter in the URL, + # e.g., `?tr=w-100,h-100`. If you want to add the transformation string in the + # path of the URL, set this to `path`. Learn more in the + # [Transformations guide](https://imagekit.io/docs/transformations). + module TransformationPosition + extend Imagekit::Internal::Type::Enum + + PATH = :path + QUERY = :query + + # @!method self.values + # @return [Array] + end + end +end diff --git a/lib/imagekit/models/unsafe_unwrap_webhook_event.rb b/lib/imagekit/models/unsafe_unwrap_webhook_event.rb new file mode 100644 index 00000000..28e1b855 --- /dev/null +++ b/lib/imagekit/models/unsafe_unwrap_webhook_event.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +module Imagekit + module Models + # Triggered when a new video transformation request is accepted for processing. + # This event confirms that ImageKit has received and queued your transformation + # request. Use this for debugging and tracking transformation lifecycle. + module UnsafeUnwrapWebhookEvent + extend Imagekit::Internal::Type::Union + + # Triggered when a new video transformation request is accepted for processing. This event confirms that ImageKit has received and queued your transformation request. Use this for debugging and tracking transformation lifecycle. + variant -> { Imagekit::VideoTransformationAcceptedEvent } + + # Triggered when video encoding is finished and the transformed resource is ready to be served. This is the key event to listen for - update your database or CMS flags when you receive this so your application can start showing the transformed video to users. + variant -> { Imagekit::VideoTransformationReadyEvent } + + # Triggered when an error occurs during video encoding. Listen to this webhook to log error reasons and debug issues. Check your origin and URL endpoint settings if the reason is related to download failure. For other errors, contact ImageKit support. + variant -> { Imagekit::VideoTransformationErrorEvent } + + # Triggered when a pre-transformation completes successfully. The file has been processed with the requested transformation and is now available in the Media Library. + variant -> { Imagekit::UploadPreTransformSuccessEvent } + + # Triggered when a pre-transformation fails. The file upload may have been accepted, but the requested transformation could not be applied. + variant -> { Imagekit::UploadPreTransformErrorEvent } + + # Triggered when a post-transformation completes successfully. The transformed version of the file is now ready and can be accessed via the provided URL. Note that each post-transformation generates a separate webhook event. + variant -> { Imagekit::UploadPostTransformSuccessEvent } + + # Triggered when a post-transformation fails. The original file remains available, but the requested transformation could not be generated. + variant -> { Imagekit::UploadPostTransformErrorEvent } + + # @!method self.variants + # @return [Array(Imagekit::Models::VideoTransformationAcceptedEvent, Imagekit::Models::VideoTransformationReadyEvent, Imagekit::Models::VideoTransformationErrorEvent, Imagekit::Models::UploadPreTransformSuccessEvent, Imagekit::Models::UploadPreTransformErrorEvent, Imagekit::Models::UploadPostTransformSuccessEvent, Imagekit::Models::UploadPostTransformErrorEvent)] + end + end +end diff --git a/lib/imagekit/models/unwrap_webhook_event.rb b/lib/imagekit/models/unwrap_webhook_event.rb new file mode 100644 index 00000000..c200c085 --- /dev/null +++ b/lib/imagekit/models/unwrap_webhook_event.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +module Imagekit + module Models + # Triggered when a new video transformation request is accepted for processing. + # This event confirms that ImageKit has received and queued your transformation + # request. Use this for debugging and tracking transformation lifecycle. + module UnwrapWebhookEvent + extend Imagekit::Internal::Type::Union + + # Triggered when a new video transformation request is accepted for processing. This event confirms that ImageKit has received and queued your transformation request. Use this for debugging and tracking transformation lifecycle. + variant -> { Imagekit::VideoTransformationAcceptedEvent } + + # Triggered when video encoding is finished and the transformed resource is ready to be served. This is the key event to listen for - update your database or CMS flags when you receive this so your application can start showing the transformed video to users. + variant -> { Imagekit::VideoTransformationReadyEvent } + + # Triggered when an error occurs during video encoding. Listen to this webhook to log error reasons and debug issues. Check your origin and URL endpoint settings if the reason is related to download failure. For other errors, contact ImageKit support. + variant -> { Imagekit::VideoTransformationErrorEvent } + + # Triggered when a pre-transformation completes successfully. The file has been processed with the requested transformation and is now available in the Media Library. + variant -> { Imagekit::UploadPreTransformSuccessEvent } + + # Triggered when a pre-transformation fails. The file upload may have been accepted, but the requested transformation could not be applied. + variant -> { Imagekit::UploadPreTransformErrorEvent } + + # Triggered when a post-transformation completes successfully. The transformed version of the file is now ready and can be accessed via the provided URL. Note that each post-transformation generates a separate webhook event. + variant -> { Imagekit::UploadPostTransformSuccessEvent } + + # Triggered when a post-transformation fails. The original file remains available, but the requested transformation could not be generated. + variant -> { Imagekit::UploadPostTransformErrorEvent } + + # @!method self.variants + # @return [Array(Imagekit::Models::VideoTransformationAcceptedEvent, Imagekit::Models::VideoTransformationReadyEvent, Imagekit::Models::VideoTransformationErrorEvent, Imagekit::Models::UploadPreTransformSuccessEvent, Imagekit::Models::UploadPreTransformErrorEvent, Imagekit::Models::UploadPostTransformSuccessEvent, Imagekit::Models::UploadPostTransformErrorEvent)] + end + end +end diff --git a/lib/imagekit/models/update_file_request.rb b/lib/imagekit/models/update_file_request.rb new file mode 100644 index 00000000..08fcdd07 --- /dev/null +++ b/lib/imagekit/models/update_file_request.rb @@ -0,0 +1,163 @@ +# frozen_string_literal: true + +module Imagekit + module Models + # Schema for update file update request. + module UpdateFileRequest + extend Imagekit::Internal::Type::Union + + variant -> { Imagekit::UpdateFileRequest::UpdateFileDetails } + + variant -> { Imagekit::UpdateFileRequest::ChangePublicationStatus } + + class UpdateFileDetails < Imagekit::Internal::Type::BaseModel + # @!attribute custom_coordinates + # Define an important area in the image in the format `x,y,width,height` e.g. + # `10,10,100,100`. Send `null` to unset this value. + # + # @return [String, nil] + optional :custom_coordinates, String, api_name: :customCoordinates, nil?: true + + # @!attribute custom_metadata + # A key-value data to be associated with the asset. To unset a key, send `null` + # value for that key. Before setting any custom metadata on an asset you have to + # create the field using custom metadata fields API. + # + # @return [Hash{Symbol=>Object}, nil] + optional :custom_metadata, + Imagekit::Internal::Type::HashOf[Imagekit::Internal::Type::Unknown], + api_name: :customMetadata + + # @!attribute description + # Optional text to describe the contents of the file. + # + # @return [String, nil] + optional :description, String + + # @!attribute extensions + # Array of extensions to be applied to the asset. Each extension can be configured + # with specific parameters based on the extension type. + # + # @return [Array, nil] + optional :extensions, -> { Imagekit::Internal::Type::ArrayOf[union: Imagekit::ExtensionItem] } + + # @!attribute remove_ai_tags + # An array of AITags associated with the file that you want to remove, e.g. + # `["car", "vehicle", "motorsports"]`. + # + # If you want to remove all AITags associated with the file, send a string - + # "all". + # + # Note: The remove operation for `AITags` executes before any of the `extensions` + # are processed. + # + # @return [Array, Symbol, :all, nil] + optional :remove_ai_tags, + union: -> { Imagekit::UpdateFileRequest::UpdateFileDetails::RemoveAITags }, + api_name: :removeAITags + + # @!attribute tags + # An array of tags associated with the file, such as `["tag1", "tag2"]`. Send + # `null` to unset all tags associated with the file. + # + # @return [Array, nil] + optional :tags, Imagekit::Internal::Type::ArrayOf[String], nil?: true + + # @!attribute webhook_url + # The final status of extensions after they have completed execution will be + # delivered to this endpoint as a POST request. + # [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + # about the webhook payload structure. + # + # @return [String, nil] + optional :webhook_url, String, api_name: :webhookUrl + + # @!method initialize(custom_coordinates: nil, custom_metadata: nil, description: nil, extensions: nil, remove_ai_tags: nil, tags: nil, webhook_url: nil) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::UpdateFileRequest::UpdateFileDetails} for more details. + # + # @param custom_coordinates [String, nil] Define an important area in the image in the format `x,y,width,height` e.g. `10, + # + # @param custom_metadata [Hash{Symbol=>Object}] A key-value data to be associated with the asset. To unset a key, send `null` va + # + # @param description [String] Optional text to describe the contents of the file. + # + # @param extensions [Array] Array of extensions to be applied to the asset. Each extension can be configured + # + # @param remove_ai_tags [Array, Symbol, :all] An array of AITags associated with the file that you want to remove, e.g. `["car + # + # @param tags [Array, nil] An array of tags associated with the file, such as `["tag1", "tag2"]`. Send `nul + # + # @param webhook_url [String] The final status of extensions after they have completed execution will be deliv + + # An array of AITags associated with the file that you want to remove, e.g. + # `["car", "vehicle", "motorsports"]`. + # + # If you want to remove all AITags associated with the file, send a string - + # "all". + # + # Note: The remove operation for `AITags` executes before any of the `extensions` + # are processed. + # + # @see Imagekit::Models::UpdateFileRequest::UpdateFileDetails#remove_ai_tags + module RemoveAITags + extend Imagekit::Internal::Type::Union + + variant -> { Imagekit::Models::UpdateFileRequest::UpdateFileDetails::RemoveAITags::StringArray } + + variant const: :all + + # @!method self.variants + # @return [Array(Array, Symbol, :all)] + + # @type [Imagekit::Internal::Type::Converter] + StringArray = Imagekit::Internal::Type::ArrayOf[String] + end + end + + class ChangePublicationStatus < Imagekit::Internal::Type::BaseModel + # @!attribute publish + # Configure the publication status of a file and its versions. + # + # @return [Imagekit::Models::UpdateFileRequest::ChangePublicationStatus::Publish, nil] + optional :publish, -> { Imagekit::UpdateFileRequest::ChangePublicationStatus::Publish } + + # @!method initialize(publish: nil) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::UpdateFileRequest::ChangePublicationStatus} for more details. + # + # @param publish [Imagekit::Models::UpdateFileRequest::ChangePublicationStatus::Publish] Configure the publication status of a file and its versions. + + # @see Imagekit::Models::UpdateFileRequest::ChangePublicationStatus#publish + class Publish < Imagekit::Internal::Type::BaseModel + # @!attribute is_published + # Set to `true` to publish the file. Set to `false` to unpublish the file. + # + # @return [Boolean] + required :is_published, Imagekit::Internal::Type::Boolean, api_name: :isPublished + + # @!attribute include_file_versions + # Set to `true` to publish/unpublish all versions of the file. Set to `false` to + # publish/unpublish only the current version of the file. + # + # @return [Boolean, nil] + optional :include_file_versions, Imagekit::Internal::Type::Boolean, api_name: :includeFileVersions + + # @!method initialize(is_published:, include_file_versions: nil) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::UpdateFileRequest::ChangePublicationStatus::Publish} for more + # details. + # + # Configure the publication status of a file and its versions. + # + # @param is_published [Boolean] Set to `true` to publish the file. Set to `false` to unpublish the file. + # + # @param include_file_versions [Boolean] Set to `true` to publish/unpublish all versions of the file. Set to `false` to p + end + end + + # @!method self.variants + # @return [Array(Imagekit::Models::UpdateFileRequest::UpdateFileDetails, Imagekit::Models::UpdateFileRequest::ChangePublicationStatus)] + end + end +end diff --git a/lib/imagekit/models/upload_post_transform_error_event.rb b/lib/imagekit/models/upload_post_transform_error_event.rb new file mode 100644 index 00000000..31abc43b --- /dev/null +++ b/lib/imagekit/models/upload_post_transform_error_event.rb @@ -0,0 +1,180 @@ +# frozen_string_literal: true + +module Imagekit + module Models + class UploadPostTransformErrorEvent < Imagekit::Models::BaseWebhookEvent + # @!attribute created_at + # Timestamp of when the event occurred in ISO8601 format. + # + # @return [Time] + required :created_at, Time + + # @!attribute data + # + # @return [Imagekit::Models::UploadPostTransformErrorEvent::Data] + required :data, -> { Imagekit::UploadPostTransformErrorEvent::Data } + + # @!attribute request + # + # @return [Imagekit::Models::UploadPostTransformErrorEvent::Request] + required :request, -> { Imagekit::UploadPostTransformErrorEvent::Request } + + # @!attribute type + # + # @return [Symbol, :"upload.post-transform.error"] + required :type, const: :"upload.post-transform.error" + + # @!method initialize(created_at:, data:, request:, type: :"upload.post-transform.error") + # Triggered when a post-transformation fails. The original file remains available, + # but the requested transformation could not be generated. + # + # @param created_at [Time] Timestamp of when the event occurred in ISO8601 format. + # + # @param data [Imagekit::Models::UploadPostTransformErrorEvent::Data] + # + # @param request [Imagekit::Models::UploadPostTransformErrorEvent::Request] + # + # @param type [Symbol, :"upload.post-transform.error"] + + class Data < Imagekit::Internal::Type::BaseModel + # @!attribute file_id + # Unique identifier of the originally uploaded file. + # + # @return [String] + required :file_id, String, api_name: :fileId + + # @!attribute name + # Name of the file. + # + # @return [String] + required :name, String + + # @!attribute path + # Path of the file. + # + # @return [String] + required :path, String + + # @!attribute transformation + # + # @return [Imagekit::Models::UploadPostTransformErrorEvent::Data::Transformation] + required :transformation, -> { Imagekit::UploadPostTransformErrorEvent::Data::Transformation } + + # @!attribute url + # URL of the attempted post-transformation. + # + # @return [String] + required :url, String + + # @!method initialize(file_id:, name:, path:, transformation:, url:) + # @param file_id [String] Unique identifier of the originally uploaded file. + # + # @param name [String] Name of the file. + # + # @param path [String] Path of the file. + # + # @param transformation [Imagekit::Models::UploadPostTransformErrorEvent::Data::Transformation] + # + # @param url [String] URL of the attempted post-transformation. + + # @see Imagekit::Models::UploadPostTransformErrorEvent::Data#transformation + class Transformation < Imagekit::Internal::Type::BaseModel + # @!attribute error + # + # @return [Imagekit::Models::UploadPostTransformErrorEvent::Data::Transformation::Error] + required :error, -> { Imagekit::UploadPostTransformErrorEvent::Data::Transformation::Error } + + # @!method initialize(error:) + # @param error [Imagekit::Models::UploadPostTransformErrorEvent::Data::Transformation::Error] + + # @see Imagekit::Models::UploadPostTransformErrorEvent::Data::Transformation#error + class Error < Imagekit::Internal::Type::BaseModel + # @!attribute reason + # Reason for the post-transformation failure. + # + # @return [String] + required :reason, String + + # @!method initialize(reason:) + # @param reason [String] Reason for the post-transformation failure. + end + end + end + + class Request < Imagekit::Internal::Type::BaseModel + # @!attribute transformation + # + # @return [Imagekit::Models::UploadPostTransformErrorEvent::Request::Transformation] + required :transformation, -> { Imagekit::UploadPostTransformErrorEvent::Request::Transformation } + + # @!attribute x_request_id + # Unique identifier for the originating request. + # + # @return [String] + required :x_request_id, String + + # @!method initialize(transformation:, x_request_id:) + # @param transformation [Imagekit::Models::UploadPostTransformErrorEvent::Request::Transformation] + # + # @param x_request_id [String] Unique identifier for the originating request. + + # @see Imagekit::Models::UploadPostTransformErrorEvent::Request#transformation + class Transformation < Imagekit::Internal::Type::BaseModel + # @!attribute type + # Type of the requested post-transformation. + # + # @return [Symbol, Imagekit::Models::UploadPostTransformErrorEvent::Request::Transformation::Type] + required :type, enum: -> { Imagekit::UploadPostTransformErrorEvent::Request::Transformation::Type } + + # @!attribute protocol + # Only applicable if transformation type is 'abs'. Streaming protocol used. + # + # @return [Symbol, Imagekit::Models::UploadPostTransformErrorEvent::Request::Transformation::Protocol, nil] + optional :protocol, + enum: -> { Imagekit::UploadPostTransformErrorEvent::Request::Transformation::Protocol } + + # @!attribute value + # Value for the requested transformation type. + # + # @return [String, nil] + optional :value, String + + # @!method initialize(type:, protocol: nil, value: nil) + # @param type [Symbol, Imagekit::Models::UploadPostTransformErrorEvent::Request::Transformation::Type] Type of the requested post-transformation. + # + # @param protocol [Symbol, Imagekit::Models::UploadPostTransformErrorEvent::Request::Transformation::Protocol] Only applicable if transformation type is 'abs'. Streaming protocol used. + # + # @param value [String] Value for the requested transformation type. + + # Type of the requested post-transformation. + # + # @see Imagekit::Models::UploadPostTransformErrorEvent::Request::Transformation#type + module Type + extend Imagekit::Internal::Type::Enum + + TRANSFORMATION = :transformation + ABS = :abs + GIF_TO_VIDEO = :"gif-to-video" + THUMBNAIL = :thumbnail + + # @!method self.values + # @return [Array] + end + + # Only applicable if transformation type is 'abs'. Streaming protocol used. + # + # @see Imagekit::Models::UploadPostTransformErrorEvent::Request::Transformation#protocol + module Protocol + extend Imagekit::Internal::Type::Enum + + HLS = :hls + DASH = :dash + + # @!method self.values + # @return [Array] + end + end + end + end + end +end diff --git a/lib/imagekit/models/upload_post_transform_success_event.rb b/lib/imagekit/models/upload_post_transform_success_event.rb new file mode 100644 index 00000000..e181c6d2 --- /dev/null +++ b/lib/imagekit/models/upload_post_transform_success_event.rb @@ -0,0 +1,143 @@ +# frozen_string_literal: true + +module Imagekit + module Models + class UploadPostTransformSuccessEvent < Imagekit::Models::BaseWebhookEvent + # @!attribute created_at + # Timestamp of when the event occurred in ISO8601 format. + # + # @return [Time] + required :created_at, Time + + # @!attribute data + # + # @return [Imagekit::Models::UploadPostTransformSuccessEvent::Data] + required :data, -> { Imagekit::UploadPostTransformSuccessEvent::Data } + + # @!attribute request + # + # @return [Imagekit::Models::UploadPostTransformSuccessEvent::Request] + required :request, -> { Imagekit::UploadPostTransformSuccessEvent::Request } + + # @!attribute type + # + # @return [Symbol, :"upload.post-transform.success"] + required :type, const: :"upload.post-transform.success" + + # @!method initialize(created_at:, data:, request:, type: :"upload.post-transform.success") + # Triggered when a post-transformation completes successfully. The transformed + # version of the file is now ready and can be accessed via the provided URL. Note + # that each post-transformation generates a separate webhook event. + # + # @param created_at [Time] Timestamp of when the event occurred in ISO8601 format. + # + # @param data [Imagekit::Models::UploadPostTransformSuccessEvent::Data] + # + # @param request [Imagekit::Models::UploadPostTransformSuccessEvent::Request] + # + # @param type [Symbol, :"upload.post-transform.success"] + + class Data < Imagekit::Internal::Type::BaseModel + # @!attribute file_id + # Unique identifier of the originally uploaded file. + # + # @return [String] + required :file_id, String, api_name: :fileId + + # @!attribute name + # Name of the file. + # + # @return [String] + required :name, String + + # @!attribute url + # URL of the generated post-transformation. + # + # @return [String] + required :url, String + + # @!method initialize(file_id:, name:, url:) + # @param file_id [String] Unique identifier of the originally uploaded file. + # + # @param name [String] Name of the file. + # + # @param url [String] URL of the generated post-transformation. + end + + class Request < Imagekit::Internal::Type::BaseModel + # @!attribute transformation + # + # @return [Imagekit::Models::UploadPostTransformSuccessEvent::Request::Transformation] + required :transformation, -> { Imagekit::UploadPostTransformSuccessEvent::Request::Transformation } + + # @!attribute x_request_id + # Unique identifier for the originating request. + # + # @return [String] + required :x_request_id, String + + # @!method initialize(transformation:, x_request_id:) + # @param transformation [Imagekit::Models::UploadPostTransformSuccessEvent::Request::Transformation] + # + # @param x_request_id [String] Unique identifier for the originating request. + + # @see Imagekit::Models::UploadPostTransformSuccessEvent::Request#transformation + class Transformation < Imagekit::Internal::Type::BaseModel + # @!attribute type + # Type of the requested post-transformation. + # + # @return [Symbol, Imagekit::Models::UploadPostTransformSuccessEvent::Request::Transformation::Type] + required :type, enum: -> { Imagekit::UploadPostTransformSuccessEvent::Request::Transformation::Type } + + # @!attribute protocol + # Only applicable if transformation type is 'abs'. Streaming protocol used. + # + # @return [Symbol, Imagekit::Models::UploadPostTransformSuccessEvent::Request::Transformation::Protocol, nil] + optional :protocol, + enum: -> { Imagekit::UploadPostTransformSuccessEvent::Request::Transformation::Protocol } + + # @!attribute value + # Value for the requested transformation type. + # + # @return [String, nil] + optional :value, String + + # @!method initialize(type:, protocol: nil, value: nil) + # @param type [Symbol, Imagekit::Models::UploadPostTransformSuccessEvent::Request::Transformation::Type] Type of the requested post-transformation. + # + # @param protocol [Symbol, Imagekit::Models::UploadPostTransformSuccessEvent::Request::Transformation::Protocol] Only applicable if transformation type is 'abs'. Streaming protocol used. + # + # @param value [String] Value for the requested transformation type. + + # Type of the requested post-transformation. + # + # @see Imagekit::Models::UploadPostTransformSuccessEvent::Request::Transformation#type + module Type + extend Imagekit::Internal::Type::Enum + + TRANSFORMATION = :transformation + ABS = :abs + GIF_TO_VIDEO = :"gif-to-video" + THUMBNAIL = :thumbnail + + # @!method self.values + # @return [Array] + end + + # Only applicable if transformation type is 'abs'. Streaming protocol used. + # + # @see Imagekit::Models::UploadPostTransformSuccessEvent::Request::Transformation#protocol + module Protocol + extend Imagekit::Internal::Type::Enum + + HLS = :hls + DASH = :dash + + # @!method self.values + # @return [Array] + end + end + end + end + end +end diff --git a/lib/imagekit/models/upload_pre_transform_error_event.rb b/lib/imagekit/models/upload_pre_transform_error_event.rb new file mode 100644 index 00000000..76eb4981 --- /dev/null +++ b/lib/imagekit/models/upload_pre_transform_error_event.rb @@ -0,0 +1,108 @@ +# frozen_string_literal: true + +module Imagekit + module Models + class UploadPreTransformErrorEvent < Imagekit::Models::BaseWebhookEvent + # @!attribute created_at + # Timestamp of when the event occurred in ISO8601 format. + # + # @return [Time] + required :created_at, Time + + # @!attribute data + # + # @return [Imagekit::Models::UploadPreTransformErrorEvent::Data] + required :data, -> { Imagekit::UploadPreTransformErrorEvent::Data } + + # @!attribute request + # + # @return [Imagekit::Models::UploadPreTransformErrorEvent::Request] + required :request, -> { Imagekit::UploadPreTransformErrorEvent::Request } + + # @!attribute type + # + # @return [Symbol, :"upload.pre-transform.error"] + required :type, const: :"upload.pre-transform.error" + + # @!method initialize(created_at:, data:, request:, type: :"upload.pre-transform.error") + # Triggered when a pre-transformation fails. The file upload may have been + # accepted, but the requested transformation could not be applied. + # + # @param created_at [Time] Timestamp of when the event occurred in ISO8601 format. + # + # @param data [Imagekit::Models::UploadPreTransformErrorEvent::Data] + # + # @param request [Imagekit::Models::UploadPreTransformErrorEvent::Request] + # + # @param type [Symbol, :"upload.pre-transform.error"] + + class Data < Imagekit::Internal::Type::BaseModel + # @!attribute name + # Name of the file. + # + # @return [String] + required :name, String + + # @!attribute path + # Path of the file. + # + # @return [String] + required :path, String + + # @!attribute transformation + # + # @return [Imagekit::Models::UploadPreTransformErrorEvent::Data::Transformation] + required :transformation, -> { Imagekit::UploadPreTransformErrorEvent::Data::Transformation } + + # @!method initialize(name:, path:, transformation:) + # @param name [String] Name of the file. + # + # @param path [String] Path of the file. + # + # @param transformation [Imagekit::Models::UploadPreTransformErrorEvent::Data::Transformation] + + # @see Imagekit::Models::UploadPreTransformErrorEvent::Data#transformation + class Transformation < Imagekit::Internal::Type::BaseModel + # @!attribute error + # + # @return [Imagekit::Models::UploadPreTransformErrorEvent::Data::Transformation::Error] + required :error, -> { Imagekit::UploadPreTransformErrorEvent::Data::Transformation::Error } + + # @!method initialize(error:) + # @param error [Imagekit::Models::UploadPreTransformErrorEvent::Data::Transformation::Error] + + # @see Imagekit::Models::UploadPreTransformErrorEvent::Data::Transformation#error + class Error < Imagekit::Internal::Type::BaseModel + # @!attribute reason + # Reason for the pre-transformation failure. + # + # @return [String] + required :reason, String + + # @!method initialize(reason:) + # @param reason [String] Reason for the pre-transformation failure. + end + end + end + + class Request < Imagekit::Internal::Type::BaseModel + # @!attribute transformation + # The requested pre-transformation string. + # + # @return [String] + required :transformation, String + + # @!attribute x_request_id + # Unique identifier for the originating request. + # + # @return [String] + required :x_request_id, String + + # @!method initialize(transformation:, x_request_id:) + # @param transformation [String] The requested pre-transformation string. + # + # @param x_request_id [String] Unique identifier for the originating request. + end + end + end +end diff --git a/lib/imagekit/models/upload_pre_transform_success_event.rb b/lib/imagekit/models/upload_pre_transform_success_event.rb new file mode 100644 index 00000000..4ba20c4e --- /dev/null +++ b/lib/imagekit/models/upload_pre_transform_success_event.rb @@ -0,0 +1,457 @@ +# frozen_string_literal: true + +module Imagekit + module Models + class UploadPreTransformSuccessEvent < Imagekit::Models::BaseWebhookEvent + # @!attribute created_at + # Timestamp of when the event occurred in ISO8601 format. + # + # @return [Time] + required :created_at, Time + + # @!attribute data + # Object containing details of a successful upload. + # + # @return [Imagekit::Models::UploadPreTransformSuccessEvent::Data] + required :data, -> { Imagekit::UploadPreTransformSuccessEvent::Data } + + # @!attribute request + # + # @return [Imagekit::Models::UploadPreTransformSuccessEvent::Request] + required :request, -> { Imagekit::UploadPreTransformSuccessEvent::Request } + + # @!attribute type + # + # @return [Symbol, :"upload.pre-transform.success"] + required :type, const: :"upload.pre-transform.success" + + # @!method initialize(created_at:, data:, request:, type: :"upload.pre-transform.success") + # Triggered when a pre-transformation completes successfully. The file has been + # processed with the requested transformation and is now available in the Media + # Library. + # + # @param created_at [Time] Timestamp of when the event occurred in ISO8601 format. + # + # @param data [Imagekit::Models::UploadPreTransformSuccessEvent::Data] Object containing details of a successful upload. + # + # @param request [Imagekit::Models::UploadPreTransformSuccessEvent::Request] + # + # @param type [Symbol, :"upload.pre-transform.success"] + + class Data < Imagekit::Internal::Type::BaseModel + # @!attribute ai_tags + # An array of tags assigned to the uploaded file by auto tagging. + # + # @return [Array, nil] + optional :ai_tags, + -> { + Imagekit::Internal::Type::ArrayOf[Imagekit::UploadPreTransformSuccessEvent::Data::AITag] + }, + api_name: :AITags, + nil?: true + + # @!attribute audio_codec + # The audio codec used in the video (only for video). + # + # @return [String, nil] + optional :audio_codec, String, api_name: :audioCodec + + # @!attribute bit_rate + # The bit rate of the video in kbps (only for video). + # + # @return [Integer, nil] + optional :bit_rate, Integer, api_name: :bitRate + + # @!attribute custom_coordinates + # Value of custom coordinates associated with the image in the format + # `x,y,width,height`. If `customCoordinates` are not defined, then it is `null`. + # Send `customCoordinates` in `responseFields` in API request to get the value of + # this field. + # + # @return [String, nil] + optional :custom_coordinates, String, api_name: :customCoordinates, nil?: true + + # @!attribute custom_metadata + # A key-value data associated with the asset. Use `responseField` in API request + # to get `customMetadata` in the upload API response. Before setting any custom + # metadata on an asset, you have to create the field using custom metadata fields + # API. Send `customMetadata` in `responseFields` in API request to get the value + # of this field. + # + # @return [Hash{Symbol=>Object}, nil] + optional :custom_metadata, + Imagekit::Internal::Type::HashOf[Imagekit::Internal::Type::Unknown], + api_name: :customMetadata + + # @!attribute description + # Optional text to describe the contents of the file. Can be set by the user or + # the ai-auto-description extension. + # + # @return [String, nil] + optional :description, String + + # @!attribute duration + # The duration of the video in seconds (only for video). + # + # @return [Integer, nil] + optional :duration, Integer + + # @!attribute embedded_metadata + # Consolidated embedded metadata associated with the file. It includes exif, iptc, + # and xmp data. Send `embeddedMetadata` in `responseFields` in API request to get + # embeddedMetadata in the upload API response. + # + # @return [Hash{Symbol=>Object}, nil] + optional :embedded_metadata, + Imagekit::Internal::Type::HashOf[Imagekit::Internal::Type::Unknown], + api_name: :embeddedMetadata + + # @!attribute extension_status + # Extension names with their processing status at the time of completion of the + # request. It could have one of the following status values: + # + # `success`: The extension has been successfully applied. `failed`: The extension + # has failed and will not be retried. `pending`: The extension will finish + # processing in some time. On completion, the final status (success / failed) will + # be sent to the `webhookUrl` provided. + # + # If no extension was requested, then this parameter is not returned. + # + # @return [Imagekit::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus, nil] + optional :extension_status, + -> { Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus }, + api_name: :extensionStatus + + # @!attribute file_id + # Unique fileId. Store this fileld in your database, as this will be used to + # perform update action on this file. + # + # @return [String, nil] + optional :file_id, String, api_name: :fileId + + # @!attribute file_path + # The relative path of the file in the media library e.g. + # `/marketing-assets/new-banner.jpg`. + # + # @return [String, nil] + optional :file_path, String, api_name: :filePath + + # @!attribute file_type + # Type of the uploaded file. Possible values are `image`, `non-image`. + # + # @return [String, nil] + optional :file_type, String, api_name: :fileType + + # @!attribute height + # Height of the image in pixels (Only for images) + # + # @return [Float, nil] + optional :height, Float + + # @!attribute is_private_file + # Is the file marked as private. It can be either `true` or `false`. Send + # `isPrivateFile` in `responseFields` in API request to get the value of this + # field. + # + # @return [Boolean, nil] + optional :is_private_file, Imagekit::Internal::Type::Boolean, api_name: :isPrivateFile + + # @!attribute is_published + # Is the file published or in draft state. It can be either `true` or `false`. + # Send `isPublished` in `responseFields` in API request to get the value of this + # field. + # + # @return [Boolean, nil] + optional :is_published, Imagekit::Internal::Type::Boolean, api_name: :isPublished + + # @!attribute metadata + # Legacy metadata. Send `metadata` in `responseFields` in API request to get + # metadata in the upload API response. + # + # @return [Imagekit::Models::Metadata, nil] + optional :metadata, -> { Imagekit::Metadata } + + # @!attribute name + # Name of the asset. + # + # @return [String, nil] + optional :name, String + + # @!attribute size + # Size of the image file in Bytes. + # + # @return [Float, nil] + optional :size, Float + + # @!attribute tags + # The array of tags associated with the asset. If no tags are set, it will be + # `null`. Send `tags` in `responseFields` in API request to get the value of this + # field. + # + # @return [Array, nil] + optional :tags, Imagekit::Internal::Type::ArrayOf[String], nil?: true + + # @!attribute thumbnail_url + # In the case of an image, a small thumbnail URL. + # + # @return [String, nil] + optional :thumbnail_url, String, api_name: :thumbnailUrl + + # @!attribute url + # A publicly accessible URL of the file. + # + # @return [String, nil] + optional :url, String + + # @!attribute version_info + # An object containing the file or file version's `id` (versionId) and `name`. + # + # @return [Imagekit::Models::UploadPreTransformSuccessEvent::Data::VersionInfo, nil] + optional :version_info, + -> { Imagekit::UploadPreTransformSuccessEvent::Data::VersionInfo }, + api_name: :versionInfo + + # @!attribute video_codec + # The video codec used in the video (only for video). + # + # @return [String, nil] + optional :video_codec, String, api_name: :videoCodec + + # @!attribute width + # Width of the image in pixels (Only for Images) + # + # @return [Float, nil] + optional :width, Float + + # @!method initialize(ai_tags: nil, audio_codec: nil, bit_rate: nil, custom_coordinates: nil, custom_metadata: nil, description: nil, duration: nil, embedded_metadata: nil, extension_status: nil, file_id: nil, file_path: nil, file_type: nil, height: nil, is_private_file: nil, is_published: nil, metadata: nil, name: nil, size: nil, tags: nil, thumbnail_url: nil, url: nil, version_info: nil, video_codec: nil, width: nil) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::UploadPreTransformSuccessEvent::Data} for more details. + # + # Object containing details of a successful upload. + # + # @param ai_tags [Array, nil] An array of tags assigned to the uploaded file by auto tagging. + # + # @param audio_codec [String] The audio codec used in the video (only for video). + # + # @param bit_rate [Integer] The bit rate of the video in kbps (only for video). + # + # @param custom_coordinates [String, nil] Value of custom coordinates associated with the image in the format `x,y,width,h + # + # @param custom_metadata [Hash{Symbol=>Object}] A key-value data associated with the asset. Use `responseField` in API request t + # + # @param description [String] Optional text to describe the contents of the file. Can be set by the user or th + # + # @param duration [Integer] The duration of the video in seconds (only for video). + # + # @param embedded_metadata [Hash{Symbol=>Object}] Consolidated embedded metadata associated with the file. It includes exif, iptc, + # + # @param extension_status [Imagekit::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus] Extension names with their processing status at the time of completion of the re + # + # @param file_id [String] Unique fileId. Store this fileld in your database, as this will be used to perfo + # + # @param file_path [String] The relative path of the file in the media library e.g. `/marketing-assets/new-b + # + # @param file_type [String] Type of the uploaded file. Possible values are `image`, `non-image`. + # + # @param height [Float] Height of the image in pixels (Only for images) + # + # @param is_private_file [Boolean] Is the file marked as private. It can be either `true` or `false`. Send `isPriva + # + # @param is_published [Boolean] Is the file published or in draft state. It can be either `true` or `false`. Sen + # + # @param metadata [Imagekit::Models::Metadata] Legacy metadata. Send `metadata` in `responseFields` in API request to get metad + # + # @param name [String] Name of the asset. + # + # @param size [Float] Size of the image file in Bytes. + # + # @param tags [Array, nil] The array of tags associated with the asset. If no tags are set, it will be `nul + # + # @param thumbnail_url [String] In the case of an image, a small thumbnail URL. + # + # @param url [String] A publicly accessible URL of the file. + # + # @param version_info [Imagekit::Models::UploadPreTransformSuccessEvent::Data::VersionInfo] An object containing the file or file version's `id` (versionId) and `name`. + # + # @param video_codec [String] The video codec used in the video (only for video). + # + # @param width [Float] Width of the image in pixels (Only for Images) + + class AITag < Imagekit::Internal::Type::BaseModel + # @!attribute confidence + # Confidence score of the tag. + # + # @return [Float, nil] + optional :confidence, Float + + # @!attribute name + # Name of the tag. + # + # @return [String, nil] + optional :name, String + + # @!attribute source + # Array of `AITags` associated with the image. If no `AITags` are set, it will be + # null. These tags can be added using the `google-auto-tagging` or + # `aws-auto-tagging` extensions. + # + # @return [String, nil] + optional :source, String + + # @!method initialize(confidence: nil, name: nil, source: nil) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::UploadPreTransformSuccessEvent::Data::AITag} for more + # details. + # + # @param confidence [Float] Confidence score of the tag. + # + # @param name [String] Name of the tag. + # + # @param source [String] Array of `AITags` associated with the image. If no `AITags` are set, it will be + end + + # @see Imagekit::Models::UploadPreTransformSuccessEvent::Data#extension_status + class ExtensionStatus < Imagekit::Internal::Type::BaseModel + # @!attribute ai_auto_description + # + # @return [Symbol, Imagekit::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::AIAutoDescription, nil] + optional :ai_auto_description, + enum: -> { + Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus::AIAutoDescription + }, + api_name: :"ai-auto-description" + + # @!attribute aws_auto_tagging + # + # @return [Symbol, Imagekit::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::AwsAutoTagging, nil] + optional :aws_auto_tagging, + enum: -> { + Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus::AwsAutoTagging + }, + api_name: :"aws-auto-tagging" + + # @!attribute google_auto_tagging + # + # @return [Symbol, Imagekit::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::GoogleAutoTagging, nil] + optional :google_auto_tagging, + enum: -> { + Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus::GoogleAutoTagging + }, + api_name: :"google-auto-tagging" + + # @!attribute remove_bg + # + # @return [Symbol, Imagekit::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::RemoveBg, nil] + optional :remove_bg, + enum: -> { Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus::RemoveBg }, + api_name: :"remove-bg" + + # @!method initialize(ai_auto_description: nil, aws_auto_tagging: nil, google_auto_tagging: nil, remove_bg: nil) + # Extension names with their processing status at the time of completion of the + # request. It could have one of the following status values: + # + # `success`: The extension has been successfully applied. `failed`: The extension + # has failed and will not be retried. `pending`: The extension will finish + # processing in some time. On completion, the final status (success / failed) will + # be sent to the `webhookUrl` provided. + # + # If no extension was requested, then this parameter is not returned. + # + # @param ai_auto_description [Symbol, Imagekit::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::AIAutoDescription] + # @param aws_auto_tagging [Symbol, Imagekit::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::AwsAutoTagging] + # @param google_auto_tagging [Symbol, Imagekit::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::GoogleAutoTagging] + # @param remove_bg [Symbol, Imagekit::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::RemoveBg] + + # @see Imagekit::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus#ai_auto_description + module AIAutoDescription + extend Imagekit::Internal::Type::Enum + + SUCCESS = :success + PENDING = :pending + FAILED = :failed + + # @!method self.values + # @return [Array] + end + + # @see Imagekit::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus#aws_auto_tagging + module AwsAutoTagging + extend Imagekit::Internal::Type::Enum + + SUCCESS = :success + PENDING = :pending + FAILED = :failed + + # @!method self.values + # @return [Array] + end + + # @see Imagekit::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus#google_auto_tagging + module GoogleAutoTagging + extend Imagekit::Internal::Type::Enum + + SUCCESS = :success + PENDING = :pending + FAILED = :failed + + # @!method self.values + # @return [Array] + end + + # @see Imagekit::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus#remove_bg + module RemoveBg + extend Imagekit::Internal::Type::Enum + + SUCCESS = :success + PENDING = :pending + FAILED = :failed + + # @!method self.values + # @return [Array] + end + end + + # @see Imagekit::Models::UploadPreTransformSuccessEvent::Data#version_info + class VersionInfo < Imagekit::Internal::Type::BaseModel + # @!attribute id + # Unique identifier of the file version. + # + # @return [String, nil] + optional :id, String + + # @!attribute name + # Name of the file version. + # + # @return [String, nil] + optional :name, String + + # @!method initialize(id: nil, name: nil) + # An object containing the file or file version's `id` (versionId) and `name`. + # + # @param id [String] Unique identifier of the file version. + # + # @param name [String] Name of the file version. + end + end + + class Request < Imagekit::Internal::Type::BaseModel + # @!attribute transformation + # The requested pre-transformation string. + # + # @return [String] + required :transformation, String + + # @!attribute x_request_id + # Unique identifier for the originating request. + # + # @return [String] + required :x_request_id, String + + # @!method initialize(transformation:, x_request_id:) + # @param transformation [String] The requested pre-transformation string. + # + # @param x_request_id [String] Unique identifier for the originating request. + end + end + end +end diff --git a/lib/imagekit/models/video_overlay.rb b/lib/imagekit/models/video_overlay.rb new file mode 100644 index 00000000..3a134813 --- /dev/null +++ b/lib/imagekit/models/video_overlay.rb @@ -0,0 +1,64 @@ +# frozen_string_literal: true + +module Imagekit + module Models + class VideoOverlay < Imagekit::Models::BaseOverlay + # @!attribute input + # Specifies the relative path to the video used as an overlay. + # + # @return [String] + required :input, String + + # @!attribute type + # + # @return [Symbol, :video] + required :type, const: :video + + # @!attribute encoding + # The input path can be included in the layer as either `i-{input}` or + # `ie-{base64_encoded_input}`. By default, the SDK determines the appropriate + # format automatically. To always use base64 encoding (`ie-{base64}`), set this + # parameter to `base64`. To always use plain text (`i-{input}`), set it to + # `plain`. + # + # @return [Symbol, Imagekit::Models::VideoOverlay::Encoding, nil] + optional :encoding, enum: -> { Imagekit::VideoOverlay::Encoding } + + # @!attribute transformation + # Array of transformation to be applied to the overlay video. Except + # `streamingResolutions`, all other video transformations are supported. See + # [Video transformations](https://imagekit.io/docs/video-transformation). + # + # @return [Array, nil] + optional :transformation, -> { Imagekit::Internal::Type::ArrayOf[Imagekit::Transformation] } + + # @!method initialize(input:, encoding: nil, transformation: nil, type: :video) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::VideoOverlay} for more details. + # + # @param input [String] Specifies the relative path to the video used as an overlay. + # + # @param encoding [Symbol, Imagekit::Models::VideoOverlay::Encoding] The input path can be included in the layer as either `i-{input}` or `ie-{base64 + # + # @param transformation [Array] Array of transformation to be applied to the overlay video. Except `streamingRes + # + # @param type [Symbol, :video] + + # The input path can be included in the layer as either `i-{input}` or + # `ie-{base64_encoded_input}`. By default, the SDK determines the appropriate + # format automatically. To always use base64 encoding (`ie-{base64}`), set this + # parameter to `base64`. To always use plain text (`i-{input}`), set it to + # `plain`. + module Encoding + extend Imagekit::Internal::Type::Enum + + AUTO = :auto + PLAIN = :plain + BASE64 = :base64 + + # @!method self.values + # @return [Array] + end + end + end +end diff --git a/lib/imagekit/models/video_transformation_accepted_event.rb b/lib/imagekit/models/video_transformation_accepted_event.rb new file mode 100644 index 00000000..1be102a0 --- /dev/null +++ b/lib/imagekit/models/video_transformation_accepted_event.rb @@ -0,0 +1,279 @@ +# frozen_string_literal: true + +module Imagekit + module Models + class VideoTransformationAcceptedEvent < Imagekit::Models::BaseWebhookEvent + # @!attribute created_at + # Timestamp when the event was created in ISO8601 format. + # + # @return [Time] + required :created_at, Time + + # @!attribute data + # + # @return [Imagekit::Models::VideoTransformationAcceptedEvent::Data] + required :data, -> { Imagekit::VideoTransformationAcceptedEvent::Data } + + # @!attribute request + # Information about the original request that triggered the video transformation. + # + # @return [Imagekit::Models::VideoTransformationAcceptedEvent::Request] + required :request, -> { Imagekit::VideoTransformationAcceptedEvent::Request } + + # @!attribute type + # + # @return [Symbol, :"video.transformation.accepted"] + required :type, const: :"video.transformation.accepted" + + # @!method initialize(created_at:, data:, request:, type: :"video.transformation.accepted") + # Triggered when a new video transformation request is accepted for processing. + # This event confirms that ImageKit has received and queued your transformation + # request. Use this for debugging and tracking transformation lifecycle. + # + # @param created_at [Time] Timestamp when the event was created in ISO8601 format. + # + # @param data [Imagekit::Models::VideoTransformationAcceptedEvent::Data] + # + # @param request [Imagekit::Models::VideoTransformationAcceptedEvent::Request] Information about the original request that triggered the video transformation. + # + # @param type [Symbol, :"video.transformation.accepted"] + + class Data < Imagekit::Internal::Type::BaseModel + # @!attribute asset + # Information about the source video asset being transformed. + # + # @return [Imagekit::Models::VideoTransformationAcceptedEvent::Data::Asset] + required :asset, -> { Imagekit::VideoTransformationAcceptedEvent::Data::Asset } + + # @!attribute transformation + # Base information about a video transformation request. + # + # @return [Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation] + required :transformation, -> { Imagekit::VideoTransformationAcceptedEvent::Data::Transformation } + + # @!method initialize(asset:, transformation:) + # @param asset [Imagekit::Models::VideoTransformationAcceptedEvent::Data::Asset] Information about the source video asset being transformed. + # + # @param transformation [Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation] Base information about a video transformation request. + + # @see Imagekit::Models::VideoTransformationAcceptedEvent::Data#asset + class Asset < Imagekit::Internal::Type::BaseModel + # @!attribute url + # URL to download or access the source video file. + # + # @return [String] + required :url, String + + # @!method initialize(url:) + # Information about the source video asset being transformed. + # + # @param url [String] URL to download or access the source video file. + end + + # @see Imagekit::Models::VideoTransformationAcceptedEvent::Data#transformation + class Transformation < Imagekit::Internal::Type::BaseModel + # @!attribute type + # Type of video transformation: + # + # - `video-transformation`: Standard video processing (resize, format conversion, + # etc.) + # - `gif-to-video`: Convert animated GIF to video format + # - `video-thumbnail`: Generate thumbnail image from video + # + # @return [Symbol, Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::Type] + required :type, enum: -> { Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Type } + + # @!attribute options + # Configuration options for video transformations. + # + # @return [Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options, nil] + optional :options, -> { Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options } + + # @!method initialize(type:, options: nil) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation} for + # more details. + # + # Base information about a video transformation request. + # + # @param type [Symbol, Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::Type] Type of video transformation: + # + # @param options [Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options] Configuration options for video transformations. + + # Type of video transformation: + # + # - `video-transformation`: Standard video processing (resize, format conversion, + # etc.) + # - `gif-to-video`: Convert animated GIF to video format + # - `video-thumbnail`: Generate thumbnail image from video + # + # @see Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation#type + module Type + extend Imagekit::Internal::Type::Enum + + VIDEO_TRANSFORMATION = :"video-transformation" + GIF_TO_VIDEO = :"gif-to-video" + VIDEO_THUMBNAIL = :"video-thumbnail" + + # @!method self.values + # @return [Array] + end + + # @see Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation#options + class Options < Imagekit::Internal::Type::BaseModel + # @!attribute audio_codec + # Audio codec used for encoding (aac or opus). + # + # @return [Symbol, Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::AudioCodec, nil] + optional :audio_codec, + enum: -> { Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options::AudioCodec } + + # @!attribute auto_rotate + # Whether to automatically rotate the video based on metadata. + # + # @return [Boolean, nil] + optional :auto_rotate, Imagekit::Internal::Type::Boolean + + # @!attribute format_ + # Output format for the transformed video or thumbnail. + # + # @return [Symbol, Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::Format, nil] + optional :format_, + enum: -> { + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options::Format + }, + api_name: :format + + # @!attribute quality + # Quality setting for the output video. + # + # @return [Integer, nil] + optional :quality, Integer + + # @!attribute stream_protocol + # Streaming protocol for adaptive bitrate streaming. + # + # @return [Symbol, Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::StreamProtocol, nil] + optional :stream_protocol, + enum: -> { Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options::StreamProtocol } + + # @!attribute variants + # Array of quality representations for adaptive bitrate streaming. + # + # @return [Array, nil] + optional :variants, Imagekit::Internal::Type::ArrayOf[String] + + # @!attribute video_codec + # Video codec used for encoding (h264, vp9, or av1). + # + # @return [Symbol, Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::VideoCodec, nil] + optional :video_codec, + enum: -> { Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options::VideoCodec } + + # @!method initialize(audio_codec: nil, auto_rotate: nil, format_: nil, quality: nil, stream_protocol: nil, variants: nil, video_codec: nil) + # Configuration options for video transformations. + # + # @param audio_codec [Symbol, Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::AudioCodec] Audio codec used for encoding (aac or opus). + # + # @param auto_rotate [Boolean] Whether to automatically rotate the video based on metadata. + # + # @param format_ [Symbol, Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::Format] Output format for the transformed video or thumbnail. + # + # @param quality [Integer] Quality setting for the output video. + # + # @param stream_protocol [Symbol, Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::StreamProtocol] Streaming protocol for adaptive bitrate streaming. + # + # @param variants [Array] Array of quality representations for adaptive bitrate streaming. + # + # @param video_codec [Symbol, Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::VideoCodec] Video codec used for encoding (h264, vp9, or av1). + + # Audio codec used for encoding (aac or opus). + # + # @see Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options#audio_codec + module AudioCodec + extend Imagekit::Internal::Type::Enum + + AAC = :aac + OPUS = :opus + + # @!method self.values + # @return [Array] + end + + # Output format for the transformed video or thumbnail. + # + # @see Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options#format_ + module Format + extend Imagekit::Internal::Type::Enum + + MP4 = :mp4 + WEBM = :webm + JPG = :jpg + PNG = :png + WEBP = :webp + + # @!method self.values + # @return [Array] + end + + # Streaming protocol for adaptive bitrate streaming. + # + # @see Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options#stream_protocol + module StreamProtocol + extend Imagekit::Internal::Type::Enum + + HLS = :HLS + DASH = :DASH + + # @!method self.values + # @return [Array] + end + + # Video codec used for encoding (h264, vp9, or av1). + # + # @see Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options#video_codec + module VideoCodec + extend Imagekit::Internal::Type::Enum + + H264 = :h264 + VP9 = :vp9 + AV1 = :av1 + + # @!method self.values + # @return [Array] + end + end + end + end + + class Request < Imagekit::Internal::Type::BaseModel + # @!attribute url + # Full URL of the transformation request that was submitted. + # + # @return [String] + required :url, String + + # @!attribute x_request_id + # Unique identifier for the originating transformation request. + # + # @return [String] + required :x_request_id, String + + # @!attribute user_agent + # User-Agent header from the original request that triggered the transformation. + # + # @return [String, nil] + optional :user_agent, String + + # @!method initialize(url:, x_request_id:, user_agent: nil) + # Information about the original request that triggered the video transformation. + # + # @param url [String] Full URL of the transformation request that was submitted. + # + # @param x_request_id [String] Unique identifier for the originating transformation request. + # + # @param user_agent [String] User-Agent header from the original request that triggered the transformation. + end + end + end +end diff --git a/lib/imagekit/models/video_transformation_error_event.rb b/lib/imagekit/models/video_transformation_error_event.rb new file mode 100644 index 00000000..8c357035 --- /dev/null +++ b/lib/imagekit/models/video_transformation_error_event.rb @@ -0,0 +1,326 @@ +# frozen_string_literal: true + +module Imagekit + module Models + class VideoTransformationErrorEvent < Imagekit::Models::BaseWebhookEvent + # @!attribute created_at + # Timestamp when the event was created in ISO8601 format. + # + # @return [Time] + required :created_at, Time + + # @!attribute data + # + # @return [Imagekit::Models::VideoTransformationErrorEvent::Data] + required :data, -> { Imagekit::VideoTransformationErrorEvent::Data } + + # @!attribute request + # Information about the original request that triggered the video transformation. + # + # @return [Imagekit::Models::VideoTransformationErrorEvent::Request] + required :request, -> { Imagekit::VideoTransformationErrorEvent::Request } + + # @!attribute type + # + # @return [Symbol, :"video.transformation.error"] + required :type, const: :"video.transformation.error" + + # @!method initialize(created_at:, data:, request:, type: :"video.transformation.error") + # Triggered when an error occurs during video encoding. Listen to this webhook to + # log error reasons and debug issues. Check your origin and URL endpoint settings + # if the reason is related to download failure. For other errors, contact ImageKit + # support. + # + # @param created_at [Time] Timestamp when the event was created in ISO8601 format. + # + # @param data [Imagekit::Models::VideoTransformationErrorEvent::Data] + # + # @param request [Imagekit::Models::VideoTransformationErrorEvent::Request] Information about the original request that triggered the video transformation. + # + # @param type [Symbol, :"video.transformation.error"] + + class Data < Imagekit::Internal::Type::BaseModel + # @!attribute asset + # Information about the source video asset being transformed. + # + # @return [Imagekit::Models::VideoTransformationErrorEvent::Data::Asset] + required :asset, -> { Imagekit::VideoTransformationErrorEvent::Data::Asset } + + # @!attribute transformation + # + # @return [Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation] + required :transformation, -> { Imagekit::VideoTransformationErrorEvent::Data::Transformation } + + # @!method initialize(asset:, transformation:) + # @param asset [Imagekit::Models::VideoTransformationErrorEvent::Data::Asset] Information about the source video asset being transformed. + # + # @param transformation [Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation] + + # @see Imagekit::Models::VideoTransformationErrorEvent::Data#asset + class Asset < Imagekit::Internal::Type::BaseModel + # @!attribute url + # URL to download or access the source video file. + # + # @return [String] + required :url, String + + # @!method initialize(url:) + # Information about the source video asset being transformed. + # + # @param url [String] URL to download or access the source video file. + end + + # @see Imagekit::Models::VideoTransformationErrorEvent::Data#transformation + class Transformation < Imagekit::Internal::Type::BaseModel + # @!attribute type + # Type of video transformation: + # + # - `video-transformation`: Standard video processing (resize, format conversion, + # etc.) + # - `gif-to-video`: Convert animated GIF to video format + # - `video-thumbnail`: Generate thumbnail image from video + # + # @return [Symbol, Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Type] + required :type, enum: -> { Imagekit::VideoTransformationErrorEvent::Data::Transformation::Type } + + # @!attribute error + # Details about the transformation error. + # + # @return [Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Error, nil] + optional :error, -> { Imagekit::VideoTransformationErrorEvent::Data::Transformation::Error } + + # @!attribute options + # Configuration options for video transformations. + # + # @return [Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Options, nil] + optional :options, -> { Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options } + + # @!method initialize(type:, error: nil, options: nil) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation} for more + # details. + # + # @param type [Symbol, Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Type] Type of video transformation: + # + # @param error [Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Error] Details about the transformation error. + # + # @param options [Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Options] Configuration options for video transformations. + + # Type of video transformation: + # + # - `video-transformation`: Standard video processing (resize, format conversion, + # etc.) + # - `gif-to-video`: Convert animated GIF to video format + # - `video-thumbnail`: Generate thumbnail image from video + # + # @see Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation#type + module Type + extend Imagekit::Internal::Type::Enum + + VIDEO_TRANSFORMATION = :"video-transformation" + GIF_TO_VIDEO = :"gif-to-video" + VIDEO_THUMBNAIL = :"video-thumbnail" + + # @!method self.values + # @return [Array] + end + + # @see Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation#error + class Error < Imagekit::Internal::Type::BaseModel + # @!attribute reason + # Specific reason for the transformation failure: + # + # - `encoding_failed`: Error during video encoding process + # - `download_failed`: Could not download source video + # - `internal_server_error`: Unexpected server error + # + # @return [Symbol, Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Error::Reason] + required :reason, + enum: -> { Imagekit::VideoTransformationErrorEvent::Data::Transformation::Error::Reason } + + # @!method initialize(reason:) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Error} + # for more details. + # + # Details about the transformation error. + # + # @param reason [Symbol, Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Error::Reason] Specific reason for the transformation failure: + + # Specific reason for the transformation failure: + # + # - `encoding_failed`: Error during video encoding process + # - `download_failed`: Could not download source video + # - `internal_server_error`: Unexpected server error + # + # @see Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Error#reason + module Reason + extend Imagekit::Internal::Type::Enum + + ENCODING_FAILED = :encoding_failed + DOWNLOAD_FAILED = :download_failed + INTERNAL_SERVER_ERROR = :internal_server_error + + # @!method self.values + # @return [Array] + end + end + + # @see Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation#options + class Options < Imagekit::Internal::Type::BaseModel + # @!attribute audio_codec + # Audio codec used for encoding (aac or opus). + # + # @return [Symbol, Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Options::AudioCodec, nil] + optional :audio_codec, + enum: -> { Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options::AudioCodec } + + # @!attribute auto_rotate + # Whether to automatically rotate the video based on metadata. + # + # @return [Boolean, nil] + optional :auto_rotate, Imagekit::Internal::Type::Boolean + + # @!attribute format_ + # Output format for the transformed video or thumbnail. + # + # @return [Symbol, Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Options::Format, nil] + optional :format_, + enum: -> { + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options::Format + }, + api_name: :format + + # @!attribute quality + # Quality setting for the output video. + # + # @return [Integer, nil] + optional :quality, Integer + + # @!attribute stream_protocol + # Streaming protocol for adaptive bitrate streaming. + # + # @return [Symbol, Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Options::StreamProtocol, nil] + optional :stream_protocol, + enum: -> { Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options::StreamProtocol } + + # @!attribute variants + # Array of quality representations for adaptive bitrate streaming. + # + # @return [Array, nil] + optional :variants, Imagekit::Internal::Type::ArrayOf[String] + + # @!attribute video_codec + # Video codec used for encoding (h264, vp9, or av1). + # + # @return [Symbol, Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Options::VideoCodec, nil] + optional :video_codec, + enum: -> { Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options::VideoCodec } + + # @!method initialize(audio_codec: nil, auto_rotate: nil, format_: nil, quality: nil, stream_protocol: nil, variants: nil, video_codec: nil) + # Configuration options for video transformations. + # + # @param audio_codec [Symbol, Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Options::AudioCodec] Audio codec used for encoding (aac or opus). + # + # @param auto_rotate [Boolean] Whether to automatically rotate the video based on metadata. + # + # @param format_ [Symbol, Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Options::Format] Output format for the transformed video or thumbnail. + # + # @param quality [Integer] Quality setting for the output video. + # + # @param stream_protocol [Symbol, Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Options::StreamProtocol] Streaming protocol for adaptive bitrate streaming. + # + # @param variants [Array] Array of quality representations for adaptive bitrate streaming. + # + # @param video_codec [Symbol, Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Options::VideoCodec] Video codec used for encoding (h264, vp9, or av1). + + # Audio codec used for encoding (aac or opus). + # + # @see Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Options#audio_codec + module AudioCodec + extend Imagekit::Internal::Type::Enum + + AAC = :aac + OPUS = :opus + + # @!method self.values + # @return [Array] + end + + # Output format for the transformed video or thumbnail. + # + # @see Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Options#format_ + module Format + extend Imagekit::Internal::Type::Enum + + MP4 = :mp4 + WEBM = :webm + JPG = :jpg + PNG = :png + WEBP = :webp + + # @!method self.values + # @return [Array] + end + + # Streaming protocol for adaptive bitrate streaming. + # + # @see Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Options#stream_protocol + module StreamProtocol + extend Imagekit::Internal::Type::Enum + + HLS = :HLS + DASH = :DASH + + # @!method self.values + # @return [Array] + end + + # Video codec used for encoding (h264, vp9, or av1). + # + # @see Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Options#video_codec + module VideoCodec + extend Imagekit::Internal::Type::Enum + + H264 = :h264 + VP9 = :vp9 + AV1 = :av1 + + # @!method self.values + # @return [Array] + end + end + end + end + + class Request < Imagekit::Internal::Type::BaseModel + # @!attribute url + # Full URL of the transformation request that was submitted. + # + # @return [String] + required :url, String + + # @!attribute x_request_id + # Unique identifier for the originating transformation request. + # + # @return [String] + required :x_request_id, String + + # @!attribute user_agent + # User-Agent header from the original request that triggered the transformation. + # + # @return [String, nil] + optional :user_agent, String + + # @!method initialize(url:, x_request_id:, user_agent: nil) + # Information about the original request that triggered the video transformation. + # + # @param url [String] Full URL of the transformation request that was submitted. + # + # @param x_request_id [String] Unique identifier for the originating transformation request. + # + # @param user_agent [String] User-Agent header from the original request that triggered the transformation. + end + end + end +end diff --git a/lib/imagekit/models/video_transformation_ready_event.rb b/lib/imagekit/models/video_transformation_ready_event.rb new file mode 100644 index 00000000..d4053bf4 --- /dev/null +++ b/lib/imagekit/models/video_transformation_ready_event.rb @@ -0,0 +1,379 @@ +# frozen_string_literal: true + +module Imagekit + module Models + class VideoTransformationReadyEvent < Imagekit::Models::BaseWebhookEvent + # @!attribute created_at + # Timestamp when the event was created in ISO8601 format. + # + # @return [Time] + required :created_at, Time + + # @!attribute data + # + # @return [Imagekit::Models::VideoTransformationReadyEvent::Data] + required :data, -> { Imagekit::VideoTransformationReadyEvent::Data } + + # @!attribute request + # Information about the original request that triggered the video transformation. + # + # @return [Imagekit::Models::VideoTransformationReadyEvent::Request] + required :request, -> { Imagekit::VideoTransformationReadyEvent::Request } + + # @!attribute type + # + # @return [Symbol, :"video.transformation.ready"] + required :type, const: :"video.transformation.ready" + + # @!attribute timings + # Performance metrics for the transformation process. + # + # @return [Imagekit::Models::VideoTransformationReadyEvent::Timings, nil] + optional :timings, -> { Imagekit::VideoTransformationReadyEvent::Timings } + + # @!method initialize(created_at:, data:, request:, timings: nil, type: :"video.transformation.ready") + # Triggered when video encoding is finished and the transformed resource is ready + # to be served. This is the key event to listen for - update your database or CMS + # flags when you receive this so your application can start showing the + # transformed video to users. + # + # @param created_at [Time] Timestamp when the event was created in ISO8601 format. + # + # @param data [Imagekit::Models::VideoTransformationReadyEvent::Data] + # + # @param request [Imagekit::Models::VideoTransformationReadyEvent::Request] Information about the original request that triggered the video transformation. + # + # @param timings [Imagekit::Models::VideoTransformationReadyEvent::Timings] Performance metrics for the transformation process. + # + # @param type [Symbol, :"video.transformation.ready"] + + class Data < Imagekit::Internal::Type::BaseModel + # @!attribute asset + # Information about the source video asset being transformed. + # + # @return [Imagekit::Models::VideoTransformationReadyEvent::Data::Asset] + required :asset, -> { Imagekit::VideoTransformationReadyEvent::Data::Asset } + + # @!attribute transformation + # + # @return [Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation] + required :transformation, -> { Imagekit::VideoTransformationReadyEvent::Data::Transformation } + + # @!method initialize(asset:, transformation:) + # @param asset [Imagekit::Models::VideoTransformationReadyEvent::Data::Asset] Information about the source video asset being transformed. + # + # @param transformation [Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation] + + # @see Imagekit::Models::VideoTransformationReadyEvent::Data#asset + class Asset < Imagekit::Internal::Type::BaseModel + # @!attribute url + # URL to download or access the source video file. + # + # @return [String] + required :url, String + + # @!method initialize(url:) + # Information about the source video asset being transformed. + # + # @param url [String] URL to download or access the source video file. + end + + # @see Imagekit::Models::VideoTransformationReadyEvent::Data#transformation + class Transformation < Imagekit::Internal::Type::BaseModel + # @!attribute type + # Type of video transformation: + # + # - `video-transformation`: Standard video processing (resize, format conversion, + # etc.) + # - `gif-to-video`: Convert animated GIF to video format + # - `video-thumbnail`: Generate thumbnail image from video + # + # @return [Symbol, Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Type] + required :type, enum: -> { Imagekit::VideoTransformationReadyEvent::Data::Transformation::Type } + + # @!attribute options + # Configuration options for video transformations. + # + # @return [Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Options, nil] + optional :options, -> { Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options } + + # @!attribute output + # Information about the transformed output video. + # + # @return [Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Output, nil] + optional :output, -> { Imagekit::VideoTransformationReadyEvent::Data::Transformation::Output } + + # @!method initialize(type:, options: nil, output: nil) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation} for more + # details. + # + # @param type [Symbol, Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Type] Type of video transformation: + # + # @param options [Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Options] Configuration options for video transformations. + # + # @param output [Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Output] Information about the transformed output video. + + # Type of video transformation: + # + # - `video-transformation`: Standard video processing (resize, format conversion, + # etc.) + # - `gif-to-video`: Convert animated GIF to video format + # - `video-thumbnail`: Generate thumbnail image from video + # + # @see Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation#type + module Type + extend Imagekit::Internal::Type::Enum + + VIDEO_TRANSFORMATION = :"video-transformation" + GIF_TO_VIDEO = :"gif-to-video" + VIDEO_THUMBNAIL = :"video-thumbnail" + + # @!method self.values + # @return [Array] + end + + # @see Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation#options + class Options < Imagekit::Internal::Type::BaseModel + # @!attribute audio_codec + # Audio codec used for encoding (aac or opus). + # + # @return [Symbol, Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Options::AudioCodec, nil] + optional :audio_codec, + enum: -> { Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options::AudioCodec } + + # @!attribute auto_rotate + # Whether to automatically rotate the video based on metadata. + # + # @return [Boolean, nil] + optional :auto_rotate, Imagekit::Internal::Type::Boolean + + # @!attribute format_ + # Output format for the transformed video or thumbnail. + # + # @return [Symbol, Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Options::Format, nil] + optional :format_, + enum: -> { + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options::Format + }, + api_name: :format + + # @!attribute quality + # Quality setting for the output video. + # + # @return [Integer, nil] + optional :quality, Integer + + # @!attribute stream_protocol + # Streaming protocol for adaptive bitrate streaming. + # + # @return [Symbol, Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Options::StreamProtocol, nil] + optional :stream_protocol, + enum: -> { Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options::StreamProtocol } + + # @!attribute variants + # Array of quality representations for adaptive bitrate streaming. + # + # @return [Array, nil] + optional :variants, Imagekit::Internal::Type::ArrayOf[String] + + # @!attribute video_codec + # Video codec used for encoding (h264, vp9, or av1). + # + # @return [Symbol, Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Options::VideoCodec, nil] + optional :video_codec, + enum: -> { Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options::VideoCodec } + + # @!method initialize(audio_codec: nil, auto_rotate: nil, format_: nil, quality: nil, stream_protocol: nil, variants: nil, video_codec: nil) + # Configuration options for video transformations. + # + # @param audio_codec [Symbol, Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Options::AudioCodec] Audio codec used for encoding (aac or opus). + # + # @param auto_rotate [Boolean] Whether to automatically rotate the video based on metadata. + # + # @param format_ [Symbol, Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Options::Format] Output format for the transformed video or thumbnail. + # + # @param quality [Integer] Quality setting for the output video. + # + # @param stream_protocol [Symbol, Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Options::StreamProtocol] Streaming protocol for adaptive bitrate streaming. + # + # @param variants [Array] Array of quality representations for adaptive bitrate streaming. + # + # @param video_codec [Symbol, Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Options::VideoCodec] Video codec used for encoding (h264, vp9, or av1). + + # Audio codec used for encoding (aac or opus). + # + # @see Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Options#audio_codec + module AudioCodec + extend Imagekit::Internal::Type::Enum + + AAC = :aac + OPUS = :opus + + # @!method self.values + # @return [Array] + end + + # Output format for the transformed video or thumbnail. + # + # @see Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Options#format_ + module Format + extend Imagekit::Internal::Type::Enum + + MP4 = :mp4 + WEBM = :webm + JPG = :jpg + PNG = :png + WEBP = :webp + + # @!method self.values + # @return [Array] + end + + # Streaming protocol for adaptive bitrate streaming. + # + # @see Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Options#stream_protocol + module StreamProtocol + extend Imagekit::Internal::Type::Enum + + HLS = :HLS + DASH = :DASH + + # @!method self.values + # @return [Array] + end + + # Video codec used for encoding (h264, vp9, or av1). + # + # @see Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Options#video_codec + module VideoCodec + extend Imagekit::Internal::Type::Enum + + H264 = :h264 + VP9 = :vp9 + AV1 = :av1 + + # @!method self.values + # @return [Array] + end + end + + # @see Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation#output + class Output < Imagekit::Internal::Type::BaseModel + # @!attribute url + # URL to access the transformed video. + # + # @return [String] + required :url, String + + # @!attribute video_metadata + # Metadata of the output video file. + # + # @return [Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Output::VideoMetadata, nil] + optional :video_metadata, + -> { Imagekit::VideoTransformationReadyEvent::Data::Transformation::Output::VideoMetadata } + + # @!method initialize(url:, video_metadata: nil) + # Information about the transformed output video. + # + # @param url [String] URL to access the transformed video. + # + # @param video_metadata [Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Output::VideoMetadata] Metadata of the output video file. + + # @see Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Output#video_metadata + class VideoMetadata < Imagekit::Internal::Type::BaseModel + # @!attribute bitrate + # Bitrate of the output video in bits per second. + # + # @return [Integer] + required :bitrate, Integer + + # @!attribute duration + # Duration of the output video in seconds. + # + # @return [Float] + required :duration, Float + + # @!attribute height + # Height of the output video in pixels. + # + # @return [Integer] + required :height, Integer + + # @!attribute width + # Width of the output video in pixels. + # + # @return [Integer] + required :width, Integer + + # @!method initialize(bitrate:, duration:, height:, width:) + # Metadata of the output video file. + # + # @param bitrate [Integer] Bitrate of the output video in bits per second. + # + # @param duration [Float] Duration of the output video in seconds. + # + # @param height [Integer] Height of the output video in pixels. + # + # @param width [Integer] Width of the output video in pixels. + end + end + end + end + + class Request < Imagekit::Internal::Type::BaseModel + # @!attribute url + # Full URL of the transformation request that was submitted. + # + # @return [String] + required :url, String + + # @!attribute x_request_id + # Unique identifier for the originating transformation request. + # + # @return [String] + required :x_request_id, String + + # @!attribute user_agent + # User-Agent header from the original request that triggered the transformation. + # + # @return [String, nil] + optional :user_agent, String + + # @!method initialize(url:, x_request_id:, user_agent: nil) + # Information about the original request that triggered the video transformation. + # + # @param url [String] Full URL of the transformation request that was submitted. + # + # @param x_request_id [String] Unique identifier for the originating transformation request. + # + # @param user_agent [String] User-Agent header from the original request that triggered the transformation. + end + + class Timings < Imagekit::Internal::Type::BaseModel + # @!attribute download_duration + # Time spent downloading the source video from your origin or media library, in + # milliseconds. + # + # @return [Integer, nil] + optional :download_duration, Integer + + # @!attribute encoding_duration + # Time spent encoding the video, in milliseconds. + # + # @return [Integer, nil] + optional :encoding_duration, Integer + + # @!method initialize(download_duration: nil, encoding_duration: nil) + # Some parameter documentations has been truncated, see + # {Imagekit::Models::VideoTransformationReadyEvent::Timings} for more details. + # + # Performance metrics for the transformation process. + # + # @param download_duration [Integer] Time spent downloading the source video from your origin or media library, in mi + # + # @param encoding_duration [Integer] Time spent encoding the video, in milliseconds. + end + end + end +end diff --git a/lib/imagekit/models/webhook_unsafe_unwrap_params.rb b/lib/imagekit/models/webhook_unsafe_unwrap_params.rb new file mode 100644 index 00000000..15530402 --- /dev/null +++ b/lib/imagekit/models/webhook_unsafe_unwrap_params.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module Imagekit + module Models + # @see Imagekit::Resources::Webhooks#unsafe_unwrap + class WebhookUnsafeUnwrapParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + # @!method initialize(request_options: {}) + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}] + end + end +end diff --git a/lib/imagekit/models/webhook_unwrap_params.rb b/lib/imagekit/models/webhook_unwrap_params.rb new file mode 100644 index 00000000..d93a86a9 --- /dev/null +++ b/lib/imagekit/models/webhook_unwrap_params.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module Imagekit + module Models + # @see Imagekit::Resources::Webhooks#unwrap + class WebhookUnwrapParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + # @!method initialize(request_options: {}) + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}] + end + end +end diff --git a/lib/imagekit/request_options.rb b/lib/imagekit/request_options.rb new file mode 100644 index 00000000..2e8ffb9e --- /dev/null +++ b/lib/imagekit/request_options.rb @@ -0,0 +1,77 @@ +# frozen_string_literal: true + +module Imagekit + # Specify HTTP behaviour to use for a specific request. These options supplement + # or override those provided at the client level. + # + # When making a request, you can pass an actual {RequestOptions} instance, or + # simply pass a Hash with symbol keys matching the attributes on this class. + class RequestOptions < Imagekit::Internal::Type::BaseModel + # @api private + # + # @param opts [Imagekit::RequestOptions, Hash{Symbol=>Object}] + # + # @raise [ArgumentError] + def self.validate!(opts) + case opts + in Imagekit::RequestOptions | Hash + opts.to_h.each_key do |k| + unless fields.include?(k) + raise ArgumentError.new("Request `opts` keys must be one of #{fields.keys}, got #{k.inspect}") + end + end + else + raise ArgumentError.new("Request `opts` must be a Hash or RequestOptions, got #{opts.inspect}") + end + end + + # @!attribute idempotency_key + # Idempotency key to send with request and all associated retries. Will only be + # sent for write requests. + # + # @return [String, nil] + optional :idempotency_key, String + + # @!attribute extra_query + # Extra query params to send with the request. These are `.merge`’d into any + # `query` given at the client level. + # + # @return [Hash{String=>Array, String, nil}, nil] + optional :extra_query, Imagekit::Internal::Type::HashOf[Imagekit::Internal::Type::ArrayOf[String]] + + # @!attribute extra_headers + # Extra headers to send with the request. These are `.merged`’d into any + # `extra_headers` given at the client level. + # + # @return [Hash{String=>String, nil}, nil] + optional :extra_headers, Imagekit::Internal::Type::HashOf[String, nil?: true] + + # @!attribute extra_body + # Extra data to send with the request. These are deep merged into any data + # generated as part of the normal request. + # + # @return [Object, nil] + optional :extra_body, Imagekit::Internal::Type::HashOf[Imagekit::Internal::Type::Unknown] + + # @!attribute max_retries + # Maximum number of retries to attempt after a failed initial request. + # + # @return [Integer, nil] + optional :max_retries, Integer + + # @!attribute timeout + # Request timeout in seconds. + # + # @return [Float, nil] + optional :timeout, Float + + # @!method initialize(values = {}) + # Returns a new instance of RequestOptions. + # + # @param values [Hash{Symbol=>Object}] + + define_sorbet_constant!(:OrHash) do + T.type_alias { T.any(Imagekit::RequestOptions, Imagekit::Internal::AnyHash) } + end + end +end diff --git a/lib/imagekit/resources/accounts.rb b/lib/imagekit/resources/accounts.rb new file mode 100644 index 00000000..5946d26e --- /dev/null +++ b/lib/imagekit/resources/accounts.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +module Imagekit + module Resources + class Accounts + # @return [Imagekit::Resources::Accounts::Usage] + attr_reader :usage + + # @return [Imagekit::Resources::Accounts::Origins] + attr_reader :origins + + # @return [Imagekit::Resources::Accounts::URLEndpoints] + attr_reader :url_endpoints + + # @api private + # + # @param client [Imagekit::Client] + def initialize(client:) + @client = client + @usage = Imagekit::Resources::Accounts::Usage.new(client: client) + @origins = Imagekit::Resources::Accounts::Origins.new(client: client) + @url_endpoints = Imagekit::Resources::Accounts::URLEndpoints.new(client: client) + end + end + end +end diff --git a/lib/imagekit/resources/accounts/origins.rb b/lib/imagekit/resources/accounts/origins.rb new file mode 100644 index 00000000..5ae00800 --- /dev/null +++ b/lib/imagekit/resources/accounts/origins.rb @@ -0,0 +1,145 @@ +# frozen_string_literal: true + +module Imagekit + module Resources + class Accounts + class Origins + # **Note:** This API is currently in beta. + # Creates a new origin and returns the origin object. + # + # @overload create(origin_request:, request_options: {}) + # + # @param origin_request [Imagekit::Accounts::OriginRequest] Schema for origin request resources. + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekit::Models::Accounts::OriginResponse::S3, Imagekit::Models::Accounts::OriginResponse::S3Compatible, Imagekit::Models::Accounts::OriginResponse::CloudinaryBackup, Imagekit::Models::Accounts::OriginResponse::WebFolder, Imagekit::Models::Accounts::OriginResponse::WebProxy, Imagekit::Models::Accounts::OriginResponse::Gcs, Imagekit::Models::Accounts::OriginResponse::AzureBlob, Imagekit::Models::Accounts::OriginResponse::AkeneoPim] + # + # @see Imagekit::Models::Accounts::OriginCreateParams + def create(params) + parsed, options = Imagekit::Accounts::OriginCreateParams.dump_request(params) + case parsed + in {origin_request: Hash => union, **rest} + parsed = {**rest, **union} + else + end + @client.request( + method: :post, + path: "v1/accounts/origins", + body: parsed, + model: Imagekit::Accounts::OriginResponse, + options: options + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Accounts::OriginUpdateParams} for more details. + # + # **Note:** This API is currently in beta. + # Updates the origin identified by `id` and returns the updated origin object. + # + # @overload update(id, origin_request:, request_options: {}) + # + # @param id [String] Unique identifier for the origin. This is generated by ImageKit when you create + # + # @param origin_request [Imagekit::Accounts::OriginRequest] Schema for origin request resources. + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekit::Models::Accounts::OriginResponse::S3, Imagekit::Models::Accounts::OriginResponse::S3Compatible, Imagekit::Models::Accounts::OriginResponse::CloudinaryBackup, Imagekit::Models::Accounts::OriginResponse::WebFolder, Imagekit::Models::Accounts::OriginResponse::WebProxy, Imagekit::Models::Accounts::OriginResponse::Gcs, Imagekit::Models::Accounts::OriginResponse::AzureBlob, Imagekit::Models::Accounts::OriginResponse::AkeneoPim] + # + # @see Imagekit::Models::Accounts::OriginUpdateParams + def update(id, params) + parsed, options = Imagekit::Accounts::OriginUpdateParams.dump_request(params) + case parsed + in {origin_request: Hash => union, **rest} + parsed = {**rest, **union} + else + end + @client.request( + method: :put, + path: ["v1/accounts/origins/%1$s", id], + body: parsed, + model: Imagekit::Accounts::OriginResponse, + options: options + ) + end + + # **Note:** This API is currently in beta. + # Returns an array of all configured origins for the current account. + # + # @overload list(request_options: {}) + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Array] + # + # @see Imagekit::Models::Accounts::OriginListParams + def list(params = {}) + @client.request( + method: :get, + path: "v1/accounts/origins", + model: Imagekit::Internal::Type::ArrayOf[union: Imagekit::Accounts::OriginResponse], + options: params[:request_options] + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Accounts::OriginDeleteParams} for more details. + # + # **Note:** This API is currently in beta. + # Permanently removes the origin identified by `id`. If the origin is in use by + # any URL‑endpoints, the API will return an error. + # + # @overload delete(id, request_options: {}) + # + # @param id [String] Unique identifier for the origin. This is generated by ImageKit when you create + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [nil] + # + # @see Imagekit::Models::Accounts::OriginDeleteParams + def delete(id, params = {}) + @client.request( + method: :delete, + path: ["v1/accounts/origins/%1$s", id], + model: NilClass, + options: params[:request_options] + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Accounts::OriginGetParams} for more details. + # + # **Note:** This API is currently in beta. + # Retrieves the origin identified by `id`. + # + # @overload get(id, request_options: {}) + # + # @param id [String] Unique identifier for the origin. This is generated by ImageKit when you create + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekit::Models::Accounts::OriginResponse::S3, Imagekit::Models::Accounts::OriginResponse::S3Compatible, Imagekit::Models::Accounts::OriginResponse::CloudinaryBackup, Imagekit::Models::Accounts::OriginResponse::WebFolder, Imagekit::Models::Accounts::OriginResponse::WebProxy, Imagekit::Models::Accounts::OriginResponse::Gcs, Imagekit::Models::Accounts::OriginResponse::AzureBlob, Imagekit::Models::Accounts::OriginResponse::AkeneoPim] + # + # @see Imagekit::Models::Accounts::OriginGetParams + def get(id, params = {}) + @client.request( + method: :get, + path: ["v1/accounts/origins/%1$s", id], + model: Imagekit::Accounts::OriginResponse, + options: params[:request_options] + ) + end + + # @api private + # + # @param client [Imagekit::Client] + def initialize(client:) + @client = client + end + end + end + end +end diff --git a/lib/imagekit/resources/accounts/url_endpoints.rb b/lib/imagekit/resources/accounts/url_endpoints.rb new file mode 100644 index 00000000..c94d9fe9 --- /dev/null +++ b/lib/imagekit/resources/accounts/url_endpoints.rb @@ -0,0 +1,151 @@ +# frozen_string_literal: true + +module Imagekit + module Resources + class Accounts + class URLEndpoints + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Accounts::URLEndpointCreateParams} for more details. + # + # **Note:** This API is currently in beta. + # Creates a new URL‑endpoint and returns the resulting object. + # + # @overload create(description:, origins: nil, url_prefix: nil, url_rewriter: nil, request_options: {}) + # + # @param description [String] Description of the URL endpoint. + # + # @param origins [Array] Ordered list of origin IDs to try when the file isn’t in the Media Library; Imag + # + # @param url_prefix [String] Path segment appended to your base URL to form the endpoint (letters, digits, an + # + # @param url_rewriter [Imagekit::Models::Accounts::URLEndpointRequest::URLRewriter::Cloudinary, Imagekit::Models::Accounts::URLEndpointRequest::URLRewriter::Imgix, Imagekit::Models::Accounts::URLEndpointRequest::URLRewriter::Akamai] Configuration for third-party URL rewriting. + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekit::Models::Accounts::URLEndpointResponse] + # + # @see Imagekit::Models::Accounts::URLEndpointCreateParams + def create(params) + parsed, options = Imagekit::Accounts::URLEndpointCreateParams.dump_request(params) + @client.request( + method: :post, + path: "v1/accounts/url-endpoints", + body: parsed, + model: Imagekit::Accounts::URLEndpointResponse, + options: options + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Accounts::URLEndpointUpdateParams} for more details. + # + # **Note:** This API is currently in beta. + # Updates the URL‑endpoint identified by `id` and returns the updated object. + # + # @overload update(id, description:, origins: nil, url_prefix: nil, url_rewriter: nil, request_options: {}) + # + # @param id [String] Unique identifier for the URL-endpoint. This is generated by ImageKit when you c + # + # @param description [String] Description of the URL endpoint. + # + # @param origins [Array] Ordered list of origin IDs to try when the file isn’t in the Media Library; Imag + # + # @param url_prefix [String] Path segment appended to your base URL to form the endpoint (letters, digits, an + # + # @param url_rewriter [Imagekit::Models::Accounts::URLEndpointRequest::URLRewriter::Cloudinary, Imagekit::Models::Accounts::URLEndpointRequest::URLRewriter::Imgix, Imagekit::Models::Accounts::URLEndpointRequest::URLRewriter::Akamai] Configuration for third-party URL rewriting. + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekit::Models::Accounts::URLEndpointResponse] + # + # @see Imagekit::Models::Accounts::URLEndpointUpdateParams + def update(id, params) + parsed, options = Imagekit::Accounts::URLEndpointUpdateParams.dump_request(params) + @client.request( + method: :put, + path: ["v1/accounts/url-endpoints/%1$s", id], + body: parsed, + model: Imagekit::Accounts::URLEndpointResponse, + options: options + ) + end + + # **Note:** This API is currently in beta. + # Returns an array of all URL‑endpoints configured including the default + # URL-endpoint generated by ImageKit during account creation. + # + # @overload list(request_options: {}) + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Array] + # + # @see Imagekit::Models::Accounts::URLEndpointListParams + def list(params = {}) + @client.request( + method: :get, + path: "v1/accounts/url-endpoints", + model: Imagekit::Internal::Type::ArrayOf[Imagekit::Accounts::URLEndpointResponse], + options: params[:request_options] + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Accounts::URLEndpointDeleteParams} for more details. + # + # **Note:** This API is currently in beta. + # Deletes the URL‑endpoint identified by `id`. You cannot delete the default + # URL‑endpoint created by ImageKit during account creation. + # + # @overload delete(id, request_options: {}) + # + # @param id [String] Unique identifier for the URL-endpoint. This is generated by ImageKit when you c + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [nil] + # + # @see Imagekit::Models::Accounts::URLEndpointDeleteParams + def delete(id, params = {}) + @client.request( + method: :delete, + path: ["v1/accounts/url-endpoints/%1$s", id], + model: NilClass, + options: params[:request_options] + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Accounts::URLEndpointGetParams} for more details. + # + # **Note:** This API is currently in beta. + # Retrieves the URL‑endpoint identified by `id`. + # + # @overload get(id, request_options: {}) + # + # @param id [String] Unique identifier for the URL-endpoint. This is generated by ImageKit when you c + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekit::Models::Accounts::URLEndpointResponse] + # + # @see Imagekit::Models::Accounts::URLEndpointGetParams + def get(id, params = {}) + @client.request( + method: :get, + path: ["v1/accounts/url-endpoints/%1$s", id], + model: Imagekit::Accounts::URLEndpointResponse, + options: params[:request_options] + ) + end + + # @api private + # + # @param client [Imagekit::Client] + def initialize(client:) + @client = client + end + end + end + end +end diff --git a/lib/imagekit/resources/accounts/usage.rb b/lib/imagekit/resources/accounts/usage.rb new file mode 100644 index 00000000..ed062095 --- /dev/null +++ b/lib/imagekit/resources/accounts/usage.rb @@ -0,0 +1,46 @@ +# frozen_string_literal: true + +module Imagekit + module Resources + class Accounts + class Usage + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Accounts::UsageGetParams} for more details. + # + # Get the account usage information between two dates. Note that the API response + # includes data from the start date while excluding data from the end date. In + # other words, the data covers the period starting from the specified start date + # up to, but not including, the end date. + # + # @overload get(end_date:, start_date:, request_options: {}) + # + # @param end_date [Date] Specify a `endDate` in `YYYY-MM-DD` format. It should be after the `startDate`. + # + # @param start_date [Date] Specify a `startDate` in `YYYY-MM-DD` format. It should be before the `endDate`. + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekit::Models::Accounts::UsageGetResponse] + # + # @see Imagekit::Models::Accounts::UsageGetParams + def get(params) + parsed, options = Imagekit::Accounts::UsageGetParams.dump_request(params) + @client.request( + method: :get, + path: "v1/accounts/usage", + query: parsed.transform_keys(end_date: "endDate", start_date: "startDate"), + model: Imagekit::Models::Accounts::UsageGetResponse, + options: options + ) + end + + # @api private + # + # @param client [Imagekit::Client] + def initialize(client:) + @client = client + end + end + end + end +end diff --git a/lib/imagekit/resources/assets.rb b/lib/imagekit/resources/assets.rb new file mode 100644 index 00000000..de7abc9a --- /dev/null +++ b/lib/imagekit/resources/assets.rb @@ -0,0 +1,54 @@ +# frozen_string_literal: true + +module Imagekit + module Resources + class Assets + # Some parameter documentations has been truncated, see + # {Imagekit::Models::AssetListParams} for more details. + # + # This API can list all the uploaded files and folders in your ImageKit.io media + # library. In addition, you can fine-tune your query by specifying various filters + # by generating a query string in a Lucene-like syntax and provide this generated + # string as the value of the `searchQuery`. + # + # @overload list(file_type: nil, limit: nil, path: nil, search_query: nil, skip: nil, sort: nil, type: nil, request_options: {}) + # + # @param file_type [Symbol, Imagekit::Models::AssetListParams::FileType] Filter results by file type. + # + # @param limit [Integer] The maximum number of results to return in response. + # + # @param path [String] Folder path if you want to limit the search within a specific folder. For exampl + # + # @param search_query [String] Query string in a Lucene-like query language e.g. `createdAt > "7d"`. + # + # @param skip [Integer] The number of results to skip before returning results. + # + # @param sort [Symbol, Imagekit::Models::AssetListParams::Sort] Sort the results by one of the supported fields in ascending or descending order + # + # @param type [Symbol, Imagekit::Models::AssetListParams::Type] Filter results by asset type. + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Array] + # + # @see Imagekit::Models::AssetListParams + def list(params = {}) + parsed, options = Imagekit::AssetListParams.dump_request(params) + @client.request( + method: :get, + path: "v1/files", + query: parsed.transform_keys(file_type: "fileType", search_query: "searchQuery"), + model: Imagekit::Internal::Type::ArrayOf[union: Imagekit::Models::AssetListResponseItem], + options: options + ) + end + + # @api private + # + # @param client [Imagekit::Client] + def initialize(client:) + @client = client + end + end + end +end diff --git a/lib/imagekit/resources/beta.rb b/lib/imagekit/resources/beta.rb new file mode 100644 index 00000000..b7d7a5ea --- /dev/null +++ b/lib/imagekit/resources/beta.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +module Imagekit + module Resources + class Beta + # @return [Imagekit::Resources::Beta::V2] + attr_reader :v2 + + # @api private + # + # @param client [Imagekit::Client] + def initialize(client:) + @client = client + @v2 = Imagekit::Resources::Beta::V2.new(client: client) + end + end + end +end diff --git a/lib/imagekit/resources/beta/v2.rb b/lib/imagekit/resources/beta/v2.rb new file mode 100644 index 00000000..8510456c --- /dev/null +++ b/lib/imagekit/resources/beta/v2.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +module Imagekit + module Resources + class Beta + class V2 + # @return [Imagekit::Resources::Beta::V2::Files] + attr_reader :files + + # @api private + # + # @param client [Imagekit::Client] + def initialize(client:) + @client = client + @files = Imagekit::Resources::Beta::V2::Files.new(client: client) + end + end + end + end +end diff --git a/lib/imagekit/resources/beta/v2/files.rb b/lib/imagekit/resources/beta/v2/files.rb new file mode 100644 index 00000000..670d5a60 --- /dev/null +++ b/lib/imagekit/resources/beta/v2/files.rb @@ -0,0 +1,110 @@ +# frozen_string_literal: true + +module Imagekit + module Resources + class Beta + class V2 + class Files + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Beta::V2::FileUploadParams} for more details. + # + # The V2 API enhances security by verifying the entire payload using JWT. This API + # is in beta. + # + # ImageKit.io allows you to upload files directly from both the server and client + # sides. For server-side uploads, private API key authentication is used. For + # client-side uploads, generate a one-time `token` from your secure backend using + # private API. + # [Learn more](/docs/api-reference/upload-file/upload-file-v2#how-to-implement-secure-client-side-file-upload) + # about how to implement secure client-side file upload. + # + # **File size limit** \ + # On the free plan, the maximum upload file sizes are 20MB for images, audio, and raw + # files, and 100MB for videos. On the paid plan, these limits increase to 40MB for + # images, audio, and raw files, and 2GB for videos. These limits can be further increased + # with higher-tier plans. + # + # **Version limit** \ + # A file can have a maximum of 100 versions. + # + # **Demo applications** + # + # - A full-fledged + # [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), + # supporting file selections from local storage, URL, Dropbox, Google Drive, + # Instagram, and more. + # - [Quick start guides](/docs/quick-start-guides) for various frameworks and + # technologies. + # + # @overload upload(file:, file_name:, token: nil, checks: nil, custom_coordinates: nil, custom_metadata: nil, description: nil, extensions: nil, folder: nil, is_private_file: nil, is_published: nil, overwrite_ai_tags: nil, overwrite_custom_metadata: nil, overwrite_file: nil, overwrite_tags: nil, response_fields: nil, tags: nil, transformation: nil, use_unique_file_name: nil, webhook_url: nil, request_options: {}) + # + # @param file [Pathname, StringIO, IO, String, Imagekit::FilePart] The API accepts any of the following: + # + # @param file_name [String] The name with which the file has to be uploaded. + # + # @param token [String] This is the client-generated JSON Web Token (JWT). The ImageKit.io server uses i + # + # @param checks [String] Server-side checks to run on the asset. + # + # @param custom_coordinates [String] Define an important area in the image. This is only relevant for image type file + # + # @param custom_metadata [Hash{Symbol=>Object}] JSON key-value pairs to associate with the asset. Create the custom metadata fie + # + # @param description [String] Optional text to describe the contents of the file. + # + # @param extensions [Array] Array of extensions to be applied to the asset. Each extension can be configured + # + # @param folder [String] The folder path in which the image has to be uploaded. If the folder(s) didn't e + # + # @param is_private_file [Boolean] Whether to mark the file as private or not. + # + # @param is_published [Boolean] Whether to upload file as published or not. + # + # @param overwrite_ai_tags [Boolean] If set to `true` and a file already exists at the exact location, its AITags wil + # + # @param overwrite_custom_metadata [Boolean] If the request does not have `customMetadata`, and a file already exists at the + # + # @param overwrite_file [Boolean] If `false` and `useUniqueFileName` is also `false`, and a file already exists at + # + # @param overwrite_tags [Boolean] If the request does not have `tags`, and a file already exists at the exact loca + # + # @param response_fields [Array] Array of response field keys to include in the API response body. + # + # @param tags [Array] Set the tags while uploading the file. + # + # @param transformation [Imagekit::Models::Beta::V2::FileUploadParams::Transformation] Configure pre-processing (`pre`) and post-processing (`post`) transformations. + # + # @param use_unique_file_name [Boolean] Whether to use a unique filename for this file or not. + # + # @param webhook_url [String] The final status of extensions after they have completed execution will be deliv + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekit::Models::Beta::V2::FileUploadResponse] + # + # @see Imagekit::Models::Beta::V2::FileUploadParams + def upload(params) + parsed, options = Imagekit::Beta::V2::FileUploadParams.dump_request(params) + path = + @client.base_url_overridden? ? "api/v2/files/upload" : "https://upload.imagekit.io/api/v2/files/upload" + @client.request( + method: :post, + path: path, + headers: {"content-type" => "multipart/form-data"}, + body: parsed, + model: Imagekit::Models::Beta::V2::FileUploadResponse, + options: options + ) + end + + # @api private + # + # @param client [Imagekit::Client] + def initialize(client:) + @client = client + end + end + end + end + end +end diff --git a/lib/imagekit/resources/cache.rb b/lib/imagekit/resources/cache.rb new file mode 100644 index 00000000..1b666377 --- /dev/null +++ b/lib/imagekit/resources/cache.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +module Imagekit + module Resources + class Cache + # @return [Imagekit::Resources::Cache::Invalidation] + attr_reader :invalidation + + # @api private + # + # @param client [Imagekit::Client] + def initialize(client:) + @client = client + @invalidation = Imagekit::Resources::Cache::Invalidation.new(client: client) + end + end + end +end diff --git a/lib/imagekit/resources/cache/invalidation.rb b/lib/imagekit/resources/cache/invalidation.rb new file mode 100644 index 00000000..a084abea --- /dev/null +++ b/lib/imagekit/resources/cache/invalidation.rb @@ -0,0 +1,66 @@ +# frozen_string_literal: true + +module Imagekit + module Resources + class Cache + class Invalidation + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Cache::InvalidationCreateParams} for more details. + # + # This API will purge CDN cache and ImageKit.io's internal cache for a file. Note: + # Purge cache is an asynchronous process and it may take some time to reflect the + # changes. + # + # @overload create(url:, request_options: {}) + # + # @param url [String] The full URL of the file to be purged. + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekit::Models::Cache::InvalidationCreateResponse] + # + # @see Imagekit::Models::Cache::InvalidationCreateParams + def create(params) + parsed, options = Imagekit::Cache::InvalidationCreateParams.dump_request(params) + @client.request( + method: :post, + path: "v1/files/purge", + body: parsed, + model: Imagekit::Models::Cache::InvalidationCreateResponse, + options: options + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Cache::InvalidationGetParams} for more details. + # + # This API returns the status of a purge cache request. + # + # @overload get(request_id, request_options: {}) + # + # @param request_id [String] Should be a valid requestId. + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekit::Models::Cache::InvalidationGetResponse] + # + # @see Imagekit::Models::Cache::InvalidationGetParams + def get(request_id, params = {}) + @client.request( + method: :get, + path: ["v1/files/purge/%1$s", request_id], + model: Imagekit::Models::Cache::InvalidationGetResponse, + options: params[:request_options] + ) + end + + # @api private + # + # @param client [Imagekit::Client] + def initialize(client:) + @client = client + end + end + end + end +end diff --git a/lib/imagekit/resources/custom_metadata_fields.rb b/lib/imagekit/resources/custom_metadata_fields.rb new file mode 100644 index 00000000..29da6980 --- /dev/null +++ b/lib/imagekit/resources/custom_metadata_fields.rb @@ -0,0 +1,126 @@ +# frozen_string_literal: true + +module Imagekit + module Resources + class CustomMetadataFields + # Some parameter documentations has been truncated, see + # {Imagekit::Models::CustomMetadataFieldCreateParams} for more details. + # + # This API creates a new custom metadata field. Once a custom metadata field is + # created either through this API or using the dashboard UI, its value can be set + # on the assets. The value of a field for an asset can be set using the media + # library UI or programmatically through upload or update assets API. + # + # @overload create(label:, name:, schema:, request_options: {}) + # + # @param label [String] Human readable name of the custom metadata field. This should be unique across a + # + # @param name [String] API name of the custom metadata field. This should be unique across all (includi + # + # @param schema [Imagekit::Models::CustomMetadataFieldCreateParams::Schema] + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekit::Models::CustomMetadataField] + # + # @see Imagekit::Models::CustomMetadataFieldCreateParams + def create(params) + parsed, options = Imagekit::CustomMetadataFieldCreateParams.dump_request(params) + @client.request( + method: :post, + path: "v1/customMetadataFields", + body: parsed, + model: Imagekit::CustomMetadataField, + options: options + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekit::Models::CustomMetadataFieldUpdateParams} for more details. + # + # This API updates the label or schema of an existing custom metadata field. + # + # @overload update(id, label: nil, schema: nil, request_options: {}) + # + # @param id [String] Should be a valid custom metadata field id. + # + # @param label [String] Human readable name of the custom metadata field. This should be unique across a + # + # @param schema [Imagekit::Models::CustomMetadataFieldUpdateParams::Schema] An object that describes the rules for the custom metadata key. This parameter i + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekit::Models::CustomMetadataField] + # + # @see Imagekit::Models::CustomMetadataFieldUpdateParams + def update(id, params = {}) + parsed, options = Imagekit::CustomMetadataFieldUpdateParams.dump_request(params) + @client.request( + method: :patch, + path: ["v1/customMetadataFields/%1$s", id], + body: parsed, + model: Imagekit::CustomMetadataField, + options: options + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekit::Models::CustomMetadataFieldListParams} for more details. + # + # This API returns the array of created custom metadata field objects. By default + # the API returns only non deleted field objects, but you can include deleted + # fields in the API response. + # + # @overload list(include_deleted: nil, request_options: {}) + # + # @param include_deleted [Boolean] Set it to `true` to include deleted field objects in the API response. + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Array] + # + # @see Imagekit::Models::CustomMetadataFieldListParams + def list(params = {}) + parsed, options = Imagekit::CustomMetadataFieldListParams.dump_request(params) + @client.request( + method: :get, + path: "v1/customMetadataFields", + query: parsed.transform_keys(include_deleted: "includeDeleted"), + model: Imagekit::Internal::Type::ArrayOf[Imagekit::CustomMetadataField], + options: options + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekit::Models::CustomMetadataFieldDeleteParams} for more details. + # + # This API deletes a custom metadata field. Even after deleting a custom metadata + # field, you cannot create any new custom metadata field with the same name. + # + # @overload delete(id, request_options: {}) + # + # @param id [String] Should be a valid custom metadata field id. + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekit::Models::CustomMetadataFieldDeleteResponse] + # + # @see Imagekit::Models::CustomMetadataFieldDeleteParams + def delete(id, params = {}) + @client.request( + method: :delete, + path: ["v1/customMetadataFields/%1$s", id], + model: Imagekit::Models::CustomMetadataFieldDeleteResponse, + options: params[:request_options] + ) + end + + # @api private + # + # @param client [Imagekit::Client] + def initialize(client:) + @client = client + end + end + end +end diff --git a/lib/imagekit/resources/files.rb b/lib/imagekit/resources/files.rb new file mode 100644 index 00000000..2ddc77ef --- /dev/null +++ b/lib/imagekit/resources/files.rb @@ -0,0 +1,305 @@ +# frozen_string_literal: true + +module Imagekit + module Resources + class Files + # @return [Imagekit::Resources::Files::Bulk] + attr_reader :bulk + + # @return [Imagekit::Resources::Files::Versions] + attr_reader :versions + + # @return [Imagekit::Resources::Files::Metadata] + attr_reader :metadata + + # Some parameter documentations has been truncated, see + # {Imagekit::Models::FileUpdateParams} for more details. + # + # This API updates the details or attributes of the current version of the file. + # You can update `tags`, `customCoordinates`, `customMetadata`, publication + # status, remove existing `AITags` and apply extensions using this API. + # + # @overload update(file_id, update_file_request:, request_options: {}) + # + # @param file_id [String] The unique `fileId` of the uploaded file. `fileId` is returned in list and searc + # + # @param update_file_request [Imagekit::UpdateFileRequest] Schema for update file update request. + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekit::Models::FileUpdateResponse] + # + # @see Imagekit::Models::FileUpdateParams + def update(file_id, params) + parsed, options = Imagekit::FileUpdateParams.dump_request(params) + case parsed + in {update_file_request: Hash => union, **rest} + parsed = {**rest, **union} + else + end + @client.request( + method: :patch, + path: ["v1/files/%1$s/details", file_id], + body: parsed, + model: Imagekit::Models::FileUpdateResponse, + options: options + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekit::Models::FileDeleteParams} for more details. + # + # This API deletes the file and all its file versions permanently. + # + # Note: If a file or specific transformation has been requested in the past, then + # the response is cached. Deleting a file does not purge the cache. You can purge + # the cache using purge cache API. + # + # @overload delete(file_id, request_options: {}) + # + # @param file_id [String] The unique `fileId` of the uploaded file. `fileId` is returned in list and searc + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [nil] + # + # @see Imagekit::Models::FileDeleteParams + def delete(file_id, params = {}) + @client.request( + method: :delete, + path: ["v1/files/%1$s", file_id], + model: NilClass, + options: params[:request_options] + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekit::Models::FileCopyParams} for more details. + # + # This will copy a file from one folder to another. + # + # Note: If any file at the destination has the same name as the source file, then + # the source file and its versions (if `includeFileVersions` is set to true) will + # be appended to the destination file version history. + # + # @overload copy(destination_path:, source_file_path:, include_file_versions: nil, request_options: {}) + # + # @param destination_path [String] Full path to the folder you want to copy the above file into. + # + # @param source_file_path [String] The full path of the file you want to copy. + # + # @param include_file_versions [Boolean] Option to copy all versions of a file. By default, only the current version of t + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekit::Models::FileCopyResponse] + # + # @see Imagekit::Models::FileCopyParams + def copy(params) + parsed, options = Imagekit::FileCopyParams.dump_request(params) + @client.request( + method: :post, + path: "v1/files/copy", + body: parsed, + model: Imagekit::Models::FileCopyResponse, + options: options + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekit::Models::FileGetParams} for more details. + # + # This API returns an object with details or attributes about the current version + # of the file. + # + # @overload get(file_id, request_options: {}) + # + # @param file_id [String] The unique `fileId` of the uploaded file. `fileId` is returned in the list and s + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekit::Models::File] + # + # @see Imagekit::Models::FileGetParams + def get(file_id, params = {}) + @client.request( + method: :get, + path: ["v1/files/%1$s/details", file_id], + model: Imagekit::File, + options: params[:request_options] + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekit::Models::FileMoveParams} for more details. + # + # This will move a file and all its versions from one folder to another. + # + # Note: If any file at the destination has the same name as the source file, then + # the source file and its versions will be appended to the destination file. + # + # @overload move(destination_path:, source_file_path:, request_options: {}) + # + # @param destination_path [String] Full path to the folder you want to move the above file into. + # + # @param source_file_path [String] The full path of the file you want to move. + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekit::Models::FileMoveResponse] + # + # @see Imagekit::Models::FileMoveParams + def move(params) + parsed, options = Imagekit::FileMoveParams.dump_request(params) + @client.request( + method: :post, + path: "v1/files/move", + body: parsed, + model: Imagekit::Models::FileMoveResponse, + options: options + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekit::Models::FileRenameParams} for more details. + # + # You can rename an already existing file in the media library using rename file + # API. This operation would rename all file versions of the file. + # + # Note: The old URLs will stop working. The file/file version URLs cached on CDN + # will continue to work unless a purge is requested. + # + # @overload rename(file_path:, new_file_name:, purge_cache: nil, request_options: {}) + # + # @param file_path [String] The full path of the file you want to rename. + # + # @param new_file_name [String] The new name of the file. A filename can contain: + # + # @param purge_cache [Boolean] Option to purge cache for the old file and its versions' URLs. + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekit::Models::FileRenameResponse] + # + # @see Imagekit::Models::FileRenameParams + def rename(params) + parsed, options = Imagekit::FileRenameParams.dump_request(params) + @client.request( + method: :put, + path: "v1/files/rename", + body: parsed, + model: Imagekit::Models::FileRenameResponse, + options: options + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekit::Models::FileUploadParams} for more details. + # + # ImageKit.io allows you to upload files directly from both the server and client + # sides. For server-side uploads, private API key authentication is used. For + # client-side uploads, generate a one-time `token`, `signature`, and `expire` from + # your secure backend using private API. + # [Learn more](/docs/api-reference/upload-file/upload-file#how-to-implement-client-side-file-upload) + # about how to implement client-side file upload. + # + # The [V2 API](/docs/api-reference/upload-file/upload-file-v2) enhances security + # by verifying the entire payload using JWT. + # + # **File size limit** \ + # On the free plan, the maximum upload file sizes are 20MB for images, audio, and raw + # files and 100MB for videos. On the paid plan, these limits increase to 40MB for images, + # audio, and raw files and 2GB for videos. These limits can be further increased with + # higher-tier plans. + # + # **Version limit** \ + # A file can have a maximum of 100 versions. + # + # **Demo applications** + # + # - A full-fledged + # [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), + # supporting file selections from local storage, URL, Dropbox, Google Drive, + # Instagram, and more. + # - [Quick start guides](/docs/quick-start-guides) for various frameworks and + # technologies. + # + # @overload upload(file:, file_name:, token: nil, checks: nil, custom_coordinates: nil, custom_metadata: nil, description: nil, expire: nil, extensions: nil, folder: nil, is_private_file: nil, is_published: nil, overwrite_ai_tags: nil, overwrite_custom_metadata: nil, overwrite_file: nil, overwrite_tags: nil, public_key: nil, response_fields: nil, signature: nil, tags: nil, transformation: nil, use_unique_file_name: nil, webhook_url: nil, request_options: {}) + # + # @param file [Pathname, StringIO, IO, String, Imagekit::FilePart] The API accepts any of the following: + # + # @param file_name [String] The name with which the file has to be uploaded. + # + # @param token [String] A unique value that the ImageKit.io server will use to recognize and prevent sub + # + # @param checks [String] Server-side checks to run on the asset. + # + # @param custom_coordinates [String] Define an important area in the image. This is only relevant for image type file + # + # @param custom_metadata [Hash{Symbol=>Object}] JSON key-value pairs to associate with the asset. Create the custom metadata fie + # + # @param description [String] Optional text to describe the contents of the file. + # + # @param expire [Integer] The time until your signature is valid. It must be a [Unix time](https://en.wiki + # + # @param extensions [Array] Array of extensions to be applied to the asset. Each extension can be configured + # + # @param folder [String] The folder path in which the image has to be uploaded. If the folder(s) didn't e + # + # @param is_private_file [Boolean] Whether to mark the file as private or not. + # + # @param is_published [Boolean] Whether to upload file as published or not. + # + # @param overwrite_ai_tags [Boolean] If set to `true` and a file already exists at the exact location, its AITags wil + # + # @param overwrite_custom_metadata [Boolean] If the request does not have `customMetadata`, and a file already exists at the + # + # @param overwrite_file [Boolean] If `false` and `useUniqueFileName` is also `false`, and a file already exists at + # + # @param overwrite_tags [Boolean] If the request does not have `tags`, and a file already exists at the exact loca + # + # @param public_key [String] Your ImageKit.io public key. This field is only required for authentication when + # + # @param response_fields [Array] Array of response field keys to include in the API response body. + # + # @param signature [String] HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a + # + # @param tags [Array] Set the tags while uploading the file. + # + # @param transformation [Imagekit::Models::FileUploadParams::Transformation] Configure pre-processing (`pre`) and post-processing (`post`) transformations. + # + # @param use_unique_file_name [Boolean] Whether to use a unique filename for this file or not. + # + # @param webhook_url [String] The final status of extensions after they have completed execution will be deliv + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekit::Models::FileUploadResponse] + # + # @see Imagekit::Models::FileUploadParams + def upload(params) + parsed, options = Imagekit::FileUploadParams.dump_request(params) + path = + @client.base_url_overridden? ? "api/v1/files/upload" : "https://upload.imagekit.io/api/v1/files/upload" + @client.request( + method: :post, + path: path, + headers: {"content-type" => "multipart/form-data"}, + body: parsed, + model: Imagekit::Models::FileUploadResponse, + options: options + ) + end + + # @api private + # + # @param client [Imagekit::Client] + def initialize(client:) + @client = client + @bulk = Imagekit::Resources::Files::Bulk.new(client: client) + @versions = Imagekit::Resources::Files::Versions.new(client: client) + @metadata = Imagekit::Resources::Files::Metadata.new(client: client) + end + end + end +end diff --git a/lib/imagekit/resources/files/bulk.rb b/lib/imagekit/resources/files/bulk.rb new file mode 100644 index 00000000..1f09cdbe --- /dev/null +++ b/lib/imagekit/resources/files/bulk.rb @@ -0,0 +1,131 @@ +# frozen_string_literal: true + +module Imagekit + module Resources + class Files + class Bulk + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Files::BulkDeleteParams} for more details. + # + # This API deletes multiple files and all their file versions permanently. + # + # Note: If a file or specific transformation has been requested in the past, then + # the response is cached. Deleting a file does not purge the cache. You can purge + # the cache using purge cache API. + # + # A maximum of 100 files can be deleted at a time. + # + # @overload delete(file_ids:, request_options: {}) + # + # @param file_ids [Array] An array of fileIds which you want to delete. + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekit::Models::Files::BulkDeleteResponse] + # + # @see Imagekit::Models::Files::BulkDeleteParams + def delete(params) + parsed, options = Imagekit::Files::BulkDeleteParams.dump_request(params) + @client.request( + method: :post, + path: "v1/files/batch/deleteByFileIds", + body: parsed, + model: Imagekit::Models::Files::BulkDeleteResponse, + options: options + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Files::BulkAddTagsParams} for more details. + # + # This API adds tags to multiple files in bulk. A maximum of 50 files can be + # specified at a time. + # + # @overload add_tags(file_ids:, tags:, request_options: {}) + # + # @param file_ids [Array] An array of fileIds to which you want to add tags. + # + # @param tags [Array] An array of tags that you want to add to the files. + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekit::Models::Files::BulkAddTagsResponse] + # + # @see Imagekit::Models::Files::BulkAddTagsParams + def add_tags(params) + parsed, options = Imagekit::Files::BulkAddTagsParams.dump_request(params) + @client.request( + method: :post, + path: "v1/files/addTags", + body: parsed, + model: Imagekit::Models::Files::BulkAddTagsResponse, + options: options + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Files::BulkRemoveAITagsParams} for more details. + # + # This API removes AITags from multiple files in bulk. A maximum of 50 files can + # be specified at a time. + # + # @overload remove_ai_tags(ai_tags:, file_ids:, request_options: {}) + # + # @param ai_tags [Array] An array of AITags that you want to remove from the files. + # + # @param file_ids [Array] An array of fileIds from which you want to remove AITags. + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekit::Models::Files::BulkRemoveAITagsResponse] + # + # @see Imagekit::Models::Files::BulkRemoveAITagsParams + def remove_ai_tags(params) + parsed, options = Imagekit::Files::BulkRemoveAITagsParams.dump_request(params) + @client.request( + method: :post, + path: "v1/files/removeAITags", + body: parsed, + model: Imagekit::Models::Files::BulkRemoveAITagsResponse, + options: options + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Files::BulkRemoveTagsParams} for more details. + # + # This API removes tags from multiple files in bulk. A maximum of 50 files can be + # specified at a time. + # + # @overload remove_tags(file_ids:, tags:, request_options: {}) + # + # @param file_ids [Array] An array of fileIds from which you want to remove tags. + # + # @param tags [Array] An array of tags that you want to remove from the files. + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekit::Models::Files::BulkRemoveTagsResponse] + # + # @see Imagekit::Models::Files::BulkRemoveTagsParams + def remove_tags(params) + parsed, options = Imagekit::Files::BulkRemoveTagsParams.dump_request(params) + @client.request( + method: :post, + path: "v1/files/removeTags", + body: parsed, + model: Imagekit::Models::Files::BulkRemoveTagsResponse, + options: options + ) + end + + # @api private + # + # @param client [Imagekit::Client] + def initialize(client:) + @client = client + end + end + end + end +end diff --git a/lib/imagekit/resources/files/metadata.rb b/lib/imagekit/resources/files/metadata.rb new file mode 100644 index 00000000..cc941499 --- /dev/null +++ b/lib/imagekit/resources/files/metadata.rb @@ -0,0 +1,69 @@ +# frozen_string_literal: true + +module Imagekit + module Resources + class Files + class Metadata + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Files::MetadataGetParams} for more details. + # + # You can programmatically get image EXIF, pHash, and other metadata for uploaded + # files in the ImageKit.io media library using this API. + # + # You can also get the metadata in upload API response by passing `metadata` in + # `responseFields` parameter. + # + # @overload get(file_id, request_options: {}) + # + # @param file_id [String] The unique `fileId` of the uploaded file. `fileId` is returned in the list and s + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekit::Models::Metadata] + # + # @see Imagekit::Models::Files::MetadataGetParams + def get(file_id, params = {}) + @client.request( + method: :get, + path: ["v1/files/%1$s/metadata", file_id], + model: Imagekit::Metadata, + options: params[:request_options] + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Files::MetadataGetFromURLParams} for more details. + # + # Get image EXIF, pHash, and other metadata from ImageKit.io powered remote URL + # using this API. + # + # @overload get_from_url(url:, request_options: {}) + # + # @param url [String] Should be a valid file URL. It should be accessible using your ImageKit.io accou + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekit::Models::Metadata] + # + # @see Imagekit::Models::Files::MetadataGetFromURLParams + def get_from_url(params) + parsed, options = Imagekit::Files::MetadataGetFromURLParams.dump_request(params) + @client.request( + method: :get, + path: "v1/files/metadata", + query: parsed, + model: Imagekit::Metadata, + options: options + ) + end + + # @api private + # + # @param client [Imagekit::Client] + def initialize(client:) + @client = client + end + end + end + end +end diff --git a/lib/imagekit/resources/files/versions.rb b/lib/imagekit/resources/files/versions.rb new file mode 100644 index 00000000..dd712b77 --- /dev/null +++ b/lib/imagekit/resources/files/versions.rb @@ -0,0 +1,132 @@ +# frozen_string_literal: true + +module Imagekit + module Resources + class Files + class Versions + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Files::VersionListParams} for more details. + # + # This API returns details of all versions of a file. + # + # @overload list(file_id, request_options: {}) + # + # @param file_id [String] The unique `fileId` of the uploaded file. `fileId` is returned in list and searc + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Array] + # + # @see Imagekit::Models::Files::VersionListParams + def list(file_id, params = {}) + @client.request( + method: :get, + path: ["v1/files/%1$s/versions", file_id], + model: Imagekit::Internal::Type::ArrayOf[Imagekit::File], + options: params[:request_options] + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Files::VersionDeleteParams} for more details. + # + # This API deletes a non-current file version permanently. The API returns an + # empty response. + # + # Note: If you want to delete all versions of a file, use the delete file API. + # + # @overload delete(version_id, file_id:, request_options: {}) + # + # @param version_id [String] The unique `versionId` of the uploaded file. `versionId` is returned in list and + # + # @param file_id [String] The unique `fileId` of the uploaded file. `fileId` is returned in list and searc + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekit::Models::Files::VersionDeleteResponse] + # + # @see Imagekit::Models::Files::VersionDeleteParams + def delete(version_id, params) + parsed, options = Imagekit::Files::VersionDeleteParams.dump_request(params) + file_id = + parsed.delete(:file_id) do + raise ArgumentError.new("missing required path argument #{_1}") + end + @client.request( + method: :delete, + path: ["v1/files/%1$s/versions/%2$s", file_id, version_id], + model: Imagekit::Models::Files::VersionDeleteResponse, + options: options + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Files::VersionGetParams} for more details. + # + # This API returns an object with details or attributes of a file version. + # + # @overload get(version_id, file_id:, request_options: {}) + # + # @param version_id [String] The unique `versionId` of the uploaded file. `versionId` is returned in list and + # + # @param file_id [String] The unique `fileId` of the uploaded file. `fileId` is returned in list and searc + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekit::Models::File] + # + # @see Imagekit::Models::Files::VersionGetParams + def get(version_id, params) + parsed, options = Imagekit::Files::VersionGetParams.dump_request(params) + file_id = + parsed.delete(:file_id) do + raise ArgumentError.new("missing required path argument #{_1}") + end + @client.request( + method: :get, + path: ["v1/files/%1$s/versions/%2$s", file_id, version_id], + model: Imagekit::File, + options: options + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Files::VersionRestoreParams} for more details. + # + # This API restores a file version as the current file version. + # + # @overload restore(version_id, file_id:, request_options: {}) + # + # @param version_id [String] The unique `versionId` of the uploaded file. `versionId` is returned in list and + # + # @param file_id [String] The unique `fileId` of the uploaded file. `fileId` is returned in list and searc + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekit::Models::File] + # + # @see Imagekit::Models::Files::VersionRestoreParams + def restore(version_id, params) + parsed, options = Imagekit::Files::VersionRestoreParams.dump_request(params) + file_id = + parsed.delete(:file_id) do + raise ArgumentError.new("missing required path argument #{_1}") + end + @client.request( + method: :put, + path: ["v1/files/%1$s/versions/%2$s/restore", file_id, version_id], + model: Imagekit::File, + options: options + ) + end + + # @api private + # + # @param client [Imagekit::Client] + def initialize(client:) + @client = client + end + end + end + end +end diff --git a/lib/imagekit/resources/folders.rb b/lib/imagekit/resources/folders.rb new file mode 100644 index 00000000..ad5e4b10 --- /dev/null +++ b/lib/imagekit/resources/folders.rb @@ -0,0 +1,166 @@ +# frozen_string_literal: true + +module Imagekit + module Resources + class Folders + # @return [Imagekit::Resources::Folders::Job] + attr_reader :job + + # Some parameter documentations has been truncated, see + # {Imagekit::Models::FolderCreateParams} for more details. + # + # This will create a new folder. You can specify the folder name and location of + # the parent folder where this new folder should be created. + # + # @overload create(folder_name:, parent_folder_path:, request_options: {}) + # + # @param folder_name [String] The folder will be created with this name. + # + # @param parent_folder_path [String] The folder where the new folder should be created, for root use `/` else the pat + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekit::Models::FolderCreateResponse] + # + # @see Imagekit::Models::FolderCreateParams + def create(params) + parsed, options = Imagekit::FolderCreateParams.dump_request(params) + @client.request( + method: :post, + path: "v1/folder", + body: parsed, + model: Imagekit::Models::FolderCreateResponse, + options: options + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekit::Models::FolderDeleteParams} for more details. + # + # This will delete a folder and all its contents permanently. The API returns an + # empty response. + # + # @overload delete(folder_path:, request_options: {}) + # + # @param folder_path [String] Full path to the folder you want to delete. For example `/folder/to/delete/`. + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekit::Models::FolderDeleteResponse] + # + # @see Imagekit::Models::FolderDeleteParams + def delete(params) + parsed, options = Imagekit::FolderDeleteParams.dump_request(params) + @client.request( + method: :delete, + path: "v1/folder", + body: parsed, + model: Imagekit::Models::FolderDeleteResponse, + options: options + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekit::Models::FolderCopyParams} for more details. + # + # This will copy one folder into another. The selected folder, its nested folders, + # files, and their versions (in `includeVersions` is set to true) are copied in + # this operation. Note: If any file at the destination has the same name as the + # source file, then the source file and its versions will be appended to the + # destination file version history. + # + # @overload copy(destination_path:, source_folder_path:, include_versions: nil, request_options: {}) + # + # @param destination_path [String] Full path to the destination folder where you want to copy the source folder int + # + # @param source_folder_path [String] The full path to the source folder you want to copy. + # + # @param include_versions [Boolean] Option to copy all versions of files that are nested inside the selected folder. + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekit::Models::FolderCopyResponse] + # + # @see Imagekit::Models::FolderCopyParams + def copy(params) + parsed, options = Imagekit::FolderCopyParams.dump_request(params) + @client.request( + method: :post, + path: "v1/bulkJobs/copyFolder", + body: parsed, + model: Imagekit::Models::FolderCopyResponse, + options: options + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekit::Models::FolderMoveParams} for more details. + # + # This will move one folder into another. The selected folder, its nested folders, + # files, and their versions are moved in this operation. Note: If any file at the + # destination has the same name as the source file, then the source file and its + # versions will be appended to the destination file version history. + # + # @overload move(destination_path:, source_folder_path:, request_options: {}) + # + # @param destination_path [String] Full path to the destination folder where you want to move the source folder int + # + # @param source_folder_path [String] The full path to the source folder you want to move. + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekit::Models::FolderMoveResponse] + # + # @see Imagekit::Models::FolderMoveParams + def move(params) + parsed, options = Imagekit::FolderMoveParams.dump_request(params) + @client.request( + method: :post, + path: "v1/bulkJobs/moveFolder", + body: parsed, + model: Imagekit::Models::FolderMoveResponse, + options: options + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekit::Models::FolderRenameParams} for more details. + # + # This API allows you to rename an existing folder. The folder and all its nested + # assets and sub-folders will remain unchanged, but their paths will be updated to + # reflect the new folder name. + # + # @overload rename(folder_path:, new_folder_name:, purge_cache: nil, request_options: {}) + # + # @param folder_path [String] The full path to the folder you want to rename. + # + # @param new_folder_name [String] The new name for the folder. + # + # @param purge_cache [Boolean] Option to purge cache for the old nested files and their versions' URLs. + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekit::Models::FolderRenameResponse] + # + # @see Imagekit::Models::FolderRenameParams + def rename(params) + parsed, options = Imagekit::FolderRenameParams.dump_request(params) + @client.request( + method: :post, + path: "v1/bulkJobs/renameFolder", + body: parsed, + model: Imagekit::Models::FolderRenameResponse, + options: options + ) + end + + # @api private + # + # @param client [Imagekit::Client] + def initialize(client:) + @client = client + @job = Imagekit::Resources::Folders::Job.new(client: client) + end + end + end +end diff --git a/lib/imagekit/resources/folders/job.rb b/lib/imagekit/resources/folders/job.rb new file mode 100644 index 00000000..8c900133 --- /dev/null +++ b/lib/imagekit/resources/folders/job.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +module Imagekit + module Resources + class Folders + class Job + # Some parameter documentations has been truncated, see + # {Imagekit::Models::Folders::JobGetParams} for more details. + # + # This API returns the status of a bulk job like copy and move folder operations. + # + # @overload get(job_id, request_options: {}) + # + # @param job_id [String] The `jobId` is returned in the response of bulk job API e.g. copy folder or move + # + # @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekit::Models::Folders::JobGetResponse] + # + # @see Imagekit::Models::Folders::JobGetParams + def get(job_id, params = {}) + @client.request( + method: :get, + path: ["v1/bulkJobs/%1$s", job_id], + model: Imagekit::Models::Folders::JobGetResponse, + options: params[:request_options] + ) + end + + # @api private + # + # @param client [Imagekit::Client] + def initialize(client:) + @client = client + end + end + end + end +end diff --git a/lib/imagekit/resources/webhooks.rb b/lib/imagekit/resources/webhooks.rb new file mode 100644 index 00000000..067574cf --- /dev/null +++ b/lib/imagekit/resources/webhooks.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +module Imagekit + module Resources + class Webhooks + # @param payload [String] The raw webhook payload as a string + # + # @return [Imagekit::Models::VideoTransformationAcceptedEvent, Imagekit::Models::VideoTransformationReadyEvent, Imagekit::Models::VideoTransformationErrorEvent, Imagekit::Models::UploadPreTransformSuccessEvent, Imagekit::Models::UploadPreTransformErrorEvent, Imagekit::Models::UploadPostTransformSuccessEvent, Imagekit::Models::UploadPostTransformErrorEvent] + def unsafe_unwrap(payload) + parsed = JSON.parse(payload, symbolize_names: true) + Imagekit::Internal::Type::Converter.coerce(Imagekit::Models::UnsafeUnwrapWebhookEvent, parsed) + end + + # @param payload [String] The raw webhook payload as a string + # + # @return [Imagekit::Models::VideoTransformationAcceptedEvent, Imagekit::Models::VideoTransformationReadyEvent, Imagekit::Models::VideoTransformationErrorEvent, Imagekit::Models::UploadPreTransformSuccessEvent, Imagekit::Models::UploadPreTransformErrorEvent, Imagekit::Models::UploadPostTransformSuccessEvent, Imagekit::Models::UploadPostTransformErrorEvent] + def unwrap(payload) + parsed = JSON.parse(payload, symbolize_names: true) + Imagekit::Internal::Type::Converter.coerce(Imagekit::Models::UnwrapWebhookEvent, parsed) + end + + # @api private + # + # @param client [Imagekit::Client] + def initialize(client:) + @client = client + end + end + end +end diff --git a/lib/imagekit/version.rb b/lib/imagekit/version.rb new file mode 100644 index 00000000..8165ed7d --- /dev/null +++ b/lib/imagekit/version.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +module Imagekit + VERSION = "0.0.2" +end diff --git a/lib/imagekitio.rb b/lib/imagekitio.rb deleted file mode 100644 index 6e15fa8e..00000000 --- a/lib/imagekitio.rb +++ /dev/null @@ -1,13 +0,0 @@ -require "imagekitio/railtie" if defined? Rails - -require 'base64' - -require_relative './imagekitio/constant' -require_relative './imagekitio/base' -require_relative './imagekitio/configurable' -require_relative './imagekitio/client' -require_relative "./imagekitio/request" -require_relative "./imagekitio/url" -require_relative './imagekitio/api_service/custom_metadata_field' -require_relative './imagekitio/api_service/file' -require_relative './imagekitio/api_service/folder' diff --git a/lib/imagekitio/api_service/bulk.rb b/lib/imagekitio/api_service/bulk.rb deleted file mode 100644 index 2ee35f63..00000000 --- a/lib/imagekitio/api_service/bulk.rb +++ /dev/null @@ -1,58 +0,0 @@ -require_relative '../constant' - -module ImageKitIo - module ApiService - class Bulk - include Constantable - - def initialize(req_obj) - @req_obj = req_obj - end - - def job_status(job_id: nil) - if job_id == '' || job_id.nil? - raise ArgumentError, 'job_id is required' - end - url = "#{constants.BULK_BASE_URL}/#{job_id}" - payload = { 'jobId': job_id } - @req_obj.request('get', url, @req_obj.create_headers, payload) - end - - def add_tags(file_ids: [], tags: []) - if file_ids.empty? || tags.empty? - raise ArgumentError, 'Parameters are required' - end - url = "#{constants.BASE_URL}/addTags" - payload = { 'fileIds': file_ids, 'tags': tags }.to_json - @req_obj.request('post', url, @req_obj.create_headers, payload) - end - - def remove_tags(file_ids: [], tags: []) - if file_ids.empty? || tags.empty? - raise ArgumentError, 'Parameters are required' - end - url = "#{constants.BASE_URL}/removeTags" - payload = { 'fileIds': file_ids, 'tags': tags }.to_json - @req_obj.request('post', url, @req_obj.create_headers, payload) - end - - def remove_ai_tags(file_ids: [], ai_tags: []) - if file_ids.empty? || ai_tags.empty? - raise ArgumentError, 'Parameters are required' - end - url = "#{constants.BASE_URL}/removeAITags" - payload = { 'fileIds': file_ids, 'AITags': ai_tags }.to_json - @req_obj.request('post', url, @req_obj.create_headers, payload) - end - - def remove_files(file_ids: []) - if file_ids.empty? - raise ArgumentError, 'File ids are required' - end - url = "#{constants.BASE_URL}#{constants.BULK_FILE_DELETE}" - payload = {'fileIds': file_ids}.to_json - @req_obj.request("post", url, @req_obj.create_headers, payload) - end - end - end -end diff --git a/lib/imagekitio/api_service/custom_metadata_field.rb b/lib/imagekitio/api_service/custom_metadata_field.rb deleted file mode 100644 index 7bc213ad..00000000 --- a/lib/imagekitio/api_service/custom_metadata_field.rb +++ /dev/null @@ -1,52 +0,0 @@ -require_relative '../utils/option_validator' -require_relative '../constant' - -module ImageKitIo - module ApiService - class CustomMetadataField - include Utils::OptionValidator - include Constantable - - def initialize(req_obj) - @req_obj = req_obj - end - - def create(name: nil, label: nil, schema: nil) - if name == '' || name.nil? || label == '' || label.nil? || schema == '' || schema.nil? - raise ArgumentError, 'Parameters required' - end - unless schema.is_a?(Hash) - raise ArgumentError, 'Schema must be hash object' - end - url = "#{constants.API_BASE_URL}/customMetadataFields" - payload = { 'name': name, 'label': label, 'schema': schema }.to_json - @req_obj.request('post', url, @req_obj.create_headers, payload) - end - - def list(**options) - url = "#{constants.API_BASE_URL}/customMetadataFields" - payload = request_formatter(options || {}) - @req_obj.request('get', url, @req_obj.create_headers, payload) - end - - def update(id: nil, label: nil, schema: nil) - if id == '' || id.nil? - raise ArgumentError, 'id is required' - end - url = "#{constants.API_BASE_URL}/customMetadataFields/#{id}" - payload = {} - payload = payload.merge({ 'label': label }) unless label.nil? - payload = payload.merge({ 'schema': label }) unless schema.nil? - @req_obj.request('patch', url, @req_obj.create_headers, payload.to_json) - end - - def delete(id: nil) - if id == '' || id.nil? - raise ArgumentError, 'id is required' - end - url = "#{constants.API_BASE_URL}/customMetadataFields/#{id}" - @req_obj.request('delete', url, @req_obj.create_headers) - end - end - end -end diff --git a/lib/imagekitio/api_service/file.rb b/lib/imagekitio/api_service/file.rb deleted file mode 100644 index 986cd21a..00000000 --- a/lib/imagekitio/api_service/file.rb +++ /dev/null @@ -1,221 +0,0 @@ -# frozen_string_literal: true -require_relative '../constant' -require_relative '../utils/option_validator' -require 'net/http/post/multipart' - -module ImageKitIo - module ApiService - class File - include Utils::OptionValidator - include Constantable - - # This File class holds file related operations like - # upload, list etc - def initialize(req_obj) - @req_obj = req_obj - end - - # uploads files with required arguments, supports bot url and binary - # Options types: - # - `extensions` should be array of hash - # eg: option['extension'] = [ - # { 'name' => 'remove-bg', 'options' => { 'add_shadow' => 'true' } }, - # { 'name' => 'google-auto-tagging', 'minConfidence' => 80 } - # ] - # - `custom_metadata` should be hash - # eg: option['custom_metadata'] = { - # "SKU": "VS882HJ2JD", - # "price": 599.99, - # "brand": "H&M", - # "discount": 30 - # } - def upload(file: nil, file_name: nil, **options) - raise ArgumentError, constants.MISSING_UPLOAD_FILE_PARAMETER unless file - raise ArgumentError, constants.MISSING_UPLOAD_FILE_PARAMETER unless file_name - - content_type = options.delete(:content_type) || '' - options = format_to_json(options, :extensions, Array) - options = format_to_json(options, :custom_metadata, Hash) - options = format_to_json(options, :transformation, Hash) - options = validate_upload_options(options || {}) - if options.is_a?(FalseClass) - raise ArgumentError, "Invalid Upload option" - else - headers = @req_obj.create_headers - payload = { - multipart: true, - file: file.is_a?(String) ? file : ::UploadIO.new(file, content_type, file_name), - fileName: file_name - } - payload.merge!(options) - url = "#{constants.BASE_URL}#{constants.UPLOAD}" - @req_obj.request("post", url, headers, payload) - end - end - - def update_details(file_id: nil, **options) - unless options.fetch(:tags, []).is_a?(Array) - raise ArgumentError, constants.UPDATE_DATA_TAGS_INVALID - end - unless options.fetch(:custom_coordinates, "").is_a?(String) - raise ArgumentError, constants.UPDATE_DATA_COORDS_INVALID - end - url = "#{constants.BASE_URL}/#{file_id}/details/" - headers = @req_obj.create_headers - payload = request_formatter(options || {}) - @req_obj.request("patch", url, headers, payload.to_json) - end - - def list(**options) - # returns list of files on ImageKitIo Server - # :options dictionary of options - formatted_options = request_formatter(options || {}) - raise KeyError(constants.LIST_FILES_INPUT_MISSING) unless formatted_options.is_a?(Hash) - url = constants.BASE_URL - headers = @req_obj.create_headers.update({params: formatted_options}) - @req_obj.request("get", url, headers, formatted_options) - end - - def get_file_versions(file_id: nil) - if file_id == '' || file_id.nil? - raise ArgumentError, 'file_id is required' - end - url = "#{constants.BASE_URL}/#{file_id}/versions" - headers = @req_obj.create_headers - @req_obj.request('get', url, headers) - end - - def get_file_version_detail(file_id: nil, version_id: nil) - if file_id == "" || file_id.nil? - raise ArgumentError, "file_id is required" - end - if version_id == "" || version_id.nil? - raise ArgumentError, "version_id is required" - end - url = "#{constants.BASE_URL}/#{file_id}/versions/#{version_id}" - headers = @req_obj.create_headers - @req_obj.request('get', url, headers) - end - - def delete_file_version(file_id: nil, version_id: nil) - if file_id == "" || file_id.nil? - raise ArgumentError, "file_id is required" - end - if version_id == "" || version_id.nil? - raise ArgumentError, "version_id is required" - end - url = "#{constants.BASE_URL}/#{file_id}/versions/#{version_id}" - headers = @req_obj.create_headers - @req_obj.request('delete', url, headers) - end - - def restore_file_version(file_id: nil, version_id: nil) - if file_id == "" || file_id.nil? - raise ArgumentError, "file_id is required" - end - if version_id == "" || version_id.nil? - raise ArgumentError, "version_id is required" - end - url = "#{constants.BASE_URL}/#{file_id}/versions/#{version_id}/restore" - headers = @req_obj.create_headers - @req_obj.request('put', url, headers) - end - - def details(file_identifier: nil) - # Get detail of file by file_identifier - if file_identifier == "" || file_identifier.nil? - raise ArgumentError, "file_identifier is required" - end - url = "#{constants.BASE_URL}/#{file_identifier}/details/" - headers = @req_obj.create_headers - @req_obj.request("get", url, headers) - end - - def get_metadata(file_id: nil) - # Get metadata of a file by file_id - if file_id == "" || file_id.nil? - raise ArgumentError, "file_id is required" - end - url = "#{constants.BASE_URL}/#{file_id}/metadata" - @req_obj.request("get", url, @req_obj.create_headers) - end - - def delete(file_id: nil) - # Delete a file_id by file_id - if file_id == "" || file_id.nil? - raise ArgumentError, "file_id is required" - end - url = "#{constants.BASE_URL}/#{file_id}" - headers = @req_obj.create_headers - @req_obj.request("delete", url, headers) - end - - def purge_cache(file_url: nil) - # purges cache from server by file_url - if file_url == "" || file_url.nil? - raise ArgumentError, "file_url is required" - end - url = "#{constants.BASE_URL}/purge" - payload = {'url': file_url} - @req_obj.request("post", url, @req_obj.create_headers, payload) - end - - def purge_cache_status(request_id: nil) - # This function is to get cache_status - if request_id == "" || request_id.nil? - raise ArgumentError, "remote_file_url is required" - end - url = "#{constants.BASE_URL}/purge/#{request_id}" - @req_obj.request("get", url, @req_obj.create_headers) - end - - def get_metadata_from_remote_url(remote_file_url: nil) - if remote_file_url == "" || remote_file_url.nil? - raise ArgumentError, "remote_file_url is required" - end - url = "#{constants.REMOTE_METADATA_FULL_URL}?url=#{remote_file_url}" - @req_obj.request("get", url, @req_obj.create_headers) - end - - def stream_file(remote_file_url: nil, &block) - if remote_file_url == '' || remote_file_url.nil? - raise ArgumentError, 'remote_file_url is required' - end - @req_obj.request_stream('get', remote_file_url, headers: @req_obj.create_headers, &block) - end - - def copy(source_file_path: nil, destination_path: nil, include_file_versions: false) - if source_file_path == '' || source_file_path.nil? || destination_path == '' || destination_path.nil? - raise ArgumentError, 'parameters required' - end - url = "#{constants.BASE_URL}/copy" - payload = { 'sourceFilePath': source_file_path, 'destinationPath': destination_path, 'includeFileVersions': include_file_versions }.to_json - @req_obj.request('post', url, @req_obj.create_headers, payload) - end - - def move(source_file_path: nil, destination_path: nil) - if source_file_path == '' || source_file_path.nil? || destination_path == '' || destination_path.nil? - raise ArgumentError, 'parameters required' - end - url = "#{constants.BASE_URL}/move" - payload = { 'sourceFilePath': source_file_path, 'destinationPath': destination_path } - @req_obj.request('post', url, @req_obj.create_headers, payload) - end - - def rename(file_path: nil, new_file_name: nil, **options) - if file_path == '' || file_path.nil? || new_file_name == '' || new_file_name.nil? - raise ArgumentError, 'parameters required' - end - url = "#{constants.BASE_URL}/rename" - payload = { 'filePath': file_path, 'newFileName': new_file_name }.merge(request_formatter(options)).to_json - @req_obj.request('put', url, @req_obj.create_headers, payload) - end - - - private - def image_format?(type) - %(image/jpeg image/bmp image/apng image/avif image/gif image/ief image/svg+xml image/tiff image/x-icon image/rgb image/webp).include?(type) - end - end - end -end diff --git a/lib/imagekitio/api_service/folder.rb b/lib/imagekitio/api_service/folder.rb deleted file mode 100644 index 41bdb453..00000000 --- a/lib/imagekitio/api_service/folder.rb +++ /dev/null @@ -1,49 +0,0 @@ -require_relative '../constant' - -module ImageKitIo - module ApiService - class Folder - include Constantable - - def initialize(req_obj) - @req_obj = req_obj - end - - def create(folder_name: nil, parent_folder_path: nil) - if folder_name == '' || folder_name.nil? - raise ArgumentError, 'folder_name is required' - end - url = "#{constants.API_BASE_URL}/folder" - payload = { 'folderName': folder_name, 'parentFolderPath': parent_folder_path }.to_json - @req_obj.request('post', url, @req_obj.create_headers, payload) - end - - def delete(folder_path: nil) - if folder_path == '' || folder_path.nil? - raise ArgumentError, 'folder_path is required' - end - url = "#{constants.API_BASE_URL}/folder" - payload = { 'folderPath': folder_path } - @req_obj.request('delete', url, @req_obj.create_headers, payload) - end - - def copy(source_folder_path: nil, destination_path: nil, include_file_versions: false) - if source_folder_path == '' || source_folder_path.nil? || destination_path == '' || destination_path.nil? - raise ArgumentError, 'Parameters required' - end - url = "#{constants.BULK_BASE_URL}/copyFolder" - payload = { 'sourceFolderPath': source_folder_path, 'destinationPath': destination_path, 'includeFileVersions': include_file_versions }.to_json - @req_obj.request('post', url, @req_obj.create_headers, payload) - end - - def move(source_folder_path: nil, destination_path: nil) - if source_folder_path == '' || source_folder_path.nil? || destination_path == '' || destination_path.nil? - raise ArgumentError, 'Parameters required' - end - url = "#{constants.BULK_BASE_URL}/moveFolder" - payload = { 'sourceFolderPath': source_folder_path, 'destinationPath': destination_path } - @req_obj.request('post', url, @req_obj.create_headers, payload) - end - end - end -end diff --git a/lib/imagekitio/base.rb b/lib/imagekitio/base.rb deleted file mode 100644 index 162e89ef..00000000 --- a/lib/imagekitio/base.rb +++ /dev/null @@ -1,12 +0,0 @@ -require_relative './configurable' - -module ImageKitIo - include ImageKitIo::Configurable - - class << self - def client - ik_config = config - @client ||= ImageKitIo::Client.new(ik_config.private_key, ik_config.public_key, ik_config.url_endpoint) - end - end -end diff --git a/lib/imagekitio/client.rb b/lib/imagekitio/client.rb deleted file mode 100644 index 3c2b7851..00000000 --- a/lib/imagekitio/client.rb +++ /dev/null @@ -1,202 +0,0 @@ -# frozen_string_literal: true - -$VERBOSE = nil - -require_relative "./request" -require_relative "./url" -require_relative "./utils/calculation" -require_relative './constant' -require_relative './configurable' -require_relative './api_service/custom_metadata_field' -require_relative './api_service/folder' -require_relative './api_service/file' -require_relative './api_service/bulk' - -module ImageKitIo - # ImageKitIo class holds each method will be used by user - class Client - include Utils::Calculation - include Constantable - - attr_reader :file_service, :custom_metadata_field_service, :folder_service, :bulk_service - - def initialize(private_key, public_key, url_endpoint, transformation_pos = nil, options = nil) - unless(private_key.is_a?(String) && private_key.to_s.strip.length != 0) - raise ArgumentError, constants.MISSING_PRIVATE_KEY - end - unless(public_key.is_a?(String) && public_key.to_s.strip.length != 0) - raise ArgumentError, constants.MISSING_PUBLIC_KEY - end - unless(url_endpoint.is_a?(String) && url_endpoint.to_s.strip.length != 0) - raise ArgumentError, constants.MISSING_URL_ENDPOINT - end - - @private_key = private_key - @public_key = public_key - @url_endpoint = url_endpoint - @transformation_position = transformation_pos - @options = options - - @ik_req = Request.new(private_key, public_key, url_endpoint) - @url_obj = Url.new(@ik_req) - @file_service = ApiService::File.new(@ik_req) - @custom_metadata_field_service = ApiService::CustomMetadataField.new(@ik_req) - @folder_service = ApiService::Folder.new(@ik_req) - @bulk_service = ApiService::Bulk.new(@ik_req) - end - - def set_ik_request(ik_req) - # setter for imagekit request mainly will be used for - # test - @ik_req = ik_req - end - - def url(options = {}) - @url_obj.generate_url(options) - end - - def upload_file(file: nil, file_name: nil, **options) - # upload file to imagekit server - @file_service.upload(file: file, file_name: file_name, **options) - end - - def list_files(options = {}) - # list all files - @file_service.list(**options) - end - - def file_versions(file_id: nil) - @file_service.get_file_versions(file_id: file_id) - end - - def file_version_detail(file_id: nil, version_id: nil) - @file_service.get_file_version_detail(file_id: file_id, version_id: version_id) - end - - def delete_file_version(file_id: nil, version_id: nil) - @file_service.delete_file_version(file_id: file_id, version_id: version_id) - end - - def restore_file_version(file_id: nil, version_id: nil) - @file_service.restore_file_version(file_id: file_id, version_id: version_id) - end - - def get_file_details(file_id: nil) - # Get file detail by file-id or file_url - @file_service.details(file_identifier: file_id) - end - - def update_file_details(file_id: nil, **options) - # update file details by file id and other options payload - @file_service.update_details(file_id: file_id, **options) - end - - def delete_file(file_id: nil) - # Delete a file by file-id - @file_service.delete(file_id: file_id) - end - - def get_file_metadata(file_id: nil) - # Get metadata of a file by file-id - @file_service.get_metadata(file_id: file_id) - end - - def purge_file_cache(file_url: nil) - # Purge cache from ImageKitIo server by file_url - @file_service.purge_cache(file_url: file_url) - end - - def purge_file_cache_status(request_id: nil) - @file_service.purge_cache_status(request_id: request_id.to_s) - end - - # Get metadata from remote_file_url - # param remote_file_url: url string of remote file - def get_remote_file_url_metadata(remote_file_url: "") - @file_service.get_metadata_from_remote_url(remote_file_url: remote_file_url) - end - - def stream_file(file_url: nil, &block) - @file_service.stream_file(remote_file_url: file_url, &block) - end - - def copy_file(source_file_path: nil, destination_path: nil, include_file_versions: false) - @file_service.copy(source_file_path: source_file_path, destination_path: destination_path, include_file_versions: include_file_versions) - end - - def move_file(source_file_path: nil, destination_path: nil) - @file_service.move(source_file_path: source_file_path, destination_path: destination_path) - end - - def rename_file(file_path: nil, new_file_name: nil, **options) - @file_service.rename(file_path: file_path, new_file_name: new_file_name, **options) - end - - def add_bulk_tags(file_ids: [], tags: []) - @bulk_service.add_tags(file_ids: file_ids, tags: tags) - end - - def delete_bulk_files(file_ids: []) - # Delete file in bulks by list of file id - @bulk_service.remove_files(file_ids: file_ids) - end - - def delete_bulk_tags(file_ids: [], tags: []) - @bulk_service.remove_tags(file_ids: file_ids, tags: tags) - end - - def delete_bulk_ai_tags(file_ids: [], ai_tags: []) - @bulk_service.remove_ai_tags(file_ids: file_ids, ai_tags: ai_tags) - end - - def bulk_job_status(job_id: nil) - @bulk_service.job_status(job_id: job_id) - end - - def create_folder(folder_name: nil, parent_folder_path: "/") - @folder_service.create(folder_name: folder_name, parent_folder_path: parent_folder_path) - end - - def delete_folder(folder_path: nil) - @folder_service.delete(folder_path: folder_path) - end - - def copy_folder(source_folder_path: nil, destination_path: nil, include_file_versions: false) - @folder_service.copy(source_folder_path: source_folder_path, destination_path: destination_path, include_file_versions: include_file_versions) - end - - def move_folder(source_folder_path: nil, destination_path: nil) - @folder_service.move(source_folder_path: source_folder_path, destination_path: destination_path) - end - - def create_custom_metadata_field(name: nil, label: nil, schema: {}) - @custom_metadata_field_service.create(name: name, label: label, schema: schema) - end - - def get_custom_metadata_fields(options = {}) - @custom_metadata_field_service.list(**options) - end - - def update_custom_metadata_field(id: nil, label: nil, schema: nil) - @custom_metadata_field_service.update(id: id, label: label, schema: schema) - end - - def delete_custom_metadata_field(id: nil) - @custom_metadata_field_service.delete(id: id) - end - - def phash_distance(first, second) - # Get hamming distance between two phash(image hash) to check - # similarity between images - if first.to_s.strip == "" || second.to_s.strip == "" - raise ArgumentError, constants.MISSING_PHASH_VALUE - end - hamming_distance(first, second) - end - - def get_authentication_parameters(token = nil, expire = nil) - # Get Authentication params - get_authenticated_params(token, expire, @ik_req.private_key) - end - end -end diff --git a/lib/imagekitio/configurable.rb b/lib/imagekitio/configurable.rb deleted file mode 100644 index 98db3414..00000000 --- a/lib/imagekitio/configurable.rb +++ /dev/null @@ -1,43 +0,0 @@ -module ImageKitIo - module Configurable - def self.included(klass) - klass.extend ClassMethods - end - - module ClassMethods - def config - @config ||= Configuration.new - end - - def configure - yield config - initialize_service - end - - def initialize_service - if config.service == :carrierwave - require_relative '../carrierwave/carrierwave' - elsif config.service == :active_storage - require_relative '../active_storage/active_storage' - end - end - - def constants - config.constants - end - end - - class Configuration - AVAILABLE_SERVICE = [:carrierwave, :active_storage] - attr_accessor :public_key, :private_key, :url_endpoint, :service - - def service - @service&.to_sym || :carrierwave - end - - def constants - @constants ||= ImageKitIo::Constant - end - end - end -end diff --git a/lib/imagekitio/constant.rb b/lib/imagekitio/constant.rb deleted file mode 100644 index 21fa44a7..00000000 --- a/lib/imagekitio/constant.rb +++ /dev/null @@ -1,36 +0,0 @@ -require_relative './constants/default' -require_relative './constants/error' -require_relative './constants/file' -require_relative './constants/supported_transformation' -require_relative './constants/url' -require_relative './configurable' - -module ImageKitIo - module Constantable - def self.included(base) - def constants - ImageKitIo.constants - end - end - end - class Constant - include Constants::Default - include Constants::Error - include Constants::File - include Constants::SupportedTransformation - include Constants::URL - - class << self - def method_missing(symbol, *args) - method_name = symbol.to_s.gsub('=', '') - if self.const_defined? method_name - return self.const_get(method_name) if args.empty? - - self.const_set(method_name, args.first) - else - super - end - end - end - end -end diff --git a/lib/imagekitio/constants/default.rb b/lib/imagekitio/constants/default.rb deleted file mode 100644 index 34d9345e..00000000 --- a/lib/imagekitio/constants/default.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -# Enum for defaults -module ImageKitIo - module Constants - module Default - TRANSFORMATION_POSITION = "path" - QUERY_TRANSFORMATION_POSITION = "query" - VALID_TRANSFORMATION_POSITION = [TRANSFORMATION_POSITION, - QUERY_TRANSFORMATION_POSITION,].freeze - DEFAULT_TIMESTAMP = "9999999999" - TRANSFORMATION_PARAMETER = "tr" - CHAIN_TRANSFORM_DELIMITER = ":" - TRANSFORM_DELIMITER = "," - TRANSFORM_KEY_VALUE_DELIMITER = "-" - - SIGNATURE_PARAMETER = "ik-s" - TIMESTAMP_PARAMETER = "ik-t" - TIMESTAMP = "9999999999" - end - end -end diff --git a/lib/imagekitio/constants/error.rb b/lib/imagekitio/constants/error.rb deleted file mode 100644 index 49c8f429..00000000 --- a/lib/imagekitio/constants/error.rb +++ /dev/null @@ -1,69 +0,0 @@ -module ImageKitIo - module Constants - module Error - MANDATORY_INIT_MISSING = { - 'message': "Missing public_key or private_key or url_endpoint during ImageKitIo initialization", - help: "", - } - INVALID_TRANSFORMATION_POS = {'message': "Invalid transformationPosition parameter", - help: "",} - INVALID_URL_GENERATION_PARAM = {'message': "Invalid url parameter", help: ""} - INVALID_TRANSFORMATION_OPTIONS = { - 'message': "Invalid transformation parameter options", - help: "", - } - CACHE_PURGE_URL_MISSING = {'message': "Missing URL parameter for this request", - help: "",} - CACHE_PURGE_STATUS_ID_MISSING = {'message': "Missing Request ID parameter for this request", - help: "",} - FILE_ID_MISSING = {'message': "Missing File ID parameter for this request", - help: "",} - UPDATE_DATA_MISSING = {'message': "Missing file update data for this request", - help: "",} - - UPDATE_DATA_TAGS_INVALID = {'message': "Invalid tags parameter for this request", - help: "tags should be passed as null or an array like ['tag1', 'tag2']",}.freeze - - UPDATE_DATA_COORDS_INVALID = - {'message': "Invalid custom_coordinates parameter for this request", - help: "custom_coordinates should be passed as null or a string like 'x,y,width,height'",} - - LIST_FILES_INPUT_MISSING = { - 'message': "Missing options for list files", - help: "If you do not want to pass any parameter for listing, pass an empty object", - } - MISSING_FILE_URL = {'message': "Missing file_url for purge_cache", help: ""} - MISSING_UPLOAD_DATA = {'message': "Missing data for upload", help: ""} - MISSING_UPLOAD_FILE_PARAMETER = { - 'message': "Missing file parameter for upload", - help: "", - } - MISSING_UPLOAD_FILENAME_PARAM = { - 'message': "Missing fileName parameter for upload", - help: "", - } - - INVALID_PHASH_VALUE = - { - 'message': "Invalid pHash value", - help: "Both pHash strings must be valid hexadecimal numbers", - } - - MISSING_PHASH_VALUE = { - 'message': "Missing pHash value", - help: "Please pass two pHash values", - } - UNEQUAL_STRING_LENGTH = { - '': "Unequal pHash string length", - help: "For distance calculation, the two pHash strings must have equal length", - } - - MISSING_PRIVATE_KEY = "ImageKitIo private key missing" - - MISSING_PUBLIC_KEY = "ImageKitIo public key missing" - - MISSING_URL_ENDPOINT = "ImageKitIo URL Endpoint missing. Default URL Endpoint: https://ik.imagekit.io//" - - end - end -end diff --git a/lib/imagekitio/constants/file.rb b/lib/imagekitio/constants/file.rb deleted file mode 100644 index 3af374dc..00000000 --- a/lib/imagekitio/constants/file.rb +++ /dev/null @@ -1,11 +0,0 @@ -module ImageKitIo - module Constants - module File - VALID_FILE_OPTIONS = %w[path fileType tags includeFolder name limit skip] - - VALID_FILE_DETAIL_OPTIONS = ["fileID"] - - VALID_UPLOAD_OPTIONS = %w[file file_name use_unique_file_name tags folder is_private_file custom_coordinates response_fields extensions webhook_url overwrite_file overwrite_AI_tags overwrite_custom_metadata custom_metadata mime overwrite_tags content_type transformation checks is_published] - end - end -end diff --git a/lib/imagekitio/constants/supported_transformation.rb b/lib/imagekitio/constants/supported_transformation.rb deleted file mode 100644 index c8158b6f..00000000 --- a/lib/imagekitio/constants/supported_transformation.rb +++ /dev/null @@ -1,39 +0,0 @@ -module ImageKitIo - module Constants - module SupportedTransformation - SUPPORTED_TRANS = { - 'height': "h", - 'width': "w", - 'aspect_ratio': "ar", - 'quality': "q", - 'crop': "c", - 'crop_mode': "cm", - 'x': "x", - 'y': "y", - 'focus': "fo", - 'format': "f", - 'radius': "r", - 'background': "bg", - 'border': "b", - 'rotation': "rt", - 'blur': "bl", - 'named': "n", - 'progressive': "pr", - 'lossless': "lo", - 'trim': "t", - 'metadata': "md", - 'color_profile': "cp", - 'default_image': "di", - 'dpr': "dpr", - 'effect_sharpen': "e-sharpen", - 'effect_usm': "e-usm", - 'effect_contrast': "e-contrast", - 'effect_gray': "e-grayscale", - 'effect_shadow': "e-shadow", - 'effect_gradient': "e-gradient", - 'original': "orig", - 'raw': 'raw', - } - end - end -end diff --git a/lib/imagekitio/constants/url.rb b/lib/imagekitio/constants/url.rb deleted file mode 100644 index 5b02252f..00000000 --- a/lib/imagekitio/constants/url.rb +++ /dev/null @@ -1,14 +0,0 @@ -module ImageKitIo - module Constants - module URL - # Default URL Constants - BASE_URL = "https://api.imagekit.io/v1/files" - PURGE_CACHE = "/purge" - BULK_FILE_DELETE = "/batch/deleteByFileIds" - UPLOAD = "/upload" - REMOTE_METADATA_FULL_URL = "https://api.imagekit.io/v1/metadata" - BULK_BASE_URL = 'https://api.imagekit.io/v1/bulkJobs' - API_BASE_URL = 'https://api.imagekit.io/v1' - end - end -end diff --git a/lib/imagekitio/errors.rb b/lib/imagekitio/errors.rb deleted file mode 100644 index eeac14de..00000000 --- a/lib/imagekitio/errors.rb +++ /dev/null @@ -1,4 +0,0 @@ -module ImageKitIo - class Error < StandardError - end -end diff --git a/lib/imagekitio/railtie.rb b/lib/imagekitio/railtie.rb deleted file mode 100644 index d07f716a..00000000 --- a/lib/imagekitio/railtie.rb +++ /dev/null @@ -1,4 +0,0 @@ -module ImageKitIo - class Railtie < ::Rails::Railtie - end -end diff --git a/lib/imagekitio/request.rb b/lib/imagekitio/request.rb deleted file mode 100644 index 355450c4..00000000 --- a/lib/imagekitio/request.rb +++ /dev/null @@ -1,98 +0,0 @@ -# frozen_string_literal: true - -require "base64" -require "rest-client" -require "json" -require 'net/http/post/multipart' -require_relative './constant' -# Request requests and sends data from server -module ImageKitIo - class Request - include Constantable - - attr_reader :private_key, :public_key, :url_endpoint, :transformation_position, :options - - def initialize(private_key, public_key, url_endpoint, transformation_position = nil, options = nil) - @private_key = private_key - @public_key = public_key - @url_endpoint = url_endpoint - @transformation_position = transformation_position || constants.TRANSFORMATION_POSITION - @options = options || {} - end - - # creates required headers - def create_headers - headers = {'Accept-Encoding': "application/json", 'Content-Type': "application/json"} - headers.update(auth_headers) - end - - def auth_headers - encoded_private_key = Base64.strict_encode64(@private_key+":") - {Authorization: "Basic #{encoded_private_key}"} - end - - # request method communicates with server - def request(method, url, headers = create_headers, payload = nil) - headers ||= create_headers - response = {} - begin - if(method.downcase.to_sym == :post && payload.is_a?(Hash) && payload[:multipart]) - uri = URI.parse(url) - http = Net::HTTP.new(uri.host, uri.port) - http.use_ssl = (uri.scheme == 'https') - req = Net::HTTP::Post::Multipart.new uri.path, payload, headers - resp = http.request(req) - response[:headers] = resp.to_hash - else - resp = RestClient::Request.new(method: method, - url: url, - headers: headers, - payload: payload).execute - response[:headers] = resp.raw_headers - end - response[:raw_body] = resp.body - response[:status_code] = resp.code - resp_c = resp.code.to_i - if [400, 403].include?(resp_c) - raise RestClient::ExceptionWithResponse, OpenStruct.new({ body: resp.body, code: resp_c, headers: response[:headers] }) - end - if (resp.code.to_i >= 200) && (resp.code.to_i < 204) - content_type = resp.respond_to?(:headers) ? resp.headers[:content_type] : resp.content_type - if (content_type.include? "application/json") - response[:response] = JSON.parse(resp.body.to_s) - else - raise RestClient::ExceptionWithResponse, OpenStruct.new(code: 404, body: resp.body) - end - elsif resp.code.to_i == 204 - response[:response] = {'success': true} - end - - rescue RestClient::ExceptionWithResponse => err - response[:status_code] = err.http_code if response[:status_code].nil? - response[:headers] = err.http_headers if response[:headers].nil? - response[:error] = if err.http_code.to_i == 404 - {'message': err.response.to_s} - else - err.response.is_a?(OpenStruct) ? JSON.parse(err.response.body) : JSON.parse(err.response) - end - end - response - end - - def request_stream(method, url, headers: nil, payload: nil, **options, &block) - headers ||= create_headers - response = { response: nil, error: nil } - begin - RestClient::Request.execute(method: method, - url: url, - headers: headers, - payload: payload, - **options, - block_response: block - ) - rescue RestClient::ExceptionWithResponse => err - err.http_code == 404 ? response[:error] = {'message': err.response.to_s} : JSON.parse(err.response) - end - end - end -end diff --git a/lib/imagekitio/sdk/version.rb b/lib/imagekitio/sdk/version.rb deleted file mode 100644 index a9dac6ed..00000000 --- a/lib/imagekitio/sdk/version.rb +++ /dev/null @@ -1,5 +0,0 @@ -module ImageKitIo - module Sdk - VERSION = '3.1.0' - end -end diff --git a/lib/imagekitio/url.rb b/lib/imagekitio/url.rb deleted file mode 100644 index b2b736ae..00000000 --- a/lib/imagekitio/url.rb +++ /dev/null @@ -1,216 +0,0 @@ -# frozen_string_literal: true - -# Url holds url generation method - -require "cgi" -require "addressable/uri" -require "openssl" -require_relative "./utils/formatter" -require_relative "sdk/version.rb" - -module ImageKitIo - class Url - include Constantable - - def initialize(request_obj) - @req_obj = request_obj - end - - def generate_url(options) - if options.key? :src - options[:transformation_position] = constants.TRANSFORMATION_POSITION - end - extended_options = extend_url_options(options) - build_url(extended_options) - end - - def build_url(options) - # build url from all options - - path = options.fetch(:path, "") - src = options.fetch(:src, "") - url_endpoint = options.fetch(:url_endpoint, "") - transformation_position = options[:transformation_position] - - unless constants.VALID_TRANSFORMATION_POSITION.include? transformation_position - raise ArgumentError, constants.INVALID_TRANSFORMATION_POS - end - - src_param_used_for_url = false - if (src != "") || (transformation_position == constants.QUERY_TRANSFORMATION_POSITION) - src_param_used_for_url = true - end - - if path == "" && src == "" - return "" - end - - result_url_hash = {'host': "", 'path': "", 'query': ""} - parsed_host = Addressable::URI.parse(url_endpoint) - existing_query = nil - if path != "" - parsed_url = Addressable::URI.parse(path) - # making sure single '/' at end - result_url_hash[:host] = parsed_host.host.to_s.chomp("/") + parsed_host.path.chomp("/") + "/" - path_without_query = Addressable::URI.parse(path) - path_without_query.fragment = path_without_query.query = nil - result_url_hash[:path] = path_without_query.hostname.nil? ? trim_slash(path_without_query.to_s) : CGI.escape(trim_slash(path_without_query.to_s)) - else - parsed_url = Addressable::URI.parse(src) - result_url_hash[:userinfo] = parsed_url.userinfo if parsed_url.userinfo - result_url_hash[:host] = parsed_url.host - result_url_hash[:path] = parsed_url.path - src_param_used_for_url = true - end - - existing_query = parsed_url.query - result_url_hash[:scheme] = parsed_host.scheme - query_params = {} - query_params = CGI.parse(existing_query).reject {|k, v| v.empty? }.transform_values(&:first) unless existing_query.nil? - options.fetch(:query_parameters, {}).each do |key, value| - query_params[key] = value - end - transformation_str = transformation_to_str(options[:transformation]).chomp("/") - unless transformation_str.nil? || transformation_str.strip.empty? - if (transformation_position == constants.QUERY_TRANSFORMATION_POSITION) || src_param_used_for_url == true - result_url_hash[:query] = "#{constants.TRANSFORMATION_PARAMETER}=#{transformation_str}" - query_params[:tr]=transformation_str - else - result_url_hash[:path] = "#{constants.TRANSFORMATION_PARAMETER}:#{transformation_str}/#{result_url_hash[:path]}" - end - end - - result_url_hash[:host] = result_url_hash[:host].to_s.reverse.chomp("/").reverse - result_url_hash[:path] = result_url_hash[:path].chomp("/") unless result_url_hash[:path].nil? - result_url_hash[:scheme] ||= "https" - - query_param_arr = [] - query_params.each do |key, value| - if value.to_s == "" - query_param_arr.push(key.to_s) - else - query_param_arr.push(key.to_s + "=" + value.to_s) - end - end - query_param_str = query_param_arr.join("&") - result_url_hash[:query] = query_param_str - url = hash_to_url(result_url_hash) - if options[:signed] - private_key = options[:private_key] - expire_seconds = options[:expire_seconds] - expire_timestamp = get_signature_timestamp(expire_seconds) - url_signature = get_signature(private_key, url, url_endpoint, expire_timestamp) - query_param_arr.push(constants.SIGNATURE_PARAMETER + "=" + url_signature) - - if expire_timestamp && (expire_timestamp != constants.TIMESTAMP) - query_param_arr.push(constants.TIMESTAMP_PARAMETER + "=" + expire_timestamp.to_s) - end - query_param_str = query_param_arr.join("&") - result_url_hash[:query] = query_param_str - - url=hash_to_url(result_url_hash) - end - url - end - - def transformation_to_str(transformation) - # creates transformation_position string for url - # from transformation dictionary - - unless transformation.is_a?(Array) - return "" - end - - parsed_transforms = [] - (0..(transformation.length - 1)).each do |i| - parsed_transform_step = [] - - transformation[i].keys.each do |key| - transform_key = constants.SUPPORTED_TRANS.fetch(key, nil) - transform_key ||= key - - if transform_key == "oi" || transform_key == "di" - transformation[i][key][0] = "" if transformation[i][key][0] == "/" - transformation[i][key] = transformation[i][key].gsub("/", "@@") - end - - if transformation[i][key] == "-" - parsed_transform_step.push(transform_key) - elsif transform_key == 'raw' - parsed_transform_step.push(transformation[i][key]) - else - parsed_transform_step.push("#{transform_key}#{constants.TRANSFORM_KEY_VALUE_DELIMITER}#{transformation[i][key]}") - end - end - parsed_transforms.push(parsed_transform_step.join(constants.TRANSFORM_DELIMITER)) - end - parsed_transforms.join(constants.CHAIN_TRANSFORM_DELIMITER) - end - - def get_signature_timestamp(seconds) - # this function returns either default time stamp - # or current unix time and expiry seconds to get - # signature time stamp - - if seconds.to_i == 0 - constants.DEFAULT_TIMESTAMP - else - DateTime.now.strftime("%s").to_i + seconds.to_i - end - end - - def get_signature(private_key, url, url_endpoint, expiry_timestamp) - # creates signature(hashed hex key) and returns from - # private_key, url, url_endpoint and expiry_timestamp - if expiry_timestamp==0 - expiry_timestamp=constants.DEFAULT_TIMESTAMP - end - if url_endpoint[url_endpoint.length-1]!="/" - url_endpoint+="/" - end - replaced_url=url.gsub(url_endpoint, "") - replaced_url = replaced_url + expiry_timestamp.to_s - OpenSSL::HMAC.hexdigest("SHA1", private_key, replaced_url) - end - - def extend_url_options(options) - attr_dict = {"public_key": @req_obj.public_key, - "private_key": @req_obj.private_key, - "url_endpoint": @req_obj.url_endpoint, - "transformation_position": @req_obj.transformation_position, } - # extending url options - attr_dict.merge(options) - end - - def hash_to_url(url_hash) - generated_url = url_hash.fetch(:scheme, "") + "://" + url_hash.fetch(:host, "") + url_hash.fetch(:path, "") - if url_hash[:query] != "" - generated_url = generated_url + "?" + url_hash.fetch(:query, "") - return generated_url - end - generated_url - end - - def trim_slash(str, both = true) - if str == "" - return "" - end - # remove slash from a string - # if both is not provide trims both slash - # example - '/abc/' returns 'abc' - # if both=false it will only trim end slash - # example - '/abc/' returns '/abc' - # NOTE: IT'S RECOMMENDED TO USE inbuilt .chomp('string you want to remove') - # FOR REMOVING ONLY TRAILING SLASh - if both - str[0].chomp("/") + str[1..-2] + str[-1].chomp("/") - else - str.chomp("/") - end - end - - # class Imagekit - - # end - end -end diff --git a/lib/imagekitio/utils/calculation.rb b/lib/imagekitio/utils/calculation.rb deleted file mode 100644 index 5709090d..00000000 --- a/lib/imagekitio/utils/calculation.rb +++ /dev/null @@ -1,45 +0,0 @@ -require "date" -require "securerandom" - -module ImageKitIo - module Utils - module Calculation - DEFAULT_TIME_DIFF = 60 * 30 - - module_function - - def is_valid_hex(hex_string) - # checks if hexadecimal value is valid or not - /^[[:xdigit:]]+$/ === hex_string - end - - def hamming_distance(first, second) - # Calculate Hamming distance between to hex string - unless is_valid_hex(first) && is_valid_hex(second) - raise ArgumentError, "Both argument should be hexadecimal" - end - a = first.to_i(16) - b = second.to_i(16) - (a ^ b).to_s(2).count("1") - end - - def get_authenticated_params(token, expire, private_key) - # return authenticated param - default_expire = DateTime.now.strftime("%s").to_i + DEFAULT_TIME_DIFF - token ||= SecureRandom.uuid - expire ||= default_expire - - auth_params = {'token': token, 'expire': expire, 'signature': ""} - unless private_key - return nil - end - - signature = OpenSSL::HMAC.hexdigest("SHA1", private_key, token.to_s + expire.to_s) - auth_params[:token] = token - auth_params[:expire] = expire - auth_params[:signature] = signature - auth_params - end - end - end -end diff --git a/lib/imagekitio/utils/formatter.rb b/lib/imagekitio/utils/formatter.rb deleted file mode 100644 index f86a09da..00000000 --- a/lib/imagekitio/utils/formatter.rb +++ /dev/null @@ -1,48 +0,0 @@ -require 'json' - -module ImageKitIo - module Utils - module Formatter - - module_function - def snake_to_camel(word) - word_list = word.split("_") - result = [] - word_list&.each { |i| - if i == word_list[0] - result.push(i) - else - result.push(i.capitalize) - end - } - result.join - end - - def camel_to_snake(camel_word) - # convert camel case to snake case - camel_word.to_s.gsub(/::/, "/") - .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2') - .gsub(/([a-z\d])([A-Z])/, '\1_\2') - .tr("-", "_") - .downcase - end - - def request_formatter(data) - result = {} - data.each do |key, val| - result[snake_to_camel(key.to_s)] = val - end - result - end - - def format_to_json(options, key, expected_class) - options ||= {} - val = options[key] - if !val.nil? && val.is_a?(expected_class) - options[key] = options[key].to_json - end - options - end - end - end -end diff --git a/lib/imagekitio/utils/option_validator.rb b/lib/imagekitio/utils/option_validator.rb deleted file mode 100644 index 45036c60..00000000 --- a/lib/imagekitio/utils/option_validator.rb +++ /dev/null @@ -1,36 +0,0 @@ -require_relative './formatter' - -module ImageKitIo - module Utils - module OptionValidator - include Formatter - include Constantable - - module_function - - def validate_upload_options(options) - - # Validates upload value, checks if params are valid, - # changes snake to camel case which is supported by - # ImageKitIo server - - - response_list = [] - options.each do |key, val| - if constants.VALID_UPLOAD_OPTIONS.include?(key.to_s) - if val.is_a?(Array) - val = val.join(",") - end - if val.is_a?(TrueClass) || val.is_a?(FalseClass) - val = val.to_s - end - options[key] = val - else - return false - end - end - request_formatter(options) - end - end - end -end diff --git a/lib/tasks/imagekitio/imagekitio_tasks.rake b/lib/tasks/imagekitio/imagekitio_tasks.rake deleted file mode 100644 index 8d6717f2..00000000 --- a/lib/tasks/imagekitio/imagekitio_tasks.rake +++ /dev/null @@ -1,4 +0,0 @@ -# desc "Explaining what the task does" -# task :imagekitio do -# # Task goes here -# end diff --git a/manifest.yaml b/manifest.yaml new file mode 100644 index 00000000..556686f5 --- /dev/null +++ b/manifest.yaml @@ -0,0 +1,15 @@ +dependencies: + - English + - cgi + - date + - erb + - etc + - json + - net/http + - pathname + - rbconfig + - securerandom + - set + - stringio + - time + - uri diff --git a/rbi/imagekit/client.rbi b/rbi/imagekit/client.rbi new file mode 100644 index 00000000..703786c5 --- /dev/null +++ b/rbi/imagekit/client.rbi @@ -0,0 +1,89 @@ +# typed: strong + +module Imagekit + class Client < Imagekit::Internal::Transport::BaseClient + DEFAULT_MAX_RETRIES = 2 + + DEFAULT_TIMEOUT_IN_SECONDS = T.let(60.0, Float) + + DEFAULT_INITIAL_RETRY_DELAY = T.let(0.5, Float) + + DEFAULT_MAX_RETRY_DELAY = T.let(8.0, Float) + + # Your ImageKit private API key (starts with `private_`). You can find this in the + # [ImageKit dashboard](https://imagekit.io/dashboard/developer/api-keys). + sig { returns(String) } + attr_reader :private_key + + # ImageKit uses your API key as username and ignores the password. The SDK sets a + # dummy value. You can ignore this field. + sig { returns(T.nilable(String)) } + attr_reader :password + + sig { returns(Imagekit::Resources::CustomMetadataFields) } + attr_reader :custom_metadata_fields + + sig { returns(Imagekit::Resources::Files) } + attr_reader :files + + sig { returns(Imagekit::Resources::Assets) } + attr_reader :assets + + sig { returns(Imagekit::Resources::Cache) } + attr_reader :cache + + sig { returns(Imagekit::Resources::Folders) } + attr_reader :folders + + sig { returns(Imagekit::Resources::Accounts) } + attr_reader :accounts + + sig { returns(Imagekit::Resources::Beta) } + attr_reader :beta + + sig { returns(Imagekit::Resources::Webhooks) } + attr_reader :webhooks + + # @api private + sig { override.returns(T::Hash[String, String]) } + private def auth_headers + end + + # @api private + sig { returns(T::Boolean) } + def base_url_overridden? + end + + # Creates and returns a new client for interacting with the API. + sig do + params( + private_key: T.nilable(String), + password: T.nilable(String), + base_url: T.nilable(String), + max_retries: Integer, + timeout: Float, + initial_retry_delay: Float, + max_retry_delay: Float + ).returns(T.attached_class) + end + def self.new( + # Your ImageKit private API key (starts with `private_`). You can find this in the + # [ImageKit dashboard](https://imagekit.io/dashboard/developer/api-keys). Defaults + # to `ENV["IMAGEKIT_PRIVATE_KEY"]` + private_key: ENV["IMAGEKIT_PRIVATE_KEY"], + # ImageKit uses your API key as username and ignores the password. The SDK sets a + # dummy value. You can ignore this field. Defaults to + # `ENV["OPTIONAL_IMAGEKIT_IGNORES_THIS"]` + password: ENV.fetch("OPTIONAL_IMAGEKIT_IGNORES_THIS", "do_not_set"), + # Override the default base URL for the API, e.g., + # `"https://api.example.com/v2/"`. Defaults to `ENV["IMAGE_KIT_BASE_URL"]` + base_url: ENV["IMAGE_KIT_BASE_URL"], + # Max number of retries to attempt after a failed retryable request. + max_retries: Imagekit::Client::DEFAULT_MAX_RETRIES, + timeout: Imagekit::Client::DEFAULT_TIMEOUT_IN_SECONDS, + initial_retry_delay: Imagekit::Client::DEFAULT_INITIAL_RETRY_DELAY, + max_retry_delay: Imagekit::Client::DEFAULT_MAX_RETRY_DELAY + ) + end + end +end diff --git a/rbi/imagekit/errors.rbi b/rbi/imagekit/errors.rbi new file mode 100644 index 00000000..c39dffaf --- /dev/null +++ b/rbi/imagekit/errors.rbi @@ -0,0 +1,205 @@ +# typed: strong + +module Imagekit + module Errors + class Error < StandardError + sig { returns(T.nilable(StandardError)) } + attr_accessor :cause + end + + class ConversionError < Imagekit::Errors::Error + sig { returns(T.nilable(StandardError)) } + def cause + end + + # @api private + sig do + params( + on: T::Class[StandardError], + method: Symbol, + target: T.anything, + value: T.anything, + cause: T.nilable(StandardError) + ).returns(T.attached_class) + end + def self.new(on:, method:, target:, value:, cause: nil) + end + end + + class APIError < Imagekit::Errors::Error + sig { returns(URI::Generic) } + attr_accessor :url + + sig { returns(T.nilable(Integer)) } + attr_accessor :status + + sig { returns(T.nilable(T::Hash[String, String])) } + attr_accessor :headers + + sig { returns(T.nilable(T.anything)) } + attr_accessor :body + + # @api private + sig do + params( + url: URI::Generic, + status: T.nilable(Integer), + headers: T.nilable(T::Hash[String, String]), + body: T.nilable(Object), + request: NilClass, + response: NilClass, + message: T.nilable(String) + ).returns(T.attached_class) + end + def self.new( + url:, + status: nil, + headers: nil, + body: nil, + request: nil, + response: nil, + message: nil + ) + end + end + + class APIConnectionError < Imagekit::Errors::APIError + sig { returns(NilClass) } + attr_accessor :status + + sig { returns(NilClass) } + attr_accessor :body + + # @api private + sig do + params( + url: URI::Generic, + status: NilClass, + headers: T.nilable(T::Hash[String, String]), + body: NilClass, + request: NilClass, + response: NilClass, + message: T.nilable(String) + ).returns(T.attached_class) + end + def self.new( + url:, + status: nil, + headers: nil, + body: nil, + request: nil, + response: nil, + message: "Connection error." + ) + end + end + + class APITimeoutError < Imagekit::Errors::APIConnectionError + # @api private + sig do + params( + url: URI::Generic, + status: NilClass, + headers: T.nilable(T::Hash[String, String]), + body: NilClass, + request: NilClass, + response: NilClass, + message: T.nilable(String) + ).returns(T.attached_class) + end + def self.new( + url:, + status: nil, + headers: nil, + body: nil, + request: nil, + response: nil, + message: "Request timed out." + ) + end + end + + class APIStatusError < Imagekit::Errors::APIError + # @api private + sig do + params( + url: URI::Generic, + status: Integer, + headers: T.nilable(T::Hash[String, String]), + body: T.nilable(Object), + request: NilClass, + response: NilClass, + message: T.nilable(String) + ).returns(T.attached_class) + end + def self.for( + url:, + status:, + headers:, + body:, + request:, + response:, + message: nil + ) + end + + sig { returns(Integer) } + attr_accessor :status + + # @api private + sig do + params( + url: URI::Generic, + status: Integer, + headers: T.nilable(T::Hash[String, String]), + body: T.nilable(Object), + request: NilClass, + response: NilClass, + message: T.nilable(String) + ).returns(T.attached_class) + end + def self.new( + url:, + status:, + headers:, + body:, + request:, + response:, + message: nil + ) + end + end + + class BadRequestError < Imagekit::Errors::APIStatusError + HTTP_STATUS = 400 + end + + class AuthenticationError < Imagekit::Errors::APIStatusError + HTTP_STATUS = 401 + end + + class PermissionDeniedError < Imagekit::Errors::APIStatusError + HTTP_STATUS = 403 + end + + class NotFoundError < Imagekit::Errors::APIStatusError + HTTP_STATUS = 404 + end + + class ConflictError < Imagekit::Errors::APIStatusError + HTTP_STATUS = 409 + end + + class UnprocessableEntityError < Imagekit::Errors::APIStatusError + HTTP_STATUS = 422 + end + + class RateLimitError < Imagekit::Errors::APIStatusError + HTTP_STATUS = 429 + end + + class InternalServerError < Imagekit::Errors::APIStatusError + HTTP_STATUS = T.let((500..), T::Range[Integer]) + end + end +end diff --git a/rbi/imagekit/file_part.rbi b/rbi/imagekit/file_part.rbi new file mode 100644 index 00000000..6662978f --- /dev/null +++ b/rbi/imagekit/file_part.rbi @@ -0,0 +1,37 @@ +# typed: strong + +module Imagekit + class FilePart + sig { returns(T.any(Pathname, StringIO, IO, String)) } + attr_reader :content + + sig { returns(T.nilable(String)) } + attr_reader :content_type + + sig { returns(T.nilable(String)) } + attr_reader :filename + + # @api private + sig { returns(String) } + private def read + end + + sig { params(a: T.anything).returns(String) } + def to_json(*a) + end + + sig { params(a: T.anything).returns(String) } + def to_yaml(*a) + end + + sig do + params( + content: T.any(Pathname, StringIO, IO, String), + filename: T.nilable(String), + content_type: T.nilable(String) + ).returns(T.attached_class) + end + def self.new(content, filename: nil, content_type: nil) + end + end +end diff --git a/rbi/imagekit/internal.rbi b/rbi/imagekit/internal.rbi new file mode 100644 index 00000000..a32e13ca --- /dev/null +++ b/rbi/imagekit/internal.rbi @@ -0,0 +1,16 @@ +# typed: strong + +module Imagekit + module Internal + extend Imagekit::Internal::Util::SorbetRuntimeSupport + + # Due to the current WIP status of Shapes support in Sorbet, types referencing + # this alias might be refined in the future. + AnyHash = T.type_alias { T::Hash[Symbol, T.anything] } + + FileInput = + T.type_alias { T.any(Pathname, StringIO, IO, String, Imagekit::FilePart) } + + OMIT = T.let(Object.new.freeze, T.anything) + end +end diff --git a/rbi/imagekit/internal/transport/base_client.rbi b/rbi/imagekit/internal/transport/base_client.rbi new file mode 100644 index 00000000..1c4bbe6b --- /dev/null +++ b/rbi/imagekit/internal/transport/base_client.rbi @@ -0,0 +1,292 @@ +# typed: strong + +module Imagekit + module Internal + module Transport + # @api private + class BaseClient + extend Imagekit::Internal::Util::SorbetRuntimeSupport + + abstract! + + RequestComponents = + T.type_alias do + { + method: Symbol, + path: T.any(String, T::Array[String]), + query: + T.nilable( + T::Hash[String, T.nilable(T.any(T::Array[String], String))] + ), + headers: + T.nilable( + T::Hash[ + String, + T.nilable( + T.any( + String, + Integer, + T::Array[T.nilable(T.any(String, Integer))] + ) + ) + ] + ), + body: T.nilable(T.anything), + unwrap: + T.nilable( + T.any( + Symbol, + Integer, + T::Array[T.any(Symbol, Integer)], + T.proc.params(arg0: T.anything).returns(T.anything) + ) + ), + page: + T.nilable( + T::Class[ + Imagekit::Internal::Type::BasePage[ + Imagekit::Internal::Type::BaseModel + ] + ] + ), + stream: T.nilable(T::Class[T.anything]), + model: T.nilable(Imagekit::Internal::Type::Converter::Input), + options: T.nilable(Imagekit::RequestOptions::OrHash) + } + end + + RequestInput = + T.type_alias do + { + method: Symbol, + url: URI::Generic, + headers: T::Hash[String, String], + body: T.anything, + max_retries: Integer, + timeout: Float + } + end + + # from whatwg fetch spec + MAX_REDIRECTS = 20 + + PLATFORM_HEADERS = T::Hash[String, String] + + class << self + # @api private + sig do + params( + req: Imagekit::Internal::Transport::BaseClient::RequestComponents + ).void + end + def validate!(req) + end + + # @api private + sig do + params(status: Integer, headers: T::Hash[String, String]).returns( + T::Boolean + ) + end + def should_retry?(status, headers:) + end + + # @api private + sig do + params( + request: Imagekit::Internal::Transport::BaseClient::RequestInput, + status: Integer, + response_headers: T::Hash[String, String] + ).returns(Imagekit::Internal::Transport::BaseClient::RequestInput) + end + def follow_redirect(request, status:, response_headers:) + end + + # @api private + sig do + params( + status: T.any(Integer, Imagekit::Errors::APIConnectionError), + stream: T.nilable(T::Enumerable[String]) + ).void + end + def reap_connection!(status, stream:) + end + end + + sig { returns(URI::Generic) } + attr_reader :base_url + + sig { returns(Float) } + attr_reader :timeout + + sig { returns(Integer) } + attr_reader :max_retries + + sig { returns(Float) } + attr_reader :initial_retry_delay + + sig { returns(Float) } + attr_reader :max_retry_delay + + sig { returns(T::Hash[String, String]) } + attr_reader :headers + + sig { returns(T.nilable(String)) } + attr_reader :idempotency_header + + # @api private + sig { returns(Imagekit::Internal::Transport::PooledNetRequester) } + attr_reader :requester + + # @api private + sig do + params( + base_url: String, + timeout: Float, + max_retries: Integer, + initial_retry_delay: Float, + max_retry_delay: Float, + headers: + T::Hash[ + String, + T.nilable( + T.any( + String, + Integer, + T::Array[T.nilable(T.any(String, Integer))] + ) + ) + ], + idempotency_header: T.nilable(String) + ).returns(T.attached_class) + end + def self.new( + base_url:, + timeout: 0.0, + max_retries: 0, + initial_retry_delay: 0.0, + max_retry_delay: 0.0, + headers: {}, + idempotency_header: nil + ) + end + + # @api private + sig { overridable.returns(T::Hash[String, String]) } + private def auth_headers + end + + # @api private + sig { returns(String) } + private def generate_idempotency_key + end + + # @api private + sig do + overridable + .params( + req: Imagekit::Internal::Transport::BaseClient::RequestComponents, + opts: Imagekit::Internal::AnyHash + ) + .returns(Imagekit::Internal::Transport::BaseClient::RequestInput) + end + private def build_request(req, opts) + end + + # @api private + sig do + params( + headers: T::Hash[String, String], + retry_count: Integer + ).returns(Float) + end + private def retry_delay(headers, retry_count:) + end + + # @api private + sig do + params( + request: Imagekit::Internal::Transport::BaseClient::RequestInput, + redirect_count: Integer, + retry_count: Integer, + send_retry_header: T::Boolean + ).returns([Integer, Net::HTTPResponse, T::Enumerable[String]]) + end + def send_request( + request, + redirect_count:, + retry_count:, + send_retry_header: + ) + end + + # Execute the request specified by `req`. This is the method that all resource + # methods call into. + # + # @overload request(method, path, query: {}, headers: {}, body: nil, unwrap: nil, page: nil, stream: nil, model: Imagekit::Internal::Type::Unknown, options: {}) + sig do + params( + method: Symbol, + path: T.any(String, T::Array[String]), + query: + T.nilable( + T::Hash[String, T.nilable(T.any(T::Array[String], String))] + ), + headers: + T.nilable( + T::Hash[ + String, + T.nilable( + T.any( + String, + Integer, + T::Array[T.nilable(T.any(String, Integer))] + ) + ) + ] + ), + body: T.nilable(T.anything), + unwrap: + T.nilable( + T.any( + Symbol, + Integer, + T::Array[T.any(Symbol, Integer)], + T.proc.params(arg0: T.anything).returns(T.anything) + ) + ), + page: + T.nilable( + T::Class[ + Imagekit::Internal::Type::BasePage[ + Imagekit::Internal::Type::BaseModel + ] + ] + ), + stream: T.nilable(T::Class[T.anything]), + model: T.nilable(Imagekit::Internal::Type::Converter::Input), + options: T.nilable(Imagekit::RequestOptions::OrHash) + ).returns(T.anything) + end + def request( + method, + path, + query: {}, + headers: {}, + body: nil, + unwrap: nil, + page: nil, + stream: nil, + model: Imagekit::Internal::Type::Unknown, + options: {} + ) + end + + # @api private + sig { returns(String) } + def inspect + end + end + end + end +end diff --git a/rbi/imagekit/internal/transport/pooled_net_requester.rbi b/rbi/imagekit/internal/transport/pooled_net_requester.rbi new file mode 100644 index 00000000..f5b90254 --- /dev/null +++ b/rbi/imagekit/internal/transport/pooled_net_requester.rbi @@ -0,0 +1,79 @@ +# typed: strong + +module Imagekit + module Internal + module Transport + # @api private + class PooledNetRequester + extend Imagekit::Internal::Util::SorbetRuntimeSupport + + Request = + T.type_alias do + { + method: Symbol, + url: URI::Generic, + headers: T::Hash[String, String], + body: T.anything, + deadline: Float + } + end + + # from the golang stdlib + # https://github.com/golang/go/blob/c8eced8580028328fde7c03cbfcb720ce15b2358/src/net/http/transport.go#L49 + KEEP_ALIVE_TIMEOUT = 30 + + DEFAULT_MAX_CONNECTIONS = T.let(T.unsafe(nil), Integer) + + class << self + # @api private + sig { params(url: URI::Generic).returns(Net::HTTP) } + def connect(url) + end + + # @api private + sig { params(conn: Net::HTTP, deadline: Float).void } + def calibrate_socket_timeout(conn, deadline) + end + + # @api private + sig do + params( + request: + Imagekit::Internal::Transport::PooledNetRequester::Request, + blk: T.proc.params(arg0: String).void + ).returns([Net::HTTPGenericRequest, T.proc.void]) + end + def build_request(request, &blk) + end + end + + # @api private + sig do + params( + url: URI::Generic, + deadline: Float, + blk: T.proc.params(arg0: Net::HTTP).void + ).void + end + private def with_pool(url, deadline:, &blk) + end + + # @api private + sig do + params( + request: Imagekit::Internal::Transport::PooledNetRequester::Request + ).returns([Integer, Net::HTTPResponse, T::Enumerable[String]]) + end + def execute(request) + end + + # @api private + sig { params(size: Integer).returns(T.attached_class) } + def self.new( + size: Imagekit::Internal::Transport::PooledNetRequester::DEFAULT_MAX_CONNECTIONS + ) + end + end + end + end +end diff --git a/rbi/imagekit/internal/type/array_of.rbi b/rbi/imagekit/internal/type/array_of.rbi new file mode 100644 index 00000000..4c739d92 --- /dev/null +++ b/rbi/imagekit/internal/type/array_of.rbi @@ -0,0 +1,104 @@ +# typed: strong + +module Imagekit + module Internal + module Type + # @api private + # + # Array of items of a given type. + class ArrayOf + include Imagekit::Internal::Type::Converter + include Imagekit::Internal::Util::SorbetRuntimeSupport + + abstract! + + Elem = type_member(:out) + + sig do + params( + type_info: + T.any( + Imagekit::Internal::AnyHash, + T.proc.returns(Imagekit::Internal::Type::Converter::Input), + Imagekit::Internal::Type::Converter::Input + ), + spec: Imagekit::Internal::AnyHash + ).returns(T.attached_class) + end + def self.[](type_info, spec = {}) + end + + sig { params(other: T.anything).returns(T::Boolean) } + def ===(other) + end + + sig { params(other: T.anything).returns(T::Boolean) } + def ==(other) + end + + sig { returns(Integer) } + def hash + end + + # @api private + sig do + override + .params( + value: T.any(T::Array[T.anything], T.anything), + state: Imagekit::Internal::Type::Converter::CoerceState + ) + .returns(T.any(T::Array[T.anything], T.anything)) + end + def coerce(value, state:) + end + + # @api private + sig do + override + .params( + value: T.any(T::Array[T.anything], T.anything), + state: Imagekit::Internal::Type::Converter::DumpState + ) + .returns(T.any(T::Array[T.anything], T.anything)) + end + def dump(value, state:) + end + + # @api private + sig { returns(T.anything) } + def to_sorbet_type + end + + # @api private + sig { returns(Elem) } + protected def item_type + end + + # @api private + sig { returns(T::Boolean) } + protected def nilable? + end + + # @api private + sig do + params( + type_info: + T.any( + Imagekit::Internal::AnyHash, + T.proc.returns(Imagekit::Internal::Type::Converter::Input), + Imagekit::Internal::Type::Converter::Input + ), + spec: Imagekit::Internal::AnyHash + ).void + end + def initialize(type_info, spec = {}) + end + + # @api private + sig { params(depth: Integer).returns(String) } + def inspect(depth: 0) + end + end + end + end +end diff --git a/rbi/imagekit/internal/type/base_model.rbi b/rbi/imagekit/internal/type/base_model.rbi new file mode 100644 index 00000000..b1ae616a --- /dev/null +++ b/rbi/imagekit/internal/type/base_model.rbi @@ -0,0 +1,302 @@ +# typed: strong + +module Imagekit + module Internal + module Type + class BaseModel + extend Imagekit::Internal::Type::Converter + extend Imagekit::Internal::Util::SorbetRuntimeSupport + + abstract! + + KnownField = + T.type_alias do + { + mode: T.nilable(Symbol), + required: T::Boolean, + nilable: T::Boolean + } + end + + OrHash = + T.type_alias do + T.any( + Imagekit::Internal::Type::BaseModel, + Imagekit::Internal::AnyHash + ) + end + + class << self + # @api private + # + # Assumes superclass fields are totally defined before fields are accessed / + # defined on subclasses. + sig { params(child: T.self_type).void } + def inherited(child) + end + + # @api private + sig do + returns( + T::Hash[ + Symbol, + T.all( + Imagekit::Internal::Type::BaseModel::KnownField, + { + type_fn: + T.proc.returns(Imagekit::Internal::Type::Converter::Input) + } + ) + ] + ) + end + def known_fields + end + + # @api private + sig do + returns( + T::Hash[ + Symbol, + T.all( + Imagekit::Internal::Type::BaseModel::KnownField, + { type: Imagekit::Internal::Type::Converter::Input } + ) + ] + ) + end + def fields + end + + # @api private + sig do + params( + name_sym: Symbol, + required: T::Boolean, + type_info: + T.any( + { + const: + T.nilable( + T.any(NilClass, T::Boolean, Integer, Float, Symbol) + ), + enum: + T.nilable( + T.proc.returns( + Imagekit::Internal::Type::Converter::Input + ) + ), + union: + T.nilable( + T.proc.returns( + Imagekit::Internal::Type::Converter::Input + ) + ), + api_name: Symbol, + nil?: T::Boolean + }, + T.proc.returns(Imagekit::Internal::Type::Converter::Input), + Imagekit::Internal::Type::Converter::Input + ), + spec: Imagekit::Internal::AnyHash + ).void + end + private def add_field(name_sym, required:, type_info:, spec:) + end + + # @api private + sig do + params( + name_sym: Symbol, + type_info: + T.any( + Imagekit::Internal::AnyHash, + T.proc.returns(Imagekit::Internal::Type::Converter::Input), + Imagekit::Internal::Type::Converter::Input + ), + spec: Imagekit::Internal::AnyHash + ).void + end + def required(name_sym, type_info, spec = {}) + end + + # @api private + sig do + params( + name_sym: Symbol, + type_info: + T.any( + Imagekit::Internal::AnyHash, + T.proc.returns(Imagekit::Internal::Type::Converter::Input), + Imagekit::Internal::Type::Converter::Input + ), + spec: Imagekit::Internal::AnyHash + ).void + end + def optional(name_sym, type_info, spec = {}) + end + + # @api private + # + # `request_only` attributes not excluded from `.#coerce` when receiving responses + # even if well behaved servers should not send them + sig { params(blk: T.proc.void).void } + private def request_only(&blk) + end + + # @api private + # + # `response_only` attributes are omitted from `.#dump` when making requests + sig { params(blk: T.proc.void).void } + private def response_only(&blk) + end + + sig { params(other: T.anything).returns(T::Boolean) } + def ==(other) + end + + sig { returns(Integer) } + def hash + end + end + + sig { params(other: T.anything).returns(T::Boolean) } + def ==(other) + end + + sig { returns(Integer) } + def hash + end + + class << self + # @api private + sig do + override + .params( + value: + T.any( + Imagekit::Internal::Type::BaseModel, + T::Hash[T.anything, T.anything], + T.anything + ), + state: Imagekit::Internal::Type::Converter::CoerceState + ) + .returns(T.any(T.attached_class, T.anything)) + end + def coerce(value, state:) + end + + # @api private + sig do + override + .params( + value: T.any(T.attached_class, T.anything), + state: Imagekit::Internal::Type::Converter::DumpState + ) + .returns(T.any(T::Hash[T.anything, T.anything], T.anything)) + end + def dump(value, state:) + end + + # @api private + sig { returns(T.anything) } + def to_sorbet_type + end + end + + class << self + # @api private + sig do + params( + model: Imagekit::Internal::Type::BaseModel, + convert: T::Boolean + ).returns(Imagekit::Internal::AnyHash) + end + def recursively_to_h(model, convert:) + end + end + + # Returns the raw value associated with the given key, if found. Otherwise, nil is + # returned. + # + # It is valid to lookup keys that are not in the API spec, for example to access + # undocumented features. This method does not parse response data into + # higher-level types. Lookup by anything other than a Symbol is an ArgumentError. + sig { params(key: Symbol).returns(T.nilable(T.anything)) } + def [](key) + end + + # Returns a Hash of the data underlying this object. O(1) + # + # Keys are Symbols and values are the raw values from the response. The return + # value indicates which values were ever set on the object. i.e. there will be a + # key in this hash if they ever were, even if the set value was nil. + # + # This method is not recursive. The returned value is shared by the object, so it + # should not be mutated. + sig { overridable.returns(Imagekit::Internal::AnyHash) } + def to_h + end + + # Returns a Hash of the data underlying this object. O(1) + # + # Keys are Symbols and values are the raw values from the response. The return + # value indicates which values were ever set on the object. i.e. there will be a + # key in this hash if they ever were, even if the set value was nil. + # + # This method is not recursive. The returned value is shared by the object, so it + # should not be mutated. + sig { overridable.returns(Imagekit::Internal::AnyHash) } + def to_hash + end + + # In addition to the behaviour of `#to_h`, this method will recursively call + # `#to_h` on nested models. + sig { overridable.returns(Imagekit::Internal::AnyHash) } + def deep_to_h + end + + sig do + params(keys: T.nilable(T::Array[Symbol])).returns( + Imagekit::Internal::AnyHash + ) + end + def deconstruct_keys(keys) + end + + sig { params(a: T.anything).returns(String) } + def to_json(*a) + end + + sig { params(a: T.anything).returns(String) } + def to_yaml(*a) + end + + # Create a new instance of a model. + sig do + params(data: T.any(T::Hash[Symbol, T.anything], T.self_type)).returns( + T.attached_class + ) + end + def self.new(data = {}) + end + + class << self + # @api private + sig { params(depth: Integer).returns(String) } + def inspect(depth: 0) + end + end + + sig { returns(String) } + def to_s + end + + # @api private + sig { returns(String) } + def inspect + end + end + end + end +end diff --git a/rbi/imagekit/internal/type/base_page.rbi b/rbi/imagekit/internal/type/base_page.rbi new file mode 100644 index 00000000..b720ff81 --- /dev/null +++ b/rbi/imagekit/internal/type/base_page.rbi @@ -0,0 +1,42 @@ +# typed: strong + +module Imagekit + module Internal + module Type + # @api private + # + # This module provides a base implementation for paginated responses in the SDK. + module BasePage + Elem = type_member(:out) + + sig { overridable.returns(T::Boolean) } + def next_page? + end + + sig { overridable.returns(T.self_type) } + def next_page + end + + sig { overridable.params(blk: T.proc.params(arg0: Elem).void).void } + def auto_paging_each(&blk) + end + + sig { returns(T::Enumerable[Elem]) } + def to_enum + end + + # @api private + sig do + params( + client: Imagekit::Internal::Transport::BaseClient, + req: Imagekit::Internal::Transport::BaseClient::RequestComponents, + headers: T::Hash[String, String], + page_data: T.anything + ).void + end + def initialize(client:, req:, headers:, page_data:) + end + end + end + end +end diff --git a/rbi/imagekit/internal/type/boolean.rbi b/rbi/imagekit/internal/type/boolean.rbi new file mode 100644 index 00000000..fd1f5df2 --- /dev/null +++ b/rbi/imagekit/internal/type/boolean.rbi @@ -0,0 +1,58 @@ +# typed: strong + +module Imagekit + module Internal + module Type + # @api private + # + # Ruby has no Boolean class; this is something for models to refer to. + class Boolean + extend Imagekit::Internal::Type::Converter + extend Imagekit::Internal::Util::SorbetRuntimeSupport + + abstract! + + sig { params(other: T.anything).returns(T::Boolean) } + def self.===(other) + end + + sig { params(other: T.anything).returns(T::Boolean) } + def self.==(other) + end + + class << self + # @api private + # + # Coerce value to Boolean if possible, otherwise return the original value. + sig do + override + .params( + value: T.any(T::Boolean, T.anything), + state: Imagekit::Internal::Type::Converter::CoerceState + ) + .returns(T.any(T::Boolean, T.anything)) + end + def coerce(value, state:) + end + + # @api private + sig do + override + .params( + value: T.any(T::Boolean, T.anything), + state: Imagekit::Internal::Type::Converter::DumpState + ) + .returns(T.any(T::Boolean, T.anything)) + end + def dump(value, state:) + end + + # @api private + sig { returns(T.anything) } + def to_sorbet_type + end + end + end + end + end +end diff --git a/rbi/imagekit/internal/type/converter.rbi b/rbi/imagekit/internal/type/converter.rbi new file mode 100644 index 00000000..34341635 --- /dev/null +++ b/rbi/imagekit/internal/type/converter.rbi @@ -0,0 +1,216 @@ +# typed: strong + +module Imagekit + module Internal + module Type + # @api private + module Converter + extend Imagekit::Internal::Util::SorbetRuntimeSupport + + Input = + T.type_alias do + T.any(Imagekit::Internal::Type::Converter, T::Class[T.anything]) + end + + CoerceState = + T.type_alias do + { + translate_names: T::Boolean, + strictness: T::Boolean, + exactness: { + yes: Integer, + no: Integer, + maybe: Integer + }, + error: T::Class[StandardError], + branched: Integer + } + end + + DumpState = T.type_alias { { can_retry: T::Boolean } } + + # @api private + sig do + overridable + .params( + value: T.anything, + state: Imagekit::Internal::Type::Converter::CoerceState + ) + .returns(T.anything) + end + def coerce(value, state:) + end + + # @api private + sig do + overridable + .params( + value: T.anything, + state: Imagekit::Internal::Type::Converter::DumpState + ) + .returns(T.anything) + end + def dump(value, state:) + end + + # @api private + sig { params(depth: Integer).returns(String) } + def inspect(depth: 0) + end + + class << self + # @api private + sig do + params( + spec: + T.any( + { + const: + T.nilable( + T.any(NilClass, T::Boolean, Integer, Float, Symbol) + ), + enum: + T.nilable( + T.proc.returns( + Imagekit::Internal::Type::Converter::Input + ) + ), + union: + T.nilable( + T.proc.returns( + Imagekit::Internal::Type::Converter::Input + ) + ) + }, + T.proc.returns(Imagekit::Internal::Type::Converter::Input), + Imagekit::Internal::Type::Converter::Input + ) + ).returns(T.proc.returns(T.anything)) + end + def self.type_info(spec) + end + + # @api private + sig do + params( + type_info: + T.any( + { + const: + T.nilable( + T.any(NilClass, T::Boolean, Integer, Float, Symbol) + ), + enum: + T.nilable( + T.proc.returns( + Imagekit::Internal::Type::Converter::Input + ) + ), + union: + T.nilable( + T.proc.returns( + Imagekit::Internal::Type::Converter::Input + ) + ) + }, + T.proc.returns(Imagekit::Internal::Type::Converter::Input), + Imagekit::Internal::Type::Converter::Input + ), + spec: + T.any( + { + const: + T.nilable( + T.any(NilClass, T::Boolean, Integer, Float, Symbol) + ), + enum: + T.nilable( + T.proc.returns( + Imagekit::Internal::Type::Converter::Input + ) + ), + union: + T.nilable( + T.proc.returns( + Imagekit::Internal::Type::Converter::Input + ) + ) + }, + T.proc.returns(Imagekit::Internal::Type::Converter::Input), + Imagekit::Internal::Type::Converter::Input + ) + ).returns(Imagekit::Internal::AnyHash) + end + def self.meta_info(type_info, spec) + end + + # @api private + sig do + params(translate_names: T::Boolean).returns( + Imagekit::Internal::Type::Converter::CoerceState + ) + end + def self.new_coerce_state(translate_names: true) + end + + # @api private + # + # Based on `target`, transform `value` into `target`, to the extent possible: + # + # 1. if the given `value` conforms to `target` already, return the given `value` + # 2. if it's possible and safe to convert the given `value` to `target`, then the + # converted value + # 3. otherwise, the given `value` unaltered + # + # The coercion process is subject to improvement between minor release versions. + # See https://docs.pydantic.dev/latest/concepts/unions/#smart-mode + sig do + params( + target: Imagekit::Internal::Type::Converter::Input, + value: T.anything, + state: Imagekit::Internal::Type::Converter::CoerceState + ).returns(T.anything) + end + def self.coerce( + target, + value, + # The `strictness` is one of `true`, `false`. This informs the coercion strategy + # when we have to decide between multiple possible conversion targets: + # + # - `true`: the conversion must be exact, with minimum coercion. + # - `false`: the conversion can be approximate, with some coercion. + # + # The `exactness` is `Hash` with keys being one of `yes`, `no`, or `maybe`. For + # any given conversion attempt, the exactness will be updated based on how closely + # the value recursively matches the target type: + # + # - `yes`: the value can be converted to the target type with minimum coercion. + # - `maybe`: the value can be converted to the target type with some reasonable + # coercion. + # - `no`: the value cannot be converted to the target type. + # + # See implementation below for more details. + state: Imagekit::Internal::Type::Converter.new_coerce_state + ) + end + + # @api private + sig do + params( + target: Imagekit::Internal::Type::Converter::Input, + value: T.anything, + state: Imagekit::Internal::Type::Converter::DumpState + ).returns(T.anything) + end + def self.dump(target, value, state: { can_retry: true }) + end + + # @api private + sig { params(target: T.anything, depth: Integer).returns(String) } + def self.inspect(target, depth:) + end + end + end + end + end +end diff --git a/rbi/imagekit/internal/type/enum.rbi b/rbi/imagekit/internal/type/enum.rbi new file mode 100644 index 00000000..c7b354ff --- /dev/null +++ b/rbi/imagekit/internal/type/enum.rbi @@ -0,0 +1,82 @@ +# typed: strong + +module Imagekit + module Internal + module Type + # @api private + # + # A value from among a specified list of options. OpenAPI enum values map to Ruby + # values in the SDK as follows: + # + # 1. boolean => true | false + # 2. integer => Integer + # 3. float => Float + # 4. string => Symbol + # + # We can therefore convert string values to Symbols, but can't convert other + # values safely. + module Enum + include Imagekit::Internal::Type::Converter + include Imagekit::Internal::Util::SorbetRuntimeSupport + + # All of the valid Symbol values for this enum. + sig do + overridable.returns( + T::Array[T.any(NilClass, T::Boolean, Integer, Float, Symbol)] + ) + end + def values + end + + sig { params(other: T.anything).returns(T::Boolean) } + def ===(other) + end + + sig { params(other: T.anything).returns(T::Boolean) } + def ==(other) + end + + sig { returns(Integer) } + def hash + end + + # @api private + # + # Unlike with primitives, `Enum` additionally validates that the value is a member + # of the enum. + sig do + override + .params( + value: T.any(String, Symbol, T.anything), + state: Imagekit::Internal::Type::Converter::CoerceState + ) + .returns(T.any(Symbol, T.anything)) + end + def coerce(value, state:) + end + + # @api private + sig do + override + .params( + value: T.any(Symbol, T.anything), + state: Imagekit::Internal::Type::Converter::DumpState + ) + .returns(T.any(Symbol, T.anything)) + end + def dump(value, state:) + end + + # @api private + sig { returns(T.anything) } + def to_sorbet_type + end + + # @api private + sig { params(depth: Integer).returns(String) } + def inspect(depth: 0) + end + end + end + end +end diff --git a/rbi/imagekit/internal/type/file_input.rbi b/rbi/imagekit/internal/type/file_input.rbi new file mode 100644 index 00000000..1982d8a2 --- /dev/null +++ b/rbi/imagekit/internal/type/file_input.rbi @@ -0,0 +1,59 @@ +# typed: strong + +module Imagekit + module Internal + module Type + # @api private + # + # Either `Pathname` or `StringIO`, or `IO`, or + # `Imagekit::Internal::Type::FileInput`. + # + # Note: when `IO` is used, all retries are disabled, since many IO` streams are + # not rewindable. + class FileInput + extend Imagekit::Internal::Type::Converter + + abstract! + + sig { params(other: T.anything).returns(T::Boolean) } + def self.===(other) + end + + sig { params(other: T.anything).returns(T::Boolean) } + def self.==(other) + end + + class << self + # @api private + sig do + override + .params( + value: T.any(StringIO, String, T.anything), + state: Imagekit::Internal::Type::Converter::CoerceState + ) + .returns(T.any(StringIO, T.anything)) + end + def coerce(value, state:) + end + + # @api private + sig do + override + .params( + value: T.any(Pathname, StringIO, IO, String, T.anything), + state: Imagekit::Internal::Type::Converter::DumpState + ) + .returns(T.any(Pathname, StringIO, IO, String, T.anything)) + end + def dump(value, state:) + end + + # @api private + sig { returns(T.anything) } + def to_sorbet_type + end + end + end + end + end +end diff --git a/rbi/imagekit/internal/type/hash_of.rbi b/rbi/imagekit/internal/type/hash_of.rbi new file mode 100644 index 00000000..0d963136 --- /dev/null +++ b/rbi/imagekit/internal/type/hash_of.rbi @@ -0,0 +1,104 @@ +# typed: strong + +module Imagekit + module Internal + module Type + # @api private + # + # Hash of items of a given type. + class HashOf + include Imagekit::Internal::Type::Converter + include Imagekit::Internal::Util::SorbetRuntimeSupport + + abstract! + + Elem = type_member(:out) + + sig do + params( + type_info: + T.any( + Imagekit::Internal::AnyHash, + T.proc.returns(Imagekit::Internal::Type::Converter::Input), + Imagekit::Internal::Type::Converter::Input + ), + spec: Imagekit::Internal::AnyHash + ).returns(T.attached_class) + end + def self.[](type_info, spec = {}) + end + + sig { params(other: T.anything).returns(T::Boolean) } + def ===(other) + end + + sig { params(other: T.anything).returns(T::Boolean) } + def ==(other) + end + + sig { returns(Integer) } + def hash + end + + # @api private + sig do + override + .params( + value: T.any(T::Hash[T.anything, T.anything], T.anything), + state: Imagekit::Internal::Type::Converter::CoerceState + ) + .returns(T.any(Imagekit::Internal::AnyHash, T.anything)) + end + def coerce(value, state:) + end + + # @api private + sig do + override + .params( + value: T.any(T::Hash[T.anything, T.anything], T.anything), + state: Imagekit::Internal::Type::Converter::DumpState + ) + .returns(T.any(Imagekit::Internal::AnyHash, T.anything)) + end + def dump(value, state:) + end + + # @api private + sig { returns(T.anything) } + def to_sorbet_type + end + + # @api private + sig { returns(Elem) } + protected def item_type + end + + # @api private + sig { returns(T::Boolean) } + protected def nilable? + end + + # @api private + sig do + params( + type_info: + T.any( + Imagekit::Internal::AnyHash, + T.proc.returns(Imagekit::Internal::Type::Converter::Input), + Imagekit::Internal::Type::Converter::Input + ), + spec: Imagekit::Internal::AnyHash + ).void + end + def initialize(type_info, spec = {}) + end + + # @api private + sig { params(depth: Integer).returns(String) } + def inspect(depth: 0) + end + end + end + end +end diff --git a/rbi/imagekit/internal/type/request_parameters.rbi b/rbi/imagekit/internal/type/request_parameters.rbi new file mode 100644 index 00000000..a8f7b350 --- /dev/null +++ b/rbi/imagekit/internal/type/request_parameters.rbi @@ -0,0 +1,29 @@ +# typed: strong + +module Imagekit + module Internal + module Type + # @api private + module RequestParameters + # Options to specify HTTP behaviour for this request. + sig { returns(Imagekit::RequestOptions) } + attr_reader :request_options + + sig { params(request_options: Imagekit::RequestOptions::OrHash).void } + attr_writer :request_options + + # @api private + module Converter + # @api private + sig do + params(params: T.anything).returns( + [T.anything, Imagekit::Internal::AnyHash] + ) + end + def dump_request(params) + end + end + end + end + end +end diff --git a/rbi/imagekit/internal/type/union.rbi b/rbi/imagekit/internal/type/union.rbi new file mode 100644 index 00000000..1fd36045 --- /dev/null +++ b/rbi/imagekit/internal/type/union.rbi @@ -0,0 +1,128 @@ +# typed: strong + +module Imagekit + module Internal + module Type + # @api private + module Union + include Imagekit::Internal::Type::Converter + include Imagekit::Internal::Util::SorbetRuntimeSupport + + # @api private + # + # All of the specified variant info for this union. + sig do + returns( + T::Array[ + [ + T.nilable(Symbol), + T.proc.returns(Imagekit::Internal::Type::Converter::Input), + Imagekit::Internal::AnyHash + ] + ] + ) + end + private def known_variants + end + + # @api private + sig do + returns( + T::Array[ + [T.nilable(Symbol), T.anything, Imagekit::Internal::AnyHash] + ] + ) + end + protected def derefed_variants + end + + # All of the specified variants for this union. + sig { overridable.returns(T::Array[T.anything]) } + def variants + end + + # @api private + sig { params(property: Symbol).void } + private def discriminator(property) + end + + # @api private + sig do + params( + key: + T.any( + Symbol, + Imagekit::Internal::AnyHash, + T.proc.returns(T.anything), + T.anything + ), + spec: + T.any( + Imagekit::Internal::AnyHash, + T.proc.returns(T.anything), + T.anything + ) + ).void + end + private def variant(key, spec = nil) + end + + # @api private + sig { params(value: T.anything).returns(T.nilable(T.anything)) } + private def resolve_variant(value) + end + + sig { params(other: T.anything).returns(T::Boolean) } + def ===(other) + end + + sig { params(other: T.anything).returns(T::Boolean) } + def ==(other) + end + + sig { returns(Integer) } + def hash + end + + # @api private + # + # Tries to efficiently coerce the given value to one of the known variants. + # + # If the value cannot match any of the known variants, the coercion is considered + # non-viable and returns the original value. + sig do + override + .params( + value: T.anything, + state: Imagekit::Internal::Type::Converter::CoerceState + ) + .returns(T.anything) + end + def coerce(value, state:) + end + + # @api private + sig do + override + .params( + value: T.anything, + state: Imagekit::Internal::Type::Converter::DumpState + ) + .returns(T.anything) + end + def dump(value, state:) + end + + # @api private + sig { returns(T.anything) } + def to_sorbet_type + end + + # @api private + sig { params(depth: Integer).returns(String) } + def inspect(depth: 0) + end + end + end + end +end diff --git a/rbi/imagekit/internal/type/unknown.rbi b/rbi/imagekit/internal/type/unknown.rbi new file mode 100644 index 00000000..27d7c467 --- /dev/null +++ b/rbi/imagekit/internal/type/unknown.rbi @@ -0,0 +1,58 @@ +# typed: strong + +module Imagekit + module Internal + module Type + # @api private + # + # When we don't know what to expect for the value. + class Unknown + extend Imagekit::Internal::Type::Converter + extend Imagekit::Internal::Util::SorbetRuntimeSupport + + abstract! + + sig { params(other: T.anything).returns(T::Boolean) } + def self.===(other) + end + + sig { params(other: T.anything).returns(T::Boolean) } + def self.==(other) + end + + class << self + # @api private + # + # No coercion needed for Unknown type. + sig do + override + .params( + value: T.anything, + state: Imagekit::Internal::Type::Converter::CoerceState + ) + .returns(T.anything) + end + def coerce(value, state:) + end + + # @api private + sig do + override + .params( + value: T.anything, + state: Imagekit::Internal::Type::Converter::DumpState + ) + .returns(T.anything) + end + def dump(value, state:) + end + + # @api private + sig { returns(T.anything) } + def to_sorbet_type + end + end + end + end + end +end diff --git a/rbi/imagekit/internal/util.rbi b/rbi/imagekit/internal/util.rbi new file mode 100644 index 00000000..808c028d --- /dev/null +++ b/rbi/imagekit/internal/util.rbi @@ -0,0 +1,487 @@ +# typed: strong + +module Imagekit + module Internal + # @api private + module Util + extend Imagekit::Internal::Util::SorbetRuntimeSupport + + # @api private + sig { returns(Float) } + def self.monotonic_secs + end + + # @api private + sig do + params(ns: T.any(Module, T::Class[T.anything])).returns( + T::Enumerable[T.any(Module, T::Class[T.anything])] + ) + end + def self.walk_namespaces(ns) + end + + class << self + # @api private + sig { returns(String) } + def arch + end + + # @api private + sig { returns(String) } + def os + end + end + + class << self + # @api private + sig { params(input: T.anything).returns(T::Boolean) } + def primitive?(input) + end + + # @api private + sig do + params(input: T.any(String, T::Boolean)).returns( + T.any(T::Boolean, T.anything) + ) + end + def coerce_boolean(input) + end + + # @api private + sig do + params(input: T.any(String, T::Boolean)).returns( + T.nilable(T::Boolean) + ) + end + def coerce_boolean!(input) + end + + # @api private + sig do + params(input: T.any(String, Integer)).returns( + T.any(Integer, T.anything) + ) + end + def coerce_integer(input) + end + + # @api private + sig do + params(input: T.any(String, Integer, Float)).returns( + T.any(Float, T.anything) + ) + end + def coerce_float(input) + end + + # @api private + sig do + params(input: T.anything).returns( + T.any(T::Hash[T.anything, T.anything], T.anything) + ) + end + def coerce_hash(input) + end + + # @api private + sig do + params(input: T.anything).returns( + T.nilable(T::Hash[T.anything, T.anything]) + ) + end + def coerce_hash!(input) + end + end + + class << self + # @api private + sig do + params(lhs: T.anything, rhs: T.anything, concat: T::Boolean).returns( + T.anything + ) + end + private def deep_merge_lr(lhs, rhs, concat: false) + end + + # @api private + # + # Recursively merge one hash with another. If the values at a given key are not + # both hashes, just take the new value. + sig do + params( + values: T::Array[T.anything], + sentinel: T.nilable(T.anything), + concat: T::Boolean + ).returns(T.anything) + end + def deep_merge( + *values, + # the value to return if no values are provided. + sentinel: nil, + # whether to merge sequences by concatenation. + concat: false + ) + end + + # @api private + sig do + params( + data: + T.any( + Imagekit::Internal::AnyHash, + T::Array[T.anything], + T.anything + ), + pick: + T.nilable( + T.any( + Symbol, + Integer, + T::Array[T.any(Symbol, Integer)], + T.proc.params(arg0: T.anything).returns(T.anything) + ) + ), + blk: T.nilable(T.proc.returns(T.anything)) + ).returns(T.nilable(T.anything)) + end + def dig(data, pick, &blk) + end + end + + class << self + # @api private + sig { params(uri: URI::Generic).returns(String) } + def uri_origin(uri) + end + + # @api private + sig { params(path: T.any(String, T::Array[String])).returns(String) } + def interpolate_path(path) + end + end + + class << self + # @api private + sig do + params(query: T.nilable(String)).returns( + T::Hash[String, T::Array[String]] + ) + end + def decode_query(query) + end + + # @api private + sig do + params( + query: + T.nilable( + T::Hash[String, T.nilable(T.any(T::Array[String], String))] + ) + ).returns(T.nilable(String)) + end + def encode_query(query) + end + end + + ParsedUri = + T.type_alias do + { + scheme: T.nilable(String), + host: T.nilable(String), + port: T.nilable(Integer), + path: T.nilable(String), + query: T::Hash[String, T::Array[String]] + } + end + + class << self + # @api private + sig do + params(url: T.any(URI::Generic, String)).returns( + Imagekit::Internal::Util::ParsedUri + ) + end + def parse_uri(url) + end + + # @api private + sig do + params(parsed: Imagekit::Internal::Util::ParsedUri).returns( + URI::Generic + ) + end + def unparse_uri(parsed) + end + + # @api private + sig do + params( + lhs: Imagekit::Internal::Util::ParsedUri, + rhs: Imagekit::Internal::Util::ParsedUri + ).returns(URI::Generic) + end + def join_parsed_uri(lhs, rhs) + end + end + + class << self + # @api private + sig do + params( + headers: + T::Hash[ + String, + T.nilable( + T.any( + String, + Integer, + T::Array[T.nilable(T.any(String, Integer))] + ) + ) + ] + ).returns(T::Hash[String, String]) + end + def normalized_headers(*headers) + end + end + + # @api private + # + # An adapter that satisfies the IO interface required by `::IO.copy_stream` + class ReadIOAdapter + # @api private + sig { returns(T.nilable(T::Boolean)) } + def close? + end + + # @api private + sig { void } + def close + end + + # @api private + sig { params(max_len: T.nilable(Integer)).returns(String) } + private def read_enum(max_len) + end + + # @api private + sig do + params( + max_len: T.nilable(Integer), + out_string: T.nilable(String) + ).returns(T.nilable(String)) + end + def read(max_len = nil, out_string = nil) + end + + # @api private + sig do + params( + src: T.any(String, Pathname, StringIO, T::Enumerable[String]), + blk: T.proc.params(arg0: String).void + ).returns(T.attached_class) + end + def self.new(src, &blk) + end + end + + class << self + sig do + params(blk: T.proc.params(y: Enumerator::Yielder).void).returns( + T::Enumerable[String] + ) + end + def writable_enum(&blk) + end + end + + JSON_CONTENT = + T.let(%r{^application/(?:vnd(?:\.[^.]+)*\+)?json(?!l)}, Regexp) + JSONL_CONTENT = + T.let(%r{^application/(:?x-(?:n|l)djson)|(:?(?:x-)?jsonl)}, Regexp) + + class << self + # @api private + sig do + params( + y: Enumerator::Yielder, + val: T.anything, + closing: T::Array[T.proc.void], + content_type: T.nilable(String) + ).void + end + private def write_multipart_content( + y, + val:, + closing:, + content_type: nil + ) + end + + # @api private + sig do + params( + y: Enumerator::Yielder, + boundary: String, + key: T.any(Symbol, String), + val: T.anything, + closing: T::Array[T.proc.void] + ).void + end + private def write_multipart_chunk(y, boundary:, key:, val:, closing:) + end + + # @api private + # + # https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.1.md#special-considerations-for-multipart-content + sig do + params(body: T.anything).returns([String, T::Enumerable[String]]) + end + private def encode_multipart_streaming(body) + end + + # @api private + sig do + params(headers: T::Hash[String, String], body: T.anything).returns( + T.anything + ) + end + def encode_content(headers, body) + end + + # @api private + # + # https://www.iana.org/assignments/character-sets/character-sets.xhtml + sig { params(content_type: String, text: String).void } + def force_charset!(content_type, text:) + end + + # @api private + # + # Assumes each chunk in stream has `Encoding::BINARY`. + sig do + params( + headers: T::Hash[String, String], + stream: T::Enumerable[String], + suppress_error: T::Boolean + ).returns(T.anything) + end + def decode_content(headers, stream:, suppress_error: false) + end + end + + class << self + # @api private + # + # https://doc.rust-lang.org/std/iter/trait.FusedIterator.html + sig do + params( + enum: T::Enumerable[T.anything], + external: T::Boolean, + close: T.proc.void + ).returns(T::Enumerable[T.anything]) + end + def fused_enum(enum, external: false, &close) + end + + # @api private + sig { params(enum: T.nilable(T::Enumerable[T.anything])).void } + def close_fused!(enum) + end + + # @api private + sig do + params( + enum: T.nilable(T::Enumerable[T.anything]), + blk: T.proc.params(arg0: Enumerator::Yielder).void + ).returns(T::Enumerable[T.anything]) + end + def chain_fused(enum, &blk) + end + end + + ServerSentEvent = + T.type_alias do + { + event: T.nilable(String), + data: T.nilable(String), + id: T.nilable(String), + retry: T.nilable(Integer) + } + end + + class << self + # @api private + # + # Assumes Strings have been forced into having `Encoding::BINARY`. + # + # This decoder is responsible for reassembling lines split across multiple + # fragments. + sig do + params(enum: T::Enumerable[String]).returns(T::Enumerable[String]) + end + def decode_lines(enum) + end + + # @api private + # + # https://html.spec.whatwg.org/multipage/server-sent-events.html#parsing-an-event-stream + # + # Assumes that `lines` has been decoded with `#decode_lines`. + sig do + params(lines: T::Enumerable[String]).returns( + T::Enumerable[Imagekit::Internal::Util::ServerSentEvent] + ) + end + def decode_sse(lines) + end + end + + # @api private + module SorbetRuntimeSupport + class MissingSorbetRuntimeError < ::RuntimeError + end + + # @api private + sig { returns(T::Hash[Symbol, T.anything]) } + private def sorbet_runtime_constants + end + + # @api private + sig { params(name: Symbol).void } + def const_missing(name) + end + + # @api private + sig { params(name: Symbol).returns(T::Boolean) } + def sorbet_constant_defined?(name) + end + + # @api private + sig { params(name: Symbol, blk: T.proc.returns(T.anything)).void } + def define_sorbet_constant!(name, &blk) + end + + # @api private + sig { returns(T.anything) } + def to_sorbet_type + end + + class << self + # @api private + sig do + params( + type: + T.any( + Imagekit::Internal::Util::SorbetRuntimeSupport, + T.anything + ) + ).returns(T.anything) + end + def to_sorbet_type(type) + end + end + end + end + end +end diff --git a/rbi/imagekit/models.rbi b/rbi/imagekit/models.rbi new file mode 100644 index 00000000..e8fe39e0 --- /dev/null +++ b/rbi/imagekit/models.rbi @@ -0,0 +1,130 @@ +# typed: strong + +module Imagekit + Accounts = Imagekit::Models::Accounts + + AssetListParams = Imagekit::Models::AssetListParams + + BaseOverlay = Imagekit::Models::BaseOverlay + + BaseWebhookEvent = Imagekit::Models::BaseWebhookEvent + + Beta = Imagekit::Models::Beta + + Cache = Imagekit::Models::Cache + + CustomMetadataField = Imagekit::Models::CustomMetadataField + + CustomMetadataFieldCreateParams = + Imagekit::Models::CustomMetadataFieldCreateParams + + CustomMetadataFieldDeleteParams = + Imagekit::Models::CustomMetadataFieldDeleteParams + + CustomMetadataFieldListParams = + Imagekit::Models::CustomMetadataFieldListParams + + CustomMetadataFieldUpdateParams = + Imagekit::Models::CustomMetadataFieldUpdateParams + + ExtensionItem = Imagekit::Models::ExtensionItem + + Extensions = + T.let(Imagekit::Models::Extensions, Imagekit::Internal::Type::Converter) + + File = Imagekit::Models::File + + FileCopyParams = Imagekit::Models::FileCopyParams + + FileDeleteParams = Imagekit::Models::FileDeleteParams + + FileGetParams = Imagekit::Models::FileGetParams + + FileMoveParams = Imagekit::Models::FileMoveParams + + FileRenameParams = Imagekit::Models::FileRenameParams + + Files = Imagekit::Models::Files + + FileUpdateParams = Imagekit::Models::FileUpdateParams + + FileUploadParams = Imagekit::Models::FileUploadParams + + Folder = Imagekit::Models::Folder + + FolderCopyParams = Imagekit::Models::FolderCopyParams + + FolderCreateParams = Imagekit::Models::FolderCreateParams + + FolderDeleteParams = Imagekit::Models::FolderDeleteParams + + FolderMoveParams = Imagekit::Models::FolderMoveParams + + FolderRenameParams = Imagekit::Models::FolderRenameParams + + Folders = Imagekit::Models::Folders + + ImageOverlay = Imagekit::Models::ImageOverlay + + Metadata = Imagekit::Models::Metadata + + Overlay = Imagekit::Models::Overlay + + OverlayPosition = Imagekit::Models::OverlayPosition + + OverlayTiming = Imagekit::Models::OverlayTiming + + SolidColorOverlay = Imagekit::Models::SolidColorOverlay + + SolidColorOverlayTransformation = + Imagekit::Models::SolidColorOverlayTransformation + + SrcOptions = Imagekit::Models::SrcOptions + + StreamingResolution = Imagekit::Models::StreamingResolution + + SubtitleOverlay = Imagekit::Models::SubtitleOverlay + + SubtitleOverlayTransformation = + Imagekit::Models::SubtitleOverlayTransformation + + TextOverlay = Imagekit::Models::TextOverlay + + TextOverlayTransformation = Imagekit::Models::TextOverlayTransformation + + Transformation = Imagekit::Models::Transformation + + TransformationPosition = Imagekit::Models::TransformationPosition + + UnsafeUnwrapWebhookEvent = Imagekit::Models::UnsafeUnwrapWebhookEvent + + UnwrapWebhookEvent = Imagekit::Models::UnwrapWebhookEvent + + UpdateFileRequest = Imagekit::Models::UpdateFileRequest + + UploadPostTransformErrorEvent = + Imagekit::Models::UploadPostTransformErrorEvent + + UploadPostTransformSuccessEvent = + Imagekit::Models::UploadPostTransformSuccessEvent + + UploadPreTransformErrorEvent = Imagekit::Models::UploadPreTransformErrorEvent + + UploadPreTransformSuccessEvent = + Imagekit::Models::UploadPreTransformSuccessEvent + + VideoOverlay = Imagekit::Models::VideoOverlay + + VideoTransformationAcceptedEvent = + Imagekit::Models::VideoTransformationAcceptedEvent + + VideoTransformationErrorEvent = + Imagekit::Models::VideoTransformationErrorEvent + + VideoTransformationReadyEvent = + Imagekit::Models::VideoTransformationReadyEvent + + WebhookUnsafeUnwrapParams = Imagekit::Models::WebhookUnsafeUnwrapParams + + WebhookUnwrapParams = Imagekit::Models::WebhookUnwrapParams +end diff --git a/rbi/imagekit/models/accounts/origin_create_params.rbi b/rbi/imagekit/models/accounts/origin_create_params.rbi new file mode 100644 index 00000000..96e32302 --- /dev/null +++ b/rbi/imagekit/models/accounts/origin_create_params.rbi @@ -0,0 +1,81 @@ +# typed: strong + +module Imagekit + module Models + module Accounts + class OriginCreateParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekit::Accounts::OriginCreateParams, + Imagekit::Internal::AnyHash + ) + end + + # Schema for origin request resources. + sig do + returns( + T.any( + Imagekit::Accounts::OriginRequest::S3, + Imagekit::Accounts::OriginRequest::S3Compatible, + Imagekit::Accounts::OriginRequest::CloudinaryBackup, + Imagekit::Accounts::OriginRequest::WebFolder, + Imagekit::Accounts::OriginRequest::WebProxy, + Imagekit::Accounts::OriginRequest::Gcs, + Imagekit::Accounts::OriginRequest::AzureBlob, + Imagekit::Accounts::OriginRequest::AkeneoPim + ) + ) + end + attr_accessor :origin_request + + sig do + params( + origin_request: + T.any( + Imagekit::Accounts::OriginRequest::S3::OrHash, + Imagekit::Accounts::OriginRequest::S3Compatible::OrHash, + Imagekit::Accounts::OriginRequest::CloudinaryBackup::OrHash, + Imagekit::Accounts::OriginRequest::WebFolder::OrHash, + Imagekit::Accounts::OriginRequest::WebProxy::OrHash, + Imagekit::Accounts::OriginRequest::Gcs::OrHash, + Imagekit::Accounts::OriginRequest::AzureBlob::OrHash, + Imagekit::Accounts::OriginRequest::AkeneoPim::OrHash + ), + request_options: Imagekit::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # Schema for origin request resources. + origin_request:, + request_options: {} + ) + end + + sig do + override.returns( + { + origin_request: + T.any( + Imagekit::Accounts::OriginRequest::S3, + Imagekit::Accounts::OriginRequest::S3Compatible, + Imagekit::Accounts::OriginRequest::CloudinaryBackup, + Imagekit::Accounts::OriginRequest::WebFolder, + Imagekit::Accounts::OriginRequest::WebProxy, + Imagekit::Accounts::OriginRequest::Gcs, + Imagekit::Accounts::OriginRequest::AzureBlob, + Imagekit::Accounts::OriginRequest::AkeneoPim + ), + request_options: Imagekit::RequestOptions + } + ) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekit/models/accounts/origin_delete_params.rbi b/rbi/imagekit/models/accounts/origin_delete_params.rbi new file mode 100644 index 00000000..02d3f036 --- /dev/null +++ b/rbi/imagekit/models/accounts/origin_delete_params.rbi @@ -0,0 +1,32 @@ +# typed: strong + +module Imagekit + module Models + module Accounts + class OriginDeleteParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekit::Accounts::OriginDeleteParams, + Imagekit::Internal::AnyHash + ) + end + + sig do + params(request_options: Imagekit::RequestOptions::OrHash).returns( + T.attached_class + ) + end + def self.new(request_options: {}) + end + + sig { override.returns({ request_options: Imagekit::RequestOptions }) } + def to_hash + end + end + end + end +end diff --git a/rbi/imagekit/models/accounts/origin_get_params.rbi b/rbi/imagekit/models/accounts/origin_get_params.rbi new file mode 100644 index 00000000..6ffd3f1a --- /dev/null +++ b/rbi/imagekit/models/accounts/origin_get_params.rbi @@ -0,0 +1,32 @@ +# typed: strong + +module Imagekit + module Models + module Accounts + class OriginGetParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekit::Accounts::OriginGetParams, + Imagekit::Internal::AnyHash + ) + end + + sig do + params(request_options: Imagekit::RequestOptions::OrHash).returns( + T.attached_class + ) + end + def self.new(request_options: {}) + end + + sig { override.returns({ request_options: Imagekit::RequestOptions }) } + def to_hash + end + end + end + end +end diff --git a/rbi/imagekit/models/accounts/origin_list_params.rbi b/rbi/imagekit/models/accounts/origin_list_params.rbi new file mode 100644 index 00000000..8179eab0 --- /dev/null +++ b/rbi/imagekit/models/accounts/origin_list_params.rbi @@ -0,0 +1,32 @@ +# typed: strong + +module Imagekit + module Models + module Accounts + class OriginListParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekit::Accounts::OriginListParams, + Imagekit::Internal::AnyHash + ) + end + + sig do + params(request_options: Imagekit::RequestOptions::OrHash).returns( + T.attached_class + ) + end + def self.new(request_options: {}) + end + + sig { override.returns({ request_options: Imagekit::RequestOptions }) } + def to_hash + end + end + end + end +end diff --git a/rbi/imagekit/models/accounts/origin_list_response.rbi b/rbi/imagekit/models/accounts/origin_list_response.rbi new file mode 100644 index 00000000..95287046 --- /dev/null +++ b/rbi/imagekit/models/accounts/origin_list_response.rbi @@ -0,0 +1,15 @@ +# typed: strong + +module Imagekit + module Models + module Accounts + OriginListResponse = + T.let( + Imagekit::Internal::Type::ArrayOf[ + union: Imagekit::Accounts::OriginResponse + ], + Imagekit::Internal::Type::Converter + ) + end + end +end diff --git a/rbi/imagekit/models/accounts/origin_request.rbi b/rbi/imagekit/models/accounts/origin_request.rbi new file mode 100644 index 00000000..3de49704 --- /dev/null +++ b/rbi/imagekit/models/accounts/origin_request.rbi @@ -0,0 +1,775 @@ +# typed: strong + +module Imagekit + module Models + module Accounts + # Schema for origin request resources. + module OriginRequest + extend Imagekit::Internal::Type::Union + + Variants = + T.type_alias do + T.any( + Imagekit::Accounts::OriginRequest::S3, + Imagekit::Accounts::OriginRequest::S3Compatible, + Imagekit::Accounts::OriginRequest::CloudinaryBackup, + Imagekit::Accounts::OriginRequest::WebFolder, + Imagekit::Accounts::OriginRequest::WebProxy, + Imagekit::Accounts::OriginRequest::Gcs, + Imagekit::Accounts::OriginRequest::AzureBlob, + Imagekit::Accounts::OriginRequest::AkeneoPim + ) + end + + class S3 < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Accounts::OriginRequest::S3, + Imagekit::Internal::AnyHash + ) + end + + # Access key for the bucket. + sig { returns(String) } + attr_accessor :access_key + + # S3 bucket name. + sig { returns(String) } + attr_accessor :bucket + + # Display name of the origin. + sig { returns(String) } + attr_accessor :name + + # Secret key for the bucket. + sig { returns(String) } + attr_accessor :secret_key + + sig { returns(Symbol) } + attr_accessor :type + + # URL used in the Canonical header (if enabled). + sig { returns(T.nilable(String)) } + attr_reader :base_url_for_canonical_header + + sig { params(base_url_for_canonical_header: String).void } + attr_writer :base_url_for_canonical_header + + # Whether to send a Canonical header. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :include_canonical_header + + sig { params(include_canonical_header: T::Boolean).void } + attr_writer :include_canonical_header + + # Path prefix inside the bucket. + sig { returns(T.nilable(String)) } + attr_reader :prefix + + sig { params(prefix: String).void } + attr_writer :prefix + + sig do + params( + access_key: String, + bucket: String, + name: String, + secret_key: String, + base_url_for_canonical_header: String, + include_canonical_header: T::Boolean, + prefix: String, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Access key for the bucket. + access_key:, + # S3 bucket name. + bucket:, + # Display name of the origin. + name:, + # Secret key for the bucket. + secret_key:, + # URL used in the Canonical header (if enabled). + base_url_for_canonical_header: nil, + # Whether to send a Canonical header. + include_canonical_header: nil, + # Path prefix inside the bucket. + prefix: nil, + type: :S3 + ) + end + + sig do + override.returns( + { + access_key: String, + bucket: String, + name: String, + secret_key: String, + type: Symbol, + base_url_for_canonical_header: String, + include_canonical_header: T::Boolean, + prefix: String + } + ) + end + def to_hash + end + end + + class S3Compatible < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Accounts::OriginRequest::S3Compatible, + Imagekit::Internal::AnyHash + ) + end + + # Access key for the bucket. + sig { returns(String) } + attr_accessor :access_key + + # S3 bucket name. + sig { returns(String) } + attr_accessor :bucket + + # Custom S3-compatible endpoint. + sig { returns(String) } + attr_accessor :endpoint + + # Display name of the origin. + sig { returns(String) } + attr_accessor :name + + # Secret key for the bucket. + sig { returns(String) } + attr_accessor :secret_key + + sig { returns(Symbol) } + attr_accessor :type + + # URL used in the Canonical header (if enabled). + sig { returns(T.nilable(String)) } + attr_reader :base_url_for_canonical_header + + sig { params(base_url_for_canonical_header: String).void } + attr_writer :base_url_for_canonical_header + + # Whether to send a Canonical header. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :include_canonical_header + + sig { params(include_canonical_header: T::Boolean).void } + attr_writer :include_canonical_header + + # Path prefix inside the bucket. + sig { returns(T.nilable(String)) } + attr_reader :prefix + + sig { params(prefix: String).void } + attr_writer :prefix + + # Use path-style S3 URLs? + sig { returns(T.nilable(T::Boolean)) } + attr_reader :s3_force_path_style + + sig { params(s3_force_path_style: T::Boolean).void } + attr_writer :s3_force_path_style + + sig do + params( + access_key: String, + bucket: String, + endpoint: String, + name: String, + secret_key: String, + base_url_for_canonical_header: String, + include_canonical_header: T::Boolean, + prefix: String, + s3_force_path_style: T::Boolean, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Access key for the bucket. + access_key:, + # S3 bucket name. + bucket:, + # Custom S3-compatible endpoint. + endpoint:, + # Display name of the origin. + name:, + # Secret key for the bucket. + secret_key:, + # URL used in the Canonical header (if enabled). + base_url_for_canonical_header: nil, + # Whether to send a Canonical header. + include_canonical_header: nil, + # Path prefix inside the bucket. + prefix: nil, + # Use path-style S3 URLs? + s3_force_path_style: nil, + type: :S3_COMPATIBLE + ) + end + + sig do + override.returns( + { + access_key: String, + bucket: String, + endpoint: String, + name: String, + secret_key: String, + type: Symbol, + base_url_for_canonical_header: String, + include_canonical_header: T::Boolean, + prefix: String, + s3_force_path_style: T::Boolean + } + ) + end + def to_hash + end + end + + class CloudinaryBackup < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Accounts::OriginRequest::CloudinaryBackup, + Imagekit::Internal::AnyHash + ) + end + + # Access key for the bucket. + sig { returns(String) } + attr_accessor :access_key + + # S3 bucket name. + sig { returns(String) } + attr_accessor :bucket + + # Display name of the origin. + sig { returns(String) } + attr_accessor :name + + # Secret key for the bucket. + sig { returns(String) } + attr_accessor :secret_key + + sig { returns(Symbol) } + attr_accessor :type + + # URL used in the Canonical header (if enabled). + sig { returns(T.nilable(String)) } + attr_reader :base_url_for_canonical_header + + sig { params(base_url_for_canonical_header: String).void } + attr_writer :base_url_for_canonical_header + + # Whether to send a Canonical header. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :include_canonical_header + + sig { params(include_canonical_header: T::Boolean).void } + attr_writer :include_canonical_header + + # Path prefix inside the bucket. + sig { returns(T.nilable(String)) } + attr_reader :prefix + + sig { params(prefix: String).void } + attr_writer :prefix + + sig do + params( + access_key: String, + bucket: String, + name: String, + secret_key: String, + base_url_for_canonical_header: String, + include_canonical_header: T::Boolean, + prefix: String, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Access key for the bucket. + access_key:, + # S3 bucket name. + bucket:, + # Display name of the origin. + name:, + # Secret key for the bucket. + secret_key:, + # URL used in the Canonical header (if enabled). + base_url_for_canonical_header: nil, + # Whether to send a Canonical header. + include_canonical_header: nil, + # Path prefix inside the bucket. + prefix: nil, + type: :CLOUDINARY_BACKUP + ) + end + + sig do + override.returns( + { + access_key: String, + bucket: String, + name: String, + secret_key: String, + type: Symbol, + base_url_for_canonical_header: String, + include_canonical_header: T::Boolean, + prefix: String + } + ) + end + def to_hash + end + end + + class WebFolder < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Accounts::OriginRequest::WebFolder, + Imagekit::Internal::AnyHash + ) + end + + # Root URL for the web folder origin. + sig { returns(String) } + attr_accessor :base_url + + # Display name of the origin. + sig { returns(String) } + attr_accessor :name + + sig { returns(Symbol) } + attr_accessor :type + + # URL used in the Canonical header (if enabled). + sig { returns(T.nilable(String)) } + attr_reader :base_url_for_canonical_header + + sig { params(base_url_for_canonical_header: String).void } + attr_writer :base_url_for_canonical_header + + # Forward the Host header to origin? + sig { returns(T.nilable(T::Boolean)) } + attr_reader :forward_host_header_to_origin + + sig { params(forward_host_header_to_origin: T::Boolean).void } + attr_writer :forward_host_header_to_origin + + # Whether to send a Canonical header. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :include_canonical_header + + sig { params(include_canonical_header: T::Boolean).void } + attr_writer :include_canonical_header + + sig do + params( + base_url: String, + name: String, + base_url_for_canonical_header: String, + forward_host_header_to_origin: T::Boolean, + include_canonical_header: T::Boolean, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Root URL for the web folder origin. + base_url:, + # Display name of the origin. + name:, + # URL used in the Canonical header (if enabled). + base_url_for_canonical_header: nil, + # Forward the Host header to origin? + forward_host_header_to_origin: nil, + # Whether to send a Canonical header. + include_canonical_header: nil, + type: :WEB_FOLDER + ) + end + + sig do + override.returns( + { + base_url: String, + name: String, + type: Symbol, + base_url_for_canonical_header: String, + forward_host_header_to_origin: T::Boolean, + include_canonical_header: T::Boolean + } + ) + end + def to_hash + end + end + + class WebProxy < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Accounts::OriginRequest::WebProxy, + Imagekit::Internal::AnyHash + ) + end + + # Display name of the origin. + sig { returns(String) } + attr_accessor :name + + sig { returns(Symbol) } + attr_accessor :type + + # URL used in the Canonical header (if enabled). + sig { returns(T.nilable(String)) } + attr_reader :base_url_for_canonical_header + + sig { params(base_url_for_canonical_header: String).void } + attr_writer :base_url_for_canonical_header + + # Whether to send a Canonical header. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :include_canonical_header + + sig { params(include_canonical_header: T::Boolean).void } + attr_writer :include_canonical_header + + sig do + params( + name: String, + base_url_for_canonical_header: String, + include_canonical_header: T::Boolean, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Display name of the origin. + name:, + # URL used in the Canonical header (if enabled). + base_url_for_canonical_header: nil, + # Whether to send a Canonical header. + include_canonical_header: nil, + type: :WEB_PROXY + ) + end + + sig do + override.returns( + { + name: String, + type: Symbol, + base_url_for_canonical_header: String, + include_canonical_header: T::Boolean + } + ) + end + def to_hash + end + end + + class Gcs < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Accounts::OriginRequest::Gcs, + Imagekit::Internal::AnyHash + ) + end + + sig { returns(String) } + attr_accessor :bucket + + sig { returns(String) } + attr_accessor :client_email + + # Display name of the origin. + sig { returns(String) } + attr_accessor :name + + sig { returns(String) } + attr_accessor :private_key + + sig { returns(Symbol) } + attr_accessor :type + + # URL used in the Canonical header (if enabled). + sig { returns(T.nilable(String)) } + attr_reader :base_url_for_canonical_header + + sig { params(base_url_for_canonical_header: String).void } + attr_writer :base_url_for_canonical_header + + # Whether to send a Canonical header. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :include_canonical_header + + sig { params(include_canonical_header: T::Boolean).void } + attr_writer :include_canonical_header + + sig { returns(T.nilable(String)) } + attr_reader :prefix + + sig { params(prefix: String).void } + attr_writer :prefix + + sig do + params( + bucket: String, + client_email: String, + name: String, + private_key: String, + base_url_for_canonical_header: String, + include_canonical_header: T::Boolean, + prefix: String, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + bucket:, + client_email:, + # Display name of the origin. + name:, + private_key:, + # URL used in the Canonical header (if enabled). + base_url_for_canonical_header: nil, + # Whether to send a Canonical header. + include_canonical_header: nil, + prefix: nil, + type: :GCS + ) + end + + sig do + override.returns( + { + bucket: String, + client_email: String, + name: String, + private_key: String, + type: Symbol, + base_url_for_canonical_header: String, + include_canonical_header: T::Boolean, + prefix: String + } + ) + end + def to_hash + end + end + + class AzureBlob < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Accounts::OriginRequest::AzureBlob, + Imagekit::Internal::AnyHash + ) + end + + sig { returns(String) } + attr_accessor :account_name + + sig { returns(String) } + attr_accessor :container + + # Display name of the origin. + sig { returns(String) } + attr_accessor :name + + sig { returns(String) } + attr_accessor :sas_token + + sig { returns(Symbol) } + attr_accessor :type + + # URL used in the Canonical header (if enabled). + sig { returns(T.nilable(String)) } + attr_reader :base_url_for_canonical_header + + sig { params(base_url_for_canonical_header: String).void } + attr_writer :base_url_for_canonical_header + + # Whether to send a Canonical header. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :include_canonical_header + + sig { params(include_canonical_header: T::Boolean).void } + attr_writer :include_canonical_header + + sig { returns(T.nilable(String)) } + attr_reader :prefix + + sig { params(prefix: String).void } + attr_writer :prefix + + sig do + params( + account_name: String, + container: String, + name: String, + sas_token: String, + base_url_for_canonical_header: String, + include_canonical_header: T::Boolean, + prefix: String, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + account_name:, + container:, + # Display name of the origin. + name:, + sas_token:, + # URL used in the Canonical header (if enabled). + base_url_for_canonical_header: nil, + # Whether to send a Canonical header. + include_canonical_header: nil, + prefix: nil, + type: :AZURE_BLOB + ) + end + + sig do + override.returns( + { + account_name: String, + container: String, + name: String, + sas_token: String, + type: Symbol, + base_url_for_canonical_header: String, + include_canonical_header: T::Boolean, + prefix: String + } + ) + end + def to_hash + end + end + + class AkeneoPim < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Accounts::OriginRequest::AkeneoPim, + Imagekit::Internal::AnyHash + ) + end + + # Akeneo instance base URL. + sig { returns(String) } + attr_accessor :base_url + + # Akeneo API client ID. + sig { returns(String) } + attr_accessor :client_id + + # Akeneo API client secret. + sig { returns(String) } + attr_accessor :client_secret + + # Display name of the origin. + sig { returns(String) } + attr_accessor :name + + # Akeneo API password. + sig { returns(String) } + attr_accessor :password + + sig { returns(Symbol) } + attr_accessor :type + + # Akeneo API username. + sig { returns(String) } + attr_accessor :username + + # URL used in the Canonical header (if enabled). + sig { returns(T.nilable(String)) } + attr_reader :base_url_for_canonical_header + + sig { params(base_url_for_canonical_header: String).void } + attr_writer :base_url_for_canonical_header + + # Whether to send a Canonical header. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :include_canonical_header + + sig { params(include_canonical_header: T::Boolean).void } + attr_writer :include_canonical_header + + sig do + params( + base_url: String, + client_id: String, + client_secret: String, + name: String, + password: String, + username: String, + base_url_for_canonical_header: String, + include_canonical_header: T::Boolean, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Akeneo instance base URL. + base_url:, + # Akeneo API client ID. + client_id:, + # Akeneo API client secret. + client_secret:, + # Display name of the origin. + name:, + # Akeneo API password. + password:, + # Akeneo API username. + username:, + # URL used in the Canonical header (if enabled). + base_url_for_canonical_header: nil, + # Whether to send a Canonical header. + include_canonical_header: nil, + type: :AKENEO_PIM + ) + end + + sig do + override.returns( + { + base_url: String, + client_id: String, + client_secret: String, + name: String, + password: String, + type: Symbol, + username: String, + base_url_for_canonical_header: String, + include_canonical_header: T::Boolean + } + ) + end + def to_hash + end + end + + sig do + override.returns( + T::Array[Imagekit::Accounts::OriginRequest::Variants] + ) + end + def self.variants + end + end + end + end +end diff --git a/rbi/imagekit/models/accounts/origin_response.rbi b/rbi/imagekit/models/accounts/origin_response.rbi new file mode 100644 index 00000000..be9fc05f --- /dev/null +++ b/rbi/imagekit/models/accounts/origin_response.rbi @@ -0,0 +1,718 @@ +# typed: strong + +module Imagekit + module Models + module Accounts + # Origin object as returned by the API (sensitive fields removed). + module OriginResponse + extend Imagekit::Internal::Type::Union + + Variants = + T.type_alias do + T.any( + Imagekit::Accounts::OriginResponse::S3, + Imagekit::Accounts::OriginResponse::S3Compatible, + Imagekit::Accounts::OriginResponse::CloudinaryBackup, + Imagekit::Accounts::OriginResponse::WebFolder, + Imagekit::Accounts::OriginResponse::WebProxy, + Imagekit::Accounts::OriginResponse::Gcs, + Imagekit::Accounts::OriginResponse::AzureBlob, + Imagekit::Accounts::OriginResponse::AkeneoPim + ) + end + + class S3 < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Accounts::OriginResponse::S3, + Imagekit::Internal::AnyHash + ) + end + + # S3 bucket name. + sig { returns(String) } + attr_accessor :bucket + + # Whether to send a Canonical header. + sig { returns(T::Boolean) } + attr_accessor :include_canonical_header + + # Display name of the origin. + sig { returns(String) } + attr_accessor :name + + # Path prefix inside the bucket. + sig { returns(String) } + attr_accessor :prefix + + sig { returns(Symbol) } + attr_accessor :type + + # URL used in the Canonical header (if enabled). + sig { returns(T.nilable(String)) } + attr_reader :base_url_for_canonical_header + + sig { params(base_url_for_canonical_header: String).void } + attr_writer :base_url_for_canonical_header + + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + sig { returns(String) } + attr_accessor :id + + sig do + params( + id: String, + bucket: String, + include_canonical_header: T::Boolean, + name: String, + prefix: String, + base_url_for_canonical_header: String, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + id:, + # S3 bucket name. + bucket:, + # Whether to send a Canonical header. + include_canonical_header:, + # Display name of the origin. + name:, + # Path prefix inside the bucket. + prefix:, + # URL used in the Canonical header (if enabled). + base_url_for_canonical_header: nil, + type: :S3 + ) + end + + sig do + override.returns( + { + id: String, + bucket: String, + include_canonical_header: T::Boolean, + name: String, + prefix: String, + type: Symbol, + base_url_for_canonical_header: String + } + ) + end + def to_hash + end + end + + class S3Compatible < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Accounts::OriginResponse::S3Compatible, + Imagekit::Internal::AnyHash + ) + end + + # S3 bucket name. + sig { returns(String) } + attr_accessor :bucket + + # Custom S3-compatible endpoint. + sig { returns(String) } + attr_accessor :endpoint + + # Whether to send a Canonical header. + sig { returns(T::Boolean) } + attr_accessor :include_canonical_header + + # Display name of the origin. + sig { returns(String) } + attr_accessor :name + + # Path prefix inside the bucket. + sig { returns(String) } + attr_accessor :prefix + + # Use path-style S3 URLs? + sig { returns(T::Boolean) } + attr_accessor :s3_force_path_style + + sig { returns(Symbol) } + attr_accessor :type + + # URL used in the Canonical header (if enabled). + sig { returns(T.nilable(String)) } + attr_reader :base_url_for_canonical_header + + sig { params(base_url_for_canonical_header: String).void } + attr_writer :base_url_for_canonical_header + + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + sig { returns(String) } + attr_accessor :id + + sig do + params( + id: String, + bucket: String, + endpoint: String, + include_canonical_header: T::Boolean, + name: String, + prefix: String, + s3_force_path_style: T::Boolean, + base_url_for_canonical_header: String, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + id:, + # S3 bucket name. + bucket:, + # Custom S3-compatible endpoint. + endpoint:, + # Whether to send a Canonical header. + include_canonical_header:, + # Display name of the origin. + name:, + # Path prefix inside the bucket. + prefix:, + # Use path-style S3 URLs? + s3_force_path_style:, + # URL used in the Canonical header (if enabled). + base_url_for_canonical_header: nil, + type: :S3_COMPATIBLE + ) + end + + sig do + override.returns( + { + id: String, + bucket: String, + endpoint: String, + include_canonical_header: T::Boolean, + name: String, + prefix: String, + s3_force_path_style: T::Boolean, + type: Symbol, + base_url_for_canonical_header: String + } + ) + end + def to_hash + end + end + + class CloudinaryBackup < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Accounts::OriginResponse::CloudinaryBackup, + Imagekit::Internal::AnyHash + ) + end + + # S3 bucket name. + sig { returns(String) } + attr_accessor :bucket + + # Whether to send a Canonical header. + sig { returns(T::Boolean) } + attr_accessor :include_canonical_header + + # Display name of the origin. + sig { returns(String) } + attr_accessor :name + + # Path prefix inside the bucket. + sig { returns(String) } + attr_accessor :prefix + + sig { returns(Symbol) } + attr_accessor :type + + # URL used in the Canonical header (if enabled). + sig { returns(T.nilable(String)) } + attr_reader :base_url_for_canonical_header + + sig { params(base_url_for_canonical_header: String).void } + attr_writer :base_url_for_canonical_header + + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + sig { returns(String) } + attr_accessor :id + + sig do + params( + id: String, + bucket: String, + include_canonical_header: T::Boolean, + name: String, + prefix: String, + base_url_for_canonical_header: String, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + id:, + # S3 bucket name. + bucket:, + # Whether to send a Canonical header. + include_canonical_header:, + # Display name of the origin. + name:, + # Path prefix inside the bucket. + prefix:, + # URL used in the Canonical header (if enabled). + base_url_for_canonical_header: nil, + type: :CLOUDINARY_BACKUP + ) + end + + sig do + override.returns( + { + id: String, + bucket: String, + include_canonical_header: T::Boolean, + name: String, + prefix: String, + type: Symbol, + base_url_for_canonical_header: String + } + ) + end + def to_hash + end + end + + class WebFolder < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Accounts::OriginResponse::WebFolder, + Imagekit::Internal::AnyHash + ) + end + + # Root URL for the web folder origin. + sig { returns(String) } + attr_accessor :base_url + + # Forward the Host header to origin? + sig { returns(T::Boolean) } + attr_accessor :forward_host_header_to_origin + + # Whether to send a Canonical header. + sig { returns(T::Boolean) } + attr_accessor :include_canonical_header + + # Display name of the origin. + sig { returns(String) } + attr_accessor :name + + sig { returns(Symbol) } + attr_accessor :type + + # URL used in the Canonical header (if enabled). + sig { returns(T.nilable(String)) } + attr_reader :base_url_for_canonical_header + + sig { params(base_url_for_canonical_header: String).void } + attr_writer :base_url_for_canonical_header + + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + sig { returns(String) } + attr_accessor :id + + sig do + params( + id: String, + base_url: String, + forward_host_header_to_origin: T::Boolean, + include_canonical_header: T::Boolean, + name: String, + base_url_for_canonical_header: String, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + id:, + # Root URL for the web folder origin. + base_url:, + # Forward the Host header to origin? + forward_host_header_to_origin:, + # Whether to send a Canonical header. + include_canonical_header:, + # Display name of the origin. + name:, + # URL used in the Canonical header (if enabled). + base_url_for_canonical_header: nil, + type: :WEB_FOLDER + ) + end + + sig do + override.returns( + { + id: String, + base_url: String, + forward_host_header_to_origin: T::Boolean, + include_canonical_header: T::Boolean, + name: String, + type: Symbol, + base_url_for_canonical_header: String + } + ) + end + def to_hash + end + end + + class WebProxy < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Accounts::OriginResponse::WebProxy, + Imagekit::Internal::AnyHash + ) + end + + # Whether to send a Canonical header. + sig { returns(T::Boolean) } + attr_accessor :include_canonical_header + + # Display name of the origin. + sig { returns(String) } + attr_accessor :name + + sig { returns(Symbol) } + attr_accessor :type + + # URL used in the Canonical header (if enabled). + sig { returns(T.nilable(String)) } + attr_reader :base_url_for_canonical_header + + sig { params(base_url_for_canonical_header: String).void } + attr_writer :base_url_for_canonical_header + + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + sig { returns(String) } + attr_accessor :id + + sig do + params( + id: String, + include_canonical_header: T::Boolean, + name: String, + base_url_for_canonical_header: String, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + id:, + # Whether to send a Canonical header. + include_canonical_header:, + # Display name of the origin. + name:, + # URL used in the Canonical header (if enabled). + base_url_for_canonical_header: nil, + type: :WEB_PROXY + ) + end + + sig do + override.returns( + { + id: String, + include_canonical_header: T::Boolean, + name: String, + type: Symbol, + base_url_for_canonical_header: String + } + ) + end + def to_hash + end + end + + class Gcs < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Accounts::OriginResponse::Gcs, + Imagekit::Internal::AnyHash + ) + end + + sig { returns(String) } + attr_accessor :bucket + + sig { returns(String) } + attr_accessor :client_email + + # Whether to send a Canonical header. + sig { returns(T::Boolean) } + attr_accessor :include_canonical_header + + # Display name of the origin. + sig { returns(String) } + attr_accessor :name + + sig { returns(String) } + attr_accessor :prefix + + sig { returns(Symbol) } + attr_accessor :type + + # URL used in the Canonical header (if enabled). + sig { returns(T.nilable(String)) } + attr_reader :base_url_for_canonical_header + + sig { params(base_url_for_canonical_header: String).void } + attr_writer :base_url_for_canonical_header + + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + sig { returns(String) } + attr_accessor :id + + sig do + params( + id: String, + bucket: String, + client_email: String, + include_canonical_header: T::Boolean, + name: String, + prefix: String, + base_url_for_canonical_header: String, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + id:, + bucket:, + client_email:, + # Whether to send a Canonical header. + include_canonical_header:, + # Display name of the origin. + name:, + prefix:, + # URL used in the Canonical header (if enabled). + base_url_for_canonical_header: nil, + type: :GCS + ) + end + + sig do + override.returns( + { + id: String, + bucket: String, + client_email: String, + include_canonical_header: T::Boolean, + name: String, + prefix: String, + type: Symbol, + base_url_for_canonical_header: String + } + ) + end + def to_hash + end + end + + class AzureBlob < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Accounts::OriginResponse::AzureBlob, + Imagekit::Internal::AnyHash + ) + end + + sig { returns(String) } + attr_accessor :account_name + + sig { returns(String) } + attr_accessor :container + + # Whether to send a Canonical header. + sig { returns(T::Boolean) } + attr_accessor :include_canonical_header + + # Display name of the origin. + sig { returns(String) } + attr_accessor :name + + sig { returns(String) } + attr_accessor :prefix + + sig { returns(Symbol) } + attr_accessor :type + + # URL used in the Canonical header (if enabled). + sig { returns(T.nilable(String)) } + attr_reader :base_url_for_canonical_header + + sig { params(base_url_for_canonical_header: String).void } + attr_writer :base_url_for_canonical_header + + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + sig { returns(String) } + attr_accessor :id + + sig do + params( + id: String, + account_name: String, + container: String, + include_canonical_header: T::Boolean, + name: String, + prefix: String, + base_url_for_canonical_header: String, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + id:, + account_name:, + container:, + # Whether to send a Canonical header. + include_canonical_header:, + # Display name of the origin. + name:, + prefix:, + # URL used in the Canonical header (if enabled). + base_url_for_canonical_header: nil, + type: :AZURE_BLOB + ) + end + + sig do + override.returns( + { + id: String, + account_name: String, + container: String, + include_canonical_header: T::Boolean, + name: String, + prefix: String, + type: Symbol, + base_url_for_canonical_header: String + } + ) + end + def to_hash + end + end + + class AkeneoPim < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Accounts::OriginResponse::AkeneoPim, + Imagekit::Internal::AnyHash + ) + end + + # Akeneo instance base URL. + sig { returns(String) } + attr_accessor :base_url + + # Whether to send a Canonical header. + sig { returns(T::Boolean) } + attr_accessor :include_canonical_header + + # Display name of the origin. + sig { returns(String) } + attr_accessor :name + + sig { returns(Symbol) } + attr_accessor :type + + # URL used in the Canonical header (if enabled). + sig { returns(T.nilable(String)) } + attr_reader :base_url_for_canonical_header + + sig { params(base_url_for_canonical_header: String).void } + attr_writer :base_url_for_canonical_header + + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + sig { returns(String) } + attr_accessor :id + + sig do + params( + id: String, + base_url: String, + include_canonical_header: T::Boolean, + name: String, + base_url_for_canonical_header: String, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + id:, + # Akeneo instance base URL. + base_url:, + # Whether to send a Canonical header. + include_canonical_header:, + # Display name of the origin. + name:, + # URL used in the Canonical header (if enabled). + base_url_for_canonical_header: nil, + type: :AKENEO_PIM + ) + end + + sig do + override.returns( + { + id: String, + base_url: String, + include_canonical_header: T::Boolean, + name: String, + type: Symbol, + base_url_for_canonical_header: String + } + ) + end + def to_hash + end + end + + sig do + override.returns( + T::Array[Imagekit::Accounts::OriginResponse::Variants] + ) + end + def self.variants + end + end + end + end +end diff --git a/rbi/imagekit/models/accounts/origin_update_params.rbi b/rbi/imagekit/models/accounts/origin_update_params.rbi new file mode 100644 index 00000000..99f6e6f2 --- /dev/null +++ b/rbi/imagekit/models/accounts/origin_update_params.rbi @@ -0,0 +1,81 @@ +# typed: strong + +module Imagekit + module Models + module Accounts + class OriginUpdateParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekit::Accounts::OriginUpdateParams, + Imagekit::Internal::AnyHash + ) + end + + # Schema for origin request resources. + sig do + returns( + T.any( + Imagekit::Accounts::OriginRequest::S3, + Imagekit::Accounts::OriginRequest::S3Compatible, + Imagekit::Accounts::OriginRequest::CloudinaryBackup, + Imagekit::Accounts::OriginRequest::WebFolder, + Imagekit::Accounts::OriginRequest::WebProxy, + Imagekit::Accounts::OriginRequest::Gcs, + Imagekit::Accounts::OriginRequest::AzureBlob, + Imagekit::Accounts::OriginRequest::AkeneoPim + ) + ) + end + attr_accessor :origin_request + + sig do + params( + origin_request: + T.any( + Imagekit::Accounts::OriginRequest::S3::OrHash, + Imagekit::Accounts::OriginRequest::S3Compatible::OrHash, + Imagekit::Accounts::OriginRequest::CloudinaryBackup::OrHash, + Imagekit::Accounts::OriginRequest::WebFolder::OrHash, + Imagekit::Accounts::OriginRequest::WebProxy::OrHash, + Imagekit::Accounts::OriginRequest::Gcs::OrHash, + Imagekit::Accounts::OriginRequest::AzureBlob::OrHash, + Imagekit::Accounts::OriginRequest::AkeneoPim::OrHash + ), + request_options: Imagekit::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # Schema for origin request resources. + origin_request:, + request_options: {} + ) + end + + sig do + override.returns( + { + origin_request: + T.any( + Imagekit::Accounts::OriginRequest::S3, + Imagekit::Accounts::OriginRequest::S3Compatible, + Imagekit::Accounts::OriginRequest::CloudinaryBackup, + Imagekit::Accounts::OriginRequest::WebFolder, + Imagekit::Accounts::OriginRequest::WebProxy, + Imagekit::Accounts::OriginRequest::Gcs, + Imagekit::Accounts::OriginRequest::AzureBlob, + Imagekit::Accounts::OriginRequest::AkeneoPim + ), + request_options: Imagekit::RequestOptions + } + ) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekit/models/accounts/url_endpoint_create_params.rbi b/rbi/imagekit/models/accounts/url_endpoint_create_params.rbi new file mode 100644 index 00000000..002fe2e3 --- /dev/null +++ b/rbi/imagekit/models/accounts/url_endpoint_create_params.rbi @@ -0,0 +1,32 @@ +# typed: strong + +module Imagekit + module Models + module Accounts + class URLEndpointCreateParams < Imagekit::Models::Accounts::URLEndpointRequest + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekit::Accounts::URLEndpointCreateParams, + Imagekit::Internal::AnyHash + ) + end + + sig do + params(request_options: Imagekit::RequestOptions::OrHash).returns( + T.attached_class + ) + end + def self.new(request_options: {}) + end + + sig { override.returns({ request_options: Imagekit::RequestOptions }) } + def to_hash + end + end + end + end +end diff --git a/rbi/imagekit/models/accounts/url_endpoint_delete_params.rbi b/rbi/imagekit/models/accounts/url_endpoint_delete_params.rbi new file mode 100644 index 00000000..c8952d88 --- /dev/null +++ b/rbi/imagekit/models/accounts/url_endpoint_delete_params.rbi @@ -0,0 +1,32 @@ +# typed: strong + +module Imagekit + module Models + module Accounts + class URLEndpointDeleteParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekit::Accounts::URLEndpointDeleteParams, + Imagekit::Internal::AnyHash + ) + end + + sig do + params(request_options: Imagekit::RequestOptions::OrHash).returns( + T.attached_class + ) + end + def self.new(request_options: {}) + end + + sig { override.returns({ request_options: Imagekit::RequestOptions }) } + def to_hash + end + end + end + end +end diff --git a/rbi/imagekit/models/accounts/url_endpoint_get_params.rbi b/rbi/imagekit/models/accounts/url_endpoint_get_params.rbi new file mode 100644 index 00000000..2d965592 --- /dev/null +++ b/rbi/imagekit/models/accounts/url_endpoint_get_params.rbi @@ -0,0 +1,32 @@ +# typed: strong + +module Imagekit + module Models + module Accounts + class URLEndpointGetParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekit::Accounts::URLEndpointGetParams, + Imagekit::Internal::AnyHash + ) + end + + sig do + params(request_options: Imagekit::RequestOptions::OrHash).returns( + T.attached_class + ) + end + def self.new(request_options: {}) + end + + sig { override.returns({ request_options: Imagekit::RequestOptions }) } + def to_hash + end + end + end + end +end diff --git a/rbi/imagekit/models/accounts/url_endpoint_list_params.rbi b/rbi/imagekit/models/accounts/url_endpoint_list_params.rbi new file mode 100644 index 00000000..fbf7b441 --- /dev/null +++ b/rbi/imagekit/models/accounts/url_endpoint_list_params.rbi @@ -0,0 +1,32 @@ +# typed: strong + +module Imagekit + module Models + module Accounts + class URLEndpointListParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekit::Accounts::URLEndpointListParams, + Imagekit::Internal::AnyHash + ) + end + + sig do + params(request_options: Imagekit::RequestOptions::OrHash).returns( + T.attached_class + ) + end + def self.new(request_options: {}) + end + + sig { override.returns({ request_options: Imagekit::RequestOptions }) } + def to_hash + end + end + end + end +end diff --git a/rbi/imagekit/models/accounts/url_endpoint_list_response.rbi b/rbi/imagekit/models/accounts/url_endpoint_list_response.rbi new file mode 100644 index 00000000..d943f0ea --- /dev/null +++ b/rbi/imagekit/models/accounts/url_endpoint_list_response.rbi @@ -0,0 +1,15 @@ +# typed: strong + +module Imagekit + module Models + module Accounts + URLEndpointListResponse = + T.let( + Imagekit::Internal::Type::ArrayOf[ + Imagekit::Accounts::URLEndpointResponse + ], + Imagekit::Internal::Type::Converter + ) + end + end +end diff --git a/rbi/imagekit/models/accounts/url_endpoint_request.rbi b/rbi/imagekit/models/accounts/url_endpoint_request.rbi new file mode 100644 index 00000000..f36ad090 --- /dev/null +++ b/rbi/imagekit/models/accounts/url_endpoint_request.rbi @@ -0,0 +1,218 @@ +# typed: strong + +module Imagekit + module Models + module Accounts + class URLEndpointRequest < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Accounts::URLEndpointRequest, + Imagekit::Internal::AnyHash + ) + end + + # Description of the URL endpoint. + sig { returns(String) } + attr_accessor :description + + # Ordered list of origin IDs to try when the file isn’t in the Media Library; + # ImageKit checks them in the sequence provided. Origin must be created before it + # can be used in a URL endpoint. + sig { returns(T.nilable(T::Array[String])) } + attr_reader :origins + + sig { params(origins: T::Array[String]).void } + attr_writer :origins + + # Path segment appended to your base URL to form the endpoint (letters, digits, + # and hyphens only — or empty for the default endpoint). + sig { returns(T.nilable(String)) } + attr_reader :url_prefix + + sig { params(url_prefix: String).void } + attr_writer :url_prefix + + # Configuration for third-party URL rewriting. + sig do + returns( + T.nilable( + T.any( + Imagekit::Accounts::URLEndpointRequest::URLRewriter::Cloudinary, + Imagekit::Accounts::URLEndpointRequest::URLRewriter::Imgix, + Imagekit::Accounts::URLEndpointRequest::URLRewriter::Akamai + ) + ) + ) + end + attr_reader :url_rewriter + + sig do + params( + url_rewriter: + T.any( + Imagekit::Accounts::URLEndpointRequest::URLRewriter::Cloudinary::OrHash, + Imagekit::Accounts::URLEndpointRequest::URLRewriter::Imgix::OrHash, + Imagekit::Accounts::URLEndpointRequest::URLRewriter::Akamai::OrHash + ) + ).void + end + attr_writer :url_rewriter + + # Schema for URL endpoint resource. + sig do + params( + description: String, + origins: T::Array[String], + url_prefix: String, + url_rewriter: + T.any( + Imagekit::Accounts::URLEndpointRequest::URLRewriter::Cloudinary::OrHash, + Imagekit::Accounts::URLEndpointRequest::URLRewriter::Imgix::OrHash, + Imagekit::Accounts::URLEndpointRequest::URLRewriter::Akamai::OrHash + ) + ).returns(T.attached_class) + end + def self.new( + # Description of the URL endpoint. + description:, + # Ordered list of origin IDs to try when the file isn’t in the Media Library; + # ImageKit checks them in the sequence provided. Origin must be created before it + # can be used in a URL endpoint. + origins: nil, + # Path segment appended to your base URL to form the endpoint (letters, digits, + # and hyphens only — or empty for the default endpoint). + url_prefix: nil, + # Configuration for third-party URL rewriting. + url_rewriter: nil + ) + end + + sig do + override.returns( + { + description: String, + origins: T::Array[String], + url_prefix: String, + url_rewriter: + T.any( + Imagekit::Accounts::URLEndpointRequest::URLRewriter::Cloudinary, + Imagekit::Accounts::URLEndpointRequest::URLRewriter::Imgix, + Imagekit::Accounts::URLEndpointRequest::URLRewriter::Akamai + ) + } + ) + end + def to_hash + end + + # Configuration for third-party URL rewriting. + module URLRewriter + extend Imagekit::Internal::Type::Union + + Variants = + T.type_alias do + T.any( + Imagekit::Accounts::URLEndpointRequest::URLRewriter::Cloudinary, + Imagekit::Accounts::URLEndpointRequest::URLRewriter::Imgix, + Imagekit::Accounts::URLEndpointRequest::URLRewriter::Akamai + ) + end + + class Cloudinary < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Accounts::URLEndpointRequest::URLRewriter::Cloudinary, + Imagekit::Internal::AnyHash + ) + end + + sig { returns(Symbol) } + attr_accessor :type + + # Whether to preserve `/` in the rewritten URL. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :preserve_asset_delivery_types + + sig { params(preserve_asset_delivery_types: T::Boolean).void } + attr_writer :preserve_asset_delivery_types + + sig do + params( + preserve_asset_delivery_types: T::Boolean, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Whether to preserve `/` in the rewritten URL. + preserve_asset_delivery_types: nil, + type: :CLOUDINARY + ) + end + + sig do + override.returns( + { type: Symbol, preserve_asset_delivery_types: T::Boolean } + ) + end + def to_hash + end + end + + class Imgix < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Accounts::URLEndpointRequest::URLRewriter::Imgix, + Imagekit::Internal::AnyHash + ) + end + + sig { returns(Symbol) } + attr_accessor :type + + sig { params(type: Symbol).returns(T.attached_class) } + def self.new(type: :IMGIX) + end + + sig { override.returns({ type: Symbol }) } + def to_hash + end + end + + class Akamai < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Accounts::URLEndpointRequest::URLRewriter::Akamai, + Imagekit::Internal::AnyHash + ) + end + + sig { returns(Symbol) } + attr_accessor :type + + sig { params(type: Symbol).returns(T.attached_class) } + def self.new(type: :AKAMAI) + end + + sig { override.returns({ type: Symbol }) } + def to_hash + end + end + + sig do + override.returns( + T::Array[ + Imagekit::Accounts::URLEndpointRequest::URLRewriter::Variants + ] + ) + end + def self.variants + end + end + end + end + end +end diff --git a/rbi/imagekit/models/accounts/url_endpoint_response.rbi b/rbi/imagekit/models/accounts/url_endpoint_response.rbi new file mode 100644 index 00000000..6600ca95 --- /dev/null +++ b/rbi/imagekit/models/accounts/url_endpoint_response.rbi @@ -0,0 +1,213 @@ +# typed: strong + +module Imagekit + module Models + module Accounts + class URLEndpointResponse < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Accounts::URLEndpointResponse, + Imagekit::Internal::AnyHash + ) + end + + # Description of the URL endpoint. + sig { returns(String) } + attr_accessor :description + + # Ordered list of origin IDs to try when the file isn’t in the Media Library; + # ImageKit checks them in the sequence provided. Origin must be created before it + # can be used in a URL endpoint. + sig { returns(T::Array[String]) } + attr_accessor :origins + + # Path segment appended to your base URL to form the endpoint (letters, digits, + # and hyphens only — or empty for the default endpoint). + sig { returns(String) } + attr_accessor :url_prefix + + # Configuration for third-party URL rewriting. + sig do + returns( + T.nilable( + Imagekit::Accounts::URLEndpointResponse::URLRewriter::Variants + ) + ) + end + attr_reader :url_rewriter + + sig do + params( + url_rewriter: + T.any( + Imagekit::Accounts::URLEndpointResponse::URLRewriter::Cloudinary::OrHash, + Imagekit::Accounts::URLEndpointResponse::URLRewriter::Imgix::OrHash, + Imagekit::Accounts::URLEndpointResponse::URLRewriter::Akamai::OrHash + ) + ).void + end + attr_writer :url_rewriter + + # Unique identifier for the URL-endpoint. This is generated by ImageKit when you + # create a new URL-endpoint. For the default URL-endpoint, this is always + # `default`. + sig { returns(String) } + attr_accessor :id + + # URL‑endpoint object as returned by the API. + sig do + params( + id: String, + description: String, + origins: T::Array[String], + url_prefix: String, + url_rewriter: + T.any( + Imagekit::Accounts::URLEndpointResponse::URLRewriter::Cloudinary::OrHash, + Imagekit::Accounts::URLEndpointResponse::URLRewriter::Imgix::OrHash, + Imagekit::Accounts::URLEndpointResponse::URLRewriter::Akamai::OrHash + ) + ).returns(T.attached_class) + end + def self.new( + # Unique identifier for the URL-endpoint. This is generated by ImageKit when you + # create a new URL-endpoint. For the default URL-endpoint, this is always + # `default`. + id:, + # Description of the URL endpoint. + description:, + # Ordered list of origin IDs to try when the file isn’t in the Media Library; + # ImageKit checks them in the sequence provided. Origin must be created before it + # can be used in a URL endpoint. + origins:, + # Path segment appended to your base URL to form the endpoint (letters, digits, + # and hyphens only — or empty for the default endpoint). + url_prefix:, + # Configuration for third-party URL rewriting. + url_rewriter: nil + ) + end + + sig do + override.returns( + { + id: String, + description: String, + origins: T::Array[String], + url_prefix: String, + url_rewriter: + Imagekit::Accounts::URLEndpointResponse::URLRewriter::Variants + } + ) + end + def to_hash + end + + # Configuration for third-party URL rewriting. + module URLRewriter + extend Imagekit::Internal::Type::Union + + Variants = + T.type_alias do + T.any( + Imagekit::Accounts::URLEndpointResponse::URLRewriter::Cloudinary, + Imagekit::Accounts::URLEndpointResponse::URLRewriter::Imgix, + Imagekit::Accounts::URLEndpointResponse::URLRewriter::Akamai + ) + end + + class Cloudinary < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Accounts::URLEndpointResponse::URLRewriter::Cloudinary, + Imagekit::Internal::AnyHash + ) + end + + # Whether to preserve `/` in the rewritten URL. + sig { returns(T::Boolean) } + attr_accessor :preserve_asset_delivery_types + + sig { returns(Symbol) } + attr_accessor :type + + sig do + params( + preserve_asset_delivery_types: T::Boolean, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Whether to preserve `/` in the rewritten URL. + preserve_asset_delivery_types:, + type: :CLOUDINARY + ) + end + + sig do + override.returns( + { preserve_asset_delivery_types: T::Boolean, type: Symbol } + ) + end + def to_hash + end + end + + class Imgix < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Accounts::URLEndpointResponse::URLRewriter::Imgix, + Imagekit::Internal::AnyHash + ) + end + + sig { returns(Symbol) } + attr_accessor :type + + sig { params(type: Symbol).returns(T.attached_class) } + def self.new(type: :IMGIX) + end + + sig { override.returns({ type: Symbol }) } + def to_hash + end + end + + class Akamai < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Accounts::URLEndpointResponse::URLRewriter::Akamai, + Imagekit::Internal::AnyHash + ) + end + + sig { returns(Symbol) } + attr_accessor :type + + sig { params(type: Symbol).returns(T.attached_class) } + def self.new(type: :AKAMAI) + end + + sig { override.returns({ type: Symbol }) } + def to_hash + end + end + + sig do + override.returns( + T::Array[ + Imagekit::Accounts::URLEndpointResponse::URLRewriter::Variants + ] + ) + end + def self.variants + end + end + end + end + end +end diff --git a/rbi/imagekit/models/accounts/url_endpoint_update_params.rbi b/rbi/imagekit/models/accounts/url_endpoint_update_params.rbi new file mode 100644 index 00000000..91f649a0 --- /dev/null +++ b/rbi/imagekit/models/accounts/url_endpoint_update_params.rbi @@ -0,0 +1,32 @@ +# typed: strong + +module Imagekit + module Models + module Accounts + class URLEndpointUpdateParams < Imagekit::Models::Accounts::URLEndpointRequest + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekit::Accounts::URLEndpointUpdateParams, + Imagekit::Internal::AnyHash + ) + end + + sig do + params(request_options: Imagekit::RequestOptions::OrHash).returns( + T.attached_class + ) + end + def self.new(request_options: {}) + end + + sig { override.returns({ request_options: Imagekit::RequestOptions }) } + def to_hash + end + end + end + end +end diff --git a/rbi/imagekit/models/accounts/usage_get_params.rbi b/rbi/imagekit/models/accounts/usage_get_params.rbi new file mode 100644 index 00000000..271e2759 --- /dev/null +++ b/rbi/imagekit/models/accounts/usage_get_params.rbi @@ -0,0 +1,60 @@ +# typed: strong + +module Imagekit + module Models + module Accounts + class UsageGetParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekit::Accounts::UsageGetParams, + Imagekit::Internal::AnyHash + ) + end + + # Specify a `endDate` in `YYYY-MM-DD` format. It should be after the `startDate`. + # The difference between `startDate` and `endDate` should be less than 90 days. + sig { returns(Date) } + attr_accessor :end_date + + # Specify a `startDate` in `YYYY-MM-DD` format. It should be before the `endDate`. + # The difference between `startDate` and `endDate` should be less than 90 days. + sig { returns(Date) } + attr_accessor :start_date + + sig do + params( + end_date: Date, + start_date: Date, + request_options: Imagekit::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # Specify a `endDate` in `YYYY-MM-DD` format. It should be after the `startDate`. + # The difference between `startDate` and `endDate` should be less than 90 days. + end_date:, + # Specify a `startDate` in `YYYY-MM-DD` format. It should be before the `endDate`. + # The difference between `startDate` and `endDate` should be less than 90 days. + start_date:, + request_options: {} + ) + end + + sig do + override.returns( + { + end_date: Date, + start_date: Date, + request_options: Imagekit::RequestOptions + } + ) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekit/models/accounts/usage_get_response.rbi b/rbi/imagekit/models/accounts/usage_get_response.rbi new file mode 100644 index 00000000..b3af7603 --- /dev/null +++ b/rbi/imagekit/models/accounts/usage_get_response.rbi @@ -0,0 +1,89 @@ +# typed: strong + +module Imagekit + module Models + module Accounts + class UsageGetResponse < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Models::Accounts::UsageGetResponse, + Imagekit::Internal::AnyHash + ) + end + + # Amount of bandwidth used in bytes. + sig { returns(T.nilable(Integer)) } + attr_reader :bandwidth_bytes + + sig { params(bandwidth_bytes: Integer).void } + attr_writer :bandwidth_bytes + + # Number of extension units used. + sig { returns(T.nilable(Integer)) } + attr_reader :extension_units_count + + sig { params(extension_units_count: Integer).void } + attr_writer :extension_units_count + + # Storage used by media library in bytes. + sig { returns(T.nilable(Integer)) } + attr_reader :media_library_storage_bytes + + sig { params(media_library_storage_bytes: Integer).void } + attr_writer :media_library_storage_bytes + + # Storage used by the original cache in bytes. + sig { returns(T.nilable(Integer)) } + attr_reader :original_cache_storage_bytes + + sig { params(original_cache_storage_bytes: Integer).void } + attr_writer :original_cache_storage_bytes + + # Number of video processing units used. + sig { returns(T.nilable(Integer)) } + attr_reader :video_processing_units_count + + sig { params(video_processing_units_count: Integer).void } + attr_writer :video_processing_units_count + + sig do + params( + bandwidth_bytes: Integer, + extension_units_count: Integer, + media_library_storage_bytes: Integer, + original_cache_storage_bytes: Integer, + video_processing_units_count: Integer + ).returns(T.attached_class) + end + def self.new( + # Amount of bandwidth used in bytes. + bandwidth_bytes: nil, + # Number of extension units used. + extension_units_count: nil, + # Storage used by media library in bytes. + media_library_storage_bytes: nil, + # Storage used by the original cache in bytes. + original_cache_storage_bytes: nil, + # Number of video processing units used. + video_processing_units_count: nil + ) + end + + sig do + override.returns( + { + bandwidth_bytes: Integer, + extension_units_count: Integer, + media_library_storage_bytes: Integer, + original_cache_storage_bytes: Integer, + video_processing_units_count: Integer + } + ) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekit/models/asset_list_params.rbi b/rbi/imagekit/models/asset_list_params.rbi new file mode 100644 index 00000000..6e43d77a --- /dev/null +++ b/rbi/imagekit/models/asset_list_params.rbi @@ -0,0 +1,269 @@ +# typed: strong + +module Imagekit + module Models + class AssetListParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any(Imagekit::AssetListParams, Imagekit::Internal::AnyHash) + end + + # Filter results by file type. + # + # - `all` — include all file types + # - `image` — include only image files + # - `non-image` — include only non-image files (e.g., JS, CSS, video) + sig { returns(T.nilable(Imagekit::AssetListParams::FileType::OrSymbol)) } + attr_reader :file_type + + sig do + params(file_type: Imagekit::AssetListParams::FileType::OrSymbol).void + end + attr_writer :file_type + + # The maximum number of results to return in response. + sig { returns(T.nilable(Integer)) } + attr_reader :limit + + sig { params(limit: Integer).void } + attr_writer :limit + + # Folder path if you want to limit the search within a specific folder. For + # example, `/sales-banner/` will only search in folder sales-banner. + # + # Note : If your use case involves searching within a folder as well as its + # subfolders, you can use `path` parameter in `searchQuery` with appropriate + # operator. Checkout + # [Supported parameters](/docs/api-reference/digital-asset-management-dam/list-and-search-assets#supported-parameters) + # for more information. + sig { returns(T.nilable(String)) } + attr_reader :path + + sig { params(path: String).void } + attr_writer :path + + # Query string in a Lucene-like query language e.g. `createdAt > "7d"`. + # + # Note : When the searchQuery parameter is present, the following query parameters + # will have no effect on the result: + # + # 1. `tags` + # 2. `type` + # 3. `name` + # + # [Learn more](/docs/api-reference/digital-asset-management-dam/list-and-search-assets#advanced-search-queries) + # from examples. + sig { returns(T.nilable(String)) } + attr_reader :search_query + + sig { params(search_query: String).void } + attr_writer :search_query + + # The number of results to skip before returning results. + sig { returns(T.nilable(Integer)) } + attr_reader :skip + + sig { params(skip: Integer).void } + attr_writer :skip + + # Sort the results by one of the supported fields in ascending or descending + # order. + sig { returns(T.nilable(Imagekit::AssetListParams::Sort::OrSymbol)) } + attr_reader :sort + + sig { params(sort: Imagekit::AssetListParams::Sort::OrSymbol).void } + attr_writer :sort + + # Filter results by asset type. + # + # - `file` — returns only files + # - `file-version` — returns specific file versions + # - `folder` — returns only folders + # - `all` — returns both files and folders (excludes `file-version`) + sig { returns(T.nilable(Imagekit::AssetListParams::Type::OrSymbol)) } + attr_reader :type + + sig { params(type: Imagekit::AssetListParams::Type::OrSymbol).void } + attr_writer :type + + sig do + params( + file_type: Imagekit::AssetListParams::FileType::OrSymbol, + limit: Integer, + path: String, + search_query: String, + skip: Integer, + sort: Imagekit::AssetListParams::Sort::OrSymbol, + type: Imagekit::AssetListParams::Type::OrSymbol, + request_options: Imagekit::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # Filter results by file type. + # + # - `all` — include all file types + # - `image` — include only image files + # - `non-image` — include only non-image files (e.g., JS, CSS, video) + file_type: nil, + # The maximum number of results to return in response. + limit: nil, + # Folder path if you want to limit the search within a specific folder. For + # example, `/sales-banner/` will only search in folder sales-banner. + # + # Note : If your use case involves searching within a folder as well as its + # subfolders, you can use `path` parameter in `searchQuery` with appropriate + # operator. Checkout + # [Supported parameters](/docs/api-reference/digital-asset-management-dam/list-and-search-assets#supported-parameters) + # for more information. + path: nil, + # Query string in a Lucene-like query language e.g. `createdAt > "7d"`. + # + # Note : When the searchQuery parameter is present, the following query parameters + # will have no effect on the result: + # + # 1. `tags` + # 2. `type` + # 3. `name` + # + # [Learn more](/docs/api-reference/digital-asset-management-dam/list-and-search-assets#advanced-search-queries) + # from examples. + search_query: nil, + # The number of results to skip before returning results. + skip: nil, + # Sort the results by one of the supported fields in ascending or descending + # order. + sort: nil, + # Filter results by asset type. + # + # - `file` — returns only files + # - `file-version` — returns specific file versions + # - `folder` — returns only folders + # - `all` — returns both files and folders (excludes `file-version`) + type: nil, + request_options: {} + ) + end + + sig do + override.returns( + { + file_type: Imagekit::AssetListParams::FileType::OrSymbol, + limit: Integer, + path: String, + search_query: String, + skip: Integer, + sort: Imagekit::AssetListParams::Sort::OrSymbol, + type: Imagekit::AssetListParams::Type::OrSymbol, + request_options: Imagekit::RequestOptions + } + ) + end + def to_hash + end + + # Filter results by file type. + # + # - `all` — include all file types + # - `image` — include only image files + # - `non-image` — include only non-image files (e.g., JS, CSS, video) + module FileType + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, Imagekit::AssetListParams::FileType) } + OrSymbol = T.type_alias { T.any(Symbol, String) } + + ALL = T.let(:all, Imagekit::AssetListParams::FileType::TaggedSymbol) + IMAGE = T.let(:image, Imagekit::AssetListParams::FileType::TaggedSymbol) + NON_IMAGE = + T.let(:"non-image", Imagekit::AssetListParams::FileType::TaggedSymbol) + + sig do + override.returns( + T::Array[Imagekit::AssetListParams::FileType::TaggedSymbol] + ) + end + def self.values + end + end + + # Sort the results by one of the supported fields in ascending or descending + # order. + module Sort + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, Imagekit::AssetListParams::Sort) } + OrSymbol = T.type_alias { T.any(Symbol, String) } + + ASC_NAME = + T.let(:ASC_NAME, Imagekit::AssetListParams::Sort::TaggedSymbol) + DESC_NAME = + T.let(:DESC_NAME, Imagekit::AssetListParams::Sort::TaggedSymbol) + ASC_CREATED = + T.let(:ASC_CREATED, Imagekit::AssetListParams::Sort::TaggedSymbol) + DESC_CREATED = + T.let(:DESC_CREATED, Imagekit::AssetListParams::Sort::TaggedSymbol) + ASC_UPDATED = + T.let(:ASC_UPDATED, Imagekit::AssetListParams::Sort::TaggedSymbol) + DESC_UPDATED = + T.let(:DESC_UPDATED, Imagekit::AssetListParams::Sort::TaggedSymbol) + ASC_HEIGHT = + T.let(:ASC_HEIGHT, Imagekit::AssetListParams::Sort::TaggedSymbol) + DESC_HEIGHT = + T.let(:DESC_HEIGHT, Imagekit::AssetListParams::Sort::TaggedSymbol) + ASC_WIDTH = + T.let(:ASC_WIDTH, Imagekit::AssetListParams::Sort::TaggedSymbol) + DESC_WIDTH = + T.let(:DESC_WIDTH, Imagekit::AssetListParams::Sort::TaggedSymbol) + ASC_SIZE = + T.let(:ASC_SIZE, Imagekit::AssetListParams::Sort::TaggedSymbol) + DESC_SIZE = + T.let(:DESC_SIZE, Imagekit::AssetListParams::Sort::TaggedSymbol) + ASC_RELEVANCE = + T.let(:ASC_RELEVANCE, Imagekit::AssetListParams::Sort::TaggedSymbol) + DESC_RELEVANCE = + T.let(:DESC_RELEVANCE, Imagekit::AssetListParams::Sort::TaggedSymbol) + + sig do + override.returns( + T::Array[Imagekit::AssetListParams::Sort::TaggedSymbol] + ) + end + def self.values + end + end + + # Filter results by asset type. + # + # - `file` — returns only files + # - `file-version` — returns specific file versions + # - `folder` — returns only folders + # - `all` — returns both files and folders (excludes `file-version`) + module Type + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, Imagekit::AssetListParams::Type) } + OrSymbol = T.type_alias { T.any(Symbol, String) } + + FILE = T.let(:file, Imagekit::AssetListParams::Type::TaggedSymbol) + FILE_VERSION = + T.let(:"file-version", Imagekit::AssetListParams::Type::TaggedSymbol) + FOLDER = T.let(:folder, Imagekit::AssetListParams::Type::TaggedSymbol) + ALL = T.let(:all, Imagekit::AssetListParams::Type::TaggedSymbol) + + sig do + override.returns( + T::Array[Imagekit::AssetListParams::Type::TaggedSymbol] + ) + end + def self.values + end + end + end + end +end diff --git a/rbi/imagekit/models/asset_list_response.rbi b/rbi/imagekit/models/asset_list_response.rbi new file mode 100644 index 00000000..3f9f4f86 --- /dev/null +++ b/rbi/imagekit/models/asset_list_response.rbi @@ -0,0 +1,28 @@ +# typed: strong + +module Imagekit + module Models + # Object containing details of a file or file version. + module AssetListResponseItem + extend Imagekit::Internal::Type::Union + + Variants = T.type_alias { T.any(Imagekit::Folder, Imagekit::File) } + + sig do + override.returns( + T::Array[Imagekit::Models::AssetListResponseItem::Variants] + ) + end + def self.variants + end + end + + AssetListResponse = + T.let( + Imagekit::Internal::Type::ArrayOf[ + union: Imagekit::Models::AssetListResponseItem + ], + Imagekit::Internal::Type::Converter + ) + end +end diff --git a/rbi/imagekit/models/base_overlay.rbi b/rbi/imagekit/models/base_overlay.rbi new file mode 100644 index 00000000..fc1a6eea --- /dev/null +++ b/rbi/imagekit/models/base_overlay.rbi @@ -0,0 +1,44 @@ +# typed: strong + +module Imagekit + module Models + class BaseOverlay < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any(Imagekit::BaseOverlay, Imagekit::Internal::AnyHash) + end + + sig { returns(T.nilable(Imagekit::OverlayPosition)) } + attr_reader :position + + sig { params(position: Imagekit::OverlayPosition::OrHash).void } + attr_writer :position + + sig { returns(T.nilable(Imagekit::OverlayTiming)) } + attr_reader :timing + + sig { params(timing: Imagekit::OverlayTiming::OrHash).void } + attr_writer :timing + + sig do + params( + position: Imagekit::OverlayPosition::OrHash, + timing: Imagekit::OverlayTiming::OrHash + ).returns(T.attached_class) + end + def self.new(position: nil, timing: nil) + end + + sig do + override.returns( + { + position: Imagekit::OverlayPosition, + timing: Imagekit::OverlayTiming + } + ) + end + def to_hash + end + end + end +end diff --git a/rbi/imagekit/models/base_webhook_event.rbi b/rbi/imagekit/models/base_webhook_event.rbi new file mode 100644 index 00000000..1420720c --- /dev/null +++ b/rbi/imagekit/models/base_webhook_event.rbi @@ -0,0 +1,33 @@ +# typed: strong + +module Imagekit + module Models + class BaseWebhookEvent < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any(Imagekit::BaseWebhookEvent, Imagekit::Internal::AnyHash) + end + + # Unique identifier for the event. + sig { returns(String) } + attr_accessor :id + + # The type of webhook event. + sig { returns(String) } + attr_accessor :type + + sig { params(id: String, type: String).returns(T.attached_class) } + def self.new( + # Unique identifier for the event. + id:, + # The type of webhook event. + type: + ) + end + + sig { override.returns({ id: String, type: String }) } + def to_hash + end + end + end +end diff --git a/rbi/imagekit/models/beta/v2/file_upload_params.rbi b/rbi/imagekit/models/beta/v2/file_upload_params.rbi new file mode 100644 index 00000000..b09ec71f --- /dev/null +++ b/rbi/imagekit/models/beta/v2/file_upload_params.rbi @@ -0,0 +1,856 @@ +# typed: strong + +module Imagekit + module Models + module Beta + module V2 + class FileUploadParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekit::Beta::V2::FileUploadParams, + Imagekit::Internal::AnyHash + ) + end + + # The API accepts any of the following: + # + # - **Binary data** – send the raw bytes as `multipart/form-data`. + # - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can + # fetch. + # - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + # + # When supplying a URL, the server must receive the response headers within 8 + # seconds; otherwise the request fails with 400 Bad Request. + sig { returns(Imagekit::Internal::FileInput) } + attr_accessor :file + + # The name with which the file has to be uploaded. + sig { returns(String) } + attr_accessor :file_name + + # This is the client-generated JSON Web Token (JWT). The ImageKit.io server uses + # it to authenticate and check that the upload request parameters have not been + # tampered with after the token has been generated. Learn how to create the token + # on the page below. This field is only required for authentication when uploading + # a file from the client side. + # + # **Note**: Sending a JWT that has been used in the past will result in a + # validation error. Even if your previous request resulted in an error, you should + # always send a new token. + # + # **⚠️Warning**: JWT must be generated on the server-side because it is generated + # using your account's private API key. This field is required for authentication + # when uploading a file from the client-side. + sig { returns(T.nilable(String)) } + attr_reader :token + + sig { params(token: String).void } + attr_writer :token + + # Server-side checks to run on the asset. Read more about + # [Upload API checks](/docs/api-reference/upload-file/upload-file-v2#upload-api-checks). + sig { returns(T.nilable(String)) } + attr_reader :checks + + sig { params(checks: String).void } + attr_writer :checks + + # Define an important area in the image. This is only relevant for image type + # files. + # + # - To be passed as a string with the x and y coordinates of the top-left corner, + # and width and height of the area of interest in the format `x,y,width,height`. + # For example - `10,10,100,100` + # - Can be used with fo-customtransformation. + # - If this field is not specified and the file is overwritten, then + # customCoordinates will be removed. + sig { returns(T.nilable(String)) } + attr_reader :custom_coordinates + + sig { params(custom_coordinates: String).void } + attr_writer :custom_coordinates + + # JSON key-value pairs to associate with the asset. Create the custom metadata + # fields before setting these values. + sig { returns(T.nilable(T::Hash[Symbol, T.anything])) } + attr_reader :custom_metadata + + sig { params(custom_metadata: T::Hash[Symbol, T.anything]).void } + attr_writer :custom_metadata + + # Optional text to describe the contents of the file. + sig { returns(T.nilable(String)) } + attr_reader :description + + sig { params(description: String).void } + attr_writer :description + + # Array of extensions to be applied to the asset. Each extension can be configured + # with specific parameters based on the extension type. + sig do + returns( + T.nilable( + T::Array[ + T.any( + Imagekit::ExtensionItem::RemoveBg, + Imagekit::ExtensionItem::AIAutoDescription, + Imagekit::ExtensionItem::AutoTaggingExtension + ) + ] + ) + ) + end + attr_reader :extensions + + sig do + params( + extensions: + T::Array[ + T.any( + Imagekit::ExtensionItem::RemoveBg::OrHash, + Imagekit::ExtensionItem::AIAutoDescription::OrHash, + Imagekit::ExtensionItem::AutoTaggingExtension::OrHash + ) + ] + ).void + end + attr_writer :extensions + + # The folder path in which the image has to be uploaded. If the folder(s) didn't + # exist before, a new folder(s) is created. Using multiple `/` creates a nested + # folder. + sig { returns(T.nilable(String)) } + attr_reader :folder + + sig { params(folder: String).void } + attr_writer :folder + + # Whether to mark the file as private or not. + # + # If `true`, the file is marked as private and is accessible only using named + # transformation or signed URL. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :is_private_file + + sig { params(is_private_file: T::Boolean).void } + attr_writer :is_private_file + + # Whether to upload file as published or not. + # + # If `false`, the file is marked as unpublished, which restricts access to the + # file only via the media library. Files in draft or unpublished state can only be + # publicly accessed after being published. + # + # The option to upload in draft state is only available in custom enterprise + # pricing plans. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :is_published + + sig { params(is_published: T::Boolean).void } + attr_writer :is_published + + # If set to `true` and a file already exists at the exact location, its AITags + # will be removed. Set `overwriteAITags` to `false` to preserve AITags. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :overwrite_ai_tags + + sig { params(overwrite_ai_tags: T::Boolean).void } + attr_writer :overwrite_ai_tags + + # If the request does not have `customMetadata`, and a file already exists at the + # exact location, existing customMetadata will be removed. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :overwrite_custom_metadata + + sig { params(overwrite_custom_metadata: T::Boolean).void } + attr_writer :overwrite_custom_metadata + + # If `false` and `useUniqueFileName` is also `false`, and a file already exists at + # the exact location, upload API will return an error immediately. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :overwrite_file + + sig { params(overwrite_file: T::Boolean).void } + attr_writer :overwrite_file + + # If the request does not have `tags`, and a file already exists at the exact + # location, existing tags will be removed. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :overwrite_tags + + sig { params(overwrite_tags: T::Boolean).void } + attr_writer :overwrite_tags + + # Array of response field keys to include in the API response body. + sig do + returns( + T.nilable( + T::Array[ + Imagekit::Beta::V2::FileUploadParams::ResponseField::OrSymbol + ] + ) + ) + end + attr_reader :response_fields + + sig do + params( + response_fields: + T::Array[ + Imagekit::Beta::V2::FileUploadParams::ResponseField::OrSymbol + ] + ).void + end + attr_writer :response_fields + + # Set the tags while uploading the file. Provide an array of tag strings (e.g. + # `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must not + # exceed 500, and the `%` character is not allowed. If this field is not specified + # and the file is overwritten, the existing tags will be removed. + sig { returns(T.nilable(T::Array[String])) } + attr_reader :tags + + sig { params(tags: T::Array[String]).void } + attr_writer :tags + + # Configure pre-processing (`pre`) and post-processing (`post`) transformations. + # + # - `pre` — applied before the file is uploaded to the Media Library. + # Useful for reducing file size or applying basic optimizations upfront (e.g., + # resize, compress). + # + # - `post` — applied immediately after upload. + # Ideal for generating transformed versions (like video encodes or thumbnails) + # in advance, so they're ready for delivery without delay. + # + # You can mix and match any combination of post-processing types. + sig do + returns( + T.nilable(Imagekit::Beta::V2::FileUploadParams::Transformation) + ) + end + attr_reader :transformation + + sig do + params( + transformation: + Imagekit::Beta::V2::FileUploadParams::Transformation::OrHash + ).void + end + attr_writer :transformation + + # Whether to use a unique filename for this file or not. + # + # If `true`, ImageKit.io will add a unique suffix to the filename parameter to get + # a unique filename. + # + # If `false`, then the image is uploaded with the provided filename parameter, and + # any existing file with the same name is replaced. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :use_unique_file_name + + sig { params(use_unique_file_name: T::Boolean).void } + attr_writer :use_unique_file_name + + # The final status of extensions after they have completed execution will be + # delivered to this endpoint as a POST request. + # [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + # about the webhook payload structure. + sig { returns(T.nilable(String)) } + attr_reader :webhook_url + + sig { params(webhook_url: String).void } + attr_writer :webhook_url + + sig do + params( + file: Imagekit::Internal::FileInput, + file_name: String, + token: String, + checks: String, + custom_coordinates: String, + custom_metadata: T::Hash[Symbol, T.anything], + description: String, + extensions: + T::Array[ + T.any( + Imagekit::ExtensionItem::RemoveBg::OrHash, + Imagekit::ExtensionItem::AIAutoDescription::OrHash, + Imagekit::ExtensionItem::AutoTaggingExtension::OrHash + ) + ], + folder: String, + is_private_file: T::Boolean, + is_published: T::Boolean, + overwrite_ai_tags: T::Boolean, + overwrite_custom_metadata: T::Boolean, + overwrite_file: T::Boolean, + overwrite_tags: T::Boolean, + response_fields: + T::Array[ + Imagekit::Beta::V2::FileUploadParams::ResponseField::OrSymbol + ], + tags: T::Array[String], + transformation: + Imagekit::Beta::V2::FileUploadParams::Transformation::OrHash, + use_unique_file_name: T::Boolean, + webhook_url: String, + request_options: Imagekit::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # The API accepts any of the following: + # + # - **Binary data** – send the raw bytes as `multipart/form-data`. + # - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can + # fetch. + # - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + # + # When supplying a URL, the server must receive the response headers within 8 + # seconds; otherwise the request fails with 400 Bad Request. + file:, + # The name with which the file has to be uploaded. + file_name:, + # This is the client-generated JSON Web Token (JWT). The ImageKit.io server uses + # it to authenticate and check that the upload request parameters have not been + # tampered with after the token has been generated. Learn how to create the token + # on the page below. This field is only required for authentication when uploading + # a file from the client side. + # + # **Note**: Sending a JWT that has been used in the past will result in a + # validation error. Even if your previous request resulted in an error, you should + # always send a new token. + # + # **⚠️Warning**: JWT must be generated on the server-side because it is generated + # using your account's private API key. This field is required for authentication + # when uploading a file from the client-side. + token: nil, + # Server-side checks to run on the asset. Read more about + # [Upload API checks](/docs/api-reference/upload-file/upload-file-v2#upload-api-checks). + checks: nil, + # Define an important area in the image. This is only relevant for image type + # files. + # + # - To be passed as a string with the x and y coordinates of the top-left corner, + # and width and height of the area of interest in the format `x,y,width,height`. + # For example - `10,10,100,100` + # - Can be used with fo-customtransformation. + # - If this field is not specified and the file is overwritten, then + # customCoordinates will be removed. + custom_coordinates: nil, + # JSON key-value pairs to associate with the asset. Create the custom metadata + # fields before setting these values. + custom_metadata: nil, + # Optional text to describe the contents of the file. + description: nil, + # Array of extensions to be applied to the asset. Each extension can be configured + # with specific parameters based on the extension type. + extensions: nil, + # The folder path in which the image has to be uploaded. If the folder(s) didn't + # exist before, a new folder(s) is created. Using multiple `/` creates a nested + # folder. + folder: nil, + # Whether to mark the file as private or not. + # + # If `true`, the file is marked as private and is accessible only using named + # transformation or signed URL. + is_private_file: nil, + # Whether to upload file as published or not. + # + # If `false`, the file is marked as unpublished, which restricts access to the + # file only via the media library. Files in draft or unpublished state can only be + # publicly accessed after being published. + # + # The option to upload in draft state is only available in custom enterprise + # pricing plans. + is_published: nil, + # If set to `true` and a file already exists at the exact location, its AITags + # will be removed. Set `overwriteAITags` to `false` to preserve AITags. + overwrite_ai_tags: nil, + # If the request does not have `customMetadata`, and a file already exists at the + # exact location, existing customMetadata will be removed. + overwrite_custom_metadata: nil, + # If `false` and `useUniqueFileName` is also `false`, and a file already exists at + # the exact location, upload API will return an error immediately. + overwrite_file: nil, + # If the request does not have `tags`, and a file already exists at the exact + # location, existing tags will be removed. + overwrite_tags: nil, + # Array of response field keys to include in the API response body. + response_fields: nil, + # Set the tags while uploading the file. Provide an array of tag strings (e.g. + # `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must not + # exceed 500, and the `%` character is not allowed. If this field is not specified + # and the file is overwritten, the existing tags will be removed. + tags: nil, + # Configure pre-processing (`pre`) and post-processing (`post`) transformations. + # + # - `pre` — applied before the file is uploaded to the Media Library. + # Useful for reducing file size or applying basic optimizations upfront (e.g., + # resize, compress). + # + # - `post` — applied immediately after upload. + # Ideal for generating transformed versions (like video encodes or thumbnails) + # in advance, so they're ready for delivery without delay. + # + # You can mix and match any combination of post-processing types. + transformation: nil, + # Whether to use a unique filename for this file or not. + # + # If `true`, ImageKit.io will add a unique suffix to the filename parameter to get + # a unique filename. + # + # If `false`, then the image is uploaded with the provided filename parameter, and + # any existing file with the same name is replaced. + use_unique_file_name: nil, + # The final status of extensions after they have completed execution will be + # delivered to this endpoint as a POST request. + # [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + # about the webhook payload structure. + webhook_url: nil, + request_options: {} + ) + end + + sig do + override.returns( + { + file: Imagekit::Internal::FileInput, + file_name: String, + token: String, + checks: String, + custom_coordinates: String, + custom_metadata: T::Hash[Symbol, T.anything], + description: String, + extensions: + T::Array[ + T.any( + Imagekit::ExtensionItem::RemoveBg, + Imagekit::ExtensionItem::AIAutoDescription, + Imagekit::ExtensionItem::AutoTaggingExtension + ) + ], + folder: String, + is_private_file: T::Boolean, + is_published: T::Boolean, + overwrite_ai_tags: T::Boolean, + overwrite_custom_metadata: T::Boolean, + overwrite_file: T::Boolean, + overwrite_tags: T::Boolean, + response_fields: + T::Array[ + Imagekit::Beta::V2::FileUploadParams::ResponseField::OrSymbol + ], + tags: T::Array[String], + transformation: + Imagekit::Beta::V2::FileUploadParams::Transformation, + use_unique_file_name: T::Boolean, + webhook_url: String, + request_options: Imagekit::RequestOptions + } + ) + end + def to_hash + end + + module ResponseField + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekit::Beta::V2::FileUploadParams::ResponseField + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + TAGS = + T.let( + :tags, + Imagekit::Beta::V2::FileUploadParams::ResponseField::TaggedSymbol + ) + CUSTOM_COORDINATES = + T.let( + :customCoordinates, + Imagekit::Beta::V2::FileUploadParams::ResponseField::TaggedSymbol + ) + IS_PRIVATE_FILE = + T.let( + :isPrivateFile, + Imagekit::Beta::V2::FileUploadParams::ResponseField::TaggedSymbol + ) + EMBEDDED_METADATA = + T.let( + :embeddedMetadata, + Imagekit::Beta::V2::FileUploadParams::ResponseField::TaggedSymbol + ) + IS_PUBLISHED = + T.let( + :isPublished, + Imagekit::Beta::V2::FileUploadParams::ResponseField::TaggedSymbol + ) + CUSTOM_METADATA = + T.let( + :customMetadata, + Imagekit::Beta::V2::FileUploadParams::ResponseField::TaggedSymbol + ) + METADATA = + T.let( + :metadata, + Imagekit::Beta::V2::FileUploadParams::ResponseField::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekit::Beta::V2::FileUploadParams::ResponseField::TaggedSymbol + ] + ) + end + def self.values + end + end + + class Transformation < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Beta::V2::FileUploadParams::Transformation, + Imagekit::Internal::AnyHash + ) + end + + # List of transformations to apply _after_ the file is uploaded. + # Each item must match one of the following types: `transformation`, + # `gif-to-video`, `thumbnail`, `abs`. + sig do + returns( + T.nilable( + T::Array[ + T.any( + Imagekit::Beta::V2::FileUploadParams::Transformation::Post::Transformation, + Imagekit::Beta::V2::FileUploadParams::Transformation::Post::GifToVideo, + Imagekit::Beta::V2::FileUploadParams::Transformation::Post::Thumbnail, + Imagekit::Beta::V2::FileUploadParams::Transformation::Post::Abs + ) + ] + ) + ) + end + attr_reader :post + + sig do + params( + post: + T::Array[ + T.any( + Imagekit::Beta::V2::FileUploadParams::Transformation::Post::Transformation::OrHash, + Imagekit::Beta::V2::FileUploadParams::Transformation::Post::GifToVideo::OrHash, + Imagekit::Beta::V2::FileUploadParams::Transformation::Post::Thumbnail::OrHash, + Imagekit::Beta::V2::FileUploadParams::Transformation::Post::Abs::OrHash + ) + ] + ).void + end + attr_writer :post + + # Transformation string to apply before uploading the file to the Media Library. + # Useful for optimizing files at ingestion. + sig { returns(T.nilable(String)) } + attr_reader :pre + + sig { params(pre: String).void } + attr_writer :pre + + # Configure pre-processing (`pre`) and post-processing (`post`) transformations. + # + # - `pre` — applied before the file is uploaded to the Media Library. + # Useful for reducing file size or applying basic optimizations upfront (e.g., + # resize, compress). + # + # - `post` — applied immediately after upload. + # Ideal for generating transformed versions (like video encodes or thumbnails) + # in advance, so they're ready for delivery without delay. + # + # You can mix and match any combination of post-processing types. + sig do + params( + post: + T::Array[ + T.any( + Imagekit::Beta::V2::FileUploadParams::Transformation::Post::Transformation::OrHash, + Imagekit::Beta::V2::FileUploadParams::Transformation::Post::GifToVideo::OrHash, + Imagekit::Beta::V2::FileUploadParams::Transformation::Post::Thumbnail::OrHash, + Imagekit::Beta::V2::FileUploadParams::Transformation::Post::Abs::OrHash + ) + ], + pre: String + ).returns(T.attached_class) + end + def self.new( + # List of transformations to apply _after_ the file is uploaded. + # Each item must match one of the following types: `transformation`, + # `gif-to-video`, `thumbnail`, `abs`. + post: nil, + # Transformation string to apply before uploading the file to the Media Library. + # Useful for optimizing files at ingestion. + pre: nil + ) + end + + sig do + override.returns( + { + post: + T::Array[ + T.any( + Imagekit::Beta::V2::FileUploadParams::Transformation::Post::Transformation, + Imagekit::Beta::V2::FileUploadParams::Transformation::Post::GifToVideo, + Imagekit::Beta::V2::FileUploadParams::Transformation::Post::Thumbnail, + Imagekit::Beta::V2::FileUploadParams::Transformation::Post::Abs + ) + ], + pre: String + } + ) + end + def to_hash + end + + module Post + extend Imagekit::Internal::Type::Union + + Variants = + T.type_alias do + T.any( + Imagekit::Beta::V2::FileUploadParams::Transformation::Post::Transformation, + Imagekit::Beta::V2::FileUploadParams::Transformation::Post::GifToVideo, + Imagekit::Beta::V2::FileUploadParams::Transformation::Post::Thumbnail, + Imagekit::Beta::V2::FileUploadParams::Transformation::Post::Abs + ) + end + + class Transformation < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Beta::V2::FileUploadParams::Transformation::Post::Transformation, + Imagekit::Internal::AnyHash + ) + end + + # Transformation type. + sig { returns(Symbol) } + attr_accessor :type + + # Transformation string (e.g. `w-200,h-200`). + # Same syntax as ImageKit URL-based transformations. + sig { returns(String) } + attr_accessor :value + + sig do + params(value: String, type: Symbol).returns(T.attached_class) + end + def self.new( + # Transformation string (e.g. `w-200,h-200`). + # Same syntax as ImageKit URL-based transformations. + value:, + # Transformation type. + type: :transformation + ) + end + + sig { override.returns({ type: Symbol, value: String }) } + def to_hash + end + end + + class GifToVideo < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Beta::V2::FileUploadParams::Transformation::Post::GifToVideo, + Imagekit::Internal::AnyHash + ) + end + + # Converts an animated GIF into an MP4. + sig { returns(Symbol) } + attr_accessor :type + + # Optional transformation string to apply to the output video. + # **Example**: `q-80` + sig { returns(T.nilable(String)) } + attr_reader :value + + sig { params(value: String).void } + attr_writer :value + + sig do + params(value: String, type: Symbol).returns(T.attached_class) + end + def self.new( + # Optional transformation string to apply to the output video. + # **Example**: `q-80` + value: nil, + # Converts an animated GIF into an MP4. + type: :"gif-to-video" + ) + end + + sig { override.returns({ type: Symbol, value: String }) } + def to_hash + end + end + + class Thumbnail < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Beta::V2::FileUploadParams::Transformation::Post::Thumbnail, + Imagekit::Internal::AnyHash + ) + end + + # Generates a thumbnail image. + sig { returns(Symbol) } + attr_accessor :type + + # Optional transformation string. + # **Example**: `w-150,h-150` + sig { returns(T.nilable(String)) } + attr_reader :value + + sig { params(value: String).void } + attr_writer :value + + sig do + params(value: String, type: Symbol).returns(T.attached_class) + end + def self.new( + # Optional transformation string. + # **Example**: `w-150,h-150` + value: nil, + # Generates a thumbnail image. + type: :thumbnail + ) + end + + sig { override.returns({ type: Symbol, value: String }) } + def to_hash + end + end + + class Abs < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Beta::V2::FileUploadParams::Transformation::Post::Abs, + Imagekit::Internal::AnyHash + ) + end + + # Streaming protocol to use (`hls` or `dash`). + sig do + returns( + Imagekit::Beta::V2::FileUploadParams::Transformation::Post::Abs::Protocol::OrSymbol + ) + end + attr_accessor :protocol + + # Adaptive Bitrate Streaming (ABS) setup. + sig { returns(Symbol) } + attr_accessor :type + + # List of different representations you want to create separated by an underscore. + sig { returns(String) } + attr_accessor :value + + sig do + params( + protocol: + Imagekit::Beta::V2::FileUploadParams::Transformation::Post::Abs::Protocol::OrSymbol, + value: String, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Streaming protocol to use (`hls` or `dash`). + protocol:, + # List of different representations you want to create separated by an underscore. + value:, + # Adaptive Bitrate Streaming (ABS) setup. + type: :abs + ) + end + + sig do + override.returns( + { + protocol: + Imagekit::Beta::V2::FileUploadParams::Transformation::Post::Abs::Protocol::OrSymbol, + type: Symbol, + value: String + } + ) + end + def to_hash + end + + # Streaming protocol to use (`hls` or `dash`). + module Protocol + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekit::Beta::V2::FileUploadParams::Transformation::Post::Abs::Protocol + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + HLS = + T.let( + :hls, + Imagekit::Beta::V2::FileUploadParams::Transformation::Post::Abs::Protocol::TaggedSymbol + ) + DASH = + T.let( + :dash, + Imagekit::Beta::V2::FileUploadParams::Transformation::Post::Abs::Protocol::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekit::Beta::V2::FileUploadParams::Transformation::Post::Abs::Protocol::TaggedSymbol + ] + ) + end + def self.values + end + end + end + + sig do + override.returns( + T::Array[ + Imagekit::Beta::V2::FileUploadParams::Transformation::Post::Variants + ] + ) + end + def self.variants + end + end + end + end + end + end + end +end diff --git a/rbi/imagekit/models/beta/v2/file_upload_response.rbi b/rbi/imagekit/models/beta/v2/file_upload_response.rbi new file mode 100644 index 00000000..ea3ffd3d --- /dev/null +++ b/rbi/imagekit/models/beta/v2/file_upload_response.rbi @@ -0,0 +1,764 @@ +# typed: strong + +module Imagekit + module Models + module Beta + module V2 + class FileUploadResponse < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Models::Beta::V2::FileUploadResponse, + Imagekit::Internal::AnyHash + ) + end + + # An array of tags assigned to the uploaded file by auto tagging. + sig do + returns( + T.nilable( + T::Array[Imagekit::Models::Beta::V2::FileUploadResponse::AITag] + ) + ) + end + attr_accessor :ai_tags + + # The audio codec used in the video (only for video). + sig { returns(T.nilable(String)) } + attr_reader :audio_codec + + sig { params(audio_codec: String).void } + attr_writer :audio_codec + + # The bit rate of the video in kbps (only for video). + sig { returns(T.nilable(Integer)) } + attr_reader :bit_rate + + sig { params(bit_rate: Integer).void } + attr_writer :bit_rate + + # Value of custom coordinates associated with the image in the format + # `x,y,width,height`. If `customCoordinates` are not defined, then it is `null`. + # Send `customCoordinates` in `responseFields` in API request to get the value of + # this field. + sig { returns(T.nilable(String)) } + attr_accessor :custom_coordinates + + # A key-value data associated with the asset. Use `responseField` in API request + # to get `customMetadata` in the upload API response. Before setting any custom + # metadata on an asset, you have to create the field using custom metadata fields + # API. Send `customMetadata` in `responseFields` in API request to get the value + # of this field. + sig { returns(T.nilable(T::Hash[Symbol, T.anything])) } + attr_reader :custom_metadata + + sig { params(custom_metadata: T::Hash[Symbol, T.anything]).void } + attr_writer :custom_metadata + + # Optional text to describe the contents of the file. Can be set by the user or + # the ai-auto-description extension. + sig { returns(T.nilable(String)) } + attr_reader :description + + sig { params(description: String).void } + attr_writer :description + + # The duration of the video in seconds (only for video). + sig { returns(T.nilable(Integer)) } + attr_reader :duration + + sig { params(duration: Integer).void } + attr_writer :duration + + # Consolidated embedded metadata associated with the file. It includes exif, iptc, + # and xmp data. Send `embeddedMetadata` in `responseFields` in API request to get + # embeddedMetadata in the upload API response. + sig { returns(T.nilable(T::Hash[Symbol, T.anything])) } + attr_reader :embedded_metadata + + sig { params(embedded_metadata: T::Hash[Symbol, T.anything]).void } + attr_writer :embedded_metadata + + # Extension names with their processing status at the time of completion of the + # request. It could have one of the following status values: + # + # `success`: The extension has been successfully applied. `failed`: The extension + # has failed and will not be retried. `pending`: The extension will finish + # processing in some time. On completion, the final status (success / failed) will + # be sent to the `webhookUrl` provided. + # + # If no extension was requested, then this parameter is not returned. + sig do + returns( + T.nilable( + Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus + ) + ) + end + attr_reader :extension_status + + sig do + params( + extension_status: + Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::OrHash + ).void + end + attr_writer :extension_status + + # Unique fileId. Store this fileld in your database, as this will be used to + # perform update action on this file. + sig { returns(T.nilable(String)) } + attr_reader :file_id + + sig { params(file_id: String).void } + attr_writer :file_id + + # The relative path of the file in the media library e.g. + # `/marketing-assets/new-banner.jpg`. + sig { returns(T.nilable(String)) } + attr_reader :file_path + + sig { params(file_path: String).void } + attr_writer :file_path + + # Type of the uploaded file. Possible values are `image`, `non-image`. + sig { returns(T.nilable(String)) } + attr_reader :file_type + + sig { params(file_type: String).void } + attr_writer :file_type + + # Height of the image in pixels (Only for images) + sig { returns(T.nilable(Float)) } + attr_reader :height + + sig { params(height: Float).void } + attr_writer :height + + # Is the file marked as private. It can be either `true` or `false`. Send + # `isPrivateFile` in `responseFields` in API request to get the value of this + # field. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :is_private_file + + sig { params(is_private_file: T::Boolean).void } + attr_writer :is_private_file + + # Is the file published or in draft state. It can be either `true` or `false`. + # Send `isPublished` in `responseFields` in API request to get the value of this + # field. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :is_published + + sig { params(is_published: T::Boolean).void } + attr_writer :is_published + + # Legacy metadata. Send `metadata` in `responseFields` in API request to get + # metadata in the upload API response. + sig { returns(T.nilable(Imagekit::Metadata)) } + attr_reader :metadata + + sig { params(metadata: Imagekit::Metadata::OrHash).void } + attr_writer :metadata + + # Name of the asset. + sig { returns(T.nilable(String)) } + attr_reader :name + + sig { params(name: String).void } + attr_writer :name + + # Size of the image file in Bytes. + sig { returns(T.nilable(Float)) } + attr_reader :size + + sig { params(size: Float).void } + attr_writer :size + + # The array of tags associated with the asset. If no tags are set, it will be + # `null`. Send `tags` in `responseFields` in API request to get the value of this + # field. + sig { returns(T.nilable(T::Array[String])) } + attr_accessor :tags + + # In the case of an image, a small thumbnail URL. + sig { returns(T.nilable(String)) } + attr_reader :thumbnail_url + + sig { params(thumbnail_url: String).void } + attr_writer :thumbnail_url + + # A publicly accessible URL of the file. + sig { returns(T.nilable(String)) } + attr_reader :url + + sig { params(url: String).void } + attr_writer :url + + # An object containing the file or file version's `id` (versionId) and `name`. + sig do + returns( + T.nilable( + Imagekit::Models::Beta::V2::FileUploadResponse::VersionInfo + ) + ) + end + attr_reader :version_info + + sig do + params( + version_info: + Imagekit::Models::Beta::V2::FileUploadResponse::VersionInfo::OrHash + ).void + end + attr_writer :version_info + + # The video codec used in the video (only for video). + sig { returns(T.nilable(String)) } + attr_reader :video_codec + + sig { params(video_codec: String).void } + attr_writer :video_codec + + # Width of the image in pixels (Only for Images) + sig { returns(T.nilable(Float)) } + attr_reader :width + + sig { params(width: Float).void } + attr_writer :width + + # Object containing details of a successful upload. + sig do + params( + ai_tags: + T.nilable( + T::Array[ + Imagekit::Models::Beta::V2::FileUploadResponse::AITag::OrHash + ] + ), + audio_codec: String, + bit_rate: Integer, + custom_coordinates: T.nilable(String), + custom_metadata: T::Hash[Symbol, T.anything], + description: String, + duration: Integer, + embedded_metadata: T::Hash[Symbol, T.anything], + extension_status: + Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::OrHash, + file_id: String, + file_path: String, + file_type: String, + height: Float, + is_private_file: T::Boolean, + is_published: T::Boolean, + metadata: Imagekit::Metadata::OrHash, + name: String, + size: Float, + tags: T.nilable(T::Array[String]), + thumbnail_url: String, + url: String, + version_info: + Imagekit::Models::Beta::V2::FileUploadResponse::VersionInfo::OrHash, + video_codec: String, + width: Float + ).returns(T.attached_class) + end + def self.new( + # An array of tags assigned to the uploaded file by auto tagging. + ai_tags: nil, + # The audio codec used in the video (only for video). + audio_codec: nil, + # The bit rate of the video in kbps (only for video). + bit_rate: nil, + # Value of custom coordinates associated with the image in the format + # `x,y,width,height`. If `customCoordinates` are not defined, then it is `null`. + # Send `customCoordinates` in `responseFields` in API request to get the value of + # this field. + custom_coordinates: nil, + # A key-value data associated with the asset. Use `responseField` in API request + # to get `customMetadata` in the upload API response. Before setting any custom + # metadata on an asset, you have to create the field using custom metadata fields + # API. Send `customMetadata` in `responseFields` in API request to get the value + # of this field. + custom_metadata: nil, + # Optional text to describe the contents of the file. Can be set by the user or + # the ai-auto-description extension. + description: nil, + # The duration of the video in seconds (only for video). + duration: nil, + # Consolidated embedded metadata associated with the file. It includes exif, iptc, + # and xmp data. Send `embeddedMetadata` in `responseFields` in API request to get + # embeddedMetadata in the upload API response. + embedded_metadata: nil, + # Extension names with their processing status at the time of completion of the + # request. It could have one of the following status values: + # + # `success`: The extension has been successfully applied. `failed`: The extension + # has failed and will not be retried. `pending`: The extension will finish + # processing in some time. On completion, the final status (success / failed) will + # be sent to the `webhookUrl` provided. + # + # If no extension was requested, then this parameter is not returned. + extension_status: nil, + # Unique fileId. Store this fileld in your database, as this will be used to + # perform update action on this file. + file_id: nil, + # The relative path of the file in the media library e.g. + # `/marketing-assets/new-banner.jpg`. + file_path: nil, + # Type of the uploaded file. Possible values are `image`, `non-image`. + file_type: nil, + # Height of the image in pixels (Only for images) + height: nil, + # Is the file marked as private. It can be either `true` or `false`. Send + # `isPrivateFile` in `responseFields` in API request to get the value of this + # field. + is_private_file: nil, + # Is the file published or in draft state. It can be either `true` or `false`. + # Send `isPublished` in `responseFields` in API request to get the value of this + # field. + is_published: nil, + # Legacy metadata. Send `metadata` in `responseFields` in API request to get + # metadata in the upload API response. + metadata: nil, + # Name of the asset. + name: nil, + # Size of the image file in Bytes. + size: nil, + # The array of tags associated with the asset. If no tags are set, it will be + # `null`. Send `tags` in `responseFields` in API request to get the value of this + # field. + tags: nil, + # In the case of an image, a small thumbnail URL. + thumbnail_url: nil, + # A publicly accessible URL of the file. + url: nil, + # An object containing the file or file version's `id` (versionId) and `name`. + version_info: nil, + # The video codec used in the video (only for video). + video_codec: nil, + # Width of the image in pixels (Only for Images) + width: nil + ) + end + + sig do + override.returns( + { + ai_tags: + T.nilable( + T::Array[ + Imagekit::Models::Beta::V2::FileUploadResponse::AITag + ] + ), + audio_codec: String, + bit_rate: Integer, + custom_coordinates: T.nilable(String), + custom_metadata: T::Hash[Symbol, T.anything], + description: String, + duration: Integer, + embedded_metadata: T::Hash[Symbol, T.anything], + extension_status: + Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus, + file_id: String, + file_path: String, + file_type: String, + height: Float, + is_private_file: T::Boolean, + is_published: T::Boolean, + metadata: Imagekit::Metadata, + name: String, + size: Float, + tags: T.nilable(T::Array[String]), + thumbnail_url: String, + url: String, + version_info: + Imagekit::Models::Beta::V2::FileUploadResponse::VersionInfo, + video_codec: String, + width: Float + } + ) + end + def to_hash + end + + class AITag < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Models::Beta::V2::FileUploadResponse::AITag, + Imagekit::Internal::AnyHash + ) + end + + # Confidence score of the tag. + sig { returns(T.nilable(Float)) } + attr_reader :confidence + + sig { params(confidence: Float).void } + attr_writer :confidence + + # Name of the tag. + sig { returns(T.nilable(String)) } + attr_reader :name + + sig { params(name: String).void } + attr_writer :name + + # Array of `AITags` associated with the image. If no `AITags` are set, it will be + # null. These tags can be added using the `google-auto-tagging` or + # `aws-auto-tagging` extensions. + sig { returns(T.nilable(String)) } + attr_reader :source + + sig { params(source: String).void } + attr_writer :source + + sig do + params(confidence: Float, name: String, source: String).returns( + T.attached_class + ) + end + def self.new( + # Confidence score of the tag. + confidence: nil, + # Name of the tag. + name: nil, + # Array of `AITags` associated with the image. If no `AITags` are set, it will be + # null. These tags can be added using the `google-auto-tagging` or + # `aws-auto-tagging` extensions. + source: nil + ) + end + + sig do + override.returns( + { confidence: Float, name: String, source: String } + ) + end + def to_hash + end + end + + class ExtensionStatus < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus, + Imagekit::Internal::AnyHash + ) + end + + sig do + returns( + T.nilable( + Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::AIAutoDescription::TaggedSymbol + ) + ) + end + attr_reader :ai_auto_description + + sig do + params( + ai_auto_description: + Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::AIAutoDescription::OrSymbol + ).void + end + attr_writer :ai_auto_description + + sig do + returns( + T.nilable( + Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::AwsAutoTagging::TaggedSymbol + ) + ) + end + attr_reader :aws_auto_tagging + + sig do + params( + aws_auto_tagging: + Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::AwsAutoTagging::OrSymbol + ).void + end + attr_writer :aws_auto_tagging + + sig do + returns( + T.nilable( + Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::GoogleAutoTagging::TaggedSymbol + ) + ) + end + attr_reader :google_auto_tagging + + sig do + params( + google_auto_tagging: + Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::GoogleAutoTagging::OrSymbol + ).void + end + attr_writer :google_auto_tagging + + sig do + returns( + T.nilable( + Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::RemoveBg::TaggedSymbol + ) + ) + end + attr_reader :remove_bg + + sig do + params( + remove_bg: + Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::RemoveBg::OrSymbol + ).void + end + attr_writer :remove_bg + + # Extension names with their processing status at the time of completion of the + # request. It could have one of the following status values: + # + # `success`: The extension has been successfully applied. `failed`: The extension + # has failed and will not be retried. `pending`: The extension will finish + # processing in some time. On completion, the final status (success / failed) will + # be sent to the `webhookUrl` provided. + # + # If no extension was requested, then this parameter is not returned. + sig do + params( + ai_auto_description: + Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::AIAutoDescription::OrSymbol, + aws_auto_tagging: + Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::AwsAutoTagging::OrSymbol, + google_auto_tagging: + Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::GoogleAutoTagging::OrSymbol, + remove_bg: + Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::RemoveBg::OrSymbol + ).returns(T.attached_class) + end + def self.new( + ai_auto_description: nil, + aws_auto_tagging: nil, + google_auto_tagging: nil, + remove_bg: nil + ) + end + + sig do + override.returns( + { + ai_auto_description: + Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::AIAutoDescription::TaggedSymbol, + aws_auto_tagging: + Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::AwsAutoTagging::TaggedSymbol, + google_auto_tagging: + Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::GoogleAutoTagging::TaggedSymbol, + remove_bg: + Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::RemoveBg::TaggedSymbol + } + ) + end + def to_hash + end + + module AIAutoDescription + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::AIAutoDescription + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + SUCCESS = + T.let( + :success, + Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::AIAutoDescription::TaggedSymbol + ) + PENDING = + T.let( + :pending, + Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::AIAutoDescription::TaggedSymbol + ) + FAILED = + T.let( + :failed, + Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::AIAutoDescription::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::AIAutoDescription::TaggedSymbol + ] + ) + end + def self.values + end + end + + module AwsAutoTagging + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::AwsAutoTagging + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + SUCCESS = + T.let( + :success, + Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::AwsAutoTagging::TaggedSymbol + ) + PENDING = + T.let( + :pending, + Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::AwsAutoTagging::TaggedSymbol + ) + FAILED = + T.let( + :failed, + Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::AwsAutoTagging::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::AwsAutoTagging::TaggedSymbol + ] + ) + end + def self.values + end + end + + module GoogleAutoTagging + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::GoogleAutoTagging + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + SUCCESS = + T.let( + :success, + Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::GoogleAutoTagging::TaggedSymbol + ) + PENDING = + T.let( + :pending, + Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::GoogleAutoTagging::TaggedSymbol + ) + FAILED = + T.let( + :failed, + Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::GoogleAutoTagging::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::GoogleAutoTagging::TaggedSymbol + ] + ) + end + def self.values + end + end + + module RemoveBg + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::RemoveBg + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + SUCCESS = + T.let( + :success, + Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::RemoveBg::TaggedSymbol + ) + PENDING = + T.let( + :pending, + Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::RemoveBg::TaggedSymbol + ) + FAILED = + T.let( + :failed, + Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::RemoveBg::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::RemoveBg::TaggedSymbol + ] + ) + end + def self.values + end + end + end + + class VersionInfo < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Models::Beta::V2::FileUploadResponse::VersionInfo, + Imagekit::Internal::AnyHash + ) + end + + # Unique identifier of the file version. + sig { returns(T.nilable(String)) } + attr_reader :id + + sig { params(id: String).void } + attr_writer :id + + # Name of the file version. + sig { returns(T.nilable(String)) } + attr_reader :name + + sig { params(name: String).void } + attr_writer :name + + # An object containing the file or file version's `id` (versionId) and `name`. + sig { params(id: String, name: String).returns(T.attached_class) } + def self.new( + # Unique identifier of the file version. + id: nil, + # Name of the file version. + name: nil + ) + end + + sig { override.returns({ id: String, name: String }) } + def to_hash + end + end + end + end + end + end +end diff --git a/rbi/imagekit/models/cache/invalidation_create_params.rbi b/rbi/imagekit/models/cache/invalidation_create_params.rbi new file mode 100644 index 00000000..bafcab6b --- /dev/null +++ b/rbi/imagekit/models/cache/invalidation_create_params.rbi @@ -0,0 +1,45 @@ +# typed: strong + +module Imagekit + module Models + module Cache + class InvalidationCreateParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekit::Cache::InvalidationCreateParams, + Imagekit::Internal::AnyHash + ) + end + + # The full URL of the file to be purged. + sig { returns(String) } + attr_accessor :url + + sig do + params( + url: String, + request_options: Imagekit::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # The full URL of the file to be purged. + url:, + request_options: {} + ) + end + + sig do + override.returns( + { url: String, request_options: Imagekit::RequestOptions } + ) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekit/models/cache/invalidation_create_response.rbi b/rbi/imagekit/models/cache/invalidation_create_response.rbi new file mode 100644 index 00000000..2d6123a7 --- /dev/null +++ b/rbi/imagekit/models/cache/invalidation_create_response.rbi @@ -0,0 +1,37 @@ +# typed: strong + +module Imagekit + module Models + module Cache + class InvalidationCreateResponse < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Models::Cache::InvalidationCreateResponse, + Imagekit::Internal::AnyHash + ) + end + + # Unique identifier of the purge request. This can be used to check the status of + # the purge request. + sig { returns(T.nilable(String)) } + attr_reader :request_id + + sig { params(request_id: String).void } + attr_writer :request_id + + sig { params(request_id: String).returns(T.attached_class) } + def self.new( + # Unique identifier of the purge request. This can be used to check the status of + # the purge request. + request_id: nil + ) + end + + sig { override.returns({ request_id: String }) } + def to_hash + end + end + end + end +end diff --git a/rbi/imagekit/models/cache/invalidation_get_params.rbi b/rbi/imagekit/models/cache/invalidation_get_params.rbi new file mode 100644 index 00000000..07375fb7 --- /dev/null +++ b/rbi/imagekit/models/cache/invalidation_get_params.rbi @@ -0,0 +1,32 @@ +# typed: strong + +module Imagekit + module Models + module Cache + class InvalidationGetParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekit::Cache::InvalidationGetParams, + Imagekit::Internal::AnyHash + ) + end + + sig do + params(request_options: Imagekit::RequestOptions::OrHash).returns( + T.attached_class + ) + end + def self.new(request_options: {}) + end + + sig { override.returns({ request_options: Imagekit::RequestOptions }) } + def to_hash + end + end + end + end +end diff --git a/rbi/imagekit/models/cache/invalidation_get_response.rbi b/rbi/imagekit/models/cache/invalidation_get_response.rbi new file mode 100644 index 00000000..c26651ef --- /dev/null +++ b/rbi/imagekit/models/cache/invalidation_get_response.rbi @@ -0,0 +1,93 @@ +# typed: strong + +module Imagekit + module Models + module Cache + class InvalidationGetResponse < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Models::Cache::InvalidationGetResponse, + Imagekit::Internal::AnyHash + ) + end + + # Status of the purge request. + sig do + returns( + T.nilable( + Imagekit::Models::Cache::InvalidationGetResponse::Status::TaggedSymbol + ) + ) + end + attr_reader :status + + sig do + params( + status: + Imagekit::Models::Cache::InvalidationGetResponse::Status::OrSymbol + ).void + end + attr_writer :status + + sig do + params( + status: + Imagekit::Models::Cache::InvalidationGetResponse::Status::OrSymbol + ).returns(T.attached_class) + end + def self.new( + # Status of the purge request. + status: nil + ) + end + + sig do + override.returns( + { + status: + Imagekit::Models::Cache::InvalidationGetResponse::Status::TaggedSymbol + } + ) + end + def to_hash + end + + # Status of the purge request. + module Status + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekit::Models::Cache::InvalidationGetResponse::Status + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + PENDING = + T.let( + :Pending, + Imagekit::Models::Cache::InvalidationGetResponse::Status::TaggedSymbol + ) + COMPLETED = + T.let( + :Completed, + Imagekit::Models::Cache::InvalidationGetResponse::Status::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekit::Models::Cache::InvalidationGetResponse::Status::TaggedSymbol + ] + ) + end + def self.values + end + end + end + end + end +end diff --git a/rbi/imagekit/models/custom_metadata_field.rbi b/rbi/imagekit/models/custom_metadata_field.rbi new file mode 100644 index 00000000..eb7b8b93 --- /dev/null +++ b/rbi/imagekit/models/custom_metadata_field.rbi @@ -0,0 +1,414 @@ +# typed: strong + +module Imagekit + module Models + class CustomMetadataField < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any(Imagekit::CustomMetadataField, Imagekit::Internal::AnyHash) + end + + # Unique identifier for the custom metadata field. Use this to update the field. + sig { returns(String) } + attr_accessor :id + + # Human readable name of the custom metadata field. This name is displayed as form + # field label to the users while setting field value on the asset in the media + # library UI. + sig { returns(String) } + attr_accessor :label + + # API name of the custom metadata field. This becomes the key while setting + # `customMetadata` (key-value object) for an asset using upload or update API. + sig { returns(String) } + attr_accessor :name + + # An object that describes the rules for the custom metadata field value. + sig { returns(Imagekit::CustomMetadataField::Schema) } + attr_reader :schema + + sig { params(schema: Imagekit::CustomMetadataField::Schema::OrHash).void } + attr_writer :schema + + # Object containing details of a custom metadata field. + sig do + params( + id: String, + label: String, + name: String, + schema: Imagekit::CustomMetadataField::Schema::OrHash + ).returns(T.attached_class) + end + def self.new( + # Unique identifier for the custom metadata field. Use this to update the field. + id:, + # Human readable name of the custom metadata field. This name is displayed as form + # field label to the users while setting field value on the asset in the media + # library UI. + label:, + # API name of the custom metadata field. This becomes the key while setting + # `customMetadata` (key-value object) for an asset using upload or update API. + name:, + # An object that describes the rules for the custom metadata field value. + schema: + ) + end + + sig do + override.returns( + { + id: String, + label: String, + name: String, + schema: Imagekit::CustomMetadataField::Schema + } + ) + end + def to_hash + end + + class Schema < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::CustomMetadataField::Schema, + Imagekit::Internal::AnyHash + ) + end + + # Type of the custom metadata field. + sig do + returns(Imagekit::CustomMetadataField::Schema::Type::TaggedSymbol) + end + attr_accessor :type + + # The default value for this custom metadata field. Date type of default value + # depends on the field type. + sig do + returns( + T.nilable( + Imagekit::CustomMetadataField::Schema::DefaultValue::Variants + ) + ) + end + attr_reader :default_value + + sig do + params( + default_value: + Imagekit::CustomMetadataField::Schema::DefaultValue::Variants + ).void + end + attr_writer :default_value + + # Specifies if the this custom metadata field is required or not. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :is_value_required + + sig { params(is_value_required: T::Boolean).void } + attr_writer :is_value_required + + # Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. + sig { returns(T.nilable(Float)) } + attr_reader :max_length + + sig { params(max_length: Float).void } + attr_writer :max_length + + # Maximum value of the field. Only set if field type is `Date` or `Number`. For + # `Date` type field, the value will be in ISO8601 string format. For `Number` type + # field, it will be a numeric value. + sig do + returns( + T.nilable(Imagekit::CustomMetadataField::Schema::MaxValue::Variants) + ) + end + attr_reader :max_value + + sig do + params( + max_value: Imagekit::CustomMetadataField::Schema::MaxValue::Variants + ).void + end + attr_writer :max_value + + # Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. + sig { returns(T.nilable(Float)) } + attr_reader :min_length + + sig { params(min_length: Float).void } + attr_writer :min_length + + # Minimum value of the field. Only set if field type is `Date` or `Number`. For + # `Date` type field, the value will be in ISO8601 string format. For `Number` type + # field, it will be a numeric value. + sig do + returns( + T.nilable(Imagekit::CustomMetadataField::Schema::MinValue::Variants) + ) + end + attr_reader :min_value + + sig do + params( + min_value: Imagekit::CustomMetadataField::Schema::MinValue::Variants + ).void + end + attr_writer :min_value + + # An array of allowed values when field type is `SingleSelect` or `MultiSelect`. + sig do + returns( + T.nilable( + T::Array[ + Imagekit::CustomMetadataField::Schema::SelectOption::Variants + ] + ) + ) + end + attr_reader :select_options + + sig do + params( + select_options: + T::Array[ + Imagekit::CustomMetadataField::Schema::SelectOption::Variants + ] + ).void + end + attr_writer :select_options + + # An object that describes the rules for the custom metadata field value. + sig do + params( + type: Imagekit::CustomMetadataField::Schema::Type::OrSymbol, + default_value: + Imagekit::CustomMetadataField::Schema::DefaultValue::Variants, + is_value_required: T::Boolean, + max_length: Float, + max_value: + Imagekit::CustomMetadataField::Schema::MaxValue::Variants, + min_length: Float, + min_value: + Imagekit::CustomMetadataField::Schema::MinValue::Variants, + select_options: + T::Array[ + Imagekit::CustomMetadataField::Schema::SelectOption::Variants + ] + ).returns(T.attached_class) + end + def self.new( + # Type of the custom metadata field. + type:, + # The default value for this custom metadata field. Date type of default value + # depends on the field type. + default_value: nil, + # Specifies if the this custom metadata field is required or not. + is_value_required: nil, + # Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. + max_length: nil, + # Maximum value of the field. Only set if field type is `Date` or `Number`. For + # `Date` type field, the value will be in ISO8601 string format. For `Number` type + # field, it will be a numeric value. + max_value: nil, + # Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. + min_length: nil, + # Minimum value of the field. Only set if field type is `Date` or `Number`. For + # `Date` type field, the value will be in ISO8601 string format. For `Number` type + # field, it will be a numeric value. + min_value: nil, + # An array of allowed values when field type is `SingleSelect` or `MultiSelect`. + select_options: nil + ) + end + + sig do + override.returns( + { + type: Imagekit::CustomMetadataField::Schema::Type::TaggedSymbol, + default_value: + Imagekit::CustomMetadataField::Schema::DefaultValue::Variants, + is_value_required: T::Boolean, + max_length: Float, + max_value: + Imagekit::CustomMetadataField::Schema::MaxValue::Variants, + min_length: Float, + min_value: + Imagekit::CustomMetadataField::Schema::MinValue::Variants, + select_options: + T::Array[ + Imagekit::CustomMetadataField::Schema::SelectOption::Variants + ] + } + ) + end + def to_hash + end + + # Type of the custom metadata field. + module Type + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all(Symbol, Imagekit::CustomMetadataField::Schema::Type) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + TEXT = + T.let( + :Text, + Imagekit::CustomMetadataField::Schema::Type::TaggedSymbol + ) + TEXTAREA = + T.let( + :Textarea, + Imagekit::CustomMetadataField::Schema::Type::TaggedSymbol + ) + NUMBER = + T.let( + :Number, + Imagekit::CustomMetadataField::Schema::Type::TaggedSymbol + ) + DATE = + T.let( + :Date, + Imagekit::CustomMetadataField::Schema::Type::TaggedSymbol + ) + BOOLEAN = + T.let( + :Boolean, + Imagekit::CustomMetadataField::Schema::Type::TaggedSymbol + ) + SINGLE_SELECT = + T.let( + :SingleSelect, + Imagekit::CustomMetadataField::Schema::Type::TaggedSymbol + ) + MULTI_SELECT = + T.let( + :MultiSelect, + Imagekit::CustomMetadataField::Schema::Type::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekit::CustomMetadataField::Schema::Type::TaggedSymbol + ] + ) + end + def self.values + end + end + + # The default value for this custom metadata field. Date type of default value + # depends on the field type. + module DefaultValue + extend Imagekit::Internal::Type::Union + + Variants = + T.type_alias do + T.any( + String, + Float, + T::Boolean, + T::Array[ + Imagekit::CustomMetadataField::Schema::DefaultValue::Mixed::Variants + ] + ) + end + + module Mixed + extend Imagekit::Internal::Type::Union + + Variants = T.type_alias { T.any(String, Float, T::Boolean) } + + sig do + override.returns( + T::Array[ + Imagekit::CustomMetadataField::Schema::DefaultValue::Mixed::Variants + ] + ) + end + def self.variants + end + end + + sig do + override.returns( + T::Array[ + Imagekit::CustomMetadataField::Schema::DefaultValue::Variants + ] + ) + end + def self.variants + end + + MixedArray = + T.let( + Imagekit::Internal::Type::ArrayOf[ + union: + Imagekit::CustomMetadataField::Schema::DefaultValue::Mixed + ], + Imagekit::Internal::Type::Converter + ) + end + + # Maximum value of the field. Only set if field type is `Date` or `Number`. For + # `Date` type field, the value will be in ISO8601 string format. For `Number` type + # field, it will be a numeric value. + module MaxValue + extend Imagekit::Internal::Type::Union + + Variants = T.type_alias { T.any(String, Float) } + + sig do + override.returns( + T::Array[ + Imagekit::CustomMetadataField::Schema::MaxValue::Variants + ] + ) + end + def self.variants + end + end + + # Minimum value of the field. Only set if field type is `Date` or `Number`. For + # `Date` type field, the value will be in ISO8601 string format. For `Number` type + # field, it will be a numeric value. + module MinValue + extend Imagekit::Internal::Type::Union + + Variants = T.type_alias { T.any(String, Float) } + + sig do + override.returns( + T::Array[ + Imagekit::CustomMetadataField::Schema::MinValue::Variants + ] + ) + end + def self.variants + end + end + + module SelectOption + extend Imagekit::Internal::Type::Union + + Variants = T.type_alias { T.any(String, Float, T::Boolean) } + + sig do + override.returns( + T::Array[ + Imagekit::CustomMetadataField::Schema::SelectOption::Variants + ] + ) + end + def self.variants + end + end + end + end + end +end diff --git a/rbi/imagekit/models/custom_metadata_field_create_params.rbi b/rbi/imagekit/models/custom_metadata_field_create_params.rbi new file mode 100644 index 00000000..78abcceb --- /dev/null +++ b/rbi/imagekit/models/custom_metadata_field_create_params.rbi @@ -0,0 +1,443 @@ +# typed: strong + +module Imagekit + module Models + class CustomMetadataFieldCreateParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekit::CustomMetadataFieldCreateParams, + Imagekit::Internal::AnyHash + ) + end + + # Human readable name of the custom metadata field. This should be unique across + # all non deleted custom metadata fields. This name is displayed as form field + # label to the users while setting field value on an asset in the media library + # UI. + sig { returns(String) } + attr_accessor :label + + # API name of the custom metadata field. This should be unique across all + # (including deleted) custom metadata fields. + sig { returns(String) } + attr_accessor :name + + sig { returns(Imagekit::CustomMetadataFieldCreateParams::Schema) } + attr_reader :schema + + sig do + params( + schema: Imagekit::CustomMetadataFieldCreateParams::Schema::OrHash + ).void + end + attr_writer :schema + + sig do + params( + label: String, + name: String, + schema: Imagekit::CustomMetadataFieldCreateParams::Schema::OrHash, + request_options: Imagekit::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # Human readable name of the custom metadata field. This should be unique across + # all non deleted custom metadata fields. This name is displayed as form field + # label to the users while setting field value on an asset in the media library + # UI. + label:, + # API name of the custom metadata field. This should be unique across all + # (including deleted) custom metadata fields. + name:, + schema:, + request_options: {} + ) + end + + sig do + override.returns( + { + label: String, + name: String, + schema: Imagekit::CustomMetadataFieldCreateParams::Schema, + request_options: Imagekit::RequestOptions + } + ) + end + def to_hash + end + + class Schema < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::CustomMetadataFieldCreateParams::Schema, + Imagekit::Internal::AnyHash + ) + end + + # Type of the custom metadata field. + sig do + returns( + Imagekit::CustomMetadataFieldCreateParams::Schema::Type::OrSymbol + ) + end + attr_accessor :type + + # The default value for this custom metadata field. This property is only required + # if `isValueRequired` property is set to `true`. The value should match the + # `type` of custom metadata field. + sig do + returns( + T.nilable( + Imagekit::CustomMetadataFieldCreateParams::Schema::DefaultValue::Variants + ) + ) + end + attr_reader :default_value + + sig do + params( + default_value: + Imagekit::CustomMetadataFieldCreateParams::Schema::DefaultValue::Variants + ).void + end + attr_writer :default_value + + # Sets this custom metadata field as required. Setting custom metadata fields on + # an asset will throw error if the value for all required fields are not present + # in upload or update asset API request body. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :is_value_required + + sig { params(is_value_required: T::Boolean).void } + attr_writer :is_value_required + + # Maximum length of string. Only set this property if `type` is set to `Text` or + # `Textarea`. + sig { returns(T.nilable(Float)) } + attr_reader :max_length + + sig { params(max_length: Float).void } + attr_writer :max_length + + # Maximum value of the field. Only set this property if field type is `Date` or + # `Number`. For `Date` type field, set the minimum date in ISO8601 string format. + # For `Number` type field, set the minimum numeric value. + sig do + returns( + T.nilable( + Imagekit::CustomMetadataFieldCreateParams::Schema::MaxValue::Variants + ) + ) + end + attr_reader :max_value + + sig do + params( + max_value: + Imagekit::CustomMetadataFieldCreateParams::Schema::MaxValue::Variants + ).void + end + attr_writer :max_value + + # Minimum length of string. Only set this property if `type` is set to `Text` or + # `Textarea`. + sig { returns(T.nilable(Float)) } + attr_reader :min_length + + sig { params(min_length: Float).void } + attr_writer :min_length + + # Minimum value of the field. Only set this property if field type is `Date` or + # `Number`. For `Date` type field, set the minimum date in ISO8601 string format. + # For `Number` type field, set the minimum numeric value. + sig do + returns( + T.nilable( + Imagekit::CustomMetadataFieldCreateParams::Schema::MinValue::Variants + ) + ) + end + attr_reader :min_value + + sig do + params( + min_value: + Imagekit::CustomMetadataFieldCreateParams::Schema::MinValue::Variants + ).void + end + attr_writer :min_value + + # An array of allowed values. This property is only required if `type` property is + # set to `SingleSelect` or `MultiSelect`. + sig do + returns( + T.nilable( + T::Array[ + Imagekit::CustomMetadataFieldCreateParams::Schema::SelectOption::Variants + ] + ) + ) + end + attr_reader :select_options + + sig do + params( + select_options: + T::Array[ + Imagekit::CustomMetadataFieldCreateParams::Schema::SelectOption::Variants + ] + ).void + end + attr_writer :select_options + + sig do + params( + type: + Imagekit::CustomMetadataFieldCreateParams::Schema::Type::OrSymbol, + default_value: + Imagekit::CustomMetadataFieldCreateParams::Schema::DefaultValue::Variants, + is_value_required: T::Boolean, + max_length: Float, + max_value: + Imagekit::CustomMetadataFieldCreateParams::Schema::MaxValue::Variants, + min_length: Float, + min_value: + Imagekit::CustomMetadataFieldCreateParams::Schema::MinValue::Variants, + select_options: + T::Array[ + Imagekit::CustomMetadataFieldCreateParams::Schema::SelectOption::Variants + ] + ).returns(T.attached_class) + end + def self.new( + # Type of the custom metadata field. + type:, + # The default value for this custom metadata field. This property is only required + # if `isValueRequired` property is set to `true`. The value should match the + # `type` of custom metadata field. + default_value: nil, + # Sets this custom metadata field as required. Setting custom metadata fields on + # an asset will throw error if the value for all required fields are not present + # in upload or update asset API request body. + is_value_required: nil, + # Maximum length of string. Only set this property if `type` is set to `Text` or + # `Textarea`. + max_length: nil, + # Maximum value of the field. Only set this property if field type is `Date` or + # `Number`. For `Date` type field, set the minimum date in ISO8601 string format. + # For `Number` type field, set the minimum numeric value. + max_value: nil, + # Minimum length of string. Only set this property if `type` is set to `Text` or + # `Textarea`. + min_length: nil, + # Minimum value of the field. Only set this property if field type is `Date` or + # `Number`. For `Date` type field, set the minimum date in ISO8601 string format. + # For `Number` type field, set the minimum numeric value. + min_value: nil, + # An array of allowed values. This property is only required if `type` property is + # set to `SingleSelect` or `MultiSelect`. + select_options: nil + ) + end + + sig do + override.returns( + { + type: + Imagekit::CustomMetadataFieldCreateParams::Schema::Type::OrSymbol, + default_value: + Imagekit::CustomMetadataFieldCreateParams::Schema::DefaultValue::Variants, + is_value_required: T::Boolean, + max_length: Float, + max_value: + Imagekit::CustomMetadataFieldCreateParams::Schema::MaxValue::Variants, + min_length: Float, + min_value: + Imagekit::CustomMetadataFieldCreateParams::Schema::MinValue::Variants, + select_options: + T::Array[ + Imagekit::CustomMetadataFieldCreateParams::Schema::SelectOption::Variants + ] + } + ) + end + def to_hash + end + + # Type of the custom metadata field. + module Type + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekit::CustomMetadataFieldCreateParams::Schema::Type + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + TEXT = + T.let( + :Text, + Imagekit::CustomMetadataFieldCreateParams::Schema::Type::TaggedSymbol + ) + TEXTAREA = + T.let( + :Textarea, + Imagekit::CustomMetadataFieldCreateParams::Schema::Type::TaggedSymbol + ) + NUMBER = + T.let( + :Number, + Imagekit::CustomMetadataFieldCreateParams::Schema::Type::TaggedSymbol + ) + DATE = + T.let( + :Date, + Imagekit::CustomMetadataFieldCreateParams::Schema::Type::TaggedSymbol + ) + BOOLEAN = + T.let( + :Boolean, + Imagekit::CustomMetadataFieldCreateParams::Schema::Type::TaggedSymbol + ) + SINGLE_SELECT = + T.let( + :SingleSelect, + Imagekit::CustomMetadataFieldCreateParams::Schema::Type::TaggedSymbol + ) + MULTI_SELECT = + T.let( + :MultiSelect, + Imagekit::CustomMetadataFieldCreateParams::Schema::Type::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekit::CustomMetadataFieldCreateParams::Schema::Type::TaggedSymbol + ] + ) + end + def self.values + end + end + + # The default value for this custom metadata field. This property is only required + # if `isValueRequired` property is set to `true`. The value should match the + # `type` of custom metadata field. + module DefaultValue + extend Imagekit::Internal::Type::Union + + Variants = + T.type_alias do + T.any( + String, + Float, + T::Boolean, + T::Array[ + Imagekit::CustomMetadataFieldCreateParams::Schema::DefaultValue::Mixed::Variants + ] + ) + end + + module Mixed + extend Imagekit::Internal::Type::Union + + Variants = T.type_alias { T.any(String, Float, T::Boolean) } + + sig do + override.returns( + T::Array[ + Imagekit::CustomMetadataFieldCreateParams::Schema::DefaultValue::Mixed::Variants + ] + ) + end + def self.variants + end + end + + sig do + override.returns( + T::Array[ + Imagekit::CustomMetadataFieldCreateParams::Schema::DefaultValue::Variants + ] + ) + end + def self.variants + end + + MixedArray = + T.let( + Imagekit::Internal::Type::ArrayOf[ + union: + Imagekit::CustomMetadataFieldCreateParams::Schema::DefaultValue::Mixed + ], + Imagekit::Internal::Type::Converter + ) + end + + # Maximum value of the field. Only set this property if field type is `Date` or + # `Number`. For `Date` type field, set the minimum date in ISO8601 string format. + # For `Number` type field, set the minimum numeric value. + module MaxValue + extend Imagekit::Internal::Type::Union + + Variants = T.type_alias { T.any(String, Float) } + + sig do + override.returns( + T::Array[ + Imagekit::CustomMetadataFieldCreateParams::Schema::MaxValue::Variants + ] + ) + end + def self.variants + end + end + + # Minimum value of the field. Only set this property if field type is `Date` or + # `Number`. For `Date` type field, set the minimum date in ISO8601 string format. + # For `Number` type field, set the minimum numeric value. + module MinValue + extend Imagekit::Internal::Type::Union + + Variants = T.type_alias { T.any(String, Float) } + + sig do + override.returns( + T::Array[ + Imagekit::CustomMetadataFieldCreateParams::Schema::MinValue::Variants + ] + ) + end + def self.variants + end + end + + module SelectOption + extend Imagekit::Internal::Type::Union + + Variants = T.type_alias { T.any(String, Float, T::Boolean) } + + sig do + override.returns( + T::Array[ + Imagekit::CustomMetadataFieldCreateParams::Schema::SelectOption::Variants + ] + ) + end + def self.variants + end + end + end + end + end +end diff --git a/rbi/imagekit/models/custom_metadata_field_delete_params.rbi b/rbi/imagekit/models/custom_metadata_field_delete_params.rbi new file mode 100644 index 00000000..677f0d13 --- /dev/null +++ b/rbi/imagekit/models/custom_metadata_field_delete_params.rbi @@ -0,0 +1,30 @@ +# typed: strong + +module Imagekit + module Models + class CustomMetadataFieldDeleteParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekit::CustomMetadataFieldDeleteParams, + Imagekit::Internal::AnyHash + ) + end + + sig do + params(request_options: Imagekit::RequestOptions::OrHash).returns( + T.attached_class + ) + end + def self.new(request_options: {}) + end + + sig { override.returns({ request_options: Imagekit::RequestOptions }) } + def to_hash + end + end + end +end diff --git a/rbi/imagekit/models/custom_metadata_field_delete_response.rbi b/rbi/imagekit/models/custom_metadata_field_delete_response.rbi new file mode 100644 index 00000000..1e9c8a3f --- /dev/null +++ b/rbi/imagekit/models/custom_metadata_field_delete_response.rbi @@ -0,0 +1,23 @@ +# typed: strong + +module Imagekit + module Models + class CustomMetadataFieldDeleteResponse < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Models::CustomMetadataFieldDeleteResponse, + Imagekit::Internal::AnyHash + ) + end + + sig { returns(T.attached_class) } + def self.new + end + + sig { override.returns({}) } + def to_hash + end + end + end +end diff --git a/rbi/imagekit/models/custom_metadata_field_list_params.rbi b/rbi/imagekit/models/custom_metadata_field_list_params.rbi new file mode 100644 index 00000000..db9f7dac --- /dev/null +++ b/rbi/imagekit/models/custom_metadata_field_list_params.rbi @@ -0,0 +1,49 @@ +# typed: strong + +module Imagekit + module Models + class CustomMetadataFieldListParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekit::CustomMetadataFieldListParams, + Imagekit::Internal::AnyHash + ) + end + + # Set it to `true` to include deleted field objects in the API response. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :include_deleted + + sig { params(include_deleted: T::Boolean).void } + attr_writer :include_deleted + + sig do + params( + include_deleted: T::Boolean, + request_options: Imagekit::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # Set it to `true` to include deleted field objects in the API response. + include_deleted: nil, + request_options: {} + ) + end + + sig do + override.returns( + { + include_deleted: T::Boolean, + request_options: Imagekit::RequestOptions + } + ) + end + def to_hash + end + end + end +end diff --git a/rbi/imagekit/models/custom_metadata_field_list_response.rbi b/rbi/imagekit/models/custom_metadata_field_list_response.rbi new file mode 100644 index 00000000..ca0368f0 --- /dev/null +++ b/rbi/imagekit/models/custom_metadata_field_list_response.rbi @@ -0,0 +1,11 @@ +# typed: strong + +module Imagekit + module Models + CustomMetadataFieldListResponse = + T.let( + Imagekit::Internal::Type::ArrayOf[Imagekit::CustomMetadataField], + Imagekit::Internal::Type::Converter + ) + end +end diff --git a/rbi/imagekit/models/custom_metadata_field_update_params.rbi b/rbi/imagekit/models/custom_metadata_field_update_params.rbi new file mode 100644 index 00000000..d94d36f6 --- /dev/null +++ b/rbi/imagekit/models/custom_metadata_field_update_params.rbi @@ -0,0 +1,376 @@ +# typed: strong + +module Imagekit + module Models + class CustomMetadataFieldUpdateParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekit::CustomMetadataFieldUpdateParams, + Imagekit::Internal::AnyHash + ) + end + + # Human readable name of the custom metadata field. This should be unique across + # all non deleted custom metadata fields. This name is displayed as form field + # label to the users while setting field value on an asset in the media library + # UI. This parameter is required if `schema` is not provided. + sig { returns(T.nilable(String)) } + attr_reader :label + + sig { params(label: String).void } + attr_writer :label + + # An object that describes the rules for the custom metadata key. This parameter + # is required if `label` is not provided. Note: `type` cannot be updated and will + # be ignored if sent with the `schema`. The schema will be validated as per the + # existing `type`. + sig do + returns(T.nilable(Imagekit::CustomMetadataFieldUpdateParams::Schema)) + end + attr_reader :schema + + sig do + params( + schema: Imagekit::CustomMetadataFieldUpdateParams::Schema::OrHash + ).void + end + attr_writer :schema + + sig do + params( + label: String, + schema: Imagekit::CustomMetadataFieldUpdateParams::Schema::OrHash, + request_options: Imagekit::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # Human readable name of the custom metadata field. This should be unique across + # all non deleted custom metadata fields. This name is displayed as form field + # label to the users while setting field value on an asset in the media library + # UI. This parameter is required if `schema` is not provided. + label: nil, + # An object that describes the rules for the custom metadata key. This parameter + # is required if `label` is not provided. Note: `type` cannot be updated and will + # be ignored if sent with the `schema`. The schema will be validated as per the + # existing `type`. + schema: nil, + request_options: {} + ) + end + + sig do + override.returns( + { + label: String, + schema: Imagekit::CustomMetadataFieldUpdateParams::Schema, + request_options: Imagekit::RequestOptions + } + ) + end + def to_hash + end + + class Schema < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::CustomMetadataFieldUpdateParams::Schema, + Imagekit::Internal::AnyHash + ) + end + + # The default value for this custom metadata field. This property is only required + # if `isValueRequired` property is set to `true`. The value should match the + # `type` of custom metadata field. + sig do + returns( + T.nilable( + Imagekit::CustomMetadataFieldUpdateParams::Schema::DefaultValue::Variants + ) + ) + end + attr_reader :default_value + + sig do + params( + default_value: + Imagekit::CustomMetadataFieldUpdateParams::Schema::DefaultValue::Variants + ).void + end + attr_writer :default_value + + # Sets this custom metadata field as required. Setting custom metadata fields on + # an asset will throw error if the value for all required fields are not present + # in upload or update asset API request body. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :is_value_required + + sig { params(is_value_required: T::Boolean).void } + attr_writer :is_value_required + + # Maximum length of string. Only set this property if `type` is set to `Text` or + # `Textarea`. + sig { returns(T.nilable(Float)) } + attr_reader :max_length + + sig { params(max_length: Float).void } + attr_writer :max_length + + # Maximum value of the field. Only set this property if field type is `Date` or + # `Number`. For `Date` type field, set the minimum date in ISO8601 string format. + # For `Number` type field, set the minimum numeric value. + sig do + returns( + T.nilable( + Imagekit::CustomMetadataFieldUpdateParams::Schema::MaxValue::Variants + ) + ) + end + attr_reader :max_value + + sig do + params( + max_value: + Imagekit::CustomMetadataFieldUpdateParams::Schema::MaxValue::Variants + ).void + end + attr_writer :max_value + + # Minimum length of string. Only set this property if `type` is set to `Text` or + # `Textarea`. + sig { returns(T.nilable(Float)) } + attr_reader :min_length + + sig { params(min_length: Float).void } + attr_writer :min_length + + # Minimum value of the field. Only set this property if field type is `Date` or + # `Number`. For `Date` type field, set the minimum date in ISO8601 string format. + # For `Number` type field, set the minimum numeric value. + sig do + returns( + T.nilable( + Imagekit::CustomMetadataFieldUpdateParams::Schema::MinValue::Variants + ) + ) + end + attr_reader :min_value + + sig do + params( + min_value: + Imagekit::CustomMetadataFieldUpdateParams::Schema::MinValue::Variants + ).void + end + attr_writer :min_value + + # An array of allowed values. This property is only required if `type` property is + # set to `SingleSelect` or `MultiSelect`. + sig do + returns( + T.nilable( + T::Array[ + Imagekit::CustomMetadataFieldUpdateParams::Schema::SelectOption::Variants + ] + ) + ) + end + attr_reader :select_options + + sig do + params( + select_options: + T::Array[ + Imagekit::CustomMetadataFieldUpdateParams::Schema::SelectOption::Variants + ] + ).void + end + attr_writer :select_options + + # An object that describes the rules for the custom metadata key. This parameter + # is required if `label` is not provided. Note: `type` cannot be updated and will + # be ignored if sent with the `schema`. The schema will be validated as per the + # existing `type`. + sig do + params( + default_value: + Imagekit::CustomMetadataFieldUpdateParams::Schema::DefaultValue::Variants, + is_value_required: T::Boolean, + max_length: Float, + max_value: + Imagekit::CustomMetadataFieldUpdateParams::Schema::MaxValue::Variants, + min_length: Float, + min_value: + Imagekit::CustomMetadataFieldUpdateParams::Schema::MinValue::Variants, + select_options: + T::Array[ + Imagekit::CustomMetadataFieldUpdateParams::Schema::SelectOption::Variants + ] + ).returns(T.attached_class) + end + def self.new( + # The default value for this custom metadata field. This property is only required + # if `isValueRequired` property is set to `true`. The value should match the + # `type` of custom metadata field. + default_value: nil, + # Sets this custom metadata field as required. Setting custom metadata fields on + # an asset will throw error if the value for all required fields are not present + # in upload or update asset API request body. + is_value_required: nil, + # Maximum length of string. Only set this property if `type` is set to `Text` or + # `Textarea`. + max_length: nil, + # Maximum value of the field. Only set this property if field type is `Date` or + # `Number`. For `Date` type field, set the minimum date in ISO8601 string format. + # For `Number` type field, set the minimum numeric value. + max_value: nil, + # Minimum length of string. Only set this property if `type` is set to `Text` or + # `Textarea`. + min_length: nil, + # Minimum value of the field. Only set this property if field type is `Date` or + # `Number`. For `Date` type field, set the minimum date in ISO8601 string format. + # For `Number` type field, set the minimum numeric value. + min_value: nil, + # An array of allowed values. This property is only required if `type` property is + # set to `SingleSelect` or `MultiSelect`. + select_options: nil + ) + end + + sig do + override.returns( + { + default_value: + Imagekit::CustomMetadataFieldUpdateParams::Schema::DefaultValue::Variants, + is_value_required: T::Boolean, + max_length: Float, + max_value: + Imagekit::CustomMetadataFieldUpdateParams::Schema::MaxValue::Variants, + min_length: Float, + min_value: + Imagekit::CustomMetadataFieldUpdateParams::Schema::MinValue::Variants, + select_options: + T::Array[ + Imagekit::CustomMetadataFieldUpdateParams::Schema::SelectOption::Variants + ] + } + ) + end + def to_hash + end + + # The default value for this custom metadata field. This property is only required + # if `isValueRequired` property is set to `true`. The value should match the + # `type` of custom metadata field. + module DefaultValue + extend Imagekit::Internal::Type::Union + + Variants = + T.type_alias do + T.any( + String, + Float, + T::Boolean, + T::Array[ + Imagekit::CustomMetadataFieldUpdateParams::Schema::DefaultValue::Mixed::Variants + ] + ) + end + + module Mixed + extend Imagekit::Internal::Type::Union + + Variants = T.type_alias { T.any(String, Float, T::Boolean) } + + sig do + override.returns( + T::Array[ + Imagekit::CustomMetadataFieldUpdateParams::Schema::DefaultValue::Mixed::Variants + ] + ) + end + def self.variants + end + end + + sig do + override.returns( + T::Array[ + Imagekit::CustomMetadataFieldUpdateParams::Schema::DefaultValue::Variants + ] + ) + end + def self.variants + end + + MixedArray = + T.let( + Imagekit::Internal::Type::ArrayOf[ + union: + Imagekit::CustomMetadataFieldUpdateParams::Schema::DefaultValue::Mixed + ], + Imagekit::Internal::Type::Converter + ) + end + + # Maximum value of the field. Only set this property if field type is `Date` or + # `Number`. For `Date` type field, set the minimum date in ISO8601 string format. + # For `Number` type field, set the minimum numeric value. + module MaxValue + extend Imagekit::Internal::Type::Union + + Variants = T.type_alias { T.any(String, Float) } + + sig do + override.returns( + T::Array[ + Imagekit::CustomMetadataFieldUpdateParams::Schema::MaxValue::Variants + ] + ) + end + def self.variants + end + end + + # Minimum value of the field. Only set this property if field type is `Date` or + # `Number`. For `Date` type field, set the minimum date in ISO8601 string format. + # For `Number` type field, set the minimum numeric value. + module MinValue + extend Imagekit::Internal::Type::Union + + Variants = T.type_alias { T.any(String, Float) } + + sig do + override.returns( + T::Array[ + Imagekit::CustomMetadataFieldUpdateParams::Schema::MinValue::Variants + ] + ) + end + def self.variants + end + end + + module SelectOption + extend Imagekit::Internal::Type::Union + + Variants = T.type_alias { T.any(String, Float, T::Boolean) } + + sig do + override.returns( + T::Array[ + Imagekit::CustomMetadataFieldUpdateParams::Schema::SelectOption::Variants + ] + ) + end + def self.variants + end + end + end + end + end +end diff --git a/rbi/imagekit/models/extensions.rbi b/rbi/imagekit/models/extensions.rbi new file mode 100644 index 00000000..46f00ece --- /dev/null +++ b/rbi/imagekit/models/extensions.rbi @@ -0,0 +1,268 @@ +# typed: strong + +module Imagekit + module Models + module ExtensionItem + extend Imagekit::Internal::Type::Union + + Variants = + T.type_alias do + T.any( + Imagekit::ExtensionItem::RemoveBg, + Imagekit::ExtensionItem::AIAutoDescription, + Imagekit::ExtensionItem::AutoTaggingExtension + ) + end + + class RemoveBg < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::ExtensionItem::RemoveBg, + Imagekit::Internal::AnyHash + ) + end + + # Specifies the background removal extension. + sig { returns(Symbol) } + attr_accessor :name + + sig { returns(T.nilable(Imagekit::ExtensionItem::RemoveBg::Options)) } + attr_reader :options + + sig do + params( + options: Imagekit::ExtensionItem::RemoveBg::Options::OrHash + ).void + end + attr_writer :options + + sig do + params( + options: Imagekit::ExtensionItem::RemoveBg::Options::OrHash, + name: Symbol + ).returns(T.attached_class) + end + def self.new( + options: nil, + # Specifies the background removal extension. + name: :"remove-bg" + ) + end + + sig do + override.returns( + { + name: Symbol, + options: Imagekit::ExtensionItem::RemoveBg::Options + } + ) + end + def to_hash + end + + class Options < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::ExtensionItem::RemoveBg::Options, + Imagekit::Internal::AnyHash + ) + end + + # Whether to add an artificial shadow to the result. Default is false. Note: + # Adding shadows is currently only supported for car photos. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :add_shadow + + sig { params(add_shadow: T::Boolean).void } + attr_writer :add_shadow + + # Specifies a solid color background using hex code (e.g., "81d4fa", "fff") or + # color name (e.g., "green"). If this parameter is set, `bg_image_url` must be + # empty. + sig { returns(T.nilable(String)) } + attr_reader :bg_color + + sig { params(bg_color: String).void } + attr_writer :bg_color + + # Sets a background image from a URL. If this parameter is set, `bg_color` must be + # empty. + sig { returns(T.nilable(String)) } + attr_reader :bg_image_url + + sig { params(bg_image_url: String).void } + attr_writer :bg_image_url + + # Allows semi-transparent regions in the result. Default is true. Note: + # Semitransparency is currently only supported for car windows. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :semitransparency + + sig { params(semitransparency: T::Boolean).void } + attr_writer :semitransparency + + sig do + params( + add_shadow: T::Boolean, + bg_color: String, + bg_image_url: String, + semitransparency: T::Boolean + ).returns(T.attached_class) + end + def self.new( + # Whether to add an artificial shadow to the result. Default is false. Note: + # Adding shadows is currently only supported for car photos. + add_shadow: nil, + # Specifies a solid color background using hex code (e.g., "81d4fa", "fff") or + # color name (e.g., "green"). If this parameter is set, `bg_image_url` must be + # empty. + bg_color: nil, + # Sets a background image from a URL. If this parameter is set, `bg_color` must be + # empty. + bg_image_url: nil, + # Allows semi-transparent regions in the result. Default is true. Note: + # Semitransparency is currently only supported for car windows. + semitransparency: nil + ) + end + + sig do + override.returns( + { + add_shadow: T::Boolean, + bg_color: String, + bg_image_url: String, + semitransparency: T::Boolean + } + ) + end + def to_hash + end + end + end + + class AutoTaggingExtension < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::ExtensionItem::AutoTaggingExtension, + Imagekit::Internal::AnyHash + ) + end + + # Maximum number of tags to attach to the asset. + sig { returns(Integer) } + attr_accessor :max_tags + + # Minimum confidence level for tags to be considered valid. + sig { returns(Integer) } + attr_accessor :min_confidence + + # Specifies the auto-tagging extension used. + sig do + returns(Imagekit::ExtensionItem::AutoTaggingExtension::Name::OrSymbol) + end + attr_accessor :name + + sig do + params( + max_tags: Integer, + min_confidence: Integer, + name: Imagekit::ExtensionItem::AutoTaggingExtension::Name::OrSymbol + ).returns(T.attached_class) + end + def self.new( + # Maximum number of tags to attach to the asset. + max_tags:, + # Minimum confidence level for tags to be considered valid. + min_confidence:, + # Specifies the auto-tagging extension used. + name: + ) + end + + sig do + override.returns( + { + max_tags: Integer, + min_confidence: Integer, + name: + Imagekit::ExtensionItem::AutoTaggingExtension::Name::OrSymbol + } + ) + end + def to_hash + end + + # Specifies the auto-tagging extension used. + module Name + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all(Symbol, Imagekit::ExtensionItem::AutoTaggingExtension::Name) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + GOOGLE_AUTO_TAGGING = + T.let( + :"google-auto-tagging", + Imagekit::ExtensionItem::AutoTaggingExtension::Name::TaggedSymbol + ) + AWS_AUTO_TAGGING = + T.let( + :"aws-auto-tagging", + Imagekit::ExtensionItem::AutoTaggingExtension::Name::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekit::ExtensionItem::AutoTaggingExtension::Name::TaggedSymbol + ] + ) + end + def self.values + end + end + end + + class AIAutoDescription < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::ExtensionItem::AIAutoDescription, + Imagekit::Internal::AnyHash + ) + end + + # Specifies the auto description extension. + sig { returns(Symbol) } + attr_accessor :name + + sig { params(name: Symbol).returns(T.attached_class) } + def self.new( + # Specifies the auto description extension. + name: :"ai-auto-description" + ) + end + + sig { override.returns({ name: Symbol }) } + def to_hash + end + end + + sig { override.returns(T::Array[Imagekit::ExtensionItem::Variants]) } + def self.variants + end + end + + Extensions = + T.let( + Imagekit::Internal::Type::ArrayOf[union: Imagekit::ExtensionItem], + Imagekit::Internal::Type::Converter + ) + end +end diff --git a/rbi/imagekit/models/file.rbi b/rbi/imagekit/models/file.rbi new file mode 100644 index 00000000..4d68e344 --- /dev/null +++ b/rbi/imagekit/models/file.rbi @@ -0,0 +1,379 @@ +# typed: strong + +module Imagekit + module Models + class File < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias { T.any(Imagekit::File, Imagekit::Internal::AnyHash) } + + # An array of tags assigned to the file by auto tagging. + sig { returns(T.nilable(T::Array[Imagekit::File::AITag])) } + attr_accessor :ai_tags + + # Date and time when the file was uploaded. The date and time is in ISO8601 + # format. + sig { returns(T.nilable(Time)) } + attr_reader :created_at + + sig { params(created_at: Time).void } + attr_writer :created_at + + # An string with custom coordinates of the file. + sig { returns(T.nilable(String)) } + attr_accessor :custom_coordinates + + # An object with custom metadata for the file. + sig { returns(T.nilable(T::Hash[Symbol, T.anything])) } + attr_reader :custom_metadata + + sig { params(custom_metadata: T::Hash[Symbol, T.anything]).void } + attr_writer :custom_metadata + + # Optional text to describe the contents of the file. Can be set by the user or + # the ai-auto-description extension. + sig { returns(T.nilable(String)) } + attr_reader :description + + sig { params(description: String).void } + attr_writer :description + + # Unique identifier of the asset. + sig { returns(T.nilable(String)) } + attr_reader :file_id + + sig { params(file_id: String).void } + attr_writer :file_id + + # Path of the file. This is the path you would use in the URL to access the file. + # For example, if the file is at the root of the media library, the path will be + # `/file.jpg`. If the file is inside a folder named `images`, the path will be + # `/images/file.jpg`. + sig { returns(T.nilable(String)) } + attr_reader :file_path + + sig { params(file_path: String).void } + attr_writer :file_path + + # Type of the file. Possible values are `image`, `non-image`. + sig { returns(T.nilable(String)) } + attr_reader :file_type + + sig { params(file_type: String).void } + attr_writer :file_type + + # Specifies if the image has an alpha channel. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :has_alpha + + sig { params(has_alpha: T::Boolean).void } + attr_writer :has_alpha + + # Height of the file. + sig { returns(T.nilable(Float)) } + attr_reader :height + + sig { params(height: Float).void } + attr_writer :height + + # Specifies if the file is private or not. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :is_private_file + + sig { params(is_private_file: T::Boolean).void } + attr_writer :is_private_file + + # Specifies if the file is published or not. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :is_published + + sig { params(is_published: T::Boolean).void } + attr_writer :is_published + + # MIME type of the file. + sig { returns(T.nilable(String)) } + attr_reader :mime + + sig { params(mime: String).void } + attr_writer :mime + + # Name of the asset. + sig { returns(T.nilable(String)) } + attr_reader :name + + sig { params(name: String).void } + attr_writer :name + + # Size of the file in bytes. + sig { returns(T.nilable(Float)) } + attr_reader :size + + sig { params(size: Float).void } + attr_writer :size + + # An array of tags assigned to the file. Tags are used to search files in the + # media library. + sig { returns(T.nilable(T::Array[String])) } + attr_accessor :tags + + # URL of the thumbnail image. This URL is used to access the thumbnail image of + # the file in the media library. + sig { returns(T.nilable(String)) } + attr_reader :thumbnail + + sig { params(thumbnail: String).void } + attr_writer :thumbnail + + # Type of the asset. + sig { returns(T.nilable(Imagekit::File::Type::TaggedSymbol)) } + attr_reader :type + + sig { params(type: Imagekit::File::Type::OrSymbol).void } + attr_writer :type + + # Date and time when the file was last updated. The date and time is in ISO8601 + # format. + sig { returns(T.nilable(Time)) } + attr_reader :updated_at + + sig { params(updated_at: Time).void } + attr_writer :updated_at + + # URL of the file. + sig { returns(T.nilable(String)) } + attr_reader :url + + sig { params(url: String).void } + attr_writer :url + + # An object with details of the file version. + sig { returns(T.nilable(Imagekit::File::VersionInfo)) } + attr_reader :version_info + + sig { params(version_info: Imagekit::File::VersionInfo::OrHash).void } + attr_writer :version_info + + # Width of the file. + sig { returns(T.nilable(Float)) } + attr_reader :width + + sig { params(width: Float).void } + attr_writer :width + + # Object containing details of a file or file version. + sig do + params( + ai_tags: T.nilable(T::Array[Imagekit::File::AITag::OrHash]), + created_at: Time, + custom_coordinates: T.nilable(String), + custom_metadata: T::Hash[Symbol, T.anything], + description: String, + file_id: String, + file_path: String, + file_type: String, + has_alpha: T::Boolean, + height: Float, + is_private_file: T::Boolean, + is_published: T::Boolean, + mime: String, + name: String, + size: Float, + tags: T.nilable(T::Array[String]), + thumbnail: String, + type: Imagekit::File::Type::OrSymbol, + updated_at: Time, + url: String, + version_info: Imagekit::File::VersionInfo::OrHash, + width: Float + ).returns(T.attached_class) + end + def self.new( + # An array of tags assigned to the file by auto tagging. + ai_tags: nil, + # Date and time when the file was uploaded. The date and time is in ISO8601 + # format. + created_at: nil, + # An string with custom coordinates of the file. + custom_coordinates: nil, + # An object with custom metadata for the file. + custom_metadata: nil, + # Optional text to describe the contents of the file. Can be set by the user or + # the ai-auto-description extension. + description: nil, + # Unique identifier of the asset. + file_id: nil, + # Path of the file. This is the path you would use in the URL to access the file. + # For example, if the file is at the root of the media library, the path will be + # `/file.jpg`. If the file is inside a folder named `images`, the path will be + # `/images/file.jpg`. + file_path: nil, + # Type of the file. Possible values are `image`, `non-image`. + file_type: nil, + # Specifies if the image has an alpha channel. + has_alpha: nil, + # Height of the file. + height: nil, + # Specifies if the file is private or not. + is_private_file: nil, + # Specifies if the file is published or not. + is_published: nil, + # MIME type of the file. + mime: nil, + # Name of the asset. + name: nil, + # Size of the file in bytes. + size: nil, + # An array of tags assigned to the file. Tags are used to search files in the + # media library. + tags: nil, + # URL of the thumbnail image. This URL is used to access the thumbnail image of + # the file in the media library. + thumbnail: nil, + # Type of the asset. + type: nil, + # Date and time when the file was last updated. The date and time is in ISO8601 + # format. + updated_at: nil, + # URL of the file. + url: nil, + # An object with details of the file version. + version_info: nil, + # Width of the file. + width: nil + ) + end + + sig do + override.returns( + { + ai_tags: T.nilable(T::Array[Imagekit::File::AITag]), + created_at: Time, + custom_coordinates: T.nilable(String), + custom_metadata: T::Hash[Symbol, T.anything], + description: String, + file_id: String, + file_path: String, + file_type: String, + has_alpha: T::Boolean, + height: Float, + is_private_file: T::Boolean, + is_published: T::Boolean, + mime: String, + name: String, + size: Float, + tags: T.nilable(T::Array[String]), + thumbnail: String, + type: Imagekit::File::Type::TaggedSymbol, + updated_at: Time, + url: String, + version_info: Imagekit::File::VersionInfo, + width: Float + } + ) + end + def to_hash + end + + class AITag < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any(Imagekit::File::AITag, Imagekit::Internal::AnyHash) + end + + # Confidence score of the tag. + sig { returns(T.nilable(Float)) } + attr_reader :confidence + + sig { params(confidence: Float).void } + attr_writer :confidence + + # Name of the tag. + sig { returns(T.nilable(String)) } + attr_reader :name + + sig { params(name: String).void } + attr_writer :name + + # Source of the tag. Possible values are `google-auto-tagging` and + # `aws-auto-tagging`. + sig { returns(T.nilable(String)) } + attr_reader :source + + sig { params(source: String).void } + attr_writer :source + + sig do + params(confidence: Float, name: String, source: String).returns( + T.attached_class + ) + end + def self.new( + # Confidence score of the tag. + confidence: nil, + # Name of the tag. + name: nil, + # Source of the tag. Possible values are `google-auto-tagging` and + # `aws-auto-tagging`. + source: nil + ) + end + + sig do + override.returns({ confidence: Float, name: String, source: String }) + end + def to_hash + end + end + + # Type of the asset. + module Type + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, Imagekit::File::Type) } + OrSymbol = T.type_alias { T.any(Symbol, String) } + + FILE = T.let(:file, Imagekit::File::Type::TaggedSymbol) + FILE_VERSION = + T.let(:"file-version", Imagekit::File::Type::TaggedSymbol) + + sig { override.returns(T::Array[Imagekit::File::Type::TaggedSymbol]) } + def self.values + end + end + + class VersionInfo < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any(Imagekit::File::VersionInfo, Imagekit::Internal::AnyHash) + end + + # Unique identifier of the file version. + sig { returns(T.nilable(String)) } + attr_reader :id + + sig { params(id: String).void } + attr_writer :id + + # Name of the file version. + sig { returns(T.nilable(String)) } + attr_reader :name + + sig { params(name: String).void } + attr_writer :name + + # An object with details of the file version. + sig { params(id: String, name: String).returns(T.attached_class) } + def self.new( + # Unique identifier of the file version. + id: nil, + # Name of the file version. + name: nil + ) + end + + sig { override.returns({ id: String, name: String }) } + def to_hash + end + end + end + end +end diff --git a/rbi/imagekit/models/file_copy_params.rbi b/rbi/imagekit/models/file_copy_params.rbi new file mode 100644 index 00000000..61987f96 --- /dev/null +++ b/rbi/imagekit/models/file_copy_params.rbi @@ -0,0 +1,66 @@ +# typed: strong + +module Imagekit + module Models + class FileCopyParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any(Imagekit::FileCopyParams, Imagekit::Internal::AnyHash) + end + + # Full path to the folder you want to copy the above file into. + sig { returns(String) } + attr_accessor :destination_path + + # The full path of the file you want to copy. + sig { returns(String) } + attr_accessor :source_file_path + + # Option to copy all versions of a file. By default, only the current version of + # the file is copied. When set to true, all versions of the file will be copied. + # Default value - `false`. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :include_file_versions + + sig { params(include_file_versions: T::Boolean).void } + attr_writer :include_file_versions + + sig do + params( + destination_path: String, + source_file_path: String, + include_file_versions: T::Boolean, + request_options: Imagekit::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # Full path to the folder you want to copy the above file into. + destination_path:, + # The full path of the file you want to copy. + source_file_path:, + # Option to copy all versions of a file. By default, only the current version of + # the file is copied. When set to true, all versions of the file will be copied. + # Default value - `false`. + include_file_versions: nil, + request_options: {} + ) + end + + sig do + override.returns( + { + destination_path: String, + source_file_path: String, + include_file_versions: T::Boolean, + request_options: Imagekit::RequestOptions + } + ) + end + def to_hash + end + end + end +end diff --git a/rbi/imagekit/models/file_copy_response.rbi b/rbi/imagekit/models/file_copy_response.rbi new file mode 100644 index 00000000..74ff699c --- /dev/null +++ b/rbi/imagekit/models/file_copy_response.rbi @@ -0,0 +1,20 @@ +# typed: strong + +module Imagekit + module Models + class FileCopyResponse < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any(Imagekit::Models::FileCopyResponse, Imagekit::Internal::AnyHash) + end + + sig { returns(T.attached_class) } + def self.new + end + + sig { override.returns({}) } + def to_hash + end + end + end +end diff --git a/rbi/imagekit/models/file_delete_params.rbi b/rbi/imagekit/models/file_delete_params.rbi new file mode 100644 index 00000000..9573cf16 --- /dev/null +++ b/rbi/imagekit/models/file_delete_params.rbi @@ -0,0 +1,27 @@ +# typed: strong + +module Imagekit + module Models + class FileDeleteParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any(Imagekit::FileDeleteParams, Imagekit::Internal::AnyHash) + end + + sig do + params(request_options: Imagekit::RequestOptions::OrHash).returns( + T.attached_class + ) + end + def self.new(request_options: {}) + end + + sig { override.returns({ request_options: Imagekit::RequestOptions }) } + def to_hash + end + end + end +end diff --git a/rbi/imagekit/models/file_get_params.rbi b/rbi/imagekit/models/file_get_params.rbi new file mode 100644 index 00000000..f6b5b068 --- /dev/null +++ b/rbi/imagekit/models/file_get_params.rbi @@ -0,0 +1,27 @@ +# typed: strong + +module Imagekit + module Models + class FileGetParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any(Imagekit::FileGetParams, Imagekit::Internal::AnyHash) + end + + sig do + params(request_options: Imagekit::RequestOptions::OrHash).returns( + T.attached_class + ) + end + def self.new(request_options: {}) + end + + sig { override.returns({ request_options: Imagekit::RequestOptions }) } + def to_hash + end + end + end +end diff --git a/rbi/imagekit/models/file_move_params.rbi b/rbi/imagekit/models/file_move_params.rbi new file mode 100644 index 00000000..eed54bf2 --- /dev/null +++ b/rbi/imagekit/models/file_move_params.rbi @@ -0,0 +1,51 @@ +# typed: strong + +module Imagekit + module Models + class FileMoveParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any(Imagekit::FileMoveParams, Imagekit::Internal::AnyHash) + end + + # Full path to the folder you want to move the above file into. + sig { returns(String) } + attr_accessor :destination_path + + # The full path of the file you want to move. + sig { returns(String) } + attr_accessor :source_file_path + + sig do + params( + destination_path: String, + source_file_path: String, + request_options: Imagekit::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # Full path to the folder you want to move the above file into. + destination_path:, + # The full path of the file you want to move. + source_file_path:, + request_options: {} + ) + end + + sig do + override.returns( + { + destination_path: String, + source_file_path: String, + request_options: Imagekit::RequestOptions + } + ) + end + def to_hash + end + end + end +end diff --git a/rbi/imagekit/models/file_move_response.rbi b/rbi/imagekit/models/file_move_response.rbi new file mode 100644 index 00000000..d59ff9bd --- /dev/null +++ b/rbi/imagekit/models/file_move_response.rbi @@ -0,0 +1,20 @@ +# typed: strong + +module Imagekit + module Models + class FileMoveResponse < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any(Imagekit::Models::FileMoveResponse, Imagekit::Internal::AnyHash) + end + + sig { returns(T.attached_class) } + def self.new + end + + sig { override.returns({}) } + def to_hash + end + end + end +end diff --git a/rbi/imagekit/models/file_rename_params.rbi b/rbi/imagekit/models/file_rename_params.rbi new file mode 100644 index 00000000..a69d0af0 --- /dev/null +++ b/rbi/imagekit/models/file_rename_params.rbi @@ -0,0 +1,102 @@ +# typed: strong + +module Imagekit + module Models + class FileRenameParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any(Imagekit::FileRenameParams, Imagekit::Internal::AnyHash) + end + + # The full path of the file you want to rename. + sig { returns(String) } + attr_accessor :file_path + + # The new name of the file. A filename can contain: + # + # Alphanumeric Characters: `a-z`, `A-Z`, `0-9` (including Unicode letters, marks, + # and numerals in other languages). Special Characters: `.`, `_`, and `-`. + # + # Any other character, including space, will be replaced by `_`. + sig { returns(String) } + attr_accessor :new_file_name + + # Option to purge cache for the old file and its versions' URLs. + # + # When set to true, it will internally issue a purge cache request on CDN to + # remove cached content of old file and its versions. This purge request is + # counted against your monthly purge quota. + # + # Note: If the old file were accessible at + # `https://ik.imagekit.io/demo/old-filename.jpg`, a purge cache request would be + # issued against `https://ik.imagekit.io/demo/old-filename.jpg*` (with a wildcard + # at the end). It will remove the file and its versions' URLs and any + # transformations made using query parameters on this file or its versions. + # However, the cache for file transformations made using path parameters will + # persist. You can purge them using the purge API. For more details, refer to the + # purge API documentation. + # + # Default value - `false` + sig { returns(T.nilable(T::Boolean)) } + attr_reader :purge_cache + + sig { params(purge_cache: T::Boolean).void } + attr_writer :purge_cache + + sig do + params( + file_path: String, + new_file_name: String, + purge_cache: T::Boolean, + request_options: Imagekit::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # The full path of the file you want to rename. + file_path:, + # The new name of the file. A filename can contain: + # + # Alphanumeric Characters: `a-z`, `A-Z`, `0-9` (including Unicode letters, marks, + # and numerals in other languages). Special Characters: `.`, `_`, and `-`. + # + # Any other character, including space, will be replaced by `_`. + new_file_name:, + # Option to purge cache for the old file and its versions' URLs. + # + # When set to true, it will internally issue a purge cache request on CDN to + # remove cached content of old file and its versions. This purge request is + # counted against your monthly purge quota. + # + # Note: If the old file were accessible at + # `https://ik.imagekit.io/demo/old-filename.jpg`, a purge cache request would be + # issued against `https://ik.imagekit.io/demo/old-filename.jpg*` (with a wildcard + # at the end). It will remove the file and its versions' URLs and any + # transformations made using query parameters on this file or its versions. + # However, the cache for file transformations made using path parameters will + # persist. You can purge them using the purge API. For more details, refer to the + # purge API documentation. + # + # Default value - `false` + purge_cache: nil, + request_options: {} + ) + end + + sig do + override.returns( + { + file_path: String, + new_file_name: String, + purge_cache: T::Boolean, + request_options: Imagekit::RequestOptions + } + ) + end + def to_hash + end + end + end +end diff --git a/rbi/imagekit/models/file_rename_response.rbi b/rbi/imagekit/models/file_rename_response.rbi new file mode 100644 index 00000000..2140d23b --- /dev/null +++ b/rbi/imagekit/models/file_rename_response.rbi @@ -0,0 +1,35 @@ +# typed: strong + +module Imagekit + module Models + class FileRenameResponse < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Models::FileRenameResponse, + Imagekit::Internal::AnyHash + ) + end + + # Unique identifier of the purge request. This can be used to check the status of + # the purge request. + sig { returns(T.nilable(String)) } + attr_reader :purge_request_id + + sig { params(purge_request_id: String).void } + attr_writer :purge_request_id + + sig { params(purge_request_id: String).returns(T.attached_class) } + def self.new( + # Unique identifier of the purge request. This can be used to check the status of + # the purge request. + purge_request_id: nil + ) + end + + sig { override.returns({ purge_request_id: String }) } + def to_hash + end + end + end +end diff --git a/rbi/imagekit/models/file_update_params.rbi b/rbi/imagekit/models/file_update_params.rbi new file mode 100644 index 00000000..908bd758 --- /dev/null +++ b/rbi/imagekit/models/file_update_params.rbi @@ -0,0 +1,58 @@ +# typed: strong + +module Imagekit + module Models + class FileUpdateParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any(Imagekit::FileUpdateParams, Imagekit::Internal::AnyHash) + end + + # Schema for update file update request. + sig do + returns( + T.any( + Imagekit::UpdateFileRequest::UpdateFileDetails, + Imagekit::UpdateFileRequest::ChangePublicationStatus + ) + ) + end + attr_accessor :update_file_request + + sig do + params( + update_file_request: + T.any( + Imagekit::UpdateFileRequest::UpdateFileDetails::OrHash, + Imagekit::UpdateFileRequest::ChangePublicationStatus::OrHash + ), + request_options: Imagekit::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # Schema for update file update request. + update_file_request:, + request_options: {} + ) + end + + sig do + override.returns( + { + update_file_request: + T.any( + Imagekit::UpdateFileRequest::UpdateFileDetails, + Imagekit::UpdateFileRequest::ChangePublicationStatus + ), + request_options: Imagekit::RequestOptions + } + ) + end + def to_hash + end + end + end +end diff --git a/rbi/imagekit/models/file_update_response.rbi b/rbi/imagekit/models/file_update_response.rbi new file mode 100644 index 00000000..92dba923 --- /dev/null +++ b/rbi/imagekit/models/file_update_response.rbi @@ -0,0 +1,322 @@ +# typed: strong + +module Imagekit + module Models + class FileUpdateResponse < Imagekit::Models::File + OrHash = + T.type_alias do + T.any( + Imagekit::Models::FileUpdateResponse, + Imagekit::Internal::AnyHash + ) + end + + sig do + returns( + T.nilable(Imagekit::Models::FileUpdateResponse::ExtensionStatus) + ) + end + attr_reader :extension_status + + sig do + params( + extension_status: + Imagekit::Models::FileUpdateResponse::ExtensionStatus::OrHash + ).void + end + attr_writer :extension_status + + # Object containing details of a file or file version. + sig do + params( + extension_status: + Imagekit::Models::FileUpdateResponse::ExtensionStatus::OrHash + ).returns(T.attached_class) + end + def self.new(extension_status: nil) + end + + sig do + override.returns( + { + extension_status: + Imagekit::Models::FileUpdateResponse::ExtensionStatus + } + ) + end + def to_hash + end + + class ExtensionStatus < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Models::FileUpdateResponse::ExtensionStatus, + Imagekit::Internal::AnyHash + ) + end + + sig do + returns( + T.nilable( + Imagekit::Models::FileUpdateResponse::ExtensionStatus::AIAutoDescription::TaggedSymbol + ) + ) + end + attr_reader :ai_auto_description + + sig do + params( + ai_auto_description: + Imagekit::Models::FileUpdateResponse::ExtensionStatus::AIAutoDescription::OrSymbol + ).void + end + attr_writer :ai_auto_description + + sig do + returns( + T.nilable( + Imagekit::Models::FileUpdateResponse::ExtensionStatus::AwsAutoTagging::TaggedSymbol + ) + ) + end + attr_reader :aws_auto_tagging + + sig do + params( + aws_auto_tagging: + Imagekit::Models::FileUpdateResponse::ExtensionStatus::AwsAutoTagging::OrSymbol + ).void + end + attr_writer :aws_auto_tagging + + sig do + returns( + T.nilable( + Imagekit::Models::FileUpdateResponse::ExtensionStatus::GoogleAutoTagging::TaggedSymbol + ) + ) + end + attr_reader :google_auto_tagging + + sig do + params( + google_auto_tagging: + Imagekit::Models::FileUpdateResponse::ExtensionStatus::GoogleAutoTagging::OrSymbol + ).void + end + attr_writer :google_auto_tagging + + sig do + returns( + T.nilable( + Imagekit::Models::FileUpdateResponse::ExtensionStatus::RemoveBg::TaggedSymbol + ) + ) + end + attr_reader :remove_bg + + sig do + params( + remove_bg: + Imagekit::Models::FileUpdateResponse::ExtensionStatus::RemoveBg::OrSymbol + ).void + end + attr_writer :remove_bg + + sig do + params( + ai_auto_description: + Imagekit::Models::FileUpdateResponse::ExtensionStatus::AIAutoDescription::OrSymbol, + aws_auto_tagging: + Imagekit::Models::FileUpdateResponse::ExtensionStatus::AwsAutoTagging::OrSymbol, + google_auto_tagging: + Imagekit::Models::FileUpdateResponse::ExtensionStatus::GoogleAutoTagging::OrSymbol, + remove_bg: + Imagekit::Models::FileUpdateResponse::ExtensionStatus::RemoveBg::OrSymbol + ).returns(T.attached_class) + end + def self.new( + ai_auto_description: nil, + aws_auto_tagging: nil, + google_auto_tagging: nil, + remove_bg: nil + ) + end + + sig do + override.returns( + { + ai_auto_description: + Imagekit::Models::FileUpdateResponse::ExtensionStatus::AIAutoDescription::TaggedSymbol, + aws_auto_tagging: + Imagekit::Models::FileUpdateResponse::ExtensionStatus::AwsAutoTagging::TaggedSymbol, + google_auto_tagging: + Imagekit::Models::FileUpdateResponse::ExtensionStatus::GoogleAutoTagging::TaggedSymbol, + remove_bg: + Imagekit::Models::FileUpdateResponse::ExtensionStatus::RemoveBg::TaggedSymbol + } + ) + end + def to_hash + end + + module AIAutoDescription + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekit::Models::FileUpdateResponse::ExtensionStatus::AIAutoDescription + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + SUCCESS = + T.let( + :success, + Imagekit::Models::FileUpdateResponse::ExtensionStatus::AIAutoDescription::TaggedSymbol + ) + PENDING = + T.let( + :pending, + Imagekit::Models::FileUpdateResponse::ExtensionStatus::AIAutoDescription::TaggedSymbol + ) + FAILED = + T.let( + :failed, + Imagekit::Models::FileUpdateResponse::ExtensionStatus::AIAutoDescription::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekit::Models::FileUpdateResponse::ExtensionStatus::AIAutoDescription::TaggedSymbol + ] + ) + end + def self.values + end + end + + module AwsAutoTagging + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekit::Models::FileUpdateResponse::ExtensionStatus::AwsAutoTagging + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + SUCCESS = + T.let( + :success, + Imagekit::Models::FileUpdateResponse::ExtensionStatus::AwsAutoTagging::TaggedSymbol + ) + PENDING = + T.let( + :pending, + Imagekit::Models::FileUpdateResponse::ExtensionStatus::AwsAutoTagging::TaggedSymbol + ) + FAILED = + T.let( + :failed, + Imagekit::Models::FileUpdateResponse::ExtensionStatus::AwsAutoTagging::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekit::Models::FileUpdateResponse::ExtensionStatus::AwsAutoTagging::TaggedSymbol + ] + ) + end + def self.values + end + end + + module GoogleAutoTagging + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekit::Models::FileUpdateResponse::ExtensionStatus::GoogleAutoTagging + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + SUCCESS = + T.let( + :success, + Imagekit::Models::FileUpdateResponse::ExtensionStatus::GoogleAutoTagging::TaggedSymbol + ) + PENDING = + T.let( + :pending, + Imagekit::Models::FileUpdateResponse::ExtensionStatus::GoogleAutoTagging::TaggedSymbol + ) + FAILED = + T.let( + :failed, + Imagekit::Models::FileUpdateResponse::ExtensionStatus::GoogleAutoTagging::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekit::Models::FileUpdateResponse::ExtensionStatus::GoogleAutoTagging::TaggedSymbol + ] + ) + end + def self.values + end + end + + module RemoveBg + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekit::Models::FileUpdateResponse::ExtensionStatus::RemoveBg + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + SUCCESS = + T.let( + :success, + Imagekit::Models::FileUpdateResponse::ExtensionStatus::RemoveBg::TaggedSymbol + ) + PENDING = + T.let( + :pending, + Imagekit::Models::FileUpdateResponse::ExtensionStatus::RemoveBg::TaggedSymbol + ) + FAILED = + T.let( + :failed, + Imagekit::Models::FileUpdateResponse::ExtensionStatus::RemoveBg::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekit::Models::FileUpdateResponse::ExtensionStatus::RemoveBg::TaggedSymbol + ] + ) + end + def self.values + end + end + end + end + end +end diff --git a/rbi/imagekit/models/file_upload_params.rbi b/rbi/imagekit/models/file_upload_params.rbi new file mode 100644 index 00000000..3c74f2da --- /dev/null +++ b/rbi/imagekit/models/file_upload_params.rbi @@ -0,0 +1,889 @@ +# typed: strong + +module Imagekit + module Models + class FileUploadParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any(Imagekit::FileUploadParams, Imagekit::Internal::AnyHash) + end + + # The API accepts any of the following: + # + # - **Binary data** – send the raw bytes as `multipart/form-data`. + # - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can + # fetch. + # - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + # + # When supplying a URL, the server must receive the response headers within 8 + # seconds; otherwise the request fails with 400 Bad Request. + sig { returns(Imagekit::Internal::FileInput) } + attr_accessor :file + + # The name with which the file has to be uploaded. The file name can contain: + # + # - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. + # - Special Characters: `.`, `-` + # + # Any other character including space will be replaced by `_` + sig { returns(String) } + attr_accessor :file_name + + # A unique value that the ImageKit.io server will use to recognize and prevent + # subsequent retries for the same request. We suggest using V4 UUIDs, or another + # random string with enough entropy to avoid collisions. This field is only + # required for authentication when uploading a file from the client side. + # + # **Note**: Sending a value that has been used in the past will result in a + # validation error. Even if your previous request resulted in an error, you should + # always send a new value for this field. + sig { returns(T.nilable(String)) } + attr_reader :token + + sig { params(token: String).void } + attr_writer :token + + # Server-side checks to run on the asset. Read more about + # [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). + sig { returns(T.nilable(String)) } + attr_reader :checks + + sig { params(checks: String).void } + attr_writer :checks + + # Define an important area in the image. This is only relevant for image type + # files. + # + # - To be passed as a string with the x and y coordinates of the top-left corner, + # and width and height of the area of interest in the format `x,y,width,height`. + # For example - `10,10,100,100` + # - Can be used with fo-customtransformation. + # - If this field is not specified and the file is overwritten, then + # customCoordinates will be removed. + sig { returns(T.nilable(String)) } + attr_reader :custom_coordinates + + sig { params(custom_coordinates: String).void } + attr_writer :custom_coordinates + + # JSON key-value pairs to associate with the asset. Create the custom metadata + # fields before setting these values. + sig { returns(T.nilable(T::Hash[Symbol, T.anything])) } + attr_reader :custom_metadata + + sig { params(custom_metadata: T::Hash[Symbol, T.anything]).void } + attr_writer :custom_metadata + + # Optional text to describe the contents of the file. + sig { returns(T.nilable(String)) } + attr_reader :description + + sig { params(description: String).void } + attr_writer :description + + # The time until your signature is valid. It must be a + # [Unix time](https://en.wikipedia.org/wiki/Unix_time) in less than 1 hour into + # the future. It should be in seconds. This field is only required for + # authentication when uploading a file from the client side. + sig { returns(T.nilable(Integer)) } + attr_reader :expire + + sig { params(expire: Integer).void } + attr_writer :expire + + # Array of extensions to be applied to the asset. Each extension can be configured + # with specific parameters based on the extension type. + sig do + returns( + T.nilable( + T::Array[ + T.any( + Imagekit::ExtensionItem::RemoveBg, + Imagekit::ExtensionItem::AIAutoDescription, + Imagekit::ExtensionItem::AutoTaggingExtension + ) + ] + ) + ) + end + attr_reader :extensions + + sig do + params( + extensions: + T::Array[ + T.any( + Imagekit::ExtensionItem::RemoveBg::OrHash, + Imagekit::ExtensionItem::AIAutoDescription::OrHash, + Imagekit::ExtensionItem::AutoTaggingExtension::OrHash + ) + ] + ).void + end + attr_writer :extensions + + # The folder path in which the image has to be uploaded. If the folder(s) didn't + # exist before, a new folder(s) is created. + # + # The folder name can contain: + # + # - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` + # - Special Characters: `/` , `_` , `-` + # + # Using multiple `/` creates a nested folder. + sig { returns(T.nilable(String)) } + attr_reader :folder + + sig { params(folder: String).void } + attr_writer :folder + + # Whether to mark the file as private or not. + # + # If `true`, the file is marked as private and is accessible only using named + # transformation or signed URL. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :is_private_file + + sig { params(is_private_file: T::Boolean).void } + attr_writer :is_private_file + + # Whether to upload file as published or not. + # + # If `false`, the file is marked as unpublished, which restricts access to the + # file only via the media library. Files in draft or unpublished state can only be + # publicly accessed after being published. + # + # The option to upload in draft state is only available in custom enterprise + # pricing plans. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :is_published + + sig { params(is_published: T::Boolean).void } + attr_writer :is_published + + # If set to `true` and a file already exists at the exact location, its AITags + # will be removed. Set `overwriteAITags` to `false` to preserve AITags. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :overwrite_ai_tags + + sig { params(overwrite_ai_tags: T::Boolean).void } + attr_writer :overwrite_ai_tags + + # If the request does not have `customMetadata`, and a file already exists at the + # exact location, existing customMetadata will be removed. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :overwrite_custom_metadata + + sig { params(overwrite_custom_metadata: T::Boolean).void } + attr_writer :overwrite_custom_metadata + + # If `false` and `useUniqueFileName` is also `false`, and a file already exists at + # the exact location, upload API will return an error immediately. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :overwrite_file + + sig { params(overwrite_file: T::Boolean).void } + attr_writer :overwrite_file + + # If the request does not have `tags`, and a file already exists at the exact + # location, existing tags will be removed. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :overwrite_tags + + sig { params(overwrite_tags: T::Boolean).void } + attr_writer :overwrite_tags + + # Your ImageKit.io public key. This field is only required for authentication when + # uploading a file from the client side. + sig { returns(T.nilable(String)) } + attr_reader :public_key + + sig { params(public_key: String).void } + attr_writer :public_key + + # Array of response field keys to include in the API response body. + sig do + returns( + T.nilable( + T::Array[Imagekit::FileUploadParams::ResponseField::OrSymbol] + ) + ) + end + attr_reader :response_fields + + sig do + params( + response_fields: + T::Array[Imagekit::FileUploadParams::ResponseField::OrSymbol] + ).void + end + attr_writer :response_fields + + # HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a + # key. Learn how to create a signature on the page below. This should be in + # lowercase. + # + # Signature must be calculated on the server-side. This field is only required for + # authentication when uploading a file from the client side. + sig { returns(T.nilable(String)) } + attr_reader :signature + + sig { params(signature: String).void } + attr_writer :signature + + # Set the tags while uploading the file. Provide an array of tag strings (e.g. + # `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must not + # exceed 500, and the `%` character is not allowed. If this field is not specified + # and the file is overwritten, the existing tags will be removed. + sig { returns(T.nilable(T::Array[String])) } + attr_reader :tags + + sig { params(tags: T::Array[String]).void } + attr_writer :tags + + # Configure pre-processing (`pre`) and post-processing (`post`) transformations. + # + # - `pre` — applied before the file is uploaded to the Media Library. + # Useful for reducing file size or applying basic optimizations upfront (e.g., + # resize, compress). + # + # - `post` — applied immediately after upload. + # Ideal for generating transformed versions (like video encodes or thumbnails) + # in advance, so they're ready for delivery without delay. + # + # You can mix and match any combination of post-processing types. + sig { returns(T.nilable(Imagekit::FileUploadParams::Transformation)) } + attr_reader :transformation + + sig do + params( + transformation: Imagekit::FileUploadParams::Transformation::OrHash + ).void + end + attr_writer :transformation + + # Whether to use a unique filename for this file or not. + # + # If `true`, ImageKit.io will add a unique suffix to the filename parameter to get + # a unique filename. + # + # If `false`, then the image is uploaded with the provided filename parameter, and + # any existing file with the same name is replaced. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :use_unique_file_name + + sig { params(use_unique_file_name: T::Boolean).void } + attr_writer :use_unique_file_name + + # The final status of extensions after they have completed execution will be + # delivered to this endpoint as a POST request. + # [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + # about the webhook payload structure. + sig { returns(T.nilable(String)) } + attr_reader :webhook_url + + sig { params(webhook_url: String).void } + attr_writer :webhook_url + + sig do + params( + file: Imagekit::Internal::FileInput, + file_name: String, + token: String, + checks: String, + custom_coordinates: String, + custom_metadata: T::Hash[Symbol, T.anything], + description: String, + expire: Integer, + extensions: + T::Array[ + T.any( + Imagekit::ExtensionItem::RemoveBg::OrHash, + Imagekit::ExtensionItem::AIAutoDescription::OrHash, + Imagekit::ExtensionItem::AutoTaggingExtension::OrHash + ) + ], + folder: String, + is_private_file: T::Boolean, + is_published: T::Boolean, + overwrite_ai_tags: T::Boolean, + overwrite_custom_metadata: T::Boolean, + overwrite_file: T::Boolean, + overwrite_tags: T::Boolean, + public_key: String, + response_fields: + T::Array[Imagekit::FileUploadParams::ResponseField::OrSymbol], + signature: String, + tags: T::Array[String], + transformation: Imagekit::FileUploadParams::Transformation::OrHash, + use_unique_file_name: T::Boolean, + webhook_url: String, + request_options: Imagekit::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # The API accepts any of the following: + # + # - **Binary data** – send the raw bytes as `multipart/form-data`. + # - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can + # fetch. + # - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + # + # When supplying a URL, the server must receive the response headers within 8 + # seconds; otherwise the request fails with 400 Bad Request. + file:, + # The name with which the file has to be uploaded. The file name can contain: + # + # - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. + # - Special Characters: `.`, `-` + # + # Any other character including space will be replaced by `_` + file_name:, + # A unique value that the ImageKit.io server will use to recognize and prevent + # subsequent retries for the same request. We suggest using V4 UUIDs, or another + # random string with enough entropy to avoid collisions. This field is only + # required for authentication when uploading a file from the client side. + # + # **Note**: Sending a value that has been used in the past will result in a + # validation error. Even if your previous request resulted in an error, you should + # always send a new value for this field. + token: nil, + # Server-side checks to run on the asset. Read more about + # [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). + checks: nil, + # Define an important area in the image. This is only relevant for image type + # files. + # + # - To be passed as a string with the x and y coordinates of the top-left corner, + # and width and height of the area of interest in the format `x,y,width,height`. + # For example - `10,10,100,100` + # - Can be used with fo-customtransformation. + # - If this field is not specified and the file is overwritten, then + # customCoordinates will be removed. + custom_coordinates: nil, + # JSON key-value pairs to associate with the asset. Create the custom metadata + # fields before setting these values. + custom_metadata: nil, + # Optional text to describe the contents of the file. + description: nil, + # The time until your signature is valid. It must be a + # [Unix time](https://en.wikipedia.org/wiki/Unix_time) in less than 1 hour into + # the future. It should be in seconds. This field is only required for + # authentication when uploading a file from the client side. + expire: nil, + # Array of extensions to be applied to the asset. Each extension can be configured + # with specific parameters based on the extension type. + extensions: nil, + # The folder path in which the image has to be uploaded. If the folder(s) didn't + # exist before, a new folder(s) is created. + # + # The folder name can contain: + # + # - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` + # - Special Characters: `/` , `_` , `-` + # + # Using multiple `/` creates a nested folder. + folder: nil, + # Whether to mark the file as private or not. + # + # If `true`, the file is marked as private and is accessible only using named + # transformation or signed URL. + is_private_file: nil, + # Whether to upload file as published or not. + # + # If `false`, the file is marked as unpublished, which restricts access to the + # file only via the media library. Files in draft or unpublished state can only be + # publicly accessed after being published. + # + # The option to upload in draft state is only available in custom enterprise + # pricing plans. + is_published: nil, + # If set to `true` and a file already exists at the exact location, its AITags + # will be removed. Set `overwriteAITags` to `false` to preserve AITags. + overwrite_ai_tags: nil, + # If the request does not have `customMetadata`, and a file already exists at the + # exact location, existing customMetadata will be removed. + overwrite_custom_metadata: nil, + # If `false` and `useUniqueFileName` is also `false`, and a file already exists at + # the exact location, upload API will return an error immediately. + overwrite_file: nil, + # If the request does not have `tags`, and a file already exists at the exact + # location, existing tags will be removed. + overwrite_tags: nil, + # Your ImageKit.io public key. This field is only required for authentication when + # uploading a file from the client side. + public_key: nil, + # Array of response field keys to include in the API response body. + response_fields: nil, + # HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a + # key. Learn how to create a signature on the page below. This should be in + # lowercase. + # + # Signature must be calculated on the server-side. This field is only required for + # authentication when uploading a file from the client side. + signature: nil, + # Set the tags while uploading the file. Provide an array of tag strings (e.g. + # `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must not + # exceed 500, and the `%` character is not allowed. If this field is not specified + # and the file is overwritten, the existing tags will be removed. + tags: nil, + # Configure pre-processing (`pre`) and post-processing (`post`) transformations. + # + # - `pre` — applied before the file is uploaded to the Media Library. + # Useful for reducing file size or applying basic optimizations upfront (e.g., + # resize, compress). + # + # - `post` — applied immediately after upload. + # Ideal for generating transformed versions (like video encodes or thumbnails) + # in advance, so they're ready for delivery without delay. + # + # You can mix and match any combination of post-processing types. + transformation: nil, + # Whether to use a unique filename for this file or not. + # + # If `true`, ImageKit.io will add a unique suffix to the filename parameter to get + # a unique filename. + # + # If `false`, then the image is uploaded with the provided filename parameter, and + # any existing file with the same name is replaced. + use_unique_file_name: nil, + # The final status of extensions after they have completed execution will be + # delivered to this endpoint as a POST request. + # [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + # about the webhook payload structure. + webhook_url: nil, + request_options: {} + ) + end + + sig do + override.returns( + { + file: Imagekit::Internal::FileInput, + file_name: String, + token: String, + checks: String, + custom_coordinates: String, + custom_metadata: T::Hash[Symbol, T.anything], + description: String, + expire: Integer, + extensions: + T::Array[ + T.any( + Imagekit::ExtensionItem::RemoveBg, + Imagekit::ExtensionItem::AIAutoDescription, + Imagekit::ExtensionItem::AutoTaggingExtension + ) + ], + folder: String, + is_private_file: T::Boolean, + is_published: T::Boolean, + overwrite_ai_tags: T::Boolean, + overwrite_custom_metadata: T::Boolean, + overwrite_file: T::Boolean, + overwrite_tags: T::Boolean, + public_key: String, + response_fields: + T::Array[Imagekit::FileUploadParams::ResponseField::OrSymbol], + signature: String, + tags: T::Array[String], + transformation: Imagekit::FileUploadParams::Transformation, + use_unique_file_name: T::Boolean, + webhook_url: String, + request_options: Imagekit::RequestOptions + } + ) + end + def to_hash + end + + module ResponseField + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all(Symbol, Imagekit::FileUploadParams::ResponseField) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + TAGS = + T.let(:tags, Imagekit::FileUploadParams::ResponseField::TaggedSymbol) + CUSTOM_COORDINATES = + T.let( + :customCoordinates, + Imagekit::FileUploadParams::ResponseField::TaggedSymbol + ) + IS_PRIVATE_FILE = + T.let( + :isPrivateFile, + Imagekit::FileUploadParams::ResponseField::TaggedSymbol + ) + EMBEDDED_METADATA = + T.let( + :embeddedMetadata, + Imagekit::FileUploadParams::ResponseField::TaggedSymbol + ) + IS_PUBLISHED = + T.let( + :isPublished, + Imagekit::FileUploadParams::ResponseField::TaggedSymbol + ) + CUSTOM_METADATA = + T.let( + :customMetadata, + Imagekit::FileUploadParams::ResponseField::TaggedSymbol + ) + METADATA = + T.let( + :metadata, + Imagekit::FileUploadParams::ResponseField::TaggedSymbol + ) + + sig do + override.returns( + T::Array[Imagekit::FileUploadParams::ResponseField::TaggedSymbol] + ) + end + def self.values + end + end + + class Transformation < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::FileUploadParams::Transformation, + Imagekit::Internal::AnyHash + ) + end + + # List of transformations to apply _after_ the file is uploaded. + # Each item must match one of the following types: `transformation`, + # `gif-to-video`, `thumbnail`, `abs`. + sig do + returns( + T.nilable( + T::Array[ + T.any( + Imagekit::FileUploadParams::Transformation::Post::Transformation, + Imagekit::FileUploadParams::Transformation::Post::GifToVideo, + Imagekit::FileUploadParams::Transformation::Post::Thumbnail, + Imagekit::FileUploadParams::Transformation::Post::Abs + ) + ] + ) + ) + end + attr_reader :post + + sig do + params( + post: + T::Array[ + T.any( + Imagekit::FileUploadParams::Transformation::Post::Transformation::OrHash, + Imagekit::FileUploadParams::Transformation::Post::GifToVideo::OrHash, + Imagekit::FileUploadParams::Transformation::Post::Thumbnail::OrHash, + Imagekit::FileUploadParams::Transformation::Post::Abs::OrHash + ) + ] + ).void + end + attr_writer :post + + # Transformation string to apply before uploading the file to the Media Library. + # Useful for optimizing files at ingestion. + sig { returns(T.nilable(String)) } + attr_reader :pre + + sig { params(pre: String).void } + attr_writer :pre + + # Configure pre-processing (`pre`) and post-processing (`post`) transformations. + # + # - `pre` — applied before the file is uploaded to the Media Library. + # Useful for reducing file size or applying basic optimizations upfront (e.g., + # resize, compress). + # + # - `post` — applied immediately after upload. + # Ideal for generating transformed versions (like video encodes or thumbnails) + # in advance, so they're ready for delivery without delay. + # + # You can mix and match any combination of post-processing types. + sig do + params( + post: + T::Array[ + T.any( + Imagekit::FileUploadParams::Transformation::Post::Transformation::OrHash, + Imagekit::FileUploadParams::Transformation::Post::GifToVideo::OrHash, + Imagekit::FileUploadParams::Transformation::Post::Thumbnail::OrHash, + Imagekit::FileUploadParams::Transformation::Post::Abs::OrHash + ) + ], + pre: String + ).returns(T.attached_class) + end + def self.new( + # List of transformations to apply _after_ the file is uploaded. + # Each item must match one of the following types: `transformation`, + # `gif-to-video`, `thumbnail`, `abs`. + post: nil, + # Transformation string to apply before uploading the file to the Media Library. + # Useful for optimizing files at ingestion. + pre: nil + ) + end + + sig do + override.returns( + { + post: + T::Array[ + T.any( + Imagekit::FileUploadParams::Transformation::Post::Transformation, + Imagekit::FileUploadParams::Transformation::Post::GifToVideo, + Imagekit::FileUploadParams::Transformation::Post::Thumbnail, + Imagekit::FileUploadParams::Transformation::Post::Abs + ) + ], + pre: String + } + ) + end + def to_hash + end + + module Post + extend Imagekit::Internal::Type::Union + + Variants = + T.type_alias do + T.any( + Imagekit::FileUploadParams::Transformation::Post::Transformation, + Imagekit::FileUploadParams::Transformation::Post::GifToVideo, + Imagekit::FileUploadParams::Transformation::Post::Thumbnail, + Imagekit::FileUploadParams::Transformation::Post::Abs + ) + end + + class Transformation < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::FileUploadParams::Transformation::Post::Transformation, + Imagekit::Internal::AnyHash + ) + end + + # Transformation type. + sig { returns(Symbol) } + attr_accessor :type + + # Transformation string (e.g. `w-200,h-200`). + # Same syntax as ImageKit URL-based transformations. + sig { returns(String) } + attr_accessor :value + + sig do + params(value: String, type: Symbol).returns(T.attached_class) + end + def self.new( + # Transformation string (e.g. `w-200,h-200`). + # Same syntax as ImageKit URL-based transformations. + value:, + # Transformation type. + type: :transformation + ) + end + + sig { override.returns({ type: Symbol, value: String }) } + def to_hash + end + end + + class GifToVideo < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::FileUploadParams::Transformation::Post::GifToVideo, + Imagekit::Internal::AnyHash + ) + end + + # Converts an animated GIF into an MP4. + sig { returns(Symbol) } + attr_accessor :type + + # Optional transformation string to apply to the output video. + # **Example**: `q-80` + sig { returns(T.nilable(String)) } + attr_reader :value + + sig { params(value: String).void } + attr_writer :value + + sig do + params(value: String, type: Symbol).returns(T.attached_class) + end + def self.new( + # Optional transformation string to apply to the output video. + # **Example**: `q-80` + value: nil, + # Converts an animated GIF into an MP4. + type: :"gif-to-video" + ) + end + + sig { override.returns({ type: Symbol, value: String }) } + def to_hash + end + end + + class Thumbnail < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::FileUploadParams::Transformation::Post::Thumbnail, + Imagekit::Internal::AnyHash + ) + end + + # Generates a thumbnail image. + sig { returns(Symbol) } + attr_accessor :type + + # Optional transformation string. + # **Example**: `w-150,h-150` + sig { returns(T.nilable(String)) } + attr_reader :value + + sig { params(value: String).void } + attr_writer :value + + sig do + params(value: String, type: Symbol).returns(T.attached_class) + end + def self.new( + # Optional transformation string. + # **Example**: `w-150,h-150` + value: nil, + # Generates a thumbnail image. + type: :thumbnail + ) + end + + sig { override.returns({ type: Symbol, value: String }) } + def to_hash + end + end + + class Abs < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::FileUploadParams::Transformation::Post::Abs, + Imagekit::Internal::AnyHash + ) + end + + # Streaming protocol to use (`hls` or `dash`). + sig do + returns( + Imagekit::FileUploadParams::Transformation::Post::Abs::Protocol::OrSymbol + ) + end + attr_accessor :protocol + + # Adaptive Bitrate Streaming (ABS) setup. + sig { returns(Symbol) } + attr_accessor :type + + # List of different representations you want to create separated by an underscore. + sig { returns(String) } + attr_accessor :value + + sig do + params( + protocol: + Imagekit::FileUploadParams::Transformation::Post::Abs::Protocol::OrSymbol, + value: String, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Streaming protocol to use (`hls` or `dash`). + protocol:, + # List of different representations you want to create separated by an underscore. + value:, + # Adaptive Bitrate Streaming (ABS) setup. + type: :abs + ) + end + + sig do + override.returns( + { + protocol: + Imagekit::FileUploadParams::Transformation::Post::Abs::Protocol::OrSymbol, + type: Symbol, + value: String + } + ) + end + def to_hash + end + + # Streaming protocol to use (`hls` or `dash`). + module Protocol + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekit::FileUploadParams::Transformation::Post::Abs::Protocol + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + HLS = + T.let( + :hls, + Imagekit::FileUploadParams::Transformation::Post::Abs::Protocol::TaggedSymbol + ) + DASH = + T.let( + :dash, + Imagekit::FileUploadParams::Transformation::Post::Abs::Protocol::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekit::FileUploadParams::Transformation::Post::Abs::Protocol::TaggedSymbol + ] + ) + end + def self.values + end + end + end + + sig do + override.returns( + T::Array[ + Imagekit::FileUploadParams::Transformation::Post::Variants + ] + ) + end + def self.variants + end + end + end + end + end +end diff --git a/rbi/imagekit/models/file_upload_response.rbi b/rbi/imagekit/models/file_upload_response.rbi new file mode 100644 index 00000000..aa46ceb4 --- /dev/null +++ b/rbi/imagekit/models/file_upload_response.rbi @@ -0,0 +1,743 @@ +# typed: strong + +module Imagekit + module Models + class FileUploadResponse < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Models::FileUploadResponse, + Imagekit::Internal::AnyHash + ) + end + + # An array of tags assigned to the uploaded file by auto tagging. + sig do + returns( + T.nilable(T::Array[Imagekit::Models::FileUploadResponse::AITag]) + ) + end + attr_accessor :ai_tags + + # The audio codec used in the video (only for video). + sig { returns(T.nilable(String)) } + attr_reader :audio_codec + + sig { params(audio_codec: String).void } + attr_writer :audio_codec + + # The bit rate of the video in kbps (only for video). + sig { returns(T.nilable(Integer)) } + attr_reader :bit_rate + + sig { params(bit_rate: Integer).void } + attr_writer :bit_rate + + # Value of custom coordinates associated with the image in the format + # `x,y,width,height`. If `customCoordinates` are not defined, then it is `null`. + # Send `customCoordinates` in `responseFields` in API request to get the value of + # this field. + sig { returns(T.nilable(String)) } + attr_accessor :custom_coordinates + + # A key-value data associated with the asset. Use `responseField` in API request + # to get `customMetadata` in the upload API response. Before setting any custom + # metadata on an asset, you have to create the field using custom metadata fields + # API. Send `customMetadata` in `responseFields` in API request to get the value + # of this field. + sig { returns(T.nilable(T::Hash[Symbol, T.anything])) } + attr_reader :custom_metadata + + sig { params(custom_metadata: T::Hash[Symbol, T.anything]).void } + attr_writer :custom_metadata + + # Optional text to describe the contents of the file. Can be set by the user or + # the ai-auto-description extension. + sig { returns(T.nilable(String)) } + attr_reader :description + + sig { params(description: String).void } + attr_writer :description + + # The duration of the video in seconds (only for video). + sig { returns(T.nilable(Integer)) } + attr_reader :duration + + sig { params(duration: Integer).void } + attr_writer :duration + + # Consolidated embedded metadata associated with the file. It includes exif, iptc, + # and xmp data. Send `embeddedMetadata` in `responseFields` in API request to get + # embeddedMetadata in the upload API response. + sig { returns(T.nilable(T::Hash[Symbol, T.anything])) } + attr_reader :embedded_metadata + + sig { params(embedded_metadata: T::Hash[Symbol, T.anything]).void } + attr_writer :embedded_metadata + + # Extension names with their processing status at the time of completion of the + # request. It could have one of the following status values: + # + # `success`: The extension has been successfully applied. `failed`: The extension + # has failed and will not be retried. `pending`: The extension will finish + # processing in some time. On completion, the final status (success / failed) will + # be sent to the `webhookUrl` provided. + # + # If no extension was requested, then this parameter is not returned. + sig do + returns( + T.nilable(Imagekit::Models::FileUploadResponse::ExtensionStatus) + ) + end + attr_reader :extension_status + + sig do + params( + extension_status: + Imagekit::Models::FileUploadResponse::ExtensionStatus::OrHash + ).void + end + attr_writer :extension_status + + # Unique fileId. Store this fileld in your database, as this will be used to + # perform update action on this file. + sig { returns(T.nilable(String)) } + attr_reader :file_id + + sig { params(file_id: String).void } + attr_writer :file_id + + # The relative path of the file in the media library e.g. + # `/marketing-assets/new-banner.jpg`. + sig { returns(T.nilable(String)) } + attr_reader :file_path + + sig { params(file_path: String).void } + attr_writer :file_path + + # Type of the uploaded file. Possible values are `image`, `non-image`. + sig { returns(T.nilable(String)) } + attr_reader :file_type + + sig { params(file_type: String).void } + attr_writer :file_type + + # Height of the image in pixels (Only for images) + sig { returns(T.nilable(Float)) } + attr_reader :height + + sig { params(height: Float).void } + attr_writer :height + + # Is the file marked as private. It can be either `true` or `false`. Send + # `isPrivateFile` in `responseFields` in API request to get the value of this + # field. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :is_private_file + + sig { params(is_private_file: T::Boolean).void } + attr_writer :is_private_file + + # Is the file published or in draft state. It can be either `true` or `false`. + # Send `isPublished` in `responseFields` in API request to get the value of this + # field. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :is_published + + sig { params(is_published: T::Boolean).void } + attr_writer :is_published + + # Legacy metadata. Send `metadata` in `responseFields` in API request to get + # metadata in the upload API response. + sig { returns(T.nilable(Imagekit::Metadata)) } + attr_reader :metadata + + sig { params(metadata: Imagekit::Metadata::OrHash).void } + attr_writer :metadata + + # Name of the asset. + sig { returns(T.nilable(String)) } + attr_reader :name + + sig { params(name: String).void } + attr_writer :name + + # Size of the image file in Bytes. + sig { returns(T.nilable(Float)) } + attr_reader :size + + sig { params(size: Float).void } + attr_writer :size + + # The array of tags associated with the asset. If no tags are set, it will be + # `null`. Send `tags` in `responseFields` in API request to get the value of this + # field. + sig { returns(T.nilable(T::Array[String])) } + attr_accessor :tags + + # In the case of an image, a small thumbnail URL. + sig { returns(T.nilable(String)) } + attr_reader :thumbnail_url + + sig { params(thumbnail_url: String).void } + attr_writer :thumbnail_url + + # A publicly accessible URL of the file. + sig { returns(T.nilable(String)) } + attr_reader :url + + sig { params(url: String).void } + attr_writer :url + + # An object containing the file or file version's `id` (versionId) and `name`. + sig do + returns(T.nilable(Imagekit::Models::FileUploadResponse::VersionInfo)) + end + attr_reader :version_info + + sig do + params( + version_info: + Imagekit::Models::FileUploadResponse::VersionInfo::OrHash + ).void + end + attr_writer :version_info + + # The video codec used in the video (only for video). + sig { returns(T.nilable(String)) } + attr_reader :video_codec + + sig { params(video_codec: String).void } + attr_writer :video_codec + + # Width of the image in pixels (Only for Images) + sig { returns(T.nilable(Float)) } + attr_reader :width + + sig { params(width: Float).void } + attr_writer :width + + # Object containing details of a successful upload. + sig do + params( + ai_tags: + T.nilable( + T::Array[Imagekit::Models::FileUploadResponse::AITag::OrHash] + ), + audio_codec: String, + bit_rate: Integer, + custom_coordinates: T.nilable(String), + custom_metadata: T::Hash[Symbol, T.anything], + description: String, + duration: Integer, + embedded_metadata: T::Hash[Symbol, T.anything], + extension_status: + Imagekit::Models::FileUploadResponse::ExtensionStatus::OrHash, + file_id: String, + file_path: String, + file_type: String, + height: Float, + is_private_file: T::Boolean, + is_published: T::Boolean, + metadata: Imagekit::Metadata::OrHash, + name: String, + size: Float, + tags: T.nilable(T::Array[String]), + thumbnail_url: String, + url: String, + version_info: + Imagekit::Models::FileUploadResponse::VersionInfo::OrHash, + video_codec: String, + width: Float + ).returns(T.attached_class) + end + def self.new( + # An array of tags assigned to the uploaded file by auto tagging. + ai_tags: nil, + # The audio codec used in the video (only for video). + audio_codec: nil, + # The bit rate of the video in kbps (only for video). + bit_rate: nil, + # Value of custom coordinates associated with the image in the format + # `x,y,width,height`. If `customCoordinates` are not defined, then it is `null`. + # Send `customCoordinates` in `responseFields` in API request to get the value of + # this field. + custom_coordinates: nil, + # A key-value data associated with the asset. Use `responseField` in API request + # to get `customMetadata` in the upload API response. Before setting any custom + # metadata on an asset, you have to create the field using custom metadata fields + # API. Send `customMetadata` in `responseFields` in API request to get the value + # of this field. + custom_metadata: nil, + # Optional text to describe the contents of the file. Can be set by the user or + # the ai-auto-description extension. + description: nil, + # The duration of the video in seconds (only for video). + duration: nil, + # Consolidated embedded metadata associated with the file. It includes exif, iptc, + # and xmp data. Send `embeddedMetadata` in `responseFields` in API request to get + # embeddedMetadata in the upload API response. + embedded_metadata: nil, + # Extension names with their processing status at the time of completion of the + # request. It could have one of the following status values: + # + # `success`: The extension has been successfully applied. `failed`: The extension + # has failed and will not be retried. `pending`: The extension will finish + # processing in some time. On completion, the final status (success / failed) will + # be sent to the `webhookUrl` provided. + # + # If no extension was requested, then this parameter is not returned. + extension_status: nil, + # Unique fileId. Store this fileld in your database, as this will be used to + # perform update action on this file. + file_id: nil, + # The relative path of the file in the media library e.g. + # `/marketing-assets/new-banner.jpg`. + file_path: nil, + # Type of the uploaded file. Possible values are `image`, `non-image`. + file_type: nil, + # Height of the image in pixels (Only for images) + height: nil, + # Is the file marked as private. It can be either `true` or `false`. Send + # `isPrivateFile` in `responseFields` in API request to get the value of this + # field. + is_private_file: nil, + # Is the file published or in draft state. It can be either `true` or `false`. + # Send `isPublished` in `responseFields` in API request to get the value of this + # field. + is_published: nil, + # Legacy metadata. Send `metadata` in `responseFields` in API request to get + # metadata in the upload API response. + metadata: nil, + # Name of the asset. + name: nil, + # Size of the image file in Bytes. + size: nil, + # The array of tags associated with the asset. If no tags are set, it will be + # `null`. Send `tags` in `responseFields` in API request to get the value of this + # field. + tags: nil, + # In the case of an image, a small thumbnail URL. + thumbnail_url: nil, + # A publicly accessible URL of the file. + url: nil, + # An object containing the file or file version's `id` (versionId) and `name`. + version_info: nil, + # The video codec used in the video (only for video). + video_codec: nil, + # Width of the image in pixels (Only for Images) + width: nil + ) + end + + sig do + override.returns( + { + ai_tags: + T.nilable(T::Array[Imagekit::Models::FileUploadResponse::AITag]), + audio_codec: String, + bit_rate: Integer, + custom_coordinates: T.nilable(String), + custom_metadata: T::Hash[Symbol, T.anything], + description: String, + duration: Integer, + embedded_metadata: T::Hash[Symbol, T.anything], + extension_status: + Imagekit::Models::FileUploadResponse::ExtensionStatus, + file_id: String, + file_path: String, + file_type: String, + height: Float, + is_private_file: T::Boolean, + is_published: T::Boolean, + metadata: Imagekit::Metadata, + name: String, + size: Float, + tags: T.nilable(T::Array[String]), + thumbnail_url: String, + url: String, + version_info: Imagekit::Models::FileUploadResponse::VersionInfo, + video_codec: String, + width: Float + } + ) + end + def to_hash + end + + class AITag < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Models::FileUploadResponse::AITag, + Imagekit::Internal::AnyHash + ) + end + + # Confidence score of the tag. + sig { returns(T.nilable(Float)) } + attr_reader :confidence + + sig { params(confidence: Float).void } + attr_writer :confidence + + # Name of the tag. + sig { returns(T.nilable(String)) } + attr_reader :name + + sig { params(name: String).void } + attr_writer :name + + # Array of `AITags` associated with the image. If no `AITags` are set, it will be + # null. These tags can be added using the `google-auto-tagging` or + # `aws-auto-tagging` extensions. + sig { returns(T.nilable(String)) } + attr_reader :source + + sig { params(source: String).void } + attr_writer :source + + sig do + params(confidence: Float, name: String, source: String).returns( + T.attached_class + ) + end + def self.new( + # Confidence score of the tag. + confidence: nil, + # Name of the tag. + name: nil, + # Array of `AITags` associated with the image. If no `AITags` are set, it will be + # null. These tags can be added using the `google-auto-tagging` or + # `aws-auto-tagging` extensions. + source: nil + ) + end + + sig do + override.returns({ confidence: Float, name: String, source: String }) + end + def to_hash + end + end + + class ExtensionStatus < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Models::FileUploadResponse::ExtensionStatus, + Imagekit::Internal::AnyHash + ) + end + + sig do + returns( + T.nilable( + Imagekit::Models::FileUploadResponse::ExtensionStatus::AIAutoDescription::TaggedSymbol + ) + ) + end + attr_reader :ai_auto_description + + sig do + params( + ai_auto_description: + Imagekit::Models::FileUploadResponse::ExtensionStatus::AIAutoDescription::OrSymbol + ).void + end + attr_writer :ai_auto_description + + sig do + returns( + T.nilable( + Imagekit::Models::FileUploadResponse::ExtensionStatus::AwsAutoTagging::TaggedSymbol + ) + ) + end + attr_reader :aws_auto_tagging + + sig do + params( + aws_auto_tagging: + Imagekit::Models::FileUploadResponse::ExtensionStatus::AwsAutoTagging::OrSymbol + ).void + end + attr_writer :aws_auto_tagging + + sig do + returns( + T.nilable( + Imagekit::Models::FileUploadResponse::ExtensionStatus::GoogleAutoTagging::TaggedSymbol + ) + ) + end + attr_reader :google_auto_tagging + + sig do + params( + google_auto_tagging: + Imagekit::Models::FileUploadResponse::ExtensionStatus::GoogleAutoTagging::OrSymbol + ).void + end + attr_writer :google_auto_tagging + + sig do + returns( + T.nilable( + Imagekit::Models::FileUploadResponse::ExtensionStatus::RemoveBg::TaggedSymbol + ) + ) + end + attr_reader :remove_bg + + sig do + params( + remove_bg: + Imagekit::Models::FileUploadResponse::ExtensionStatus::RemoveBg::OrSymbol + ).void + end + attr_writer :remove_bg + + # Extension names with their processing status at the time of completion of the + # request. It could have one of the following status values: + # + # `success`: The extension has been successfully applied. `failed`: The extension + # has failed and will not be retried. `pending`: The extension will finish + # processing in some time. On completion, the final status (success / failed) will + # be sent to the `webhookUrl` provided. + # + # If no extension was requested, then this parameter is not returned. + sig do + params( + ai_auto_description: + Imagekit::Models::FileUploadResponse::ExtensionStatus::AIAutoDescription::OrSymbol, + aws_auto_tagging: + Imagekit::Models::FileUploadResponse::ExtensionStatus::AwsAutoTagging::OrSymbol, + google_auto_tagging: + Imagekit::Models::FileUploadResponse::ExtensionStatus::GoogleAutoTagging::OrSymbol, + remove_bg: + Imagekit::Models::FileUploadResponse::ExtensionStatus::RemoveBg::OrSymbol + ).returns(T.attached_class) + end + def self.new( + ai_auto_description: nil, + aws_auto_tagging: nil, + google_auto_tagging: nil, + remove_bg: nil + ) + end + + sig do + override.returns( + { + ai_auto_description: + Imagekit::Models::FileUploadResponse::ExtensionStatus::AIAutoDescription::TaggedSymbol, + aws_auto_tagging: + Imagekit::Models::FileUploadResponse::ExtensionStatus::AwsAutoTagging::TaggedSymbol, + google_auto_tagging: + Imagekit::Models::FileUploadResponse::ExtensionStatus::GoogleAutoTagging::TaggedSymbol, + remove_bg: + Imagekit::Models::FileUploadResponse::ExtensionStatus::RemoveBg::TaggedSymbol + } + ) + end + def to_hash + end + + module AIAutoDescription + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekit::Models::FileUploadResponse::ExtensionStatus::AIAutoDescription + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + SUCCESS = + T.let( + :success, + Imagekit::Models::FileUploadResponse::ExtensionStatus::AIAutoDescription::TaggedSymbol + ) + PENDING = + T.let( + :pending, + Imagekit::Models::FileUploadResponse::ExtensionStatus::AIAutoDescription::TaggedSymbol + ) + FAILED = + T.let( + :failed, + Imagekit::Models::FileUploadResponse::ExtensionStatus::AIAutoDescription::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekit::Models::FileUploadResponse::ExtensionStatus::AIAutoDescription::TaggedSymbol + ] + ) + end + def self.values + end + end + + module AwsAutoTagging + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekit::Models::FileUploadResponse::ExtensionStatus::AwsAutoTagging + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + SUCCESS = + T.let( + :success, + Imagekit::Models::FileUploadResponse::ExtensionStatus::AwsAutoTagging::TaggedSymbol + ) + PENDING = + T.let( + :pending, + Imagekit::Models::FileUploadResponse::ExtensionStatus::AwsAutoTagging::TaggedSymbol + ) + FAILED = + T.let( + :failed, + Imagekit::Models::FileUploadResponse::ExtensionStatus::AwsAutoTagging::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekit::Models::FileUploadResponse::ExtensionStatus::AwsAutoTagging::TaggedSymbol + ] + ) + end + def self.values + end + end + + module GoogleAutoTagging + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekit::Models::FileUploadResponse::ExtensionStatus::GoogleAutoTagging + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + SUCCESS = + T.let( + :success, + Imagekit::Models::FileUploadResponse::ExtensionStatus::GoogleAutoTagging::TaggedSymbol + ) + PENDING = + T.let( + :pending, + Imagekit::Models::FileUploadResponse::ExtensionStatus::GoogleAutoTagging::TaggedSymbol + ) + FAILED = + T.let( + :failed, + Imagekit::Models::FileUploadResponse::ExtensionStatus::GoogleAutoTagging::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekit::Models::FileUploadResponse::ExtensionStatus::GoogleAutoTagging::TaggedSymbol + ] + ) + end + def self.values + end + end + + module RemoveBg + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekit::Models::FileUploadResponse::ExtensionStatus::RemoveBg + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + SUCCESS = + T.let( + :success, + Imagekit::Models::FileUploadResponse::ExtensionStatus::RemoveBg::TaggedSymbol + ) + PENDING = + T.let( + :pending, + Imagekit::Models::FileUploadResponse::ExtensionStatus::RemoveBg::TaggedSymbol + ) + FAILED = + T.let( + :failed, + Imagekit::Models::FileUploadResponse::ExtensionStatus::RemoveBg::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekit::Models::FileUploadResponse::ExtensionStatus::RemoveBg::TaggedSymbol + ] + ) + end + def self.values + end + end + end + + class VersionInfo < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Models::FileUploadResponse::VersionInfo, + Imagekit::Internal::AnyHash + ) + end + + # Unique identifier of the file version. + sig { returns(T.nilable(String)) } + attr_reader :id + + sig { params(id: String).void } + attr_writer :id + + # Name of the file version. + sig { returns(T.nilable(String)) } + attr_reader :name + + sig { params(name: String).void } + attr_writer :name + + # An object containing the file or file version's `id` (versionId) and `name`. + sig { params(id: String, name: String).returns(T.attached_class) } + def self.new( + # Unique identifier of the file version. + id: nil, + # Name of the file version. + name: nil + ) + end + + sig { override.returns({ id: String, name: String }) } + def to_hash + end + end + end + end +end diff --git a/rbi/imagekit/models/files/bulk_add_tags_params.rbi b/rbi/imagekit/models/files/bulk_add_tags_params.rbi new file mode 100644 index 00000000..6825f8f1 --- /dev/null +++ b/rbi/imagekit/models/files/bulk_add_tags_params.rbi @@ -0,0 +1,56 @@ +# typed: strong + +module Imagekit + module Models + module Files + class BulkAddTagsParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekit::Files::BulkAddTagsParams, + Imagekit::Internal::AnyHash + ) + end + + # An array of fileIds to which you want to add tags. + sig { returns(T::Array[String]) } + attr_accessor :file_ids + + # An array of tags that you want to add to the files. + sig { returns(T::Array[String]) } + attr_accessor :tags + + sig do + params( + file_ids: T::Array[String], + tags: T::Array[String], + request_options: Imagekit::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # An array of fileIds to which you want to add tags. + file_ids:, + # An array of tags that you want to add to the files. + tags:, + request_options: {} + ) + end + + sig do + override.returns( + { + file_ids: T::Array[String], + tags: T::Array[String], + request_options: Imagekit::RequestOptions + } + ) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekit/models/files/bulk_add_tags_response.rbi b/rbi/imagekit/models/files/bulk_add_tags_response.rbi new file mode 100644 index 00000000..a33291a4 --- /dev/null +++ b/rbi/imagekit/models/files/bulk_add_tags_response.rbi @@ -0,0 +1,41 @@ +# typed: strong + +module Imagekit + module Models + module Files + class BulkAddTagsResponse < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Models::Files::BulkAddTagsResponse, + Imagekit::Internal::AnyHash + ) + end + + # An array of fileIds that in which tags were successfully added. + sig { returns(T.nilable(T::Array[String])) } + attr_reader :successfully_updated_file_ids + + sig { params(successfully_updated_file_ids: T::Array[String]).void } + attr_writer :successfully_updated_file_ids + + sig do + params(successfully_updated_file_ids: T::Array[String]).returns( + T.attached_class + ) + end + def self.new( + # An array of fileIds that in which tags were successfully added. + successfully_updated_file_ids: nil + ) + end + + sig do + override.returns({ successfully_updated_file_ids: T::Array[String] }) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekit/models/files/bulk_delete_params.rbi b/rbi/imagekit/models/files/bulk_delete_params.rbi new file mode 100644 index 00000000..6aa1de5f --- /dev/null +++ b/rbi/imagekit/models/files/bulk_delete_params.rbi @@ -0,0 +1,48 @@ +# typed: strong + +module Imagekit + module Models + module Files + class BulkDeleteParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekit::Files::BulkDeleteParams, + Imagekit::Internal::AnyHash + ) + end + + # An array of fileIds which you want to delete. + sig { returns(T::Array[String]) } + attr_accessor :file_ids + + sig do + params( + file_ids: T::Array[String], + request_options: Imagekit::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # An array of fileIds which you want to delete. + file_ids:, + request_options: {} + ) + end + + sig do + override.returns( + { + file_ids: T::Array[String], + request_options: Imagekit::RequestOptions + } + ) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekit/models/files/bulk_delete_response.rbi b/rbi/imagekit/models/files/bulk_delete_response.rbi new file mode 100644 index 00000000..28ce486e --- /dev/null +++ b/rbi/imagekit/models/files/bulk_delete_response.rbi @@ -0,0 +1,41 @@ +# typed: strong + +module Imagekit + module Models + module Files + class BulkDeleteResponse < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Models::Files::BulkDeleteResponse, + Imagekit::Internal::AnyHash + ) + end + + # An array of fileIds that were successfully deleted. + sig { returns(T.nilable(T::Array[String])) } + attr_reader :successfully_deleted_file_ids + + sig { params(successfully_deleted_file_ids: T::Array[String]).void } + attr_writer :successfully_deleted_file_ids + + sig do + params(successfully_deleted_file_ids: T::Array[String]).returns( + T.attached_class + ) + end + def self.new( + # An array of fileIds that were successfully deleted. + successfully_deleted_file_ids: nil + ) + end + + sig do + override.returns({ successfully_deleted_file_ids: T::Array[String] }) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekit/models/files/bulk_remove_ai_tags_params.rbi b/rbi/imagekit/models/files/bulk_remove_ai_tags_params.rbi new file mode 100644 index 00000000..b28187ea --- /dev/null +++ b/rbi/imagekit/models/files/bulk_remove_ai_tags_params.rbi @@ -0,0 +1,56 @@ +# typed: strong + +module Imagekit + module Models + module Files + class BulkRemoveAITagsParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekit::Files::BulkRemoveAITagsParams, + Imagekit::Internal::AnyHash + ) + end + + # An array of AITags that you want to remove from the files. + sig { returns(T::Array[String]) } + attr_accessor :ai_tags + + # An array of fileIds from which you want to remove AITags. + sig { returns(T::Array[String]) } + attr_accessor :file_ids + + sig do + params( + ai_tags: T::Array[String], + file_ids: T::Array[String], + request_options: Imagekit::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # An array of AITags that you want to remove from the files. + ai_tags:, + # An array of fileIds from which you want to remove AITags. + file_ids:, + request_options: {} + ) + end + + sig do + override.returns( + { + ai_tags: T::Array[String], + file_ids: T::Array[String], + request_options: Imagekit::RequestOptions + } + ) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekit/models/files/bulk_remove_ai_tags_response.rbi b/rbi/imagekit/models/files/bulk_remove_ai_tags_response.rbi new file mode 100644 index 00000000..404fb021 --- /dev/null +++ b/rbi/imagekit/models/files/bulk_remove_ai_tags_response.rbi @@ -0,0 +1,41 @@ +# typed: strong + +module Imagekit + module Models + module Files + class BulkRemoveAITagsResponse < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Models::Files::BulkRemoveAITagsResponse, + Imagekit::Internal::AnyHash + ) + end + + # An array of fileIds that in which AITags were successfully removed. + sig { returns(T.nilable(T::Array[String])) } + attr_reader :successfully_updated_file_ids + + sig { params(successfully_updated_file_ids: T::Array[String]).void } + attr_writer :successfully_updated_file_ids + + sig do + params(successfully_updated_file_ids: T::Array[String]).returns( + T.attached_class + ) + end + def self.new( + # An array of fileIds that in which AITags were successfully removed. + successfully_updated_file_ids: nil + ) + end + + sig do + override.returns({ successfully_updated_file_ids: T::Array[String] }) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekit/models/files/bulk_remove_tags_params.rbi b/rbi/imagekit/models/files/bulk_remove_tags_params.rbi new file mode 100644 index 00000000..bbbaeebe --- /dev/null +++ b/rbi/imagekit/models/files/bulk_remove_tags_params.rbi @@ -0,0 +1,56 @@ +# typed: strong + +module Imagekit + module Models + module Files + class BulkRemoveTagsParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekit::Files::BulkRemoveTagsParams, + Imagekit::Internal::AnyHash + ) + end + + # An array of fileIds from which you want to remove tags. + sig { returns(T::Array[String]) } + attr_accessor :file_ids + + # An array of tags that you want to remove from the files. + sig { returns(T::Array[String]) } + attr_accessor :tags + + sig do + params( + file_ids: T::Array[String], + tags: T::Array[String], + request_options: Imagekit::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # An array of fileIds from which you want to remove tags. + file_ids:, + # An array of tags that you want to remove from the files. + tags:, + request_options: {} + ) + end + + sig do + override.returns( + { + file_ids: T::Array[String], + tags: T::Array[String], + request_options: Imagekit::RequestOptions + } + ) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekit/models/files/bulk_remove_tags_response.rbi b/rbi/imagekit/models/files/bulk_remove_tags_response.rbi new file mode 100644 index 00000000..68d16d5d --- /dev/null +++ b/rbi/imagekit/models/files/bulk_remove_tags_response.rbi @@ -0,0 +1,41 @@ +# typed: strong + +module Imagekit + module Models + module Files + class BulkRemoveTagsResponse < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Models::Files::BulkRemoveTagsResponse, + Imagekit::Internal::AnyHash + ) + end + + # An array of fileIds that in which tags were successfully removed. + sig { returns(T.nilable(T::Array[String])) } + attr_reader :successfully_updated_file_ids + + sig { params(successfully_updated_file_ids: T::Array[String]).void } + attr_writer :successfully_updated_file_ids + + sig do + params(successfully_updated_file_ids: T::Array[String]).returns( + T.attached_class + ) + end + def self.new( + # An array of fileIds that in which tags were successfully removed. + successfully_updated_file_ids: nil + ) + end + + sig do + override.returns({ successfully_updated_file_ids: T::Array[String] }) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekit/models/files/metadata_get_from_url_params.rbi b/rbi/imagekit/models/files/metadata_get_from_url_params.rbi new file mode 100644 index 00000000..b22de2f1 --- /dev/null +++ b/rbi/imagekit/models/files/metadata_get_from_url_params.rbi @@ -0,0 +1,47 @@ +# typed: strong + +module Imagekit + module Models + module Files + class MetadataGetFromURLParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekit::Files::MetadataGetFromURLParams, + Imagekit::Internal::AnyHash + ) + end + + # Should be a valid file URL. It should be accessible using your ImageKit.io + # account. + sig { returns(String) } + attr_accessor :url + + sig do + params( + url: String, + request_options: Imagekit::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # Should be a valid file URL. It should be accessible using your ImageKit.io + # account. + url:, + request_options: {} + ) + end + + sig do + override.returns( + { url: String, request_options: Imagekit::RequestOptions } + ) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekit/models/files/metadata_get_params.rbi b/rbi/imagekit/models/files/metadata_get_params.rbi new file mode 100644 index 00000000..af5861ac --- /dev/null +++ b/rbi/imagekit/models/files/metadata_get_params.rbi @@ -0,0 +1,32 @@ +# typed: strong + +module Imagekit + module Models + module Files + class MetadataGetParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekit::Files::MetadataGetParams, + Imagekit::Internal::AnyHash + ) + end + + sig do + params(request_options: Imagekit::RequestOptions::OrHash).returns( + T.attached_class + ) + end + def self.new(request_options: {}) + end + + sig { override.returns({ request_options: Imagekit::RequestOptions }) } + def to_hash + end + end + end + end +end diff --git a/rbi/imagekit/models/files/version_delete_params.rbi b/rbi/imagekit/models/files/version_delete_params.rbi new file mode 100644 index 00000000..ba925a21 --- /dev/null +++ b/rbi/imagekit/models/files/version_delete_params.rbi @@ -0,0 +1,40 @@ +# typed: strong + +module Imagekit + module Models + module Files + class VersionDeleteParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekit::Files::VersionDeleteParams, + Imagekit::Internal::AnyHash + ) + end + + sig { returns(String) } + attr_accessor :file_id + + sig do + params( + file_id: String, + request_options: Imagekit::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new(file_id:, request_options: {}) + end + + sig do + override.returns( + { file_id: String, request_options: Imagekit::RequestOptions } + ) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekit/models/files/version_delete_response.rbi b/rbi/imagekit/models/files/version_delete_response.rbi new file mode 100644 index 00000000..6d0f6ab9 --- /dev/null +++ b/rbi/imagekit/models/files/version_delete_response.rbi @@ -0,0 +1,25 @@ +# typed: strong + +module Imagekit + module Models + module Files + class VersionDeleteResponse < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Models::Files::VersionDeleteResponse, + Imagekit::Internal::AnyHash + ) + end + + sig { returns(T.attached_class) } + def self.new + end + + sig { override.returns({}) } + def to_hash + end + end + end + end +end diff --git a/rbi/imagekit/models/files/version_get_params.rbi b/rbi/imagekit/models/files/version_get_params.rbi new file mode 100644 index 00000000..107a03d0 --- /dev/null +++ b/rbi/imagekit/models/files/version_get_params.rbi @@ -0,0 +1,40 @@ +# typed: strong + +module Imagekit + module Models + module Files + class VersionGetParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekit::Files::VersionGetParams, + Imagekit::Internal::AnyHash + ) + end + + sig { returns(String) } + attr_accessor :file_id + + sig do + params( + file_id: String, + request_options: Imagekit::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new(file_id:, request_options: {}) + end + + sig do + override.returns( + { file_id: String, request_options: Imagekit::RequestOptions } + ) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekit/models/files/version_list_params.rbi b/rbi/imagekit/models/files/version_list_params.rbi new file mode 100644 index 00000000..496f70bb --- /dev/null +++ b/rbi/imagekit/models/files/version_list_params.rbi @@ -0,0 +1,32 @@ +# typed: strong + +module Imagekit + module Models + module Files + class VersionListParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekit::Files::VersionListParams, + Imagekit::Internal::AnyHash + ) + end + + sig do + params(request_options: Imagekit::RequestOptions::OrHash).returns( + T.attached_class + ) + end + def self.new(request_options: {}) + end + + sig { override.returns({ request_options: Imagekit::RequestOptions }) } + def to_hash + end + end + end + end +end diff --git a/rbi/imagekit/models/files/version_list_response.rbi b/rbi/imagekit/models/files/version_list_response.rbi new file mode 100644 index 00000000..8ac552c7 --- /dev/null +++ b/rbi/imagekit/models/files/version_list_response.rbi @@ -0,0 +1,13 @@ +# typed: strong + +module Imagekit + module Models + module Files + VersionListResponse = + T.let( + Imagekit::Internal::Type::ArrayOf[Imagekit::File], + Imagekit::Internal::Type::Converter + ) + end + end +end diff --git a/rbi/imagekit/models/files/version_restore_params.rbi b/rbi/imagekit/models/files/version_restore_params.rbi new file mode 100644 index 00000000..c4b466fd --- /dev/null +++ b/rbi/imagekit/models/files/version_restore_params.rbi @@ -0,0 +1,40 @@ +# typed: strong + +module Imagekit + module Models + module Files + class VersionRestoreParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekit::Files::VersionRestoreParams, + Imagekit::Internal::AnyHash + ) + end + + sig { returns(String) } + attr_accessor :file_id + + sig do + params( + file_id: String, + request_options: Imagekit::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new(file_id:, request_options: {}) + end + + sig do + override.returns( + { file_id: String, request_options: Imagekit::RequestOptions } + ) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekit/models/folder.rbi b/rbi/imagekit/models/folder.rbi new file mode 100644 index 00000000..ae0620c3 --- /dev/null +++ b/rbi/imagekit/models/folder.rbi @@ -0,0 +1,117 @@ +# typed: strong + +module Imagekit + module Models + class Folder < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias { T.any(Imagekit::Folder, Imagekit::Internal::AnyHash) } + + # Date and time when the folder was created. The date and time is in ISO8601 + # format. + sig { returns(T.nilable(Time)) } + attr_reader :created_at + + sig { params(created_at: Time).void } + attr_writer :created_at + + # Unique identifier of the asset. + sig { returns(T.nilable(String)) } + attr_reader :folder_id + + sig { params(folder_id: String).void } + attr_writer :folder_id + + # Path of the folder. This is the path you would use in the URL to access the + # folder. For example, if the folder is at the root of the media library, the path + # will be /folder. If the folder is inside another folder named images, the path + # will be /images/folder. + sig { returns(T.nilable(String)) } + attr_reader :folder_path + + sig { params(folder_path: String).void } + attr_writer :folder_path + + # Name of the asset. + sig { returns(T.nilable(String)) } + attr_reader :name + + sig { params(name: String).void } + attr_writer :name + + # Type of the asset. + sig { returns(T.nilable(Imagekit::Folder::Type::TaggedSymbol)) } + attr_reader :type + + sig { params(type: Imagekit::Folder::Type::OrSymbol).void } + attr_writer :type + + # Date and time when the folder was last updated. The date and time is in ISO8601 + # format. + sig { returns(T.nilable(Time)) } + attr_reader :updated_at + + sig { params(updated_at: Time).void } + attr_writer :updated_at + + sig do + params( + created_at: Time, + folder_id: String, + folder_path: String, + name: String, + type: Imagekit::Folder::Type::OrSymbol, + updated_at: Time + ).returns(T.attached_class) + end + def self.new( + # Date and time when the folder was created. The date and time is in ISO8601 + # format. + created_at: nil, + # Unique identifier of the asset. + folder_id: nil, + # Path of the folder. This is the path you would use in the URL to access the + # folder. For example, if the folder is at the root of the media library, the path + # will be /folder. If the folder is inside another folder named images, the path + # will be /images/folder. + folder_path: nil, + # Name of the asset. + name: nil, + # Type of the asset. + type: nil, + # Date and time when the folder was last updated. The date and time is in ISO8601 + # format. + updated_at: nil + ) + end + + sig do + override.returns( + { + created_at: Time, + folder_id: String, + folder_path: String, + name: String, + type: Imagekit::Folder::Type::TaggedSymbol, + updated_at: Time + } + ) + end + def to_hash + end + + # Type of the asset. + module Type + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, Imagekit::Folder::Type) } + OrSymbol = T.type_alias { T.any(Symbol, String) } + + FOLDER = T.let(:folder, Imagekit::Folder::Type::TaggedSymbol) + + sig { override.returns(T::Array[Imagekit::Folder::Type::TaggedSymbol]) } + def self.values + end + end + end + end +end diff --git a/rbi/imagekit/models/folder_copy_params.rbi b/rbi/imagekit/models/folder_copy_params.rbi new file mode 100644 index 00000000..b73945bc --- /dev/null +++ b/rbi/imagekit/models/folder_copy_params.rbi @@ -0,0 +1,68 @@ +# typed: strong + +module Imagekit + module Models + class FolderCopyParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any(Imagekit::FolderCopyParams, Imagekit::Internal::AnyHash) + end + + # Full path to the destination folder where you want to copy the source folder + # into. + sig { returns(String) } + attr_accessor :destination_path + + # The full path to the source folder you want to copy. + sig { returns(String) } + attr_accessor :source_folder_path + + # Option to copy all versions of files that are nested inside the selected folder. + # By default, only the current version of each file will be copied. When set to + # true, all versions of each file will be copied. Default value - `false`. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :include_versions + + sig { params(include_versions: T::Boolean).void } + attr_writer :include_versions + + sig do + params( + destination_path: String, + source_folder_path: String, + include_versions: T::Boolean, + request_options: Imagekit::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # Full path to the destination folder where you want to copy the source folder + # into. + destination_path:, + # The full path to the source folder you want to copy. + source_folder_path:, + # Option to copy all versions of files that are nested inside the selected folder. + # By default, only the current version of each file will be copied. When set to + # true, all versions of each file will be copied. Default value - `false`. + include_versions: nil, + request_options: {} + ) + end + + sig do + override.returns( + { + destination_path: String, + source_folder_path: String, + include_versions: T::Boolean, + request_options: Imagekit::RequestOptions + } + ) + end + def to_hash + end + end + end +end diff --git a/rbi/imagekit/models/folder_copy_response.rbi b/rbi/imagekit/models/folder_copy_response.rbi new file mode 100644 index 00000000..f294ad91 --- /dev/null +++ b/rbi/imagekit/models/folder_copy_response.rbi @@ -0,0 +1,33 @@ +# typed: strong + +module Imagekit + module Models + class FolderCopyResponse < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Models::FolderCopyResponse, + Imagekit::Internal::AnyHash + ) + end + + # Unique identifier of the bulk job. This can be used to check the status of the + # bulk job. + sig { returns(String) } + attr_accessor :job_id + + # Job submitted successfully. A `jobId` will be returned. + sig { params(job_id: String).returns(T.attached_class) } + def self.new( + # Unique identifier of the bulk job. This can be used to check the status of the + # bulk job. + job_id: + ) + end + + sig { override.returns({ job_id: String }) } + def to_hash + end + end + end +end diff --git a/rbi/imagekit/models/folder_create_params.rbi b/rbi/imagekit/models/folder_create_params.rbi new file mode 100644 index 00000000..c33e9c28 --- /dev/null +++ b/rbi/imagekit/models/folder_create_params.rbi @@ -0,0 +1,71 @@ +# typed: strong + +module Imagekit + module Models + class FolderCreateParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any(Imagekit::FolderCreateParams, Imagekit::Internal::AnyHash) + end + + # The folder will be created with this name. + # + # All characters except alphabets and numbers (inclusive of unicode letters, + # marks, and numerals in other languages) will be replaced by an underscore i.e. + # `_`. + sig { returns(String) } + attr_accessor :folder_name + + # The folder where the new folder should be created, for root use `/` else the + # path e.g. `containing/folder/`. + # + # Note: If any folder(s) is not present in the parentFolderPath parameter, it will + # be automatically created. For example, if you pass `/product/images/summer`, + # then `product`, `images`, and `summer` folders will be created if they don't + # already exist. + sig { returns(String) } + attr_accessor :parent_folder_path + + sig do + params( + folder_name: String, + parent_folder_path: String, + request_options: Imagekit::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # The folder will be created with this name. + # + # All characters except alphabets and numbers (inclusive of unicode letters, + # marks, and numerals in other languages) will be replaced by an underscore i.e. + # `_`. + folder_name:, + # The folder where the new folder should be created, for root use `/` else the + # path e.g. `containing/folder/`. + # + # Note: If any folder(s) is not present in the parentFolderPath parameter, it will + # be automatically created. For example, if you pass `/product/images/summer`, + # then `product`, `images`, and `summer` folders will be created if they don't + # already exist. + parent_folder_path:, + request_options: {} + ) + end + + sig do + override.returns( + { + folder_name: String, + parent_folder_path: String, + request_options: Imagekit::RequestOptions + } + ) + end + def to_hash + end + end + end +end diff --git a/rbi/imagekit/models/folder_create_response.rbi b/rbi/imagekit/models/folder_create_response.rbi new file mode 100644 index 00000000..f3d143f9 --- /dev/null +++ b/rbi/imagekit/models/folder_create_response.rbi @@ -0,0 +1,23 @@ +# typed: strong + +module Imagekit + module Models + class FolderCreateResponse < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Models::FolderCreateResponse, + Imagekit::Internal::AnyHash + ) + end + + sig { returns(T.attached_class) } + def self.new + end + + sig { override.returns({}) } + def to_hash + end + end + end +end diff --git a/rbi/imagekit/models/folder_delete_params.rbi b/rbi/imagekit/models/folder_delete_params.rbi new file mode 100644 index 00000000..09e1c54c --- /dev/null +++ b/rbi/imagekit/models/folder_delete_params.rbi @@ -0,0 +1,40 @@ +# typed: strong + +module Imagekit + module Models + class FolderDeleteParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any(Imagekit::FolderDeleteParams, Imagekit::Internal::AnyHash) + end + + # Full path to the folder you want to delete. For example `/folder/to/delete/`. + sig { returns(String) } + attr_accessor :folder_path + + sig do + params( + folder_path: String, + request_options: Imagekit::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # Full path to the folder you want to delete. For example `/folder/to/delete/`. + folder_path:, + request_options: {} + ) + end + + sig do + override.returns( + { folder_path: String, request_options: Imagekit::RequestOptions } + ) + end + def to_hash + end + end + end +end diff --git a/rbi/imagekit/models/folder_delete_response.rbi b/rbi/imagekit/models/folder_delete_response.rbi new file mode 100644 index 00000000..74f9d60b --- /dev/null +++ b/rbi/imagekit/models/folder_delete_response.rbi @@ -0,0 +1,23 @@ +# typed: strong + +module Imagekit + module Models + class FolderDeleteResponse < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Models::FolderDeleteResponse, + Imagekit::Internal::AnyHash + ) + end + + sig { returns(T.attached_class) } + def self.new + end + + sig { override.returns({}) } + def to_hash + end + end + end +end diff --git a/rbi/imagekit/models/folder_move_params.rbi b/rbi/imagekit/models/folder_move_params.rbi new file mode 100644 index 00000000..c8bb4036 --- /dev/null +++ b/rbi/imagekit/models/folder_move_params.rbi @@ -0,0 +1,53 @@ +# typed: strong + +module Imagekit + module Models + class FolderMoveParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any(Imagekit::FolderMoveParams, Imagekit::Internal::AnyHash) + end + + # Full path to the destination folder where you want to move the source folder + # into. + sig { returns(String) } + attr_accessor :destination_path + + # The full path to the source folder you want to move. + sig { returns(String) } + attr_accessor :source_folder_path + + sig do + params( + destination_path: String, + source_folder_path: String, + request_options: Imagekit::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # Full path to the destination folder where you want to move the source folder + # into. + destination_path:, + # The full path to the source folder you want to move. + source_folder_path:, + request_options: {} + ) + end + + sig do + override.returns( + { + destination_path: String, + source_folder_path: String, + request_options: Imagekit::RequestOptions + } + ) + end + def to_hash + end + end + end +end diff --git a/rbi/imagekit/models/folder_move_response.rbi b/rbi/imagekit/models/folder_move_response.rbi new file mode 100644 index 00000000..e19ca456 --- /dev/null +++ b/rbi/imagekit/models/folder_move_response.rbi @@ -0,0 +1,33 @@ +# typed: strong + +module Imagekit + module Models + class FolderMoveResponse < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Models::FolderMoveResponse, + Imagekit::Internal::AnyHash + ) + end + + # Unique identifier of the bulk job. This can be used to check the status of the + # bulk job. + sig { returns(String) } + attr_accessor :job_id + + # Job submitted successfully. A `jobId` will be returned. + sig { params(job_id: String).returns(T.attached_class) } + def self.new( + # Unique identifier of the bulk job. This can be used to check the status of the + # bulk job. + job_id: + ) + end + + sig { override.returns({ job_id: String }) } + def to_hash + end + end + end +end diff --git a/rbi/imagekit/models/folder_rename_params.rbi b/rbi/imagekit/models/folder_rename_params.rbi new file mode 100644 index 00000000..3de0ef79 --- /dev/null +++ b/rbi/imagekit/models/folder_rename_params.rbi @@ -0,0 +1,98 @@ +# typed: strong + +module Imagekit + module Models + class FolderRenameParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any(Imagekit::FolderRenameParams, Imagekit::Internal::AnyHash) + end + + # The full path to the folder you want to rename. + sig { returns(String) } + attr_accessor :folder_path + + # The new name for the folder. + # + # All characters except alphabets and numbers (inclusive of unicode letters, + # marks, and numerals in other languages) and `-` will be replaced by an + # underscore i.e. `_`. + sig { returns(String) } + attr_accessor :new_folder_name + + # Option to purge cache for the old nested files and their versions' URLs. + # + # When set to true, it will internally issue a purge cache request on CDN to + # remove the cached content of the old nested files and their versions. There will + # only be one purge request for all the nested files, which will be counted + # against your monthly purge quota. + # + # Note: A purge cache request will be issued against + # `https://ik.imagekit.io/old/folder/path*` (with a wildcard at the end). This + # will remove all nested files, their versions' URLs, and any transformations made + # using query parameters on these files or their versions. However, the cache for + # file transformations made using path parameters will persist. You can purge them + # using the purge API. For more details, refer to the purge API documentation. + # + # Default value - `false` + sig { returns(T.nilable(T::Boolean)) } + attr_reader :purge_cache + + sig { params(purge_cache: T::Boolean).void } + attr_writer :purge_cache + + sig do + params( + folder_path: String, + new_folder_name: String, + purge_cache: T::Boolean, + request_options: Imagekit::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # The full path to the folder you want to rename. + folder_path:, + # The new name for the folder. + # + # All characters except alphabets and numbers (inclusive of unicode letters, + # marks, and numerals in other languages) and `-` will be replaced by an + # underscore i.e. `_`. + new_folder_name:, + # Option to purge cache for the old nested files and their versions' URLs. + # + # When set to true, it will internally issue a purge cache request on CDN to + # remove the cached content of the old nested files and their versions. There will + # only be one purge request for all the nested files, which will be counted + # against your monthly purge quota. + # + # Note: A purge cache request will be issued against + # `https://ik.imagekit.io/old/folder/path*` (with a wildcard at the end). This + # will remove all nested files, their versions' URLs, and any transformations made + # using query parameters on these files or their versions. However, the cache for + # file transformations made using path parameters will persist. You can purge them + # using the purge API. For more details, refer to the purge API documentation. + # + # Default value - `false` + purge_cache: nil, + request_options: {} + ) + end + + sig do + override.returns( + { + folder_path: String, + new_folder_name: String, + purge_cache: T::Boolean, + request_options: Imagekit::RequestOptions + } + ) + end + def to_hash + end + end + end +end diff --git a/rbi/imagekit/models/folder_rename_response.rbi b/rbi/imagekit/models/folder_rename_response.rbi new file mode 100644 index 00000000..5fad09f4 --- /dev/null +++ b/rbi/imagekit/models/folder_rename_response.rbi @@ -0,0 +1,33 @@ +# typed: strong + +module Imagekit + module Models + class FolderRenameResponse < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Models::FolderRenameResponse, + Imagekit::Internal::AnyHash + ) + end + + # Unique identifier of the bulk job. This can be used to check the status of the + # bulk job. + sig { returns(String) } + attr_accessor :job_id + + # Job submitted successfully. A `jobId` will be returned. + sig { params(job_id: String).returns(T.attached_class) } + def self.new( + # Unique identifier of the bulk job. This can be used to check the status of the + # bulk job. + job_id: + ) + end + + sig { override.returns({ job_id: String }) } + def to_hash + end + end + end +end diff --git a/rbi/imagekit/models/folders/job_get_params.rbi b/rbi/imagekit/models/folders/job_get_params.rbi new file mode 100644 index 00000000..5dc84db4 --- /dev/null +++ b/rbi/imagekit/models/folders/job_get_params.rbi @@ -0,0 +1,29 @@ +# typed: strong + +module Imagekit + module Models + module Folders + class JobGetParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any(Imagekit::Folders::JobGetParams, Imagekit::Internal::AnyHash) + end + + sig do + params(request_options: Imagekit::RequestOptions::OrHash).returns( + T.attached_class + ) + end + def self.new(request_options: {}) + end + + sig { override.returns({ request_options: Imagekit::RequestOptions }) } + def to_hash + end + end + end + end +end diff --git a/rbi/imagekit/models/folders/job_get_response.rbi b/rbi/imagekit/models/folders/job_get_response.rbi new file mode 100644 index 00000000..518392e0 --- /dev/null +++ b/rbi/imagekit/models/folders/job_get_response.rbi @@ -0,0 +1,171 @@ +# typed: strong + +module Imagekit + module Models + module Folders + class JobGetResponse < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Models::Folders::JobGetResponse, + Imagekit::Internal::AnyHash + ) + end + + # Unique identifier of the bulk job. + sig { returns(T.nilable(String)) } + attr_reader :job_id + + sig { params(job_id: String).void } + attr_writer :job_id + + # Unique identifier of the purge request. This will be present only if + # `purgeCache` is set to `true` in the rename folder API request. + sig { returns(T.nilable(String)) } + attr_reader :purge_request_id + + sig { params(purge_request_id: String).void } + attr_writer :purge_request_id + + # Status of the bulk job. + sig do + returns( + T.nilable( + Imagekit::Models::Folders::JobGetResponse::Status::TaggedSymbol + ) + ) + end + attr_reader :status + + sig do + params( + status: Imagekit::Models::Folders::JobGetResponse::Status::OrSymbol + ).void + end + attr_writer :status + + # Type of the bulk job. + sig do + returns( + T.nilable( + Imagekit::Models::Folders::JobGetResponse::Type::TaggedSymbol + ) + ) + end + attr_reader :type + + sig do + params( + type: Imagekit::Models::Folders::JobGetResponse::Type::OrSymbol + ).void + end + attr_writer :type + + sig do + params( + job_id: String, + purge_request_id: String, + status: Imagekit::Models::Folders::JobGetResponse::Status::OrSymbol, + type: Imagekit::Models::Folders::JobGetResponse::Type::OrSymbol + ).returns(T.attached_class) + end + def self.new( + # Unique identifier of the bulk job. + job_id: nil, + # Unique identifier of the purge request. This will be present only if + # `purgeCache` is set to `true` in the rename folder API request. + purge_request_id: nil, + # Status of the bulk job. + status: nil, + # Type of the bulk job. + type: nil + ) + end + + sig do + override.returns( + { + job_id: String, + purge_request_id: String, + status: + Imagekit::Models::Folders::JobGetResponse::Status::TaggedSymbol, + type: + Imagekit::Models::Folders::JobGetResponse::Type::TaggedSymbol + } + ) + end + def to_hash + end + + # Status of the bulk job. + module Status + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all(Symbol, Imagekit::Models::Folders::JobGetResponse::Status) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + PENDING = + T.let( + :Pending, + Imagekit::Models::Folders::JobGetResponse::Status::TaggedSymbol + ) + COMPLETED = + T.let( + :Completed, + Imagekit::Models::Folders::JobGetResponse::Status::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekit::Models::Folders::JobGetResponse::Status::TaggedSymbol + ] + ) + end + def self.values + end + end + + # Type of the bulk job. + module Type + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all(Symbol, Imagekit::Models::Folders::JobGetResponse::Type) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + COPY_FOLDER = + T.let( + :COPY_FOLDER, + Imagekit::Models::Folders::JobGetResponse::Type::TaggedSymbol + ) + MOVE_FOLDER = + T.let( + :MOVE_FOLDER, + Imagekit::Models::Folders::JobGetResponse::Type::TaggedSymbol + ) + RENAME_FOLDER = + T.let( + :RENAME_FOLDER, + Imagekit::Models::Folders::JobGetResponse::Type::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekit::Models::Folders::JobGetResponse::Type::TaggedSymbol + ] + ) + end + def self.values + end + end + end + end + end +end diff --git a/rbi/imagekit/models/image_overlay.rbi b/rbi/imagekit/models/image_overlay.rbi new file mode 100644 index 00000000..409aa105 --- /dev/null +++ b/rbi/imagekit/models/image_overlay.rbi @@ -0,0 +1,106 @@ +# typed: strong + +module Imagekit + module Models + class ImageOverlay < Imagekit::Models::BaseOverlay + OrHash = + T.type_alias do + T.any(Imagekit::ImageOverlay, Imagekit::Internal::AnyHash) + end + + # Specifies the relative path to the image used as an overlay. + sig { returns(String) } + attr_accessor :input + + sig { returns(Symbol) } + attr_accessor :type + + # The input path can be included in the layer as either `i-{input}` or + # `ie-{base64_encoded_input}`. By default, the SDK determines the appropriate + # format automatically. To always use base64 encoding (`ie-{base64}`), set this + # parameter to `base64`. To always use plain text (`i-{input}`), set it to + # `plain`. + sig { returns(T.nilable(Imagekit::ImageOverlay::Encoding::OrSymbol)) } + attr_reader :encoding + + sig { params(encoding: Imagekit::ImageOverlay::Encoding::OrSymbol).void } + attr_writer :encoding + + # Array of transformations to be applied to the overlay image. Supported + # transformations depends on the base/parent asset. See overlays on + # [Images](https://imagekit.io/docs/add-overlays-on-images#list-of-supported-image-transformations-in-image-layers) + # and + # [Videos](https://imagekit.io/docs/add-overlays-on-videos#list-of-transformations-supported-on-image-overlay). + sig { returns(T.nilable(T::Array[Imagekit::Transformation])) } + attr_reader :transformation + + sig { params(transformation: T::Array[Imagekit::Transformation]).void } + attr_writer :transformation + + sig do + params( + input: String, + encoding: Imagekit::ImageOverlay::Encoding::OrSymbol, + transformation: T::Array[Imagekit::Transformation], + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Specifies the relative path to the image used as an overlay. + input:, + # The input path can be included in the layer as either `i-{input}` or + # `ie-{base64_encoded_input}`. By default, the SDK determines the appropriate + # format automatically. To always use base64 encoding (`ie-{base64}`), set this + # parameter to `base64`. To always use plain text (`i-{input}`), set it to + # `plain`. + encoding: nil, + # Array of transformations to be applied to the overlay image. Supported + # transformations depends on the base/parent asset. See overlays on + # [Images](https://imagekit.io/docs/add-overlays-on-images#list-of-supported-image-transformations-in-image-layers) + # and + # [Videos](https://imagekit.io/docs/add-overlays-on-videos#list-of-transformations-supported-on-image-overlay). + transformation: nil, + type: :image + ) + end + + sig do + override.returns( + { + input: String, + type: Symbol, + encoding: Imagekit::ImageOverlay::Encoding::OrSymbol, + transformation: T::Array[Imagekit::Transformation] + } + ) + end + def to_hash + end + + # The input path can be included in the layer as either `i-{input}` or + # `ie-{base64_encoded_input}`. By default, the SDK determines the appropriate + # format automatically. To always use base64 encoding (`ie-{base64}`), set this + # parameter to `base64`. To always use plain text (`i-{input}`), set it to + # `plain`. + module Encoding + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, Imagekit::ImageOverlay::Encoding) } + OrSymbol = T.type_alias { T.any(Symbol, String) } + + AUTO = T.let(:auto, Imagekit::ImageOverlay::Encoding::TaggedSymbol) + PLAIN = T.let(:plain, Imagekit::ImageOverlay::Encoding::TaggedSymbol) + BASE64 = T.let(:base64, Imagekit::ImageOverlay::Encoding::TaggedSymbol) + + sig do + override.returns( + T::Array[Imagekit::ImageOverlay::Encoding::TaggedSymbol] + ) + end + def self.values + end + end + end + end +end diff --git a/rbi/imagekit/models/metadata.rbi b/rbi/imagekit/models/metadata.rbi new file mode 100644 index 00000000..53bea104 --- /dev/null +++ b/rbi/imagekit/models/metadata.rbi @@ -0,0 +1,804 @@ +# typed: strong + +module Imagekit + module Models + class Metadata < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias { T.any(Imagekit::Metadata, Imagekit::Internal::AnyHash) } + + # The audio codec used in the video (only for video). + sig { returns(T.nilable(String)) } + attr_reader :audio_codec + + sig { params(audio_codec: String).void } + attr_writer :audio_codec + + # The bit rate of the video in kbps (only for video). + sig { returns(T.nilable(Integer)) } + attr_reader :bit_rate + + sig { params(bit_rate: Integer).void } + attr_writer :bit_rate + + # The density of the image in DPI. + sig { returns(T.nilable(Integer)) } + attr_reader :density + + sig { params(density: Integer).void } + attr_writer :density + + # The duration of the video in seconds (only for video). + sig { returns(T.nilable(Integer)) } + attr_reader :duration + + sig { params(duration: Integer).void } + attr_writer :duration + + sig { returns(T.nilable(Imagekit::Metadata::Exif)) } + attr_reader :exif + + sig { params(exif: Imagekit::Metadata::Exif::OrHash).void } + attr_writer :exif + + # The format of the file (e.g., 'jpg', 'mp4'). + sig { returns(T.nilable(String)) } + attr_reader :format_ + + sig { params(format_: String).void } + attr_writer :format_ + + # Indicates if the image has a color profile. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :has_color_profile + + sig { params(has_color_profile: T::Boolean).void } + attr_writer :has_color_profile + + # Indicates if the image contains transparent areas. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :has_transparency + + sig { params(has_transparency: T::Boolean).void } + attr_writer :has_transparency + + # The height of the image or video in pixels. + sig { returns(T.nilable(Integer)) } + attr_reader :height + + sig { params(height: Integer).void } + attr_writer :height + + # Perceptual hash of the image. + sig { returns(T.nilable(String)) } + attr_reader :p_hash + + sig { params(p_hash: String).void } + attr_writer :p_hash + + # The quality indicator of the image. + sig { returns(T.nilable(Integer)) } + attr_reader :quality + + sig { params(quality: Integer).void } + attr_writer :quality + + # The file size in bytes. + sig { returns(T.nilable(Integer)) } + attr_reader :size + + sig { params(size: Integer).void } + attr_writer :size + + # The video codec used in the video (only for video). + sig { returns(T.nilable(String)) } + attr_reader :video_codec + + sig { params(video_codec: String).void } + attr_writer :video_codec + + # The width of the image or video in pixels. + sig { returns(T.nilable(Integer)) } + attr_reader :width + + sig { params(width: Integer).void } + attr_writer :width + + # JSON object containing metadata. + sig do + params( + audio_codec: String, + bit_rate: Integer, + density: Integer, + duration: Integer, + exif: Imagekit::Metadata::Exif::OrHash, + format_: String, + has_color_profile: T::Boolean, + has_transparency: T::Boolean, + height: Integer, + p_hash: String, + quality: Integer, + size: Integer, + video_codec: String, + width: Integer + ).returns(T.attached_class) + end + def self.new( + # The audio codec used in the video (only for video). + audio_codec: nil, + # The bit rate of the video in kbps (only for video). + bit_rate: nil, + # The density of the image in DPI. + density: nil, + # The duration of the video in seconds (only for video). + duration: nil, + exif: nil, + # The format of the file (e.g., 'jpg', 'mp4'). + format_: nil, + # Indicates if the image has a color profile. + has_color_profile: nil, + # Indicates if the image contains transparent areas. + has_transparency: nil, + # The height of the image or video in pixels. + height: nil, + # Perceptual hash of the image. + p_hash: nil, + # The quality indicator of the image. + quality: nil, + # The file size in bytes. + size: nil, + # The video codec used in the video (only for video). + video_codec: nil, + # The width of the image or video in pixels. + width: nil + ) + end + + sig do + override.returns( + { + audio_codec: String, + bit_rate: Integer, + density: Integer, + duration: Integer, + exif: Imagekit::Metadata::Exif, + format_: String, + has_color_profile: T::Boolean, + has_transparency: T::Boolean, + height: Integer, + p_hash: String, + quality: Integer, + size: Integer, + video_codec: String, + width: Integer + } + ) + end + def to_hash + end + + class Exif < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any(Imagekit::Metadata::Exif, Imagekit::Internal::AnyHash) + end + + # Object containing Exif details. + sig { returns(T.nilable(Imagekit::Metadata::Exif::Exif)) } + attr_reader :exif + + sig { params(exif: Imagekit::Metadata::Exif::Exif::OrHash).void } + attr_writer :exif + + # Object containing GPS information. + sig { returns(T.nilable(Imagekit::Metadata::Exif::Gps)) } + attr_reader :gps + + sig { params(gps: Imagekit::Metadata::Exif::Gps::OrHash).void } + attr_writer :gps + + # Object containing EXIF image information. + sig { returns(T.nilable(Imagekit::Metadata::Exif::Image)) } + attr_reader :image + + sig { params(image: Imagekit::Metadata::Exif::Image::OrHash).void } + attr_writer :image + + # JSON object. + sig { returns(T.nilable(Imagekit::Metadata::Exif::Interoperability)) } + attr_reader :interoperability + + sig do + params( + interoperability: Imagekit::Metadata::Exif::Interoperability::OrHash + ).void + end + attr_writer :interoperability + + sig { returns(T.nilable(T::Hash[Symbol, T.anything])) } + attr_reader :makernote + + sig { params(makernote: T::Hash[Symbol, T.anything]).void } + attr_writer :makernote + + # Object containing Thumbnail information. + sig { returns(T.nilable(Imagekit::Metadata::Exif::Thumbnail)) } + attr_reader :thumbnail + + sig do + params(thumbnail: Imagekit::Metadata::Exif::Thumbnail::OrHash).void + end + attr_writer :thumbnail + + sig do + params( + exif: Imagekit::Metadata::Exif::Exif::OrHash, + gps: Imagekit::Metadata::Exif::Gps::OrHash, + image: Imagekit::Metadata::Exif::Image::OrHash, + interoperability: + Imagekit::Metadata::Exif::Interoperability::OrHash, + makernote: T::Hash[Symbol, T.anything], + thumbnail: Imagekit::Metadata::Exif::Thumbnail::OrHash + ).returns(T.attached_class) + end + def self.new( + # Object containing Exif details. + exif: nil, + # Object containing GPS information. + gps: nil, + # Object containing EXIF image information. + image: nil, + # JSON object. + interoperability: nil, + makernote: nil, + # Object containing Thumbnail information. + thumbnail: nil + ) + end + + sig do + override.returns( + { + exif: Imagekit::Metadata::Exif::Exif, + gps: Imagekit::Metadata::Exif::Gps, + image: Imagekit::Metadata::Exif::Image, + interoperability: Imagekit::Metadata::Exif::Interoperability, + makernote: T::Hash[Symbol, T.anything], + thumbnail: Imagekit::Metadata::Exif::Thumbnail + } + ) + end + def to_hash + end + + class Exif < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any(Imagekit::Metadata::Exif::Exif, Imagekit::Internal::AnyHash) + end + + sig { returns(T.nilable(Float)) } + attr_reader :aperture_value + + sig { params(aperture_value: Float).void } + attr_writer :aperture_value + + sig { returns(T.nilable(Integer)) } + attr_reader :color_space + + sig { params(color_space: Integer).void } + attr_writer :color_space + + sig { returns(T.nilable(String)) } + attr_reader :create_date + + sig { params(create_date: String).void } + attr_writer :create_date + + sig { returns(T.nilable(Integer)) } + attr_reader :custom_rendered + + sig { params(custom_rendered: Integer).void } + attr_writer :custom_rendered + + sig { returns(T.nilable(String)) } + attr_reader :date_time_original + + sig { params(date_time_original: String).void } + attr_writer :date_time_original + + sig { returns(T.nilable(Integer)) } + attr_reader :exif_image_height + + sig { params(exif_image_height: Integer).void } + attr_writer :exif_image_height + + sig { returns(T.nilable(Integer)) } + attr_reader :exif_image_width + + sig { params(exif_image_width: Integer).void } + attr_writer :exif_image_width + + sig { returns(T.nilable(String)) } + attr_reader :exif_version + + sig { params(exif_version: String).void } + attr_writer :exif_version + + sig { returns(T.nilable(Float)) } + attr_reader :exposure_compensation + + sig { params(exposure_compensation: Float).void } + attr_writer :exposure_compensation + + sig { returns(T.nilable(Integer)) } + attr_reader :exposure_mode + + sig { params(exposure_mode: Integer).void } + attr_writer :exposure_mode + + sig { returns(T.nilable(Integer)) } + attr_reader :exposure_program + + sig { params(exposure_program: Integer).void } + attr_writer :exposure_program + + sig { returns(T.nilable(Float)) } + attr_reader :exposure_time + + sig { params(exposure_time: Float).void } + attr_writer :exposure_time + + sig { returns(T.nilable(Integer)) } + attr_reader :flash + + sig { params(flash: Integer).void } + attr_writer :flash + + sig { returns(T.nilable(String)) } + attr_reader :flashpix_version + + sig { params(flashpix_version: String).void } + attr_writer :flashpix_version + + sig { returns(T.nilable(Float)) } + attr_reader :f_number + + sig { params(f_number: Float).void } + attr_writer :f_number + + sig { returns(T.nilable(Integer)) } + attr_reader :focal_length + + sig { params(focal_length: Integer).void } + attr_writer :focal_length + + sig { returns(T.nilable(Integer)) } + attr_reader :focal_plane_resolution_unit + + sig { params(focal_plane_resolution_unit: Integer).void } + attr_writer :focal_plane_resolution_unit + + sig { returns(T.nilable(Float)) } + attr_reader :focal_plane_x_resolution + + sig { params(focal_plane_x_resolution: Float).void } + attr_writer :focal_plane_x_resolution + + sig { returns(T.nilable(Float)) } + attr_reader :focal_plane_y_resolution + + sig { params(focal_plane_y_resolution: Float).void } + attr_writer :focal_plane_y_resolution + + sig { returns(T.nilable(Integer)) } + attr_reader :interop_offset + + sig { params(interop_offset: Integer).void } + attr_writer :interop_offset + + sig { returns(T.nilable(Integer)) } + attr_reader :iso + + sig { params(iso: Integer).void } + attr_writer :iso + + sig { returns(T.nilable(Integer)) } + attr_reader :metering_mode + + sig { params(metering_mode: Integer).void } + attr_writer :metering_mode + + sig { returns(T.nilable(Integer)) } + attr_reader :scene_capture_type + + sig { params(scene_capture_type: Integer).void } + attr_writer :scene_capture_type + + sig { returns(T.nilable(Float)) } + attr_reader :shutter_speed_value + + sig { params(shutter_speed_value: Float).void } + attr_writer :shutter_speed_value + + sig { returns(T.nilable(String)) } + attr_reader :sub_sec_time + + sig { params(sub_sec_time: String).void } + attr_writer :sub_sec_time + + sig { returns(T.nilable(Integer)) } + attr_reader :white_balance + + sig { params(white_balance: Integer).void } + attr_writer :white_balance + + # Object containing Exif details. + sig do + params( + aperture_value: Float, + color_space: Integer, + create_date: String, + custom_rendered: Integer, + date_time_original: String, + exif_image_height: Integer, + exif_image_width: Integer, + exif_version: String, + exposure_compensation: Float, + exposure_mode: Integer, + exposure_program: Integer, + exposure_time: Float, + flash: Integer, + flashpix_version: String, + f_number: Float, + focal_length: Integer, + focal_plane_resolution_unit: Integer, + focal_plane_x_resolution: Float, + focal_plane_y_resolution: Float, + interop_offset: Integer, + iso: Integer, + metering_mode: Integer, + scene_capture_type: Integer, + shutter_speed_value: Float, + sub_sec_time: String, + white_balance: Integer + ).returns(T.attached_class) + end + def self.new( + aperture_value: nil, + color_space: nil, + create_date: nil, + custom_rendered: nil, + date_time_original: nil, + exif_image_height: nil, + exif_image_width: nil, + exif_version: nil, + exposure_compensation: nil, + exposure_mode: nil, + exposure_program: nil, + exposure_time: nil, + flash: nil, + flashpix_version: nil, + f_number: nil, + focal_length: nil, + focal_plane_resolution_unit: nil, + focal_plane_x_resolution: nil, + focal_plane_y_resolution: nil, + interop_offset: nil, + iso: nil, + metering_mode: nil, + scene_capture_type: nil, + shutter_speed_value: nil, + sub_sec_time: nil, + white_balance: nil + ) + end + + sig do + override.returns( + { + aperture_value: Float, + color_space: Integer, + create_date: String, + custom_rendered: Integer, + date_time_original: String, + exif_image_height: Integer, + exif_image_width: Integer, + exif_version: String, + exposure_compensation: Float, + exposure_mode: Integer, + exposure_program: Integer, + exposure_time: Float, + flash: Integer, + flashpix_version: String, + f_number: Float, + focal_length: Integer, + focal_plane_resolution_unit: Integer, + focal_plane_x_resolution: Float, + focal_plane_y_resolution: Float, + interop_offset: Integer, + iso: Integer, + metering_mode: Integer, + scene_capture_type: Integer, + shutter_speed_value: Float, + sub_sec_time: String, + white_balance: Integer + } + ) + end + def to_hash + end + end + + class Gps < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any(Imagekit::Metadata::Exif::Gps, Imagekit::Internal::AnyHash) + end + + sig { returns(T.nilable(T::Array[Integer])) } + attr_reader :gps_version_id + + sig { params(gps_version_id: T::Array[Integer]).void } + attr_writer :gps_version_id + + # Object containing GPS information. + sig do + params(gps_version_id: T::Array[Integer]).returns(T.attached_class) + end + def self.new(gps_version_id: nil) + end + + sig { override.returns({ gps_version_id: T::Array[Integer] }) } + def to_hash + end + end + + class Image < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Metadata::Exif::Image, + Imagekit::Internal::AnyHash + ) + end + + sig { returns(T.nilable(Integer)) } + attr_reader :exif_offset + + sig { params(exif_offset: Integer).void } + attr_writer :exif_offset + + sig { returns(T.nilable(Integer)) } + attr_reader :gps_info + + sig { params(gps_info: Integer).void } + attr_writer :gps_info + + sig { returns(T.nilable(String)) } + attr_reader :make + + sig { params(make: String).void } + attr_writer :make + + sig { returns(T.nilable(String)) } + attr_reader :model + + sig { params(model: String).void } + attr_writer :model + + sig { returns(T.nilable(String)) } + attr_reader :modify_date + + sig { params(modify_date: String).void } + attr_writer :modify_date + + sig { returns(T.nilable(Integer)) } + attr_reader :orientation + + sig { params(orientation: Integer).void } + attr_writer :orientation + + sig { returns(T.nilable(Integer)) } + attr_reader :resolution_unit + + sig { params(resolution_unit: Integer).void } + attr_writer :resolution_unit + + sig { returns(T.nilable(String)) } + attr_reader :software + + sig { params(software: String).void } + attr_writer :software + + sig { returns(T.nilable(Integer)) } + attr_reader :x_resolution + + sig { params(x_resolution: Integer).void } + attr_writer :x_resolution + + sig { returns(T.nilable(Integer)) } + attr_reader :y_cb_cr_positioning + + sig { params(y_cb_cr_positioning: Integer).void } + attr_writer :y_cb_cr_positioning + + sig { returns(T.nilable(Integer)) } + attr_reader :y_resolution + + sig { params(y_resolution: Integer).void } + attr_writer :y_resolution + + # Object containing EXIF image information. + sig do + params( + exif_offset: Integer, + gps_info: Integer, + make: String, + model: String, + modify_date: String, + orientation: Integer, + resolution_unit: Integer, + software: String, + x_resolution: Integer, + y_cb_cr_positioning: Integer, + y_resolution: Integer + ).returns(T.attached_class) + end + def self.new( + exif_offset: nil, + gps_info: nil, + make: nil, + model: nil, + modify_date: nil, + orientation: nil, + resolution_unit: nil, + software: nil, + x_resolution: nil, + y_cb_cr_positioning: nil, + y_resolution: nil + ) + end + + sig do + override.returns( + { + exif_offset: Integer, + gps_info: Integer, + make: String, + model: String, + modify_date: String, + orientation: Integer, + resolution_unit: Integer, + software: String, + x_resolution: Integer, + y_cb_cr_positioning: Integer, + y_resolution: Integer + } + ) + end + def to_hash + end + end + + class Interoperability < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Metadata::Exif::Interoperability, + Imagekit::Internal::AnyHash + ) + end + + sig { returns(T.nilable(String)) } + attr_reader :interop_index + + sig { params(interop_index: String).void } + attr_writer :interop_index + + sig { returns(T.nilable(String)) } + attr_reader :interop_version + + sig { params(interop_version: String).void } + attr_writer :interop_version + + # JSON object. + sig do + params(interop_index: String, interop_version: String).returns( + T.attached_class + ) + end + def self.new(interop_index: nil, interop_version: nil) + end + + sig do + override.returns({ interop_index: String, interop_version: String }) + end + def to_hash + end + end + + class Thumbnail < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::Metadata::Exif::Thumbnail, + Imagekit::Internal::AnyHash + ) + end + + sig { returns(T.nilable(Integer)) } + attr_reader :compression + + sig { params(compression: Integer).void } + attr_writer :compression + + sig { returns(T.nilable(Integer)) } + attr_reader :resolution_unit + + sig { params(resolution_unit: Integer).void } + attr_writer :resolution_unit + + sig { returns(T.nilable(Integer)) } + attr_reader :thumbnail_length + + sig { params(thumbnail_length: Integer).void } + attr_writer :thumbnail_length + + sig { returns(T.nilable(Integer)) } + attr_reader :thumbnail_offset + + sig { params(thumbnail_offset: Integer).void } + attr_writer :thumbnail_offset + + sig { returns(T.nilable(Integer)) } + attr_reader :x_resolution + + sig { params(x_resolution: Integer).void } + attr_writer :x_resolution + + sig { returns(T.nilable(Integer)) } + attr_reader :y_resolution + + sig { params(y_resolution: Integer).void } + attr_writer :y_resolution + + # Object containing Thumbnail information. + sig do + params( + compression: Integer, + resolution_unit: Integer, + thumbnail_length: Integer, + thumbnail_offset: Integer, + x_resolution: Integer, + y_resolution: Integer + ).returns(T.attached_class) + end + def self.new( + compression: nil, + resolution_unit: nil, + thumbnail_length: nil, + thumbnail_offset: nil, + x_resolution: nil, + y_resolution: nil + ) + end + + sig do + override.returns( + { + compression: Integer, + resolution_unit: Integer, + thumbnail_length: Integer, + thumbnail_offset: Integer, + x_resolution: Integer, + y_resolution: Integer + } + ) + end + def to_hash + end + end + end + end + end +end diff --git a/rbi/imagekit/models/overlay.rbi b/rbi/imagekit/models/overlay.rbi new file mode 100644 index 00000000..59e0e042 --- /dev/null +++ b/rbi/imagekit/models/overlay.rbi @@ -0,0 +1,28 @@ +# typed: strong + +module Imagekit + module Models + # Specifies an overlay to be applied on the parent image or video. ImageKit + # supports overlays including images, text, videos, subtitles, and solid colors. + # See + # [Overlay using layers](https://imagekit.io/docs/transformations#overlay-using-layers). + module Overlay + extend Imagekit::Internal::Type::Union + + Variants = + T.type_alias do + T.any( + Imagekit::TextOverlay, + Imagekit::ImageOverlay, + Imagekit::VideoOverlay, + Imagekit::SubtitleOverlay, + Imagekit::SolidColorOverlay + ) + end + + sig { override.returns(T::Array[Imagekit::Overlay::Variants]) } + def self.variants + end + end + end +end diff --git a/rbi/imagekit/models/overlay_position.rbi b/rbi/imagekit/models/overlay_position.rbi new file mode 100644 index 00000000..96202b12 --- /dev/null +++ b/rbi/imagekit/models/overlay_position.rbi @@ -0,0 +1,146 @@ +# typed: strong + +module Imagekit + module Models + class OverlayPosition < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any(Imagekit::OverlayPosition, Imagekit::Internal::AnyHash) + end + + # Specifies the position of the overlay relative to the parent image or video. + # Maps to `lfo` in the URL. + sig { returns(T.nilable(Imagekit::OverlayPosition::Focus::OrSymbol)) } + attr_reader :focus + + sig { params(focus: Imagekit::OverlayPosition::Focus::OrSymbol).void } + attr_writer :focus + + # Specifies the x-coordinate of the top-left corner of the base asset where the + # overlay's top-left corner will be positioned. It also accepts arithmetic + # expressions such as `bw_mul_0.4` or `bw_sub_cw`. Maps to `lx` in the URL. Learn + # about + # [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + sig { returns(T.nilable(Imagekit::OverlayPosition::X::Variants)) } + attr_reader :x + + sig { params(x: Imagekit::OverlayPosition::X::Variants).void } + attr_writer :x + + # Specifies the y-coordinate of the top-left corner of the base asset where the + # overlay's top-left corner will be positioned. It also accepts arithmetic + # expressions such as `bh_mul_0.4` or `bh_sub_ch`. Maps to `ly` in the URL. Learn + # about + # [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + sig { returns(T.nilable(Imagekit::OverlayPosition::Y::Variants)) } + attr_reader :y_ + + sig { params(y_: Imagekit::OverlayPosition::Y::Variants).void } + attr_writer :y_ + + sig do + params( + focus: Imagekit::OverlayPosition::Focus::OrSymbol, + x: Imagekit::OverlayPosition::X::Variants, + y_: Imagekit::OverlayPosition::Y::Variants + ).returns(T.attached_class) + end + def self.new( + # Specifies the position of the overlay relative to the parent image or video. + # Maps to `lfo` in the URL. + focus: nil, + # Specifies the x-coordinate of the top-left corner of the base asset where the + # overlay's top-left corner will be positioned. It also accepts arithmetic + # expressions such as `bw_mul_0.4` or `bw_sub_cw`. Maps to `lx` in the URL. Learn + # about + # [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + x: nil, + # Specifies the y-coordinate of the top-left corner of the base asset where the + # overlay's top-left corner will be positioned. It also accepts arithmetic + # expressions such as `bh_mul_0.4` or `bh_sub_ch`. Maps to `ly` in the URL. Learn + # about + # [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + y_: nil + ) + end + + sig do + override.returns( + { + focus: Imagekit::OverlayPosition::Focus::OrSymbol, + x: Imagekit::OverlayPosition::X::Variants, + y_: Imagekit::OverlayPosition::Y::Variants + } + ) + end + def to_hash + end + + # Specifies the position of the overlay relative to the parent image or video. + # Maps to `lfo` in the URL. + module Focus + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, Imagekit::OverlayPosition::Focus) } + OrSymbol = T.type_alias { T.any(Symbol, String) } + + CENTER = T.let(:center, Imagekit::OverlayPosition::Focus::TaggedSymbol) + TOP = T.let(:top, Imagekit::OverlayPosition::Focus::TaggedSymbol) + LEFT = T.let(:left, Imagekit::OverlayPosition::Focus::TaggedSymbol) + BOTTOM = T.let(:bottom, Imagekit::OverlayPosition::Focus::TaggedSymbol) + RIGHT = T.let(:right, Imagekit::OverlayPosition::Focus::TaggedSymbol) + TOP_LEFT = + T.let(:top_left, Imagekit::OverlayPosition::Focus::TaggedSymbol) + TOP_RIGHT = + T.let(:top_right, Imagekit::OverlayPosition::Focus::TaggedSymbol) + BOTTOM_LEFT = + T.let(:bottom_left, Imagekit::OverlayPosition::Focus::TaggedSymbol) + BOTTOM_RIGHT = + T.let(:bottom_right, Imagekit::OverlayPosition::Focus::TaggedSymbol) + + sig do + override.returns( + T::Array[Imagekit::OverlayPosition::Focus::TaggedSymbol] + ) + end + def self.values + end + end + + # Specifies the x-coordinate of the top-left corner of the base asset where the + # overlay's top-left corner will be positioned. It also accepts arithmetic + # expressions such as `bw_mul_0.4` or `bw_sub_cw`. Maps to `lx` in the URL. Learn + # about + # [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + module X + extend Imagekit::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns(T::Array[Imagekit::OverlayPosition::X::Variants]) + end + def self.variants + end + end + + # Specifies the y-coordinate of the top-left corner of the base asset where the + # overlay's top-left corner will be positioned. It also accepts arithmetic + # expressions such as `bh_mul_0.4` or `bh_sub_ch`. Maps to `ly` in the URL. Learn + # about + # [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + module Y + extend Imagekit::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns(T::Array[Imagekit::OverlayPosition::Y::Variants]) + end + def self.variants + end + end + end + end +end diff --git a/rbi/imagekit/models/overlay_timing.rbi b/rbi/imagekit/models/overlay_timing.rbi new file mode 100644 index 00000000..50d25cae --- /dev/null +++ b/rbi/imagekit/models/overlay_timing.rbi @@ -0,0 +1,133 @@ +# typed: strong + +module Imagekit + module Models + class OverlayTiming < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any(Imagekit::OverlayTiming, Imagekit::Internal::AnyHash) + end + + # Specifies the duration (in seconds) during which the overlay should appear on + # the base video. Accepts a positive number up to two decimal places (e.g., `20` + # or `20.50`) and arithmetic expressions such as `bdu_mul_0.4` or `bdu_sub_idu`. + # Applies only if the base asset is a video. Maps to `ldu` in the URL. + sig { returns(T.nilable(Imagekit::OverlayTiming::Duration::Variants)) } + attr_reader :duration + + sig { params(duration: Imagekit::OverlayTiming::Duration::Variants).void } + attr_writer :duration + + # Specifies the end time (in seconds) for when the overlay should disappear from + # the base video. If both end and duration are provided, duration is ignored. + # Accepts a positive number up to two decimal places (e.g., `20` or `20.50`) and + # arithmetic expressions such as `bdu_mul_0.4` or `bdu_sub_idu`. Applies only if + # the base asset is a video. Maps to `leo` in the URL. + sig { returns(T.nilable(Imagekit::OverlayTiming::End::Variants)) } + attr_reader :end_ + + sig { params(end_: Imagekit::OverlayTiming::End::Variants).void } + attr_writer :end_ + + # Specifies the start time (in seconds) for when the overlay should appear on the + # base video. Accepts a positive number up to two decimal places (e.g., `20` or + # `20.50`) and arithmetic expressions such as `bdu_mul_0.4` or `bdu_sub_idu`. + # Applies only if the base asset is a video. Maps to `lso` in the URL. + sig { returns(T.nilable(Imagekit::OverlayTiming::Start::Variants)) } + attr_reader :start + + sig { params(start: Imagekit::OverlayTiming::Start::Variants).void } + attr_writer :start + + sig do + params( + duration: Imagekit::OverlayTiming::Duration::Variants, + end_: Imagekit::OverlayTiming::End::Variants, + start: Imagekit::OverlayTiming::Start::Variants + ).returns(T.attached_class) + end + def self.new( + # Specifies the duration (in seconds) during which the overlay should appear on + # the base video. Accepts a positive number up to two decimal places (e.g., `20` + # or `20.50`) and arithmetic expressions such as `bdu_mul_0.4` or `bdu_sub_idu`. + # Applies only if the base asset is a video. Maps to `ldu` in the URL. + duration: nil, + # Specifies the end time (in seconds) for when the overlay should disappear from + # the base video. If both end and duration are provided, duration is ignored. + # Accepts a positive number up to two decimal places (e.g., `20` or `20.50`) and + # arithmetic expressions such as `bdu_mul_0.4` or `bdu_sub_idu`. Applies only if + # the base asset is a video. Maps to `leo` in the URL. + end_: nil, + # Specifies the start time (in seconds) for when the overlay should appear on the + # base video. Accepts a positive number up to two decimal places (e.g., `20` or + # `20.50`) and arithmetic expressions such as `bdu_mul_0.4` or `bdu_sub_idu`. + # Applies only if the base asset is a video. Maps to `lso` in the URL. + start: nil + ) + end + + sig do + override.returns( + { + duration: Imagekit::OverlayTiming::Duration::Variants, + end_: Imagekit::OverlayTiming::End::Variants, + start: Imagekit::OverlayTiming::Start::Variants + } + ) + end + def to_hash + end + + # Specifies the duration (in seconds) during which the overlay should appear on + # the base video. Accepts a positive number up to two decimal places (e.g., `20` + # or `20.50`) and arithmetic expressions such as `bdu_mul_0.4` or `bdu_sub_idu`. + # Applies only if the base asset is a video. Maps to `ldu` in the URL. + module Duration + extend Imagekit::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns( + T::Array[Imagekit::OverlayTiming::Duration::Variants] + ) + end + def self.variants + end + end + + # Specifies the end time (in seconds) for when the overlay should disappear from + # the base video. If both end and duration are provided, duration is ignored. + # Accepts a positive number up to two decimal places (e.g., `20` or `20.50`) and + # arithmetic expressions such as `bdu_mul_0.4` or `bdu_sub_idu`. Applies only if + # the base asset is a video. Maps to `leo` in the URL. + module End + extend Imagekit::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns(T::Array[Imagekit::OverlayTiming::End::Variants]) + end + def self.variants + end + end + + # Specifies the start time (in seconds) for when the overlay should appear on the + # base video. Accepts a positive number up to two decimal places (e.g., `20` or + # `20.50`) and arithmetic expressions such as `bdu_mul_0.4` or `bdu_sub_idu`. + # Applies only if the base asset is a video. Maps to `lso` in the URL. + module Start + extend Imagekit::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns(T::Array[Imagekit::OverlayTiming::Start::Variants]) + end + def self.variants + end + end + end + end +end diff --git a/rbi/imagekit/models/solid_color_overlay.rbi b/rbi/imagekit/models/solid_color_overlay.rbi new file mode 100644 index 00000000..54cbbac7 --- /dev/null +++ b/rbi/imagekit/models/solid_color_overlay.rbi @@ -0,0 +1,76 @@ +# typed: strong + +module Imagekit + module Models + class SolidColorOverlay < Imagekit::Models::BaseOverlay + OrHash = + T.type_alias do + T.any(Imagekit::SolidColorOverlay, Imagekit::Internal::AnyHash) + end + + # Specifies the color of the block using an RGB hex code (e.g., `FF0000`), an RGBA + # code (e.g., `FFAABB50`), or a color name (e.g., `red`). If an 8-character value + # is provided, the last two characters represent the opacity level (from `00` for + # 0.00 to `99` for 0.99). + sig { returns(String) } + attr_accessor :color + + sig { returns(Symbol) } + attr_accessor :type + + # Control width and height of the solid color overlay. Supported transformations + # depend on the base/parent asset. See overlays on + # [Images](https://imagekit.io/docs/add-overlays-on-images#apply-transformation-on-solid-color-overlay) + # and + # [Videos](https://imagekit.io/docs/add-overlays-on-videos#apply-transformations-on-solid-color-block-overlay). + sig do + returns(T.nilable(T::Array[Imagekit::SolidColorOverlayTransformation])) + end + attr_reader :transformation + + sig do + params( + transformation: + T::Array[Imagekit::SolidColorOverlayTransformation::OrHash] + ).void + end + attr_writer :transformation + + sig do + params( + color: String, + transformation: + T::Array[Imagekit::SolidColorOverlayTransformation::OrHash], + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Specifies the color of the block using an RGB hex code (e.g., `FF0000`), an RGBA + # code (e.g., `FFAABB50`), or a color name (e.g., `red`). If an 8-character value + # is provided, the last two characters represent the opacity level (from `00` for + # 0.00 to `99` for 0.99). + color:, + # Control width and height of the solid color overlay. Supported transformations + # depend on the base/parent asset. See overlays on + # [Images](https://imagekit.io/docs/add-overlays-on-images#apply-transformation-on-solid-color-overlay) + # and + # [Videos](https://imagekit.io/docs/add-overlays-on-videos#apply-transformations-on-solid-color-block-overlay). + transformation: nil, + type: :solidColor + ) + end + + sig do + override.returns( + { + color: String, + type: Symbol, + transformation: T::Array[Imagekit::SolidColorOverlayTransformation] + } + ) + end + def to_hash + end + end + end +end diff --git a/rbi/imagekit/models/solid_color_overlay_transformation.rbi b/rbi/imagekit/models/solid_color_overlay_transformation.rbi new file mode 100644 index 00000000..698a29f6 --- /dev/null +++ b/rbi/imagekit/models/solid_color_overlay_transformation.rbi @@ -0,0 +1,211 @@ +# typed: strong + +module Imagekit + module Models + class SolidColorOverlayTransformation < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::SolidColorOverlayTransformation, + Imagekit::Internal::AnyHash + ) + end + + # Specifies the transparency level of the solid color overlay. Accepts integers + # from `1` to `9`. + sig { returns(T.nilable(Float)) } + attr_reader :alpha + + sig { params(alpha: Float).void } + attr_writer :alpha + + # Specifies the background color of the solid color overlay. Accepts an RGB hex + # code (e.g., `FF0000`), an RGBA code (e.g., `FFAABB50`), or a color name. + sig { returns(T.nilable(String)) } + attr_reader :background + + sig { params(background: String).void } + attr_writer :background + + # Creates a linear gradient with two colors. Pass `true` for a default gradient, + # or provide a string for a custom gradient. Only works if the base asset is an + # image. See + # [gradient](https://imagekit.io/docs/effects-and-enhancements#gradient---e-gradient). + sig { returns(T.nilable(T.any(T::Boolean, String))) } + attr_reader :gradient + + sig { params(gradient: T.any(T::Boolean, String)).void } + attr_writer :gradient + + # Controls the height of the solid color overlay. Accepts a numeric value or an + # arithmetic expression. Learn about + # [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + sig do + returns( + T.nilable(Imagekit::SolidColorOverlayTransformation::Height::Variants) + ) + end + attr_reader :height + + sig do + params( + height: Imagekit::SolidColorOverlayTransformation::Height::Variants + ).void + end + attr_writer :height + + # Specifies the corner radius of the solid color overlay. Set to `max` for + # circular or oval shape. See + # [radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). + sig { returns(T.nilable(T.any(Float, Symbol))) } + attr_reader :radius + + sig { params(radius: T.any(Float, Symbol)).void } + attr_writer :radius + + # Controls the width of the solid color overlay. Accepts a numeric value or an + # arithmetic expression (e.g., `bw_mul_0.2` or `bh_div_2`). Learn about + # [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + sig do + returns( + T.nilable(Imagekit::SolidColorOverlayTransformation::Width::Variants) + ) + end + attr_reader :width + + sig do + params( + width: Imagekit::SolidColorOverlayTransformation::Width::Variants + ).void + end + attr_writer :width + + sig do + params( + alpha: Float, + background: String, + gradient: T.any(T::Boolean, String), + height: Imagekit::SolidColorOverlayTransformation::Height::Variants, + radius: T.any(Float, Symbol), + width: Imagekit::SolidColorOverlayTransformation::Width::Variants + ).returns(T.attached_class) + end + def self.new( + # Specifies the transparency level of the solid color overlay. Accepts integers + # from `1` to `9`. + alpha: nil, + # Specifies the background color of the solid color overlay. Accepts an RGB hex + # code (e.g., `FF0000`), an RGBA code (e.g., `FFAABB50`), or a color name. + background: nil, + # Creates a linear gradient with two colors. Pass `true` for a default gradient, + # or provide a string for a custom gradient. Only works if the base asset is an + # image. See + # [gradient](https://imagekit.io/docs/effects-and-enhancements#gradient---e-gradient). + gradient: nil, + # Controls the height of the solid color overlay. Accepts a numeric value or an + # arithmetic expression. Learn about + # [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + height: nil, + # Specifies the corner radius of the solid color overlay. Set to `max` for + # circular or oval shape. See + # [radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). + radius: nil, + # Controls the width of the solid color overlay. Accepts a numeric value or an + # arithmetic expression (e.g., `bw_mul_0.2` or `bh_div_2`). Learn about + # [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + width: nil + ) + end + + sig do + override.returns( + { + alpha: Float, + background: String, + gradient: T.any(T::Boolean, String), + height: Imagekit::SolidColorOverlayTransformation::Height::Variants, + radius: T.any(Float, Symbol), + width: Imagekit::SolidColorOverlayTransformation::Width::Variants + } + ) + end + def to_hash + end + + # Creates a linear gradient with two colors. Pass `true` for a default gradient, + # or provide a string for a custom gradient. Only works if the base asset is an + # image. See + # [gradient](https://imagekit.io/docs/effects-and-enhancements#gradient---e-gradient). + module Gradient + extend Imagekit::Internal::Type::Union + + Variants = T.type_alias { T.any(T::Boolean, String) } + + sig do + override.returns( + T::Array[ + Imagekit::SolidColorOverlayTransformation::Gradient::Variants + ] + ) + end + def self.variants + end + end + + # Controls the height of the solid color overlay. Accepts a numeric value or an + # arithmetic expression. Learn about + # [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + module Height + extend Imagekit::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns( + T::Array[ + Imagekit::SolidColorOverlayTransformation::Height::Variants + ] + ) + end + def self.variants + end + end + + # Specifies the corner radius of the solid color overlay. Set to `max` for + # circular or oval shape. See + # [radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). + module Radius + extend Imagekit::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, Symbol) } + + sig do + override.returns( + T::Array[ + Imagekit::SolidColorOverlayTransformation::Radius::Variants + ] + ) + end + def self.variants + end + end + + # Controls the width of the solid color overlay. Accepts a numeric value or an + # arithmetic expression (e.g., `bw_mul_0.2` or `bh_div_2`). Learn about + # [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + module Width + extend Imagekit::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns( + T::Array[Imagekit::SolidColorOverlayTransformation::Width::Variants] + ) + end + def self.variants + end + end + end + end +end diff --git a/rbi/imagekit/models/src_options.rbi b/rbi/imagekit/models/src_options.rbi new file mode 100644 index 00000000..30c5cdaf --- /dev/null +++ b/rbi/imagekit/models/src_options.rbi @@ -0,0 +1,156 @@ +# typed: strong + +module Imagekit + module Models + class SrcOptions < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any(Imagekit::SrcOptions, Imagekit::Internal::AnyHash) + end + + # Accepts a relative or absolute path of the resource. If a relative path is + # provided, it is appended to the `urlEndpoint`. If an absolute path is provided, + # `urlEndpoint` is ignored. + sig { returns(String) } + attr_accessor :src + + # Get your urlEndpoint from the + # [ImageKit dashboard](https://imagekit.io/dashboard/url-endpoints). + sig { returns(String) } + attr_accessor :url_endpoint + + # When you want the signed URL to expire, specified in seconds. If `expiresIn` is + # anything above 0, the URL will always be signed even if `signed` is set to + # false. If not specified and `signed` is `true`, the signed URL will not expire + # (valid indefinitely). + # + # Example: Setting `expiresIn: 3600` will make the URL expire 1 hour from + # generation time. After the expiry time, the signed URL will no longer be valid + # and ImageKit will return a 401 Unauthorized status code. + # + # [Learn more](https://imagekit.io/docs/media-delivery-basic-security#how-to-generate-signed-urls). + sig { returns(T.nilable(Float)) } + attr_reader :expires_in + + sig { params(expires_in: Float).void } + attr_writer :expires_in + + # These are additional query parameters that you want to add to the final URL. + # They can be any query parameters and not necessarily related to ImageKit. This + # is especially useful if you want to add a versioning parameter to your URLs. + sig { returns(T.nilable(T::Hash[Symbol, String])) } + attr_reader :query_parameters + + sig { params(query_parameters: T::Hash[Symbol, String]).void } + attr_writer :query_parameters + + # Whether to sign the URL or not. Set this to `true` if you want to generate a + # signed URL. If `signed` is `true` and `expiresIn` is not specified, the signed + # URL will not expire (valid indefinitely). Note: If `expiresIn` is set to any + # value above 0, the URL will always be signed regardless of this setting. + # [Learn more](https://imagekit.io/docs/media-delivery-basic-security#how-to-generate-signed-urls). + sig { returns(T.nilable(T::Boolean)) } + attr_reader :signed + + sig { params(signed: T::Boolean).void } + attr_writer :signed + + # An array of objects specifying the transformations to be applied in the URL. If + # more than one transformation is specified, they are applied in the order they + # are specified as chained transformations. See + # [Chained transformations](https://imagekit.io/docs/transformations#chained-transformations). + sig { returns(T.nilable(T::Array[Imagekit::Transformation])) } + attr_reader :transformation + + sig do + params(transformation: T::Array[Imagekit::Transformation::OrHash]).void + end + attr_writer :transformation + + # By default, the transformation string is added as a query parameter in the URL, + # e.g., `?tr=w-100,h-100`. If you want to add the transformation string in the + # path of the URL, set this to `path`. Learn more in the + # [Transformations guide](https://imagekit.io/docs/transformations). + sig { returns(T.nilable(Imagekit::TransformationPosition::OrSymbol)) } + attr_reader :transformation_position + + sig do + params( + transformation_position: Imagekit::TransformationPosition::OrSymbol + ).void + end + attr_writer :transformation_position + + # Options for generating ImageKit URLs with transformations. See the + # [Transformations guide](https://imagekit.io/docs/transformations). + sig do + params( + src: String, + url_endpoint: String, + expires_in: Float, + query_parameters: T::Hash[Symbol, String], + signed: T::Boolean, + transformation: T::Array[Imagekit::Transformation::OrHash], + transformation_position: Imagekit::TransformationPosition::OrSymbol + ).returns(T.attached_class) + end + def self.new( + # Accepts a relative or absolute path of the resource. If a relative path is + # provided, it is appended to the `urlEndpoint`. If an absolute path is provided, + # `urlEndpoint` is ignored. + src:, + # Get your urlEndpoint from the + # [ImageKit dashboard](https://imagekit.io/dashboard/url-endpoints). + url_endpoint:, + # When you want the signed URL to expire, specified in seconds. If `expiresIn` is + # anything above 0, the URL will always be signed even if `signed` is set to + # false. If not specified and `signed` is `true`, the signed URL will not expire + # (valid indefinitely). + # + # Example: Setting `expiresIn: 3600` will make the URL expire 1 hour from + # generation time. After the expiry time, the signed URL will no longer be valid + # and ImageKit will return a 401 Unauthorized status code. + # + # [Learn more](https://imagekit.io/docs/media-delivery-basic-security#how-to-generate-signed-urls). + expires_in: nil, + # These are additional query parameters that you want to add to the final URL. + # They can be any query parameters and not necessarily related to ImageKit. This + # is especially useful if you want to add a versioning parameter to your URLs. + query_parameters: nil, + # Whether to sign the URL or not. Set this to `true` if you want to generate a + # signed URL. If `signed` is `true` and `expiresIn` is not specified, the signed + # URL will not expire (valid indefinitely). Note: If `expiresIn` is set to any + # value above 0, the URL will always be signed regardless of this setting. + # [Learn more](https://imagekit.io/docs/media-delivery-basic-security#how-to-generate-signed-urls). + signed: nil, + # An array of objects specifying the transformations to be applied in the URL. If + # more than one transformation is specified, they are applied in the order they + # are specified as chained transformations. See + # [Chained transformations](https://imagekit.io/docs/transformations#chained-transformations). + transformation: nil, + # By default, the transformation string is added as a query parameter in the URL, + # e.g., `?tr=w-100,h-100`. If you want to add the transformation string in the + # path of the URL, set this to `path`. Learn more in the + # [Transformations guide](https://imagekit.io/docs/transformations). + transformation_position: nil + ) + end + + sig do + override.returns( + { + src: String, + url_endpoint: String, + expires_in: Float, + query_parameters: T::Hash[Symbol, String], + signed: T::Boolean, + transformation: T::Array[Imagekit::Transformation], + transformation_position: Imagekit::TransformationPosition::OrSymbol + } + ) + end + def to_hash + end + end + end +end diff --git a/rbi/imagekit/models/streaming_resolution.rbi b/rbi/imagekit/models/streaming_resolution.rbi new file mode 100644 index 00000000..d64a122e --- /dev/null +++ b/rbi/imagekit/models/streaming_resolution.rbi @@ -0,0 +1,36 @@ +# typed: strong + +module Imagekit + module Models + # Available streaming resolutions for + # [adaptive bitrate streaming](https://imagekit.io/docs/adaptive-bitrate-streaming) + module StreamingResolution + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, Imagekit::StreamingResolution) } + OrSymbol = T.type_alias { T.any(Symbol, String) } + + STREAMING_RESOLUTION_240 = + T.let(:"240", Imagekit::StreamingResolution::TaggedSymbol) + STREAMING_RESOLUTION_360 = + T.let(:"360", Imagekit::StreamingResolution::TaggedSymbol) + STREAMING_RESOLUTION_480 = + T.let(:"480", Imagekit::StreamingResolution::TaggedSymbol) + STREAMING_RESOLUTION_720 = + T.let(:"720", Imagekit::StreamingResolution::TaggedSymbol) + STREAMING_RESOLUTION_1080 = + T.let(:"1080", Imagekit::StreamingResolution::TaggedSymbol) + STREAMING_RESOLUTION_1440 = + T.let(:"1440", Imagekit::StreamingResolution::TaggedSymbol) + STREAMING_RESOLUTION_2160 = + T.let(:"2160", Imagekit::StreamingResolution::TaggedSymbol) + + sig do + override.returns(T::Array[Imagekit::StreamingResolution::TaggedSymbol]) + end + def self.values + end + end + end +end diff --git a/rbi/imagekit/models/subtitle_overlay.rbi b/rbi/imagekit/models/subtitle_overlay.rbi new file mode 100644 index 00000000..baa166f0 --- /dev/null +++ b/rbi/imagekit/models/subtitle_overlay.rbi @@ -0,0 +1,111 @@ +# typed: strong + +module Imagekit + module Models + class SubtitleOverlay < Imagekit::Models::BaseOverlay + OrHash = + T.type_alias do + T.any(Imagekit::SubtitleOverlay, Imagekit::Internal::AnyHash) + end + + # Specifies the relative path to the subtitle file used as an overlay. + sig { returns(String) } + attr_accessor :input + + sig { returns(Symbol) } + attr_accessor :type + + # The input path can be included in the layer as either `i-{input}` or + # `ie-{base64_encoded_input}`. By default, the SDK determines the appropriate + # format automatically. To always use base64 encoding (`ie-{base64}`), set this + # parameter to `base64`. To always use plain text (`i-{input}`), set it to + # `plain`. + sig { returns(T.nilable(Imagekit::SubtitleOverlay::Encoding::OrSymbol)) } + attr_reader :encoding + + sig do + params(encoding: Imagekit::SubtitleOverlay::Encoding::OrSymbol).void + end + attr_writer :encoding + + # Control styling of the subtitle. See + # [Styling subtitles](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer). + sig do + returns(T.nilable(T::Array[Imagekit::SubtitleOverlayTransformation])) + end + attr_reader :transformation + + sig do + params( + transformation: + T::Array[Imagekit::SubtitleOverlayTransformation::OrHash] + ).void + end + attr_writer :transformation + + sig do + params( + input: String, + encoding: Imagekit::SubtitleOverlay::Encoding::OrSymbol, + transformation: + T::Array[Imagekit::SubtitleOverlayTransformation::OrHash], + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Specifies the relative path to the subtitle file used as an overlay. + input:, + # The input path can be included in the layer as either `i-{input}` or + # `ie-{base64_encoded_input}`. By default, the SDK determines the appropriate + # format automatically. To always use base64 encoding (`ie-{base64}`), set this + # parameter to `base64`. To always use plain text (`i-{input}`), set it to + # `plain`. + encoding: nil, + # Control styling of the subtitle. See + # [Styling subtitles](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer). + transformation: nil, + type: :subtitle + ) + end + + sig do + override.returns( + { + input: String, + type: Symbol, + encoding: Imagekit::SubtitleOverlay::Encoding::OrSymbol, + transformation: T::Array[Imagekit::SubtitleOverlayTransformation] + } + ) + end + def to_hash + end + + # The input path can be included in the layer as either `i-{input}` or + # `ie-{base64_encoded_input}`. By default, the SDK determines the appropriate + # format automatically. To always use base64 encoding (`ie-{base64}`), set this + # parameter to `base64`. To always use plain text (`i-{input}`), set it to + # `plain`. + module Encoding + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, Imagekit::SubtitleOverlay::Encoding) } + OrSymbol = T.type_alias { T.any(Symbol, String) } + + AUTO = T.let(:auto, Imagekit::SubtitleOverlay::Encoding::TaggedSymbol) + PLAIN = T.let(:plain, Imagekit::SubtitleOverlay::Encoding::TaggedSymbol) + BASE64 = + T.let(:base64, Imagekit::SubtitleOverlay::Encoding::TaggedSymbol) + + sig do + override.returns( + T::Array[Imagekit::SubtitleOverlay::Encoding::TaggedSymbol] + ) + end + def self.values + end + end + end + end +end diff --git a/rbi/imagekit/models/subtitle_overlay_transformation.rbi b/rbi/imagekit/models/subtitle_overlay_transformation.rbi new file mode 100644 index 00000000..3ad34a2b --- /dev/null +++ b/rbi/imagekit/models/subtitle_overlay_transformation.rbi @@ -0,0 +1,215 @@ +# typed: strong + +module Imagekit + module Models + class SubtitleOverlayTransformation < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::SubtitleOverlayTransformation, + Imagekit::Internal::AnyHash + ) + end + + # Specifies the subtitle background color using a standard color name, an RGB + # color code (e.g., FF0000), or an RGBA color code (e.g., FFAABB50). + # + # [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + sig { returns(T.nilable(String)) } + attr_reader :background + + sig { params(background: String).void } + attr_writer :background + + # Sets the font color of the subtitle text using a standard color name, an RGB + # color code (e.g., FF0000), or an RGBA color code (e.g., FFAABB50). + # + # [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + sig { returns(T.nilable(String)) } + attr_reader :color + + sig { params(color: String).void } + attr_writer :color + + # Font family for subtitles. Refer to the + # [supported fonts](https://imagekit.io/docs/add-overlays-on-images#supported-text-font-list). + sig { returns(T.nilable(String)) } + attr_reader :font_family + + sig { params(font_family: String).void } + attr_writer :font_family + + # Sets the font outline of the subtitle text. Requires the outline width (an + # integer) and the outline color (as an RGB color code, RGBA color code, or + # standard web color name) separated by an underscore. Example: `fol-2_blue` + # (outline width of 2px and outline color blue), `fol-2_A1CCDD` (outline width of + # 2px and outline color `#A1CCDD`) and `fol-2_A1CCDD50` (outline width of 2px and + # outline color `#A1CCDD` at 50% opacity). + # + # [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + sig { returns(T.nilable(String)) } + attr_reader :font_outline + + sig { params(font_outline: String).void } + attr_writer :font_outline + + # Sets the font shadow for the subtitle text. Requires the shadow color (as an RGB + # color code, RGBA color code, or standard web color name) and shadow indent (an + # integer) separated by an underscore. Example: `fsh-blue_2` (shadow color blue, + # indent of 2px), `fsh-A1CCDD_3` (shadow color `#A1CCDD`, indent of 3px), + # `fsh-A1CCDD50_3` (shadow color `#A1CCDD` at 50% opacity, indent of 3px). + # + # [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + sig { returns(T.nilable(String)) } + attr_reader :font_shadow + + sig { params(font_shadow: String).void } + attr_writer :font_shadow + + # Sets the font size of subtitle text. + # + # [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + sig { returns(T.nilable(Float)) } + attr_reader :font_size + + sig { params(font_size: Float).void } + attr_writer :font_size + + # Sets the typography style of the subtitle text. Supports values are `b` for + # bold, `i` for italics, and `b_i` for bold with italics. + # + # [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + sig do + returns( + T.nilable( + Imagekit::SubtitleOverlayTransformation::Typography::OrSymbol + ) + ) + end + attr_reader :typography + + sig do + params( + typography: + Imagekit::SubtitleOverlayTransformation::Typography::OrSymbol + ).void + end + attr_writer :typography + + # Subtitle styling options. + # [Learn more](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + # from the docs. + sig do + params( + background: String, + color: String, + font_family: String, + font_outline: String, + font_shadow: String, + font_size: Float, + typography: + Imagekit::SubtitleOverlayTransformation::Typography::OrSymbol + ).returns(T.attached_class) + end + def self.new( + # Specifies the subtitle background color using a standard color name, an RGB + # color code (e.g., FF0000), or an RGBA color code (e.g., FFAABB50). + # + # [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + background: nil, + # Sets the font color of the subtitle text using a standard color name, an RGB + # color code (e.g., FF0000), or an RGBA color code (e.g., FFAABB50). + # + # [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + color: nil, + # Font family for subtitles. Refer to the + # [supported fonts](https://imagekit.io/docs/add-overlays-on-images#supported-text-font-list). + font_family: nil, + # Sets the font outline of the subtitle text. Requires the outline width (an + # integer) and the outline color (as an RGB color code, RGBA color code, or + # standard web color name) separated by an underscore. Example: `fol-2_blue` + # (outline width of 2px and outline color blue), `fol-2_A1CCDD` (outline width of + # 2px and outline color `#A1CCDD`) and `fol-2_A1CCDD50` (outline width of 2px and + # outline color `#A1CCDD` at 50% opacity). + # + # [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + font_outline: nil, + # Sets the font shadow for the subtitle text. Requires the shadow color (as an RGB + # color code, RGBA color code, or standard web color name) and shadow indent (an + # integer) separated by an underscore. Example: `fsh-blue_2` (shadow color blue, + # indent of 2px), `fsh-A1CCDD_3` (shadow color `#A1CCDD`, indent of 3px), + # `fsh-A1CCDD50_3` (shadow color `#A1CCDD` at 50% opacity, indent of 3px). + # + # [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + font_shadow: nil, + # Sets the font size of subtitle text. + # + # [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + font_size: nil, + # Sets the typography style of the subtitle text. Supports values are `b` for + # bold, `i` for italics, and `b_i` for bold with italics. + # + # [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + typography: nil + ) + end + + sig do + override.returns( + { + background: String, + color: String, + font_family: String, + font_outline: String, + font_shadow: String, + font_size: Float, + typography: + Imagekit::SubtitleOverlayTransformation::Typography::OrSymbol + } + ) + end + def to_hash + end + + # Sets the typography style of the subtitle text. Supports values are `b` for + # bold, `i` for italics, and `b_i` for bold with italics. + # + # [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + module Typography + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all(Symbol, Imagekit::SubtitleOverlayTransformation::Typography) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + B = + T.let( + :b, + Imagekit::SubtitleOverlayTransformation::Typography::TaggedSymbol + ) + I = + T.let( + :i, + Imagekit::SubtitleOverlayTransformation::Typography::TaggedSymbol + ) + B_I = + T.let( + :b_i, + Imagekit::SubtitleOverlayTransformation::Typography::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekit::SubtitleOverlayTransformation::Typography::TaggedSymbol + ] + ) + end + def self.values + end + end + end + end +end diff --git a/rbi/imagekit/models/text_overlay.rbi b/rbi/imagekit/models/text_overlay.rbi new file mode 100644 index 00000000..9ee9cb98 --- /dev/null +++ b/rbi/imagekit/models/text_overlay.rbi @@ -0,0 +1,106 @@ +# typed: strong + +module Imagekit + module Models + class TextOverlay < Imagekit::Models::BaseOverlay + OrHash = + T.type_alias do + T.any(Imagekit::TextOverlay, Imagekit::Internal::AnyHash) + end + + # Specifies the text to be displayed in the overlay. The SDK automatically handles + # special characters and encoding. + sig { returns(String) } + attr_accessor :text + + sig { returns(Symbol) } + attr_accessor :type + + # Text can be included in the layer as either `i-{input}` (plain text) or + # `ie-{base64_encoded_input}` (base64). By default, the SDK selects the + # appropriate format based on the input text. To always use base64 + # (`ie-{base64}`), set this parameter to `base64`. To always use plain text + # (`i-{input}`), set it to `plain`. + sig { returns(T.nilable(Imagekit::TextOverlay::Encoding::OrSymbol)) } + attr_reader :encoding + + sig { params(encoding: Imagekit::TextOverlay::Encoding::OrSymbol).void } + attr_writer :encoding + + # Control styling of the text overlay. See + # [Text overlays](https://imagekit.io/docs/add-overlays-on-images#text-overlay). + sig { returns(T.nilable(T::Array[Imagekit::TextOverlayTransformation])) } + attr_reader :transformation + + sig do + params( + transformation: T::Array[Imagekit::TextOverlayTransformation::OrHash] + ).void + end + attr_writer :transformation + + sig do + params( + text: String, + encoding: Imagekit::TextOverlay::Encoding::OrSymbol, + transformation: T::Array[Imagekit::TextOverlayTransformation::OrHash], + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Specifies the text to be displayed in the overlay. The SDK automatically handles + # special characters and encoding. + text:, + # Text can be included in the layer as either `i-{input}` (plain text) or + # `ie-{base64_encoded_input}` (base64). By default, the SDK selects the + # appropriate format based on the input text. To always use base64 + # (`ie-{base64}`), set this parameter to `base64`. To always use plain text + # (`i-{input}`), set it to `plain`. + encoding: nil, + # Control styling of the text overlay. See + # [Text overlays](https://imagekit.io/docs/add-overlays-on-images#text-overlay). + transformation: nil, + type: :text + ) + end + + sig do + override.returns( + { + text: String, + type: Symbol, + encoding: Imagekit::TextOverlay::Encoding::OrSymbol, + transformation: T::Array[Imagekit::TextOverlayTransformation] + } + ) + end + def to_hash + end + + # Text can be included in the layer as either `i-{input}` (plain text) or + # `ie-{base64_encoded_input}` (base64). By default, the SDK selects the + # appropriate format based on the input text. To always use base64 + # (`ie-{base64}`), set this parameter to `base64`. To always use plain text + # (`i-{input}`), set it to `plain`. + module Encoding + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, Imagekit::TextOverlay::Encoding) } + OrSymbol = T.type_alias { T.any(Symbol, String) } + + AUTO = T.let(:auto, Imagekit::TextOverlay::Encoding::TaggedSymbol) + PLAIN = T.let(:plain, Imagekit::TextOverlay::Encoding::TaggedSymbol) + BASE64 = T.let(:base64, Imagekit::TextOverlay::Encoding::TaggedSymbol) + + sig do + override.returns( + T::Array[Imagekit::TextOverlay::Encoding::TaggedSymbol] + ) + end + def self.values + end + end + end + end +end diff --git a/rbi/imagekit/models/text_overlay_transformation.rbi b/rbi/imagekit/models/text_overlay_transformation.rbi new file mode 100644 index 00000000..a2ea165d --- /dev/null +++ b/rbi/imagekit/models/text_overlay_transformation.rbi @@ -0,0 +1,441 @@ +# typed: strong + +module Imagekit + module Models + class TextOverlayTransformation < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::TextOverlayTransformation, + Imagekit::Internal::AnyHash + ) + end + + # Specifies the transparency level of the text overlay. Accepts integers from `1` + # to `9`. + sig { returns(T.nilable(Float)) } + attr_reader :alpha + + sig { params(alpha: Float).void } + attr_writer :alpha + + # Specifies the background color of the text overlay. Accepts an RGB hex code, an + # RGBA code, or a color name. + sig { returns(T.nilable(String)) } + attr_reader :background + + sig { params(background: String).void } + attr_writer :background + + # Flip the text overlay horizontally, vertically, or both. + sig do + returns(T.nilable(Imagekit::TextOverlayTransformation::Flip::OrSymbol)) + end + attr_reader :flip + + sig do + params(flip: Imagekit::TextOverlayTransformation::Flip::OrSymbol).void + end + attr_writer :flip + + # Specifies the font color of the overlaid text. Accepts an RGB hex code (e.g., + # `FF0000`), an RGBA code (e.g., `FFAABB50`), or a color name. + sig { returns(T.nilable(String)) } + attr_reader :font_color + + sig { params(font_color: String).void } + attr_writer :font_color + + # Specifies the font family of the overlaid text. Choose from the supported fonts + # list or use a custom font. See + # [Supported fonts](https://imagekit.io/docs/add-overlays-on-images#supported-text-font-list) + # and + # [Custom font](https://imagekit.io/docs/add-overlays-on-images#change-font-family-in-text-overlay). + sig { returns(T.nilable(String)) } + attr_reader :font_family + + sig { params(font_family: String).void } + attr_writer :font_family + + # Specifies the font size of the overlaid text. Accepts a numeric value or an + # arithmetic expression. + sig do + returns( + T.nilable(Imagekit::TextOverlayTransformation::FontSize::Variants) + ) + end + attr_reader :font_size + + sig do + params( + font_size: Imagekit::TextOverlayTransformation::FontSize::Variants + ).void + end + attr_writer :font_size + + # Specifies the inner alignment of the text when width is more than the text + # length. + sig do + returns( + T.nilable( + Imagekit::TextOverlayTransformation::InnerAlignment::OrSymbol + ) + ) + end + attr_reader :inner_alignment + + sig do + params( + inner_alignment: + Imagekit::TextOverlayTransformation::InnerAlignment::OrSymbol + ).void + end + attr_writer :inner_alignment + + # Specifies the line height of the text overlay. Accepts integer values + # representing line height in points. It can also accept + # [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations) + # such as `bw_mul_0.2`, or `bh_div_20`. + sig do + returns( + T.nilable(Imagekit::TextOverlayTransformation::LineHeight::Variants) + ) + end + attr_reader :line_height + + sig do + params( + line_height: Imagekit::TextOverlayTransformation::LineHeight::Variants + ).void + end + attr_writer :line_height + + # Specifies the padding around the overlaid text. Can be provided as a single + # positive integer or multiple values separated by underscores (following CSS + # shorthand order). Arithmetic expressions are also accepted. + sig do + returns( + T.nilable(Imagekit::TextOverlayTransformation::Padding::Variants) + ) + end + attr_reader :padding + + sig do + params( + padding: Imagekit::TextOverlayTransformation::Padding::Variants + ).void + end + attr_writer :padding + + # Specifies the corner radius of the text overlay. Set to `max` to achieve a + # circular or oval shape. + sig { returns(T.nilable(T.any(Float, Symbol))) } + attr_reader :radius + + sig { params(radius: T.any(Float, Symbol)).void } + attr_writer :radius + + # Specifies the rotation angle of the text overlay. Accepts a numeric value for + # clockwise rotation or a string prefixed with "N" for counter-clockwise rotation. + sig do + returns( + T.nilable(Imagekit::TextOverlayTransformation::Rotation::Variants) + ) + end + attr_reader :rotation + + sig do + params( + rotation: Imagekit::TextOverlayTransformation::Rotation::Variants + ).void + end + attr_writer :rotation + + # Specifies the typography style of the text. Supported values: + # + # - Single styles: `b` (bold), `i` (italic), `strikethrough`. + # - Combinations: Any combination separated by underscores, e.g., `b_i`, + # `b_i_strikethrough`. + sig { returns(T.nilable(String)) } + attr_reader :typography + + sig { params(typography: String).void } + attr_writer :typography + + # Specifies the maximum width (in pixels) of the overlaid text. The text wraps + # automatically, and arithmetic expressions (e.g., `bw_mul_0.2` or `bh_div_2`) are + # supported. Useful when used in conjunction with the `background`. Learn about + # [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + sig do + returns(T.nilable(Imagekit::TextOverlayTransformation::Width::Variants)) + end + attr_reader :width + + sig do + params(width: Imagekit::TextOverlayTransformation::Width::Variants).void + end + attr_writer :width + + sig do + params( + alpha: Float, + background: String, + flip: Imagekit::TextOverlayTransformation::Flip::OrSymbol, + font_color: String, + font_family: String, + font_size: Imagekit::TextOverlayTransformation::FontSize::Variants, + inner_alignment: + Imagekit::TextOverlayTransformation::InnerAlignment::OrSymbol, + line_height: + Imagekit::TextOverlayTransformation::LineHeight::Variants, + padding: Imagekit::TextOverlayTransformation::Padding::Variants, + radius: T.any(Float, Symbol), + rotation: Imagekit::TextOverlayTransformation::Rotation::Variants, + typography: String, + width: Imagekit::TextOverlayTransformation::Width::Variants + ).returns(T.attached_class) + end + def self.new( + # Specifies the transparency level of the text overlay. Accepts integers from `1` + # to `9`. + alpha: nil, + # Specifies the background color of the text overlay. Accepts an RGB hex code, an + # RGBA code, or a color name. + background: nil, + # Flip the text overlay horizontally, vertically, or both. + flip: nil, + # Specifies the font color of the overlaid text. Accepts an RGB hex code (e.g., + # `FF0000`), an RGBA code (e.g., `FFAABB50`), or a color name. + font_color: nil, + # Specifies the font family of the overlaid text. Choose from the supported fonts + # list or use a custom font. See + # [Supported fonts](https://imagekit.io/docs/add-overlays-on-images#supported-text-font-list) + # and + # [Custom font](https://imagekit.io/docs/add-overlays-on-images#change-font-family-in-text-overlay). + font_family: nil, + # Specifies the font size of the overlaid text. Accepts a numeric value or an + # arithmetic expression. + font_size: nil, + # Specifies the inner alignment of the text when width is more than the text + # length. + inner_alignment: nil, + # Specifies the line height of the text overlay. Accepts integer values + # representing line height in points. It can also accept + # [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations) + # such as `bw_mul_0.2`, or `bh_div_20`. + line_height: nil, + # Specifies the padding around the overlaid text. Can be provided as a single + # positive integer or multiple values separated by underscores (following CSS + # shorthand order). Arithmetic expressions are also accepted. + padding: nil, + # Specifies the corner radius of the text overlay. Set to `max` to achieve a + # circular or oval shape. + radius: nil, + # Specifies the rotation angle of the text overlay. Accepts a numeric value for + # clockwise rotation or a string prefixed with "N" for counter-clockwise rotation. + rotation: nil, + # Specifies the typography style of the text. Supported values: + # + # - Single styles: `b` (bold), `i` (italic), `strikethrough`. + # - Combinations: Any combination separated by underscores, e.g., `b_i`, + # `b_i_strikethrough`. + typography: nil, + # Specifies the maximum width (in pixels) of the overlaid text. The text wraps + # automatically, and arithmetic expressions (e.g., `bw_mul_0.2` or `bh_div_2`) are + # supported. Useful when used in conjunction with the `background`. Learn about + # [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + width: nil + ) + end + + sig do + override.returns( + { + alpha: Float, + background: String, + flip: Imagekit::TextOverlayTransformation::Flip::OrSymbol, + font_color: String, + font_family: String, + font_size: Imagekit::TextOverlayTransformation::FontSize::Variants, + inner_alignment: + Imagekit::TextOverlayTransformation::InnerAlignment::OrSymbol, + line_height: + Imagekit::TextOverlayTransformation::LineHeight::Variants, + padding: Imagekit::TextOverlayTransformation::Padding::Variants, + radius: T.any(Float, Symbol), + rotation: Imagekit::TextOverlayTransformation::Rotation::Variants, + typography: String, + width: Imagekit::TextOverlayTransformation::Width::Variants + } + ) + end + def to_hash + end + + # Flip the text overlay horizontally, vertically, or both. + module Flip + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all(Symbol, Imagekit::TextOverlayTransformation::Flip) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + H = T.let(:h, Imagekit::TextOverlayTransformation::Flip::TaggedSymbol) + V = T.let(:v, Imagekit::TextOverlayTransformation::Flip::TaggedSymbol) + H_V = + T.let(:h_v, Imagekit::TextOverlayTransformation::Flip::TaggedSymbol) + V_H = + T.let(:v_h, Imagekit::TextOverlayTransformation::Flip::TaggedSymbol) + + sig do + override.returns( + T::Array[Imagekit::TextOverlayTransformation::Flip::TaggedSymbol] + ) + end + def self.values + end + end + + # Specifies the font size of the overlaid text. Accepts a numeric value or an + # arithmetic expression. + module FontSize + extend Imagekit::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns( + T::Array[Imagekit::TextOverlayTransformation::FontSize::Variants] + ) + end + def self.variants + end + end + + # Specifies the inner alignment of the text when width is more than the text + # length. + module InnerAlignment + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all(Symbol, Imagekit::TextOverlayTransformation::InnerAlignment) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + LEFT = + T.let( + :left, + Imagekit::TextOverlayTransformation::InnerAlignment::TaggedSymbol + ) + RIGHT = + T.let( + :right, + Imagekit::TextOverlayTransformation::InnerAlignment::TaggedSymbol + ) + CENTER = + T.let( + :center, + Imagekit::TextOverlayTransformation::InnerAlignment::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekit::TextOverlayTransformation::InnerAlignment::TaggedSymbol + ] + ) + end + def self.values + end + end + + # Specifies the line height of the text overlay. Accepts integer values + # representing line height in points. It can also accept + # [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations) + # such as `bw_mul_0.2`, or `bh_div_20`. + module LineHeight + extend Imagekit::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns( + T::Array[Imagekit::TextOverlayTransformation::LineHeight::Variants] + ) + end + def self.variants + end + end + + # Specifies the padding around the overlaid text. Can be provided as a single + # positive integer or multiple values separated by underscores (following CSS + # shorthand order). Arithmetic expressions are also accepted. + module Padding + extend Imagekit::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns( + T::Array[Imagekit::TextOverlayTransformation::Padding::Variants] + ) + end + def self.variants + end + end + + # Specifies the corner radius of the text overlay. Set to `max` to achieve a + # circular or oval shape. + module Radius + extend Imagekit::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, Symbol) } + + sig do + override.returns( + T::Array[Imagekit::TextOverlayTransformation::Radius::Variants] + ) + end + def self.variants + end + end + + # Specifies the rotation angle of the text overlay. Accepts a numeric value for + # clockwise rotation or a string prefixed with "N" for counter-clockwise rotation. + module Rotation + extend Imagekit::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns( + T::Array[Imagekit::TextOverlayTransformation::Rotation::Variants] + ) + end + def self.variants + end + end + + # Specifies the maximum width (in pixels) of the overlaid text. The text wraps + # automatically, and arithmetic expressions (e.g., `bw_mul_0.2` or `bh_div_2`) are + # supported. Useful when used in conjunction with the `background`. Learn about + # [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + module Width + extend Imagekit::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns( + T::Array[Imagekit::TextOverlayTransformation::Width::Variants] + ) + end + def self.variants + end + end + end + end +end diff --git a/rbi/imagekit/models/transformation.rbi b/rbi/imagekit/models/transformation.rbi new file mode 100644 index 00000000..2c0f7137 --- /dev/null +++ b/rbi/imagekit/models/transformation.rbi @@ -0,0 +1,1600 @@ +# typed: strong + +module Imagekit + module Models + class Transformation < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any(Imagekit::Transformation, Imagekit::Internal::AnyHash) + end + + # Uses AI to change the background. Provide a text prompt or a base64-encoded + # prompt, e.g., `prompt-snow road` or `prompte-[urlencoded_base64_encoded_text]`. + # Not supported inside overlay. See + # [AI Change Background](https://imagekit.io/docs/ai-transformations#change-background-e-changebg). + sig { returns(T.nilable(String)) } + attr_reader :ai_change_background + + sig { params(ai_change_background: String).void } + attr_writer :ai_change_background + + # Adds an AI-based drop shadow around a foreground object on a transparent or + # removed background. Optionally, control the direction, elevation, and saturation + # of the light source (e.g., `az-45` to change light direction). Pass `true` for + # the default drop shadow, or provide a string for a custom drop shadow. Supported + # inside overlay. See + # [AI Drop Shadow](https://imagekit.io/docs/ai-transformations#ai-drop-shadow-e-dropshadow). + sig { returns(T.nilable(T.any(T::Boolean, String))) } + attr_reader :ai_drop_shadow + + sig { params(ai_drop_shadow: T.any(T::Boolean, String)).void } + attr_writer :ai_drop_shadow + + # Uses AI to edit images based on a text prompt. Provide a text prompt or a + # base64-encoded prompt, e.g., `prompt-snow road` or + # `prompte-[urlencoded_base64_encoded_text]`. Not supported inside overlay. + # See [AI Edit](https://imagekit.io/docs/ai-transformations#edit-image-e-edit). + sig { returns(T.nilable(String)) } + attr_reader :ai_edit + + sig { params(ai_edit: String).void } + attr_writer :ai_edit + + # Applies ImageKit's in-house background removal. Supported inside overlay. See + # [AI Background Removal](https://imagekit.io/docs/ai-transformations#imagekit-background-removal-e-bgremove). + sig do + returns( + T.nilable(Imagekit::Transformation::AIRemoveBackground::OrBoolean) + ) + end + attr_reader :ai_remove_background + + sig do + params( + ai_remove_background: + Imagekit::Transformation::AIRemoveBackground::OrBoolean + ).void + end + attr_writer :ai_remove_background + + # Uses third-party background removal. Note: It is recommended to use + # aiRemoveBackground, ImageKit's in-house solution, which is more cost-effective. + # Supported inside overlay. See + # [External Background Removal](https://imagekit.io/docs/ai-transformations#background-removal-e-removedotbg). + sig do + returns( + T.nilable( + Imagekit::Transformation::AIRemoveBackgroundExternal::OrBoolean + ) + ) + end + attr_reader :ai_remove_background_external + + sig do + params( + ai_remove_background_external: + Imagekit::Transformation::AIRemoveBackgroundExternal::OrBoolean + ).void + end + attr_writer :ai_remove_background_external + + # Performs AI-based retouching to improve faces or product shots. Not supported + # inside overlay. See + # [AI Retouch](https://imagekit.io/docs/ai-transformations#retouch-e-retouch). + sig { returns(T.nilable(Imagekit::Transformation::AIRetouch::OrBoolean)) } + attr_reader :ai_retouch + + sig do + params(ai_retouch: Imagekit::Transformation::AIRetouch::OrBoolean).void + end + attr_writer :ai_retouch + + # Upscales images beyond their original dimensions using AI. Not supported inside + # overlay. See + # [AI Upscale](https://imagekit.io/docs/ai-transformations#upscale-e-upscale). + sig { returns(T.nilable(Imagekit::Transformation::AIUpscale::OrBoolean)) } + attr_reader :ai_upscale + + sig do + params(ai_upscale: Imagekit::Transformation::AIUpscale::OrBoolean).void + end + attr_writer :ai_upscale + + # Generates a variation of an image using AI. This produces a new image with + # slight variations from the original, such as changes in color, texture, and + # other visual elements, while preserving the structure and essence of the + # original image. Not supported inside overlay. See + # [AI Generate Variations](https://imagekit.io/docs/ai-transformations#generate-variations-of-an-image-e-genvar). + sig do + returns(T.nilable(Imagekit::Transformation::AIVariation::OrBoolean)) + end + attr_reader :ai_variation + + sig do + params( + ai_variation: Imagekit::Transformation::AIVariation::OrBoolean + ).void + end + attr_writer :ai_variation + + # Specifies the aspect ratio for the output, e.g., "ar-4-3". Typically used with + # either width or height (but not both). For example: aspectRatio = `4:3`, `4_3`, + # or an expression like `iar_div_2`. See + # [Image resize and crop – Aspect ratio](https://imagekit.io/docs/image-resize-and-crop#aspect-ratio---ar). + sig do + returns(T.nilable(Imagekit::Transformation::AspectRatio::Variants)) + end + attr_reader :aspect_ratio + + sig do + params( + aspect_ratio: Imagekit::Transformation::AspectRatio::Variants + ).void + end + attr_writer :aspect_ratio + + # Specifies the audio codec, e.g., `aac`, `opus`, or `none`. See + # [Audio codec](https://imagekit.io/docs/video-optimization#audio-codec---ac). + sig { returns(T.nilable(Imagekit::Transformation::AudioCodec::OrSymbol)) } + attr_reader :audio_codec + + sig do + params(audio_codec: Imagekit::Transformation::AudioCodec::OrSymbol).void + end + attr_writer :audio_codec + + # Specifies the background to be used in conjunction with certain cropping + # strategies when resizing an image. + # + # - A solid color: e.g., `red`, `F3F3F3`, `AAFF0010`. See + # [Solid color background](https://imagekit.io/docs/effects-and-enhancements#solid-color-background). + # - A blurred background: e.g., `blurred`, `blurred_25_N15`, etc. See + # [Blurred background](https://imagekit.io/docs/effects-and-enhancements#blurred-background). + # - Expand the image boundaries using generative fill: `genfill`. Not supported + # inside overlay. Optionally, control the background scene by passing a text + # prompt: `genfill[:-prompt-${text}]` or + # `genfill[:-prompte-${urlencoded_base64_encoded_text}]`. See + # [Generative fill background](https://imagekit.io/docs/ai-transformations#generative-fill-bg-genfill). + sig { returns(T.nilable(String)) } + attr_reader :background + + sig { params(background: String).void } + attr_writer :background + + # Specifies the Gaussian blur level. Accepts an integer value between 1 and 100, + # or an expression like `bl-10`. See + # [Blur](https://imagekit.io/docs/effects-and-enhancements#blur---bl). + sig { returns(T.nilable(Float)) } + attr_reader :blur + + sig { params(blur: Float).void } + attr_writer :blur + + # Adds a border to the output media. Accepts a string in the format + # `_` (e.g., `5_FFF000` for a 5px yellow border), or an + # expression like `ih_div_20_FF00FF`. See + # [Border](https://imagekit.io/docs/effects-and-enhancements#border---b). + sig { returns(T.nilable(String)) } + attr_reader :border + + sig { params(border: String).void } + attr_writer :border + + # Indicates whether the output image should retain the original color profile. See + # [Color profile](https://imagekit.io/docs/image-optimization#color-profile---cp). + sig { returns(T.nilable(T::Boolean)) } + attr_reader :color_profile + + sig { params(color_profile: T::Boolean).void } + attr_writer :color_profile + + # Automatically enhances the contrast of an image (contrast stretch). See + # [Contrast Stretch](https://imagekit.io/docs/effects-and-enhancements#contrast-stretch---e-contrast). + sig do + returns(T.nilable(Imagekit::Transformation::ContrastStretch::OrBoolean)) + end + attr_reader :contrast_stretch + + sig do + params( + contrast_stretch: Imagekit::Transformation::ContrastStretch::OrBoolean + ).void + end + attr_writer :contrast_stretch + + # Crop modes for image resizing. See + # [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). + sig { returns(T.nilable(Imagekit::Transformation::Crop::OrSymbol)) } + attr_reader :crop + + sig { params(crop: Imagekit::Transformation::Crop::OrSymbol).void } + attr_writer :crop + + # Additional crop modes for image resizing. See + # [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). + sig { returns(T.nilable(Imagekit::Transformation::CropMode::OrSymbol)) } + attr_reader :crop_mode + + sig do + params(crop_mode: Imagekit::Transformation::CropMode::OrSymbol).void + end + attr_writer :crop_mode + + # Specifies a fallback image if the resource is not found, e.g., a URL or file + # path. See + # [Default image](https://imagekit.io/docs/image-transformation#default-image---di). + sig { returns(T.nilable(String)) } + attr_reader :default_image + + sig { params(default_image: String).void } + attr_writer :default_image + + # Accepts values between 0.1 and 5, or `auto` for automatic device pixel ratio + # (DPR) calculation. See + # [DPR](https://imagekit.io/docs/image-resize-and-crop#dpr---dpr). + sig { returns(T.nilable(Float)) } + attr_reader :dpr + + sig { params(dpr: Float).void } + attr_writer :dpr + + # Specifies the duration (in seconds) for trimming videos, e.g., `5` or `10.5`. + # Typically used with startOffset to indicate the length from the start offset. + # Arithmetic expressions are supported. See + # [Trim videos – Duration](https://imagekit.io/docs/trim-videos#duration---du). + sig { returns(T.nilable(Imagekit::Transformation::Duration::Variants)) } + attr_reader :duration + + sig do + params(duration: Imagekit::Transformation::Duration::Variants).void + end + attr_writer :duration + + # Specifies the end offset (in seconds) for trimming videos, e.g., `5` or `10.5`. + # Typically used with startOffset to define a time window. Arithmetic expressions + # are supported. See + # [Trim videos – End offset](https://imagekit.io/docs/trim-videos#end-offset---eo). + sig { returns(T.nilable(Imagekit::Transformation::EndOffset::Variants)) } + attr_reader :end_offset + + sig do + params(end_offset: Imagekit::Transformation::EndOffset::Variants).void + end + attr_writer :end_offset + + # Flips or mirrors an image either horizontally, vertically, or both. Acceptable + # values: `h` (horizontal), `v` (vertical), `h_v` (horizontal and vertical), or + # `v_h`. See [Flip](https://imagekit.io/docs/effects-and-enhancements#flip---fl). + sig { returns(T.nilable(Imagekit::Transformation::Flip::OrSymbol)) } + attr_reader :flip + + sig { params(flip: Imagekit::Transformation::Flip::OrSymbol).void } + attr_writer :flip + + # Refines padding and cropping behavior for pad resize, maintain ratio, and + # extract crop modes. Supports manual positions and coordinate-based focus. With + # AI-based cropping, you can automatically keep key subjects in frame—such as + # faces or detected objects (e.g., `fo-face`, `fo-person`, `fo-car`)— while + # resizing. + # + # - See [Focus](https://imagekit.io/docs/image-resize-and-crop#focus---fo). + # - [Object aware cropping](https://imagekit.io/docs/image-resize-and-crop#object-aware-cropping---fo-object-name) + sig { returns(T.nilable(String)) } + attr_reader :focus + + sig { params(focus: String).void } + attr_writer :focus + + # Specifies the output format for images or videos, e.g., `jpg`, `png`, `webp`, + # `mp4`, or `auto`. You can also pass `orig` for images to return the original + # format. ImageKit automatically delivers images and videos in the optimal format + # based on device support unless overridden by the dashboard settings or the + # format parameter. See + # [Image format](https://imagekit.io/docs/image-optimization#format---f) and + # [Video format](https://imagekit.io/docs/video-optimization#format---f). + sig { returns(T.nilable(Imagekit::Transformation::Format::OrSymbol)) } + attr_reader :format_ + + sig { params(format_: Imagekit::Transformation::Format::OrSymbol).void } + attr_writer :format_ + + # Creates a linear gradient with two colors. Pass `true` for a default gradient, + # or provide a string for a custom gradient. See + # [Gradient](https://imagekit.io/docs/effects-and-enhancements#gradient---e-gradient). + sig { returns(T.nilable(T.any(T::Boolean, String))) } + attr_reader :gradient + + sig { params(gradient: T.any(T::Boolean, String)).void } + attr_writer :gradient + + # Enables a grayscale effect for images. See + # [Grayscale](https://imagekit.io/docs/effects-and-enhancements#grayscale---e-grayscale). + sig { returns(T.nilable(Imagekit::Transformation::Grayscale::OrBoolean)) } + attr_reader :grayscale + + sig do + params(grayscale: Imagekit::Transformation::Grayscale::OrBoolean).void + end + attr_writer :grayscale + + # Specifies the height of the output. If a value between 0 and 1 is provided, it + # is treated as a percentage (e.g., `0.5` represents 50% of the original height). + # You can also supply arithmetic expressions (e.g., `ih_mul_0.5`). Height + # transformation – + # [Images](https://imagekit.io/docs/image-resize-and-crop#height---h) · + # [Videos](https://imagekit.io/docs/video-resize-and-crop#height---h) + sig { returns(T.nilable(Imagekit::Transformation::Height::Variants)) } + attr_reader :height + + sig { params(height: Imagekit::Transformation::Height::Variants).void } + attr_writer :height + + # Specifies whether the output image (in JPEG or PNG) should be compressed + # losslessly. See + # [Lossless compression](https://imagekit.io/docs/image-optimization#lossless-webp-and-png---lo). + sig { returns(T.nilable(T::Boolean)) } + attr_reader :lossless + + sig { params(lossless: T::Boolean).void } + attr_writer :lossless + + # By default, ImageKit removes all metadata during automatic image compression. + # Set this to true to preserve metadata. See + # [Image metadata](https://imagekit.io/docs/image-optimization#image-metadata---md). + sig { returns(T.nilable(T::Boolean)) } + attr_reader :metadata + + sig { params(metadata: T::Boolean).void } + attr_writer :metadata + + # Named transformation reference. See + # [Named transformations](https://imagekit.io/docs/transformations#named-transformations). + sig { returns(T.nilable(String)) } + attr_reader :named + + sig { params(named: String).void } + attr_writer :named + + # Specifies the opacity level of the output image. See + # [Opacity](https://imagekit.io/docs/effects-and-enhancements#opacity---o). + sig { returns(T.nilable(Float)) } + attr_reader :opacity + + sig { params(opacity: Float).void } + attr_writer :opacity + + # If set to true, serves the original file without applying any transformations. + # See + # [Deliver original file as-is](https://imagekit.io/docs/core-delivery-features#deliver-original-file-as-is---orig-true). + sig { returns(T.nilable(T::Boolean)) } + attr_reader :original + + sig { params(original: T::Boolean).void } + attr_writer :original + + # Specifies an overlay to be applied on the parent image or video. ImageKit + # supports overlays including images, text, videos, subtitles, and solid colors. + # See + # [Overlay using layers](https://imagekit.io/docs/transformations#overlay-using-layers). + sig { returns(T.nilable(Imagekit::Overlay)) } + attr_reader :overlay + + sig { params(overlay: Imagekit::Overlay).void } + attr_writer :overlay + + # Extracts a specific page or frame from multi-page or layered files (PDF, PSD, + # AI). For example, specify by number (e.g., `2`), a range (e.g., `3-4` for the + # 2nd and 3rd layers), or by name (e.g., `name-layer-4` for a PSD layer). See + # [Thumbnail extraction](https://imagekit.io/docs/vector-and-animated-images#get-thumbnail-from-psd-pdf-ai-eps-and-animated-files). + sig { returns(T.nilable(Imagekit::Transformation::Page::Variants)) } + attr_reader :page + + sig { params(page: Imagekit::Transformation::Page::Variants).void } + attr_writer :page + + # Specifies whether the output JPEG image should be rendered progressively. + # Progressive loading begins with a low-quality, pixelated version of the full + # image, which gradually improves to provide a faster perceived load time. See + # [Progressive images](https://imagekit.io/docs/image-optimization#progressive-image---pr). + sig { returns(T.nilable(T::Boolean)) } + attr_reader :progressive + + sig { params(progressive: T::Boolean).void } + attr_writer :progressive + + # Specifies the quality of the output image for lossy formats such as JPEG, WebP, + # and AVIF. A higher quality value results in a larger file size with better + # quality, while a lower value produces a smaller file size with reduced quality. + # See [Quality](https://imagekit.io/docs/image-optimization#quality---q). + sig { returns(T.nilable(Float)) } + attr_reader :quality + + sig { params(quality: Float).void } + attr_writer :quality + + # Specifies the corner radius for rounded corners (e.g., 20) or `max` for circular + # or oval shape. See + # [Radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). + sig { returns(T.nilable(T.any(Float, Symbol))) } + attr_reader :radius + + sig { params(radius: T.any(Float, Symbol)).void } + attr_writer :radius + + # Pass any transformation not directly supported by the SDK. This transformation + # string is appended to the URL as provided. + sig { returns(T.nilable(String)) } + attr_reader :raw + + sig { params(raw: String).void } + attr_writer :raw + + # Specifies the rotation angle in degrees. Positive values rotate the image + # clockwise; you can also use, for example, `N40` for counterclockwise rotation or + # `auto` to use the orientation specified in the image's EXIF data. For videos, + # only the following values are supported: 0, 90, 180, 270, or 360. See + # [Rotate](https://imagekit.io/docs/effects-and-enhancements#rotate---rt). + sig { returns(T.nilable(Imagekit::Transformation::Rotation::Variants)) } + attr_reader :rotation + + sig do + params(rotation: Imagekit::Transformation::Rotation::Variants).void + end + attr_writer :rotation + + # Adds a shadow beneath solid objects in an image with a transparent background. + # For AI-based drop shadows, refer to aiDropShadow. Pass `true` for a default + # shadow, or provide a string for a custom shadow. See + # [Shadow](https://imagekit.io/docs/effects-and-enhancements#shadow---e-shadow). + sig { returns(T.nilable(T.any(T::Boolean, String))) } + attr_reader :shadow + + sig { params(shadow: T.any(T::Boolean, String)).void } + attr_writer :shadow + + # Sharpens the input image, highlighting edges and finer details. Pass `true` for + # default sharpening, or provide a numeric value for custom sharpening. See + # [Sharpen](https://imagekit.io/docs/effects-and-enhancements#sharpen---e-sharpen). + sig { returns(T.nilable(T.any(T::Boolean, Float))) } + attr_reader :sharpen + + sig { params(sharpen: T.any(T::Boolean, Float)).void } + attr_writer :sharpen + + # Specifies the start offset (in seconds) for trimming videos, e.g., `5` or + # `10.5`. Arithmetic expressions are also supported. See + # [Trim videos – Start offset](https://imagekit.io/docs/trim-videos#start-offset---so). + sig do + returns(T.nilable(Imagekit::Transformation::StartOffset::Variants)) + end + attr_reader :start_offset + + sig do + params( + start_offset: Imagekit::Transformation::StartOffset::Variants + ).void + end + attr_writer :start_offset + + # An array of resolutions for adaptive bitrate streaming, e.g., [`240`, `360`, + # `480`, `720`, `1080`]. See + # [Adaptive Bitrate Streaming](https://imagekit.io/docs/adaptive-bitrate-streaming). + sig do + returns(T.nilable(T::Array[Imagekit::StreamingResolution::OrSymbol])) + end + attr_reader :streaming_resolutions + + sig do + params( + streaming_resolutions: + T::Array[Imagekit::StreamingResolution::OrSymbol] + ).void + end + attr_writer :streaming_resolutions + + # Useful for images with a solid or nearly solid background and a central object. + # This parameter trims the background, leaving only the central object in the + # output image. See + # [Trim edges](https://imagekit.io/docs/effects-and-enhancements#trim-edges---t). + sig { returns(T.nilable(T.any(T::Boolean, Float))) } + attr_reader :trim + + sig { params(trim: T.any(T::Boolean, Float)).void } + attr_writer :trim + + # Applies Unsharp Masking (USM), an image sharpening technique. Pass `true` for a + # default unsharp mask, or provide a string for a custom unsharp mask. See + # [Unsharp Mask](https://imagekit.io/docs/effects-and-enhancements#unsharp-mask---e-usm). + sig { returns(T.nilable(T.any(T::Boolean, String))) } + attr_reader :unsharp_mask + + sig { params(unsharp_mask: T.any(T::Boolean, String)).void } + attr_writer :unsharp_mask + + # Specifies the video codec, e.g., `h264`, `vp9`, `av1`, or `none`. See + # [Video codec](https://imagekit.io/docs/video-optimization#video-codec---vc). + sig { returns(T.nilable(Imagekit::Transformation::VideoCodec::OrSymbol)) } + attr_reader :video_codec + + sig do + params(video_codec: Imagekit::Transformation::VideoCodec::OrSymbol).void + end + attr_writer :video_codec + + # Specifies the width of the output. If a value between 0 and 1 is provided, it is + # treated as a percentage (e.g., `0.4` represents 40% of the original width). You + # can also supply arithmetic expressions (e.g., `iw_div_2`). Width transformation + # – [Images](https://imagekit.io/docs/image-resize-and-crop#width---w) · + # [Videos](https://imagekit.io/docs/video-resize-and-crop#width---w) + sig { returns(T.nilable(Imagekit::Transformation::Width::Variants)) } + attr_reader :width + + sig { params(width: Imagekit::Transformation::Width::Variants).void } + attr_writer :width + + # Focus using cropped image coordinates - X coordinate. See + # [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). + sig { returns(T.nilable(Imagekit::Transformation::X::Variants)) } + attr_reader :x + + sig { params(x: Imagekit::Transformation::X::Variants).void } + attr_writer :x + + # Focus using cropped image coordinates - X center coordinate. See + # [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). + sig { returns(T.nilable(Imagekit::Transformation::XCenter::Variants)) } + attr_reader :x_center + + sig { params(x_center: Imagekit::Transformation::XCenter::Variants).void } + attr_writer :x_center + + # Focus using cropped image coordinates - Y coordinate. See + # [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). + sig { returns(T.nilable(Imagekit::Transformation::Y::Variants)) } + attr_reader :y_ + + sig { params(y_: Imagekit::Transformation::Y::Variants).void } + attr_writer :y_ + + # Focus using cropped image coordinates - Y center coordinate. See + # [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). + sig { returns(T.nilable(Imagekit::Transformation::YCenter::Variants)) } + attr_reader :y_center + + sig { params(y_center: Imagekit::Transformation::YCenter::Variants).void } + attr_writer :y_center + + # Accepts a numeric value that determines how much to zoom in or out of the + # cropped area. It should be used in conjunction with fo-face or fo-. + # See [Zoom](https://imagekit.io/docs/image-resize-and-crop#zoom---z). + sig { returns(T.nilable(Float)) } + attr_reader :zoom + + sig { params(zoom: Float).void } + attr_writer :zoom + + # The SDK provides easy-to-use names for transformations. These names are + # converted to the corresponding transformation string before being added to the + # URL. SDKs are updated regularly to support new transformations. If you want to + # use a transformation that is not supported by the SDK, You can use the `raw` + # parameter to pass the transformation string directly. See the + # [Transformations documentation](https://imagekit.io/docs/transformations). + sig do + params( + ai_change_background: String, + ai_drop_shadow: T.any(T::Boolean, String), + ai_edit: String, + ai_remove_background: + Imagekit::Transformation::AIRemoveBackground::OrBoolean, + ai_remove_background_external: + Imagekit::Transformation::AIRemoveBackgroundExternal::OrBoolean, + ai_retouch: Imagekit::Transformation::AIRetouch::OrBoolean, + ai_upscale: Imagekit::Transformation::AIUpscale::OrBoolean, + ai_variation: Imagekit::Transformation::AIVariation::OrBoolean, + aspect_ratio: Imagekit::Transformation::AspectRatio::Variants, + audio_codec: Imagekit::Transformation::AudioCodec::OrSymbol, + background: String, + blur: Float, + border: String, + color_profile: T::Boolean, + contrast_stretch: + Imagekit::Transformation::ContrastStretch::OrBoolean, + crop: Imagekit::Transformation::Crop::OrSymbol, + crop_mode: Imagekit::Transformation::CropMode::OrSymbol, + default_image: String, + dpr: Float, + duration: Imagekit::Transformation::Duration::Variants, + end_offset: Imagekit::Transformation::EndOffset::Variants, + flip: Imagekit::Transformation::Flip::OrSymbol, + focus: String, + format_: Imagekit::Transformation::Format::OrSymbol, + gradient: T.any(T::Boolean, String), + grayscale: Imagekit::Transformation::Grayscale::OrBoolean, + height: Imagekit::Transformation::Height::Variants, + lossless: T::Boolean, + metadata: T::Boolean, + named: String, + opacity: Float, + original: T::Boolean, + overlay: Imagekit::Overlay, + page: Imagekit::Transformation::Page::Variants, + progressive: T::Boolean, + quality: Float, + radius: T.any(Float, Symbol), + raw: String, + rotation: Imagekit::Transformation::Rotation::Variants, + shadow: T.any(T::Boolean, String), + sharpen: T.any(T::Boolean, Float), + start_offset: Imagekit::Transformation::StartOffset::Variants, + streaming_resolutions: + T::Array[Imagekit::StreamingResolution::OrSymbol], + trim: T.any(T::Boolean, Float), + unsharp_mask: T.any(T::Boolean, String), + video_codec: Imagekit::Transformation::VideoCodec::OrSymbol, + width: Imagekit::Transformation::Width::Variants, + x: Imagekit::Transformation::X::Variants, + x_center: Imagekit::Transformation::XCenter::Variants, + y_: Imagekit::Transformation::Y::Variants, + y_center: Imagekit::Transformation::YCenter::Variants, + zoom: Float + ).returns(T.attached_class) + end + def self.new( + # Uses AI to change the background. Provide a text prompt or a base64-encoded + # prompt, e.g., `prompt-snow road` or `prompte-[urlencoded_base64_encoded_text]`. + # Not supported inside overlay. See + # [AI Change Background](https://imagekit.io/docs/ai-transformations#change-background-e-changebg). + ai_change_background: nil, + # Adds an AI-based drop shadow around a foreground object on a transparent or + # removed background. Optionally, control the direction, elevation, and saturation + # of the light source (e.g., `az-45` to change light direction). Pass `true` for + # the default drop shadow, or provide a string for a custom drop shadow. Supported + # inside overlay. See + # [AI Drop Shadow](https://imagekit.io/docs/ai-transformations#ai-drop-shadow-e-dropshadow). + ai_drop_shadow: nil, + # Uses AI to edit images based on a text prompt. Provide a text prompt or a + # base64-encoded prompt, e.g., `prompt-snow road` or + # `prompte-[urlencoded_base64_encoded_text]`. Not supported inside overlay. + # See [AI Edit](https://imagekit.io/docs/ai-transformations#edit-image-e-edit). + ai_edit: nil, + # Applies ImageKit's in-house background removal. Supported inside overlay. See + # [AI Background Removal](https://imagekit.io/docs/ai-transformations#imagekit-background-removal-e-bgremove). + ai_remove_background: nil, + # Uses third-party background removal. Note: It is recommended to use + # aiRemoveBackground, ImageKit's in-house solution, which is more cost-effective. + # Supported inside overlay. See + # [External Background Removal](https://imagekit.io/docs/ai-transformations#background-removal-e-removedotbg). + ai_remove_background_external: nil, + # Performs AI-based retouching to improve faces or product shots. Not supported + # inside overlay. See + # [AI Retouch](https://imagekit.io/docs/ai-transformations#retouch-e-retouch). + ai_retouch: nil, + # Upscales images beyond their original dimensions using AI. Not supported inside + # overlay. See + # [AI Upscale](https://imagekit.io/docs/ai-transformations#upscale-e-upscale). + ai_upscale: nil, + # Generates a variation of an image using AI. This produces a new image with + # slight variations from the original, such as changes in color, texture, and + # other visual elements, while preserving the structure and essence of the + # original image. Not supported inside overlay. See + # [AI Generate Variations](https://imagekit.io/docs/ai-transformations#generate-variations-of-an-image-e-genvar). + ai_variation: nil, + # Specifies the aspect ratio for the output, e.g., "ar-4-3". Typically used with + # either width or height (but not both). For example: aspectRatio = `4:3`, `4_3`, + # or an expression like `iar_div_2`. See + # [Image resize and crop – Aspect ratio](https://imagekit.io/docs/image-resize-and-crop#aspect-ratio---ar). + aspect_ratio: nil, + # Specifies the audio codec, e.g., `aac`, `opus`, or `none`. See + # [Audio codec](https://imagekit.io/docs/video-optimization#audio-codec---ac). + audio_codec: nil, + # Specifies the background to be used in conjunction with certain cropping + # strategies when resizing an image. + # + # - A solid color: e.g., `red`, `F3F3F3`, `AAFF0010`. See + # [Solid color background](https://imagekit.io/docs/effects-and-enhancements#solid-color-background). + # - A blurred background: e.g., `blurred`, `blurred_25_N15`, etc. See + # [Blurred background](https://imagekit.io/docs/effects-and-enhancements#blurred-background). + # - Expand the image boundaries using generative fill: `genfill`. Not supported + # inside overlay. Optionally, control the background scene by passing a text + # prompt: `genfill[:-prompt-${text}]` or + # `genfill[:-prompte-${urlencoded_base64_encoded_text}]`. See + # [Generative fill background](https://imagekit.io/docs/ai-transformations#generative-fill-bg-genfill). + background: nil, + # Specifies the Gaussian blur level. Accepts an integer value between 1 and 100, + # or an expression like `bl-10`. See + # [Blur](https://imagekit.io/docs/effects-and-enhancements#blur---bl). + blur: nil, + # Adds a border to the output media. Accepts a string in the format + # `_` (e.g., `5_FFF000` for a 5px yellow border), or an + # expression like `ih_div_20_FF00FF`. See + # [Border](https://imagekit.io/docs/effects-and-enhancements#border---b). + border: nil, + # Indicates whether the output image should retain the original color profile. See + # [Color profile](https://imagekit.io/docs/image-optimization#color-profile---cp). + color_profile: nil, + # Automatically enhances the contrast of an image (contrast stretch). See + # [Contrast Stretch](https://imagekit.io/docs/effects-and-enhancements#contrast-stretch---e-contrast). + contrast_stretch: nil, + # Crop modes for image resizing. See + # [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). + crop: nil, + # Additional crop modes for image resizing. See + # [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). + crop_mode: nil, + # Specifies a fallback image if the resource is not found, e.g., a URL or file + # path. See + # [Default image](https://imagekit.io/docs/image-transformation#default-image---di). + default_image: nil, + # Accepts values between 0.1 and 5, or `auto` for automatic device pixel ratio + # (DPR) calculation. See + # [DPR](https://imagekit.io/docs/image-resize-and-crop#dpr---dpr). + dpr: nil, + # Specifies the duration (in seconds) for trimming videos, e.g., `5` or `10.5`. + # Typically used with startOffset to indicate the length from the start offset. + # Arithmetic expressions are supported. See + # [Trim videos – Duration](https://imagekit.io/docs/trim-videos#duration---du). + duration: nil, + # Specifies the end offset (in seconds) for trimming videos, e.g., `5` or `10.5`. + # Typically used with startOffset to define a time window. Arithmetic expressions + # are supported. See + # [Trim videos – End offset](https://imagekit.io/docs/trim-videos#end-offset---eo). + end_offset: nil, + # Flips or mirrors an image either horizontally, vertically, or both. Acceptable + # values: `h` (horizontal), `v` (vertical), `h_v` (horizontal and vertical), or + # `v_h`. See [Flip](https://imagekit.io/docs/effects-and-enhancements#flip---fl). + flip: nil, + # Refines padding and cropping behavior for pad resize, maintain ratio, and + # extract crop modes. Supports manual positions and coordinate-based focus. With + # AI-based cropping, you can automatically keep key subjects in frame—such as + # faces or detected objects (e.g., `fo-face`, `fo-person`, `fo-car`)— while + # resizing. + # + # - See [Focus](https://imagekit.io/docs/image-resize-and-crop#focus---fo). + # - [Object aware cropping](https://imagekit.io/docs/image-resize-and-crop#object-aware-cropping---fo-object-name) + focus: nil, + # Specifies the output format for images or videos, e.g., `jpg`, `png`, `webp`, + # `mp4`, or `auto`. You can also pass `orig` for images to return the original + # format. ImageKit automatically delivers images and videos in the optimal format + # based on device support unless overridden by the dashboard settings or the + # format parameter. See + # [Image format](https://imagekit.io/docs/image-optimization#format---f) and + # [Video format](https://imagekit.io/docs/video-optimization#format---f). + format_: nil, + # Creates a linear gradient with two colors. Pass `true` for a default gradient, + # or provide a string for a custom gradient. See + # [Gradient](https://imagekit.io/docs/effects-and-enhancements#gradient---e-gradient). + gradient: nil, + # Enables a grayscale effect for images. See + # [Grayscale](https://imagekit.io/docs/effects-and-enhancements#grayscale---e-grayscale). + grayscale: nil, + # Specifies the height of the output. If a value between 0 and 1 is provided, it + # is treated as a percentage (e.g., `0.5` represents 50% of the original height). + # You can also supply arithmetic expressions (e.g., `ih_mul_0.5`). Height + # transformation – + # [Images](https://imagekit.io/docs/image-resize-and-crop#height---h) · + # [Videos](https://imagekit.io/docs/video-resize-and-crop#height---h) + height: nil, + # Specifies whether the output image (in JPEG or PNG) should be compressed + # losslessly. See + # [Lossless compression](https://imagekit.io/docs/image-optimization#lossless-webp-and-png---lo). + lossless: nil, + # By default, ImageKit removes all metadata during automatic image compression. + # Set this to true to preserve metadata. See + # [Image metadata](https://imagekit.io/docs/image-optimization#image-metadata---md). + metadata: nil, + # Named transformation reference. See + # [Named transformations](https://imagekit.io/docs/transformations#named-transformations). + named: nil, + # Specifies the opacity level of the output image. See + # [Opacity](https://imagekit.io/docs/effects-and-enhancements#opacity---o). + opacity: nil, + # If set to true, serves the original file without applying any transformations. + # See + # [Deliver original file as-is](https://imagekit.io/docs/core-delivery-features#deliver-original-file-as-is---orig-true). + original: nil, + # Specifies an overlay to be applied on the parent image or video. ImageKit + # supports overlays including images, text, videos, subtitles, and solid colors. + # See + # [Overlay using layers](https://imagekit.io/docs/transformations#overlay-using-layers). + overlay: nil, + # Extracts a specific page or frame from multi-page or layered files (PDF, PSD, + # AI). For example, specify by number (e.g., `2`), a range (e.g., `3-4` for the + # 2nd and 3rd layers), or by name (e.g., `name-layer-4` for a PSD layer). See + # [Thumbnail extraction](https://imagekit.io/docs/vector-and-animated-images#get-thumbnail-from-psd-pdf-ai-eps-and-animated-files). + page: nil, + # Specifies whether the output JPEG image should be rendered progressively. + # Progressive loading begins with a low-quality, pixelated version of the full + # image, which gradually improves to provide a faster perceived load time. See + # [Progressive images](https://imagekit.io/docs/image-optimization#progressive-image---pr). + progressive: nil, + # Specifies the quality of the output image for lossy formats such as JPEG, WebP, + # and AVIF. A higher quality value results in a larger file size with better + # quality, while a lower value produces a smaller file size with reduced quality. + # See [Quality](https://imagekit.io/docs/image-optimization#quality---q). + quality: nil, + # Specifies the corner radius for rounded corners (e.g., 20) or `max` for circular + # or oval shape. See + # [Radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). + radius: nil, + # Pass any transformation not directly supported by the SDK. This transformation + # string is appended to the URL as provided. + raw: nil, + # Specifies the rotation angle in degrees. Positive values rotate the image + # clockwise; you can also use, for example, `N40` for counterclockwise rotation or + # `auto` to use the orientation specified in the image's EXIF data. For videos, + # only the following values are supported: 0, 90, 180, 270, or 360. See + # [Rotate](https://imagekit.io/docs/effects-and-enhancements#rotate---rt). + rotation: nil, + # Adds a shadow beneath solid objects in an image with a transparent background. + # For AI-based drop shadows, refer to aiDropShadow. Pass `true` for a default + # shadow, or provide a string for a custom shadow. See + # [Shadow](https://imagekit.io/docs/effects-and-enhancements#shadow---e-shadow). + shadow: nil, + # Sharpens the input image, highlighting edges and finer details. Pass `true` for + # default sharpening, or provide a numeric value for custom sharpening. See + # [Sharpen](https://imagekit.io/docs/effects-and-enhancements#sharpen---e-sharpen). + sharpen: nil, + # Specifies the start offset (in seconds) for trimming videos, e.g., `5` or + # `10.5`. Arithmetic expressions are also supported. See + # [Trim videos – Start offset](https://imagekit.io/docs/trim-videos#start-offset---so). + start_offset: nil, + # An array of resolutions for adaptive bitrate streaming, e.g., [`240`, `360`, + # `480`, `720`, `1080`]. See + # [Adaptive Bitrate Streaming](https://imagekit.io/docs/adaptive-bitrate-streaming). + streaming_resolutions: nil, + # Useful for images with a solid or nearly solid background and a central object. + # This parameter trims the background, leaving only the central object in the + # output image. See + # [Trim edges](https://imagekit.io/docs/effects-and-enhancements#trim-edges---t). + trim: nil, + # Applies Unsharp Masking (USM), an image sharpening technique. Pass `true` for a + # default unsharp mask, or provide a string for a custom unsharp mask. See + # [Unsharp Mask](https://imagekit.io/docs/effects-and-enhancements#unsharp-mask---e-usm). + unsharp_mask: nil, + # Specifies the video codec, e.g., `h264`, `vp9`, `av1`, or `none`. See + # [Video codec](https://imagekit.io/docs/video-optimization#video-codec---vc). + video_codec: nil, + # Specifies the width of the output. If a value between 0 and 1 is provided, it is + # treated as a percentage (e.g., `0.4` represents 40% of the original width). You + # can also supply arithmetic expressions (e.g., `iw_div_2`). Width transformation + # – [Images](https://imagekit.io/docs/image-resize-and-crop#width---w) · + # [Videos](https://imagekit.io/docs/video-resize-and-crop#width---w) + width: nil, + # Focus using cropped image coordinates - X coordinate. See + # [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). + x: nil, + # Focus using cropped image coordinates - X center coordinate. See + # [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). + x_center: nil, + # Focus using cropped image coordinates - Y coordinate. See + # [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). + y_: nil, + # Focus using cropped image coordinates - Y center coordinate. See + # [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). + y_center: nil, + # Accepts a numeric value that determines how much to zoom in or out of the + # cropped area. It should be used in conjunction with fo-face or fo-. + # See [Zoom](https://imagekit.io/docs/image-resize-and-crop#zoom---z). + zoom: nil + ) + end + + sig do + override.returns( + { + ai_change_background: String, + ai_drop_shadow: T.any(T::Boolean, String), + ai_edit: String, + ai_remove_background: + Imagekit::Transformation::AIRemoveBackground::OrBoolean, + ai_remove_background_external: + Imagekit::Transformation::AIRemoveBackgroundExternal::OrBoolean, + ai_retouch: Imagekit::Transformation::AIRetouch::OrBoolean, + ai_upscale: Imagekit::Transformation::AIUpscale::OrBoolean, + ai_variation: Imagekit::Transformation::AIVariation::OrBoolean, + aspect_ratio: Imagekit::Transformation::AspectRatio::Variants, + audio_codec: Imagekit::Transformation::AudioCodec::OrSymbol, + background: String, + blur: Float, + border: String, + color_profile: T::Boolean, + contrast_stretch: + Imagekit::Transformation::ContrastStretch::OrBoolean, + crop: Imagekit::Transformation::Crop::OrSymbol, + crop_mode: Imagekit::Transformation::CropMode::OrSymbol, + default_image: String, + dpr: Float, + duration: Imagekit::Transformation::Duration::Variants, + end_offset: Imagekit::Transformation::EndOffset::Variants, + flip: Imagekit::Transformation::Flip::OrSymbol, + focus: String, + format_: Imagekit::Transformation::Format::OrSymbol, + gradient: T.any(T::Boolean, String), + grayscale: Imagekit::Transformation::Grayscale::OrBoolean, + height: Imagekit::Transformation::Height::Variants, + lossless: T::Boolean, + metadata: T::Boolean, + named: String, + opacity: Float, + original: T::Boolean, + overlay: Imagekit::Overlay, + page: Imagekit::Transformation::Page::Variants, + progressive: T::Boolean, + quality: Float, + radius: T.any(Float, Symbol), + raw: String, + rotation: Imagekit::Transformation::Rotation::Variants, + shadow: T.any(T::Boolean, String), + sharpen: T.any(T::Boolean, Float), + start_offset: Imagekit::Transformation::StartOffset::Variants, + streaming_resolutions: + T::Array[Imagekit::StreamingResolution::OrSymbol], + trim: T.any(T::Boolean, Float), + unsharp_mask: T.any(T::Boolean, String), + video_codec: Imagekit::Transformation::VideoCodec::OrSymbol, + width: Imagekit::Transformation::Width::Variants, + x: Imagekit::Transformation::X::Variants, + x_center: Imagekit::Transformation::XCenter::Variants, + y_: Imagekit::Transformation::Y::Variants, + y_center: Imagekit::Transformation::YCenter::Variants, + zoom: Float + } + ) + end + def to_hash + end + + # Adds an AI-based drop shadow around a foreground object on a transparent or + # removed background. Optionally, control the direction, elevation, and saturation + # of the light source (e.g., `az-45` to change light direction). Pass `true` for + # the default drop shadow, or provide a string for a custom drop shadow. Supported + # inside overlay. See + # [AI Drop Shadow](https://imagekit.io/docs/ai-transformations#ai-drop-shadow-e-dropshadow). + module AIDropShadow + extend Imagekit::Internal::Type::Union + + Variants = T.type_alias { T.any(T::Boolean, String) } + + sig do + override.returns( + T::Array[Imagekit::Transformation::AIDropShadow::Variants] + ) + end + def self.variants + end + end + + # Applies ImageKit's in-house background removal. Supported inside overlay. See + # [AI Background Removal](https://imagekit.io/docs/ai-transformations#imagekit-background-removal-e-bgremove). + module AIRemoveBackground + extend Imagekit::Internal::Type::Enum + + TaggedBoolean = + T.type_alias do + T.all(T::Boolean, Imagekit::Transformation::AIRemoveBackground) + end + OrBoolean = T.type_alias { T::Boolean } + + TRUE = + T.let( + true, + Imagekit::Transformation::AIRemoveBackground::TaggedBoolean + ) + + sig do + override.returns( + T::Array[ + Imagekit::Transformation::AIRemoveBackground::TaggedBoolean + ] + ) + end + def self.values + end + end + + # Uses third-party background removal. Note: It is recommended to use + # aiRemoveBackground, ImageKit's in-house solution, which is more cost-effective. + # Supported inside overlay. See + # [External Background Removal](https://imagekit.io/docs/ai-transformations#background-removal-e-removedotbg). + module AIRemoveBackgroundExternal + extend Imagekit::Internal::Type::Enum + + TaggedBoolean = + T.type_alias do + T.all( + T::Boolean, + Imagekit::Transformation::AIRemoveBackgroundExternal + ) + end + OrBoolean = T.type_alias { T::Boolean } + + TRUE = + T.let( + true, + Imagekit::Transformation::AIRemoveBackgroundExternal::TaggedBoolean + ) + + sig do + override.returns( + T::Array[ + Imagekit::Transformation::AIRemoveBackgroundExternal::TaggedBoolean + ] + ) + end + def self.values + end + end + + # Performs AI-based retouching to improve faces or product shots. Not supported + # inside overlay. See + # [AI Retouch](https://imagekit.io/docs/ai-transformations#retouch-e-retouch). + module AIRetouch + extend Imagekit::Internal::Type::Enum + + TaggedBoolean = + T.type_alias do + T.all(T::Boolean, Imagekit::Transformation::AIRetouch) + end + OrBoolean = T.type_alias { T::Boolean } + + TRUE = T.let(true, Imagekit::Transformation::AIRetouch::TaggedBoolean) + + sig do + override.returns( + T::Array[Imagekit::Transformation::AIRetouch::TaggedBoolean] + ) + end + def self.values + end + end + + # Upscales images beyond their original dimensions using AI. Not supported inside + # overlay. See + # [AI Upscale](https://imagekit.io/docs/ai-transformations#upscale-e-upscale). + module AIUpscale + extend Imagekit::Internal::Type::Enum + + TaggedBoolean = + T.type_alias do + T.all(T::Boolean, Imagekit::Transformation::AIUpscale) + end + OrBoolean = T.type_alias { T::Boolean } + + TRUE = T.let(true, Imagekit::Transformation::AIUpscale::TaggedBoolean) + + sig do + override.returns( + T::Array[Imagekit::Transformation::AIUpscale::TaggedBoolean] + ) + end + def self.values + end + end + + # Generates a variation of an image using AI. This produces a new image with + # slight variations from the original, such as changes in color, texture, and + # other visual elements, while preserving the structure and essence of the + # original image. Not supported inside overlay. See + # [AI Generate Variations](https://imagekit.io/docs/ai-transformations#generate-variations-of-an-image-e-genvar). + module AIVariation + extend Imagekit::Internal::Type::Enum + + TaggedBoolean = + T.type_alias do + T.all(T::Boolean, Imagekit::Transformation::AIVariation) + end + OrBoolean = T.type_alias { T::Boolean } + + TRUE = T.let(true, Imagekit::Transformation::AIVariation::TaggedBoolean) + + sig do + override.returns( + T::Array[Imagekit::Transformation::AIVariation::TaggedBoolean] + ) + end + def self.values + end + end + + # Specifies the aspect ratio for the output, e.g., "ar-4-3". Typically used with + # either width or height (but not both). For example: aspectRatio = `4:3`, `4_3`, + # or an expression like `iar_div_2`. See + # [Image resize and crop – Aspect ratio](https://imagekit.io/docs/image-resize-and-crop#aspect-ratio---ar). + module AspectRatio + extend Imagekit::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns( + T::Array[Imagekit::Transformation::AspectRatio::Variants] + ) + end + def self.variants + end + end + + # Specifies the audio codec, e.g., `aac`, `opus`, or `none`. See + # [Audio codec](https://imagekit.io/docs/video-optimization#audio-codec---ac). + module AudioCodec + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, Imagekit::Transformation::AudioCodec) } + OrSymbol = T.type_alias { T.any(Symbol, String) } + + AAC = T.let(:aac, Imagekit::Transformation::AudioCodec::TaggedSymbol) + OPUS = T.let(:opus, Imagekit::Transformation::AudioCodec::TaggedSymbol) + NONE = T.let(:none, Imagekit::Transformation::AudioCodec::TaggedSymbol) + + sig do + override.returns( + T::Array[Imagekit::Transformation::AudioCodec::TaggedSymbol] + ) + end + def self.values + end + end + + # Automatically enhances the contrast of an image (contrast stretch). See + # [Contrast Stretch](https://imagekit.io/docs/effects-and-enhancements#contrast-stretch---e-contrast). + module ContrastStretch + extend Imagekit::Internal::Type::Enum + + TaggedBoolean = + T.type_alias do + T.all(T::Boolean, Imagekit::Transformation::ContrastStretch) + end + OrBoolean = T.type_alias { T::Boolean } + + TRUE = + T.let(true, Imagekit::Transformation::ContrastStretch::TaggedBoolean) + + sig do + override.returns( + T::Array[Imagekit::Transformation::ContrastStretch::TaggedBoolean] + ) + end + def self.values + end + end + + # Crop modes for image resizing. See + # [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). + module Crop + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, Imagekit::Transformation::Crop) } + OrSymbol = T.type_alias { T.any(Symbol, String) } + + FORCE = T.let(:force, Imagekit::Transformation::Crop::TaggedSymbol) + AT_MAX = T.let(:at_max, Imagekit::Transformation::Crop::TaggedSymbol) + AT_MAX_ENLARGE = + T.let(:at_max_enlarge, Imagekit::Transformation::Crop::TaggedSymbol) + AT_LEAST = + T.let(:at_least, Imagekit::Transformation::Crop::TaggedSymbol) + MAINTAIN_RATIO = + T.let(:maintain_ratio, Imagekit::Transformation::Crop::TaggedSymbol) + + sig do + override.returns( + T::Array[Imagekit::Transformation::Crop::TaggedSymbol] + ) + end + def self.values + end + end + + # Additional crop modes for image resizing. See + # [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). + module CropMode + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, Imagekit::Transformation::CropMode) } + OrSymbol = T.type_alias { T.any(Symbol, String) } + + PAD_RESIZE = + T.let(:pad_resize, Imagekit::Transformation::CropMode::TaggedSymbol) + EXTRACT = + T.let(:extract, Imagekit::Transformation::CropMode::TaggedSymbol) + PAD_EXTRACT = + T.let(:pad_extract, Imagekit::Transformation::CropMode::TaggedSymbol) + + sig do + override.returns( + T::Array[Imagekit::Transformation::CropMode::TaggedSymbol] + ) + end + def self.values + end + end + + # Specifies the duration (in seconds) for trimming videos, e.g., `5` or `10.5`. + # Typically used with startOffset to indicate the length from the start offset. + # Arithmetic expressions are supported. See + # [Trim videos – Duration](https://imagekit.io/docs/trim-videos#duration---du). + module Duration + extend Imagekit::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns( + T::Array[Imagekit::Transformation::Duration::Variants] + ) + end + def self.variants + end + end + + # Specifies the end offset (in seconds) for trimming videos, e.g., `5` or `10.5`. + # Typically used with startOffset to define a time window. Arithmetic expressions + # are supported. See + # [Trim videos – End offset](https://imagekit.io/docs/trim-videos#end-offset---eo). + module EndOffset + extend Imagekit::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns( + T::Array[Imagekit::Transformation::EndOffset::Variants] + ) + end + def self.variants + end + end + + # Flips or mirrors an image either horizontally, vertically, or both. Acceptable + # values: `h` (horizontal), `v` (vertical), `h_v` (horizontal and vertical), or + # `v_h`. See [Flip](https://imagekit.io/docs/effects-and-enhancements#flip---fl). + module Flip + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, Imagekit::Transformation::Flip) } + OrSymbol = T.type_alias { T.any(Symbol, String) } + + H = T.let(:h, Imagekit::Transformation::Flip::TaggedSymbol) + V = T.let(:v, Imagekit::Transformation::Flip::TaggedSymbol) + H_V = T.let(:h_v, Imagekit::Transformation::Flip::TaggedSymbol) + V_H = T.let(:v_h, Imagekit::Transformation::Flip::TaggedSymbol) + + sig do + override.returns( + T::Array[Imagekit::Transformation::Flip::TaggedSymbol] + ) + end + def self.values + end + end + + # Specifies the output format for images or videos, e.g., `jpg`, `png`, `webp`, + # `mp4`, or `auto`. You can also pass `orig` for images to return the original + # format. ImageKit automatically delivers images and videos in the optimal format + # based on device support unless overridden by the dashboard settings or the + # format parameter. See + # [Image format](https://imagekit.io/docs/image-optimization#format---f) and + # [Video format](https://imagekit.io/docs/video-optimization#format---f). + module Format + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, Imagekit::Transformation::Format) } + OrSymbol = T.type_alias { T.any(Symbol, String) } + + AUTO = T.let(:auto, Imagekit::Transformation::Format::TaggedSymbol) + WEBP = T.let(:webp, Imagekit::Transformation::Format::TaggedSymbol) + JPG = T.let(:jpg, Imagekit::Transformation::Format::TaggedSymbol) + JPEG = T.let(:jpeg, Imagekit::Transformation::Format::TaggedSymbol) + PNG = T.let(:png, Imagekit::Transformation::Format::TaggedSymbol) + GIF = T.let(:gif, Imagekit::Transformation::Format::TaggedSymbol) + SVG = T.let(:svg, Imagekit::Transformation::Format::TaggedSymbol) + MP4 = T.let(:mp4, Imagekit::Transformation::Format::TaggedSymbol) + WEBM = T.let(:webm, Imagekit::Transformation::Format::TaggedSymbol) + AVIF = T.let(:avif, Imagekit::Transformation::Format::TaggedSymbol) + ORIG = T.let(:orig, Imagekit::Transformation::Format::TaggedSymbol) + + sig do + override.returns( + T::Array[Imagekit::Transformation::Format::TaggedSymbol] + ) + end + def self.values + end + end + + # Creates a linear gradient with two colors. Pass `true` for a default gradient, + # or provide a string for a custom gradient. See + # [Gradient](https://imagekit.io/docs/effects-and-enhancements#gradient---e-gradient). + module Gradient + extend Imagekit::Internal::Type::Union + + Variants = T.type_alias { T.any(T::Boolean, String) } + + sig do + override.returns( + T::Array[Imagekit::Transformation::Gradient::Variants] + ) + end + def self.variants + end + end + + # Enables a grayscale effect for images. See + # [Grayscale](https://imagekit.io/docs/effects-and-enhancements#grayscale---e-grayscale). + module Grayscale + extend Imagekit::Internal::Type::Enum + + TaggedBoolean = + T.type_alias do + T.all(T::Boolean, Imagekit::Transformation::Grayscale) + end + OrBoolean = T.type_alias { T::Boolean } + + TRUE = T.let(true, Imagekit::Transformation::Grayscale::TaggedBoolean) + + sig do + override.returns( + T::Array[Imagekit::Transformation::Grayscale::TaggedBoolean] + ) + end + def self.values + end + end + + # Specifies the height of the output. If a value between 0 and 1 is provided, it + # is treated as a percentage (e.g., `0.5` represents 50% of the original height). + # You can also supply arithmetic expressions (e.g., `ih_mul_0.5`). Height + # transformation – + # [Images](https://imagekit.io/docs/image-resize-and-crop#height---h) · + # [Videos](https://imagekit.io/docs/video-resize-and-crop#height---h) + module Height + extend Imagekit::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns(T::Array[Imagekit::Transformation::Height::Variants]) + end + def self.variants + end + end + + # Extracts a specific page or frame from multi-page or layered files (PDF, PSD, + # AI). For example, specify by number (e.g., `2`), a range (e.g., `3-4` for the + # 2nd and 3rd layers), or by name (e.g., `name-layer-4` for a PSD layer). See + # [Thumbnail extraction](https://imagekit.io/docs/vector-and-animated-images#get-thumbnail-from-psd-pdf-ai-eps-and-animated-files). + module Page + extend Imagekit::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns(T::Array[Imagekit::Transformation::Page::Variants]) + end + def self.variants + end + end + + # Specifies the corner radius for rounded corners (e.g., 20) or `max` for circular + # or oval shape. See + # [Radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). + module Radius + extend Imagekit::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, Symbol) } + + sig do + override.returns(T::Array[Imagekit::Transformation::Radius::Variants]) + end + def self.variants + end + end + + # Specifies the rotation angle in degrees. Positive values rotate the image + # clockwise; you can also use, for example, `N40` for counterclockwise rotation or + # `auto` to use the orientation specified in the image's EXIF data. For videos, + # only the following values are supported: 0, 90, 180, 270, or 360. See + # [Rotate](https://imagekit.io/docs/effects-and-enhancements#rotate---rt). + module Rotation + extend Imagekit::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns( + T::Array[Imagekit::Transformation::Rotation::Variants] + ) + end + def self.variants + end + end + + # Adds a shadow beneath solid objects in an image with a transparent background. + # For AI-based drop shadows, refer to aiDropShadow. Pass `true` for a default + # shadow, or provide a string for a custom shadow. See + # [Shadow](https://imagekit.io/docs/effects-and-enhancements#shadow---e-shadow). + module Shadow + extend Imagekit::Internal::Type::Union + + Variants = T.type_alias { T.any(T::Boolean, String) } + + sig do + override.returns(T::Array[Imagekit::Transformation::Shadow::Variants]) + end + def self.variants + end + end + + # Sharpens the input image, highlighting edges and finer details. Pass `true` for + # default sharpening, or provide a numeric value for custom sharpening. See + # [Sharpen](https://imagekit.io/docs/effects-and-enhancements#sharpen---e-sharpen). + module Sharpen + extend Imagekit::Internal::Type::Union + + Variants = T.type_alias { T.any(T::Boolean, Float) } + + sig do + override.returns( + T::Array[Imagekit::Transformation::Sharpen::Variants] + ) + end + def self.variants + end + end + + # Specifies the start offset (in seconds) for trimming videos, e.g., `5` or + # `10.5`. Arithmetic expressions are also supported. See + # [Trim videos – Start offset](https://imagekit.io/docs/trim-videos#start-offset---so). + module StartOffset + extend Imagekit::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns( + T::Array[Imagekit::Transformation::StartOffset::Variants] + ) + end + def self.variants + end + end + + # Useful for images with a solid or nearly solid background and a central object. + # This parameter trims the background, leaving only the central object in the + # output image. See + # [Trim edges](https://imagekit.io/docs/effects-and-enhancements#trim-edges---t). + module Trim + extend Imagekit::Internal::Type::Union + + Variants = T.type_alias { T.any(T::Boolean, Float) } + + sig do + override.returns(T::Array[Imagekit::Transformation::Trim::Variants]) + end + def self.variants + end + end + + # Applies Unsharp Masking (USM), an image sharpening technique. Pass `true` for a + # default unsharp mask, or provide a string for a custom unsharp mask. See + # [Unsharp Mask](https://imagekit.io/docs/effects-and-enhancements#unsharp-mask---e-usm). + module UnsharpMask + extend Imagekit::Internal::Type::Union + + Variants = T.type_alias { T.any(T::Boolean, String) } + + sig do + override.returns( + T::Array[Imagekit::Transformation::UnsharpMask::Variants] + ) + end + def self.variants + end + end + + # Specifies the video codec, e.g., `h264`, `vp9`, `av1`, or `none`. See + # [Video codec](https://imagekit.io/docs/video-optimization#video-codec---vc). + module VideoCodec + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, Imagekit::Transformation::VideoCodec) } + OrSymbol = T.type_alias { T.any(Symbol, String) } + + H264 = T.let(:h264, Imagekit::Transformation::VideoCodec::TaggedSymbol) + VP9 = T.let(:vp9, Imagekit::Transformation::VideoCodec::TaggedSymbol) + AV1 = T.let(:av1, Imagekit::Transformation::VideoCodec::TaggedSymbol) + NONE = T.let(:none, Imagekit::Transformation::VideoCodec::TaggedSymbol) + + sig do + override.returns( + T::Array[Imagekit::Transformation::VideoCodec::TaggedSymbol] + ) + end + def self.values + end + end + + # Specifies the width of the output. If a value between 0 and 1 is provided, it is + # treated as a percentage (e.g., `0.4` represents 40% of the original width). You + # can also supply arithmetic expressions (e.g., `iw_div_2`). Width transformation + # – [Images](https://imagekit.io/docs/image-resize-and-crop#width---w) · + # [Videos](https://imagekit.io/docs/video-resize-and-crop#width---w) + module Width + extend Imagekit::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns(T::Array[Imagekit::Transformation::Width::Variants]) + end + def self.variants + end + end + + # Focus using cropped image coordinates - X coordinate. See + # [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). + module X + extend Imagekit::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns(T::Array[Imagekit::Transformation::X::Variants]) + end + def self.variants + end + end + + # Focus using cropped image coordinates - X center coordinate. See + # [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). + module XCenter + extend Imagekit::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns( + T::Array[Imagekit::Transformation::XCenter::Variants] + ) + end + def self.variants + end + end + + # Focus using cropped image coordinates - Y coordinate. See + # [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). + module Y + extend Imagekit::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns(T::Array[Imagekit::Transformation::Y::Variants]) + end + def self.variants + end + end + + # Focus using cropped image coordinates - Y center coordinate. See + # [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). + module YCenter + extend Imagekit::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns( + T::Array[Imagekit::Transformation::YCenter::Variants] + ) + end + def self.variants + end + end + end + end +end diff --git a/rbi/imagekit/models/transformation_position.rbi b/rbi/imagekit/models/transformation_position.rbi new file mode 100644 index 00000000..603588e6 --- /dev/null +++ b/rbi/imagekit/models/transformation_position.rbi @@ -0,0 +1,28 @@ +# typed: strong + +module Imagekit + module Models + # By default, the transformation string is added as a query parameter in the URL, + # e.g., `?tr=w-100,h-100`. If you want to add the transformation string in the + # path of the URL, set this to `path`. Learn more in the + # [Transformations guide](https://imagekit.io/docs/transformations). + module TransformationPosition + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, Imagekit::TransformationPosition) } + OrSymbol = T.type_alias { T.any(Symbol, String) } + + PATH = T.let(:path, Imagekit::TransformationPosition::TaggedSymbol) + QUERY = T.let(:query, Imagekit::TransformationPosition::TaggedSymbol) + + sig do + override.returns( + T::Array[Imagekit::TransformationPosition::TaggedSymbol] + ) + end + def self.values + end + end + end +end diff --git a/rbi/imagekit/models/unsafe_unwrap_webhook_event.rbi b/rbi/imagekit/models/unsafe_unwrap_webhook_event.rbi new file mode 100644 index 00000000..4dbc761c --- /dev/null +++ b/rbi/imagekit/models/unsafe_unwrap_webhook_event.rbi @@ -0,0 +1,31 @@ +# typed: strong + +module Imagekit + module Models + # Triggered when a new video transformation request is accepted for processing. + # This event confirms that ImageKit has received and queued your transformation + # request. Use this for debugging and tracking transformation lifecycle. + module UnsafeUnwrapWebhookEvent + extend Imagekit::Internal::Type::Union + + Variants = + T.type_alias do + T.any( + Imagekit::VideoTransformationAcceptedEvent, + Imagekit::VideoTransformationReadyEvent, + Imagekit::VideoTransformationErrorEvent, + Imagekit::UploadPreTransformSuccessEvent, + Imagekit::UploadPreTransformErrorEvent, + Imagekit::UploadPostTransformSuccessEvent, + Imagekit::UploadPostTransformErrorEvent + ) + end + + sig do + override.returns(T::Array[Imagekit::UnsafeUnwrapWebhookEvent::Variants]) + end + def self.variants + end + end + end +end diff --git a/rbi/imagekit/models/unwrap_webhook_event.rbi b/rbi/imagekit/models/unwrap_webhook_event.rbi new file mode 100644 index 00000000..b94a7e27 --- /dev/null +++ b/rbi/imagekit/models/unwrap_webhook_event.rbi @@ -0,0 +1,29 @@ +# typed: strong + +module Imagekit + module Models + # Triggered when a new video transformation request is accepted for processing. + # This event confirms that ImageKit has received and queued your transformation + # request. Use this for debugging and tracking transformation lifecycle. + module UnwrapWebhookEvent + extend Imagekit::Internal::Type::Union + + Variants = + T.type_alias do + T.any( + Imagekit::VideoTransformationAcceptedEvent, + Imagekit::VideoTransformationReadyEvent, + Imagekit::VideoTransformationErrorEvent, + Imagekit::UploadPreTransformSuccessEvent, + Imagekit::UploadPreTransformErrorEvent, + Imagekit::UploadPostTransformSuccessEvent, + Imagekit::UploadPostTransformErrorEvent + ) + end + + sig { override.returns(T::Array[Imagekit::UnwrapWebhookEvent::Variants]) } + def self.variants + end + end + end +end diff --git a/rbi/imagekit/models/update_file_request.rbi b/rbi/imagekit/models/update_file_request.rbi new file mode 100644 index 00000000..b259bf0e --- /dev/null +++ b/rbi/imagekit/models/update_file_request.rbi @@ -0,0 +1,314 @@ +# typed: strong + +module Imagekit + module Models + # Schema for update file update request. + module UpdateFileRequest + extend Imagekit::Internal::Type::Union + + Variants = + T.type_alias do + T.any( + Imagekit::UpdateFileRequest::UpdateFileDetails, + Imagekit::UpdateFileRequest::ChangePublicationStatus + ) + end + + class UpdateFileDetails < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::UpdateFileRequest::UpdateFileDetails, + Imagekit::Internal::AnyHash + ) + end + + # Define an important area in the image in the format `x,y,width,height` e.g. + # `10,10,100,100`. Send `null` to unset this value. + sig { returns(T.nilable(String)) } + attr_accessor :custom_coordinates + + # A key-value data to be associated with the asset. To unset a key, send `null` + # value for that key. Before setting any custom metadata on an asset you have to + # create the field using custom metadata fields API. + sig { returns(T.nilable(T::Hash[Symbol, T.anything])) } + attr_reader :custom_metadata + + sig { params(custom_metadata: T::Hash[Symbol, T.anything]).void } + attr_writer :custom_metadata + + # Optional text to describe the contents of the file. + sig { returns(T.nilable(String)) } + attr_reader :description + + sig { params(description: String).void } + attr_writer :description + + # Array of extensions to be applied to the asset. Each extension can be configured + # with specific parameters based on the extension type. + sig do + returns( + T.nilable( + T::Array[ + T.any( + Imagekit::ExtensionItem::RemoveBg, + Imagekit::ExtensionItem::AIAutoDescription, + Imagekit::ExtensionItem::AutoTaggingExtension + ) + ] + ) + ) + end + attr_reader :extensions + + sig do + params( + extensions: + T::Array[ + T.any( + Imagekit::ExtensionItem::RemoveBg::OrHash, + Imagekit::ExtensionItem::AIAutoDescription::OrHash, + Imagekit::ExtensionItem::AutoTaggingExtension::OrHash + ) + ] + ).void + end + attr_writer :extensions + + # An array of AITags associated with the file that you want to remove, e.g. + # `["car", "vehicle", "motorsports"]`. + # + # If you want to remove all AITags associated with the file, send a string - + # "all". + # + # Note: The remove operation for `AITags` executes before any of the `extensions` + # are processed. + sig { returns(T.nilable(T.any(T::Array[String], Symbol))) } + attr_reader :remove_ai_tags + + sig { params(remove_ai_tags: T.any(T::Array[String], Symbol)).void } + attr_writer :remove_ai_tags + + # An array of tags associated with the file, such as `["tag1", "tag2"]`. Send + # `null` to unset all tags associated with the file. + sig { returns(T.nilable(T::Array[String])) } + attr_accessor :tags + + # The final status of extensions after they have completed execution will be + # delivered to this endpoint as a POST request. + # [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + # about the webhook payload structure. + sig { returns(T.nilable(String)) } + attr_reader :webhook_url + + sig { params(webhook_url: String).void } + attr_writer :webhook_url + + sig do + params( + custom_coordinates: T.nilable(String), + custom_metadata: T::Hash[Symbol, T.anything], + description: String, + extensions: + T::Array[ + T.any( + Imagekit::ExtensionItem::RemoveBg::OrHash, + Imagekit::ExtensionItem::AIAutoDescription::OrHash, + Imagekit::ExtensionItem::AutoTaggingExtension::OrHash + ) + ], + remove_ai_tags: T.any(T::Array[String], Symbol), + tags: T.nilable(T::Array[String]), + webhook_url: String + ).returns(T.attached_class) + end + def self.new( + # Define an important area in the image in the format `x,y,width,height` e.g. + # `10,10,100,100`. Send `null` to unset this value. + custom_coordinates: nil, + # A key-value data to be associated with the asset. To unset a key, send `null` + # value for that key. Before setting any custom metadata on an asset you have to + # create the field using custom metadata fields API. + custom_metadata: nil, + # Optional text to describe the contents of the file. + description: nil, + # Array of extensions to be applied to the asset. Each extension can be configured + # with specific parameters based on the extension type. + extensions: nil, + # An array of AITags associated with the file that you want to remove, e.g. + # `["car", "vehicle", "motorsports"]`. + # + # If you want to remove all AITags associated with the file, send a string - + # "all". + # + # Note: The remove operation for `AITags` executes before any of the `extensions` + # are processed. + remove_ai_tags: nil, + # An array of tags associated with the file, such as `["tag1", "tag2"]`. Send + # `null` to unset all tags associated with the file. + tags: nil, + # The final status of extensions after they have completed execution will be + # delivered to this endpoint as a POST request. + # [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + # about the webhook payload structure. + webhook_url: nil + ) + end + + sig do + override.returns( + { + custom_coordinates: T.nilable(String), + custom_metadata: T::Hash[Symbol, T.anything], + description: String, + extensions: + T::Array[ + T.any( + Imagekit::ExtensionItem::RemoveBg, + Imagekit::ExtensionItem::AIAutoDescription, + Imagekit::ExtensionItem::AutoTaggingExtension + ) + ], + remove_ai_tags: T.any(T::Array[String], Symbol), + tags: T.nilable(T::Array[String]), + webhook_url: String + } + ) + end + def to_hash + end + + # An array of AITags associated with the file that you want to remove, e.g. + # `["car", "vehicle", "motorsports"]`. + # + # If you want to remove all AITags associated with the file, send a string - + # "all". + # + # Note: The remove operation for `AITags` executes before any of the `extensions` + # are processed. + module RemoveAITags + extend Imagekit::Internal::Type::Union + + Variants = T.type_alias { T.any(T::Array[String], Symbol) } + + sig do + override.returns( + T::Array[ + Imagekit::UpdateFileRequest::UpdateFileDetails::RemoveAITags::Variants + ] + ) + end + def self.variants + end + + StringArray = + T.let( + Imagekit::Internal::Type::ArrayOf[String], + Imagekit::Internal::Type::Converter + ) + end + end + + class ChangePublicationStatus < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::UpdateFileRequest::ChangePublicationStatus, + Imagekit::Internal::AnyHash + ) + end + + # Configure the publication status of a file and its versions. + sig do + returns( + T.nilable( + Imagekit::UpdateFileRequest::ChangePublicationStatus::Publish + ) + ) + end + attr_reader :publish + + sig do + params( + publish: + Imagekit::UpdateFileRequest::ChangePublicationStatus::Publish::OrHash + ).void + end + attr_writer :publish + + sig do + params( + publish: + Imagekit::UpdateFileRequest::ChangePublicationStatus::Publish::OrHash + ).returns(T.attached_class) + end + def self.new( + # Configure the publication status of a file and its versions. + publish: nil + ) + end + + sig do + override.returns( + { + publish: + Imagekit::UpdateFileRequest::ChangePublicationStatus::Publish + } + ) + end + def to_hash + end + + class Publish < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::UpdateFileRequest::ChangePublicationStatus::Publish, + Imagekit::Internal::AnyHash + ) + end + + # Set to `true` to publish the file. Set to `false` to unpublish the file. + sig { returns(T::Boolean) } + attr_accessor :is_published + + # Set to `true` to publish/unpublish all versions of the file. Set to `false` to + # publish/unpublish only the current version of the file. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :include_file_versions + + sig { params(include_file_versions: T::Boolean).void } + attr_writer :include_file_versions + + # Configure the publication status of a file and its versions. + sig do + params( + is_published: T::Boolean, + include_file_versions: T::Boolean + ).returns(T.attached_class) + end + def self.new( + # Set to `true` to publish the file. Set to `false` to unpublish the file. + is_published:, + # Set to `true` to publish/unpublish all versions of the file. Set to `false` to + # publish/unpublish only the current version of the file. + include_file_versions: nil + ) + end + + sig do + override.returns( + { is_published: T::Boolean, include_file_versions: T::Boolean } + ) + end + def to_hash + end + end + end + + sig { override.returns(T::Array[Imagekit::UpdateFileRequest::Variants]) } + def self.variants + end + end + end +end diff --git a/rbi/imagekit/models/upload_post_transform_error_event.rbi b/rbi/imagekit/models/upload_post_transform_error_event.rbi new file mode 100644 index 00000000..71aa5b20 --- /dev/null +++ b/rbi/imagekit/models/upload_post_transform_error_event.rbi @@ -0,0 +1,430 @@ +# typed: strong + +module Imagekit + module Models + class UploadPostTransformErrorEvent < Imagekit::Models::BaseWebhookEvent + OrHash = + T.type_alias do + T.any( + Imagekit::UploadPostTransformErrorEvent, + Imagekit::Internal::AnyHash + ) + end + + # Timestamp of when the event occurred in ISO8601 format. + sig { returns(Time) } + attr_accessor :created_at + + sig { returns(Imagekit::UploadPostTransformErrorEvent::Data) } + attr_reader :data + + sig do + params(data: Imagekit::UploadPostTransformErrorEvent::Data::OrHash).void + end + attr_writer :data + + sig { returns(Imagekit::UploadPostTransformErrorEvent::Request) } + attr_reader :request + + sig do + params( + request: Imagekit::UploadPostTransformErrorEvent::Request::OrHash + ).void + end + attr_writer :request + + sig { returns(Symbol) } + attr_accessor :type + + # Triggered when a post-transformation fails. The original file remains available, + # but the requested transformation could not be generated. + sig do + params( + created_at: Time, + data: Imagekit::UploadPostTransformErrorEvent::Data::OrHash, + request: Imagekit::UploadPostTransformErrorEvent::Request::OrHash, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Timestamp of when the event occurred in ISO8601 format. + created_at:, + data:, + request:, + type: :"upload.post-transform.error" + ) + end + + sig do + override.returns( + { + created_at: Time, + data: Imagekit::UploadPostTransformErrorEvent::Data, + request: Imagekit::UploadPostTransformErrorEvent::Request, + type: Symbol + } + ) + end + def to_hash + end + + class Data < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::UploadPostTransformErrorEvent::Data, + Imagekit::Internal::AnyHash + ) + end + + # Unique identifier of the originally uploaded file. + sig { returns(String) } + attr_accessor :file_id + + # Name of the file. + sig { returns(String) } + attr_accessor :name + + # Path of the file. + sig { returns(String) } + attr_accessor :path + + sig do + returns(Imagekit::UploadPostTransformErrorEvent::Data::Transformation) + end + attr_reader :transformation + + sig do + params( + transformation: + Imagekit::UploadPostTransformErrorEvent::Data::Transformation::OrHash + ).void + end + attr_writer :transformation + + # URL of the attempted post-transformation. + sig { returns(String) } + attr_accessor :url + + sig do + params( + file_id: String, + name: String, + path: String, + transformation: + Imagekit::UploadPostTransformErrorEvent::Data::Transformation::OrHash, + url: String + ).returns(T.attached_class) + end + def self.new( + # Unique identifier of the originally uploaded file. + file_id:, + # Name of the file. + name:, + # Path of the file. + path:, + transformation:, + # URL of the attempted post-transformation. + url: + ) + end + + sig do + override.returns( + { + file_id: String, + name: String, + path: String, + transformation: + Imagekit::UploadPostTransformErrorEvent::Data::Transformation, + url: String + } + ) + end + def to_hash + end + + class Transformation < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::UploadPostTransformErrorEvent::Data::Transformation, + Imagekit::Internal::AnyHash + ) + end + + sig do + returns( + Imagekit::UploadPostTransformErrorEvent::Data::Transformation::Error + ) + end + attr_reader :error + + sig do + params( + error: + Imagekit::UploadPostTransformErrorEvent::Data::Transformation::Error::OrHash + ).void + end + attr_writer :error + + sig do + params( + error: + Imagekit::UploadPostTransformErrorEvent::Data::Transformation::Error::OrHash + ).returns(T.attached_class) + end + def self.new(error:) + end + + sig do + override.returns( + { + error: + Imagekit::UploadPostTransformErrorEvent::Data::Transformation::Error + } + ) + end + def to_hash + end + + class Error < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::UploadPostTransformErrorEvent::Data::Transformation::Error, + Imagekit::Internal::AnyHash + ) + end + + # Reason for the post-transformation failure. + sig { returns(String) } + attr_accessor :reason + + sig { params(reason: String).returns(T.attached_class) } + def self.new( + # Reason for the post-transformation failure. + reason: + ) + end + + sig { override.returns({ reason: String }) } + def to_hash + end + end + end + end + + class Request < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::UploadPostTransformErrorEvent::Request, + Imagekit::Internal::AnyHash + ) + end + + sig do + returns( + Imagekit::UploadPostTransformErrorEvent::Request::Transformation + ) + end + attr_reader :transformation + + sig do + params( + transformation: + Imagekit::UploadPostTransformErrorEvent::Request::Transformation::OrHash + ).void + end + attr_writer :transformation + + # Unique identifier for the originating request. + sig { returns(String) } + attr_accessor :x_request_id + + sig do + params( + transformation: + Imagekit::UploadPostTransformErrorEvent::Request::Transformation::OrHash, + x_request_id: String + ).returns(T.attached_class) + end + def self.new( + transformation:, + # Unique identifier for the originating request. + x_request_id: + ) + end + + sig do + override.returns( + { + transformation: + Imagekit::UploadPostTransformErrorEvent::Request::Transformation, + x_request_id: String + } + ) + end + def to_hash + end + + class Transformation < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::UploadPostTransformErrorEvent::Request::Transformation, + Imagekit::Internal::AnyHash + ) + end + + # Type of the requested post-transformation. + sig do + returns( + Imagekit::UploadPostTransformErrorEvent::Request::Transformation::Type::TaggedSymbol + ) + end + attr_accessor :type + + # Only applicable if transformation type is 'abs'. Streaming protocol used. + sig do + returns( + T.nilable( + Imagekit::UploadPostTransformErrorEvent::Request::Transformation::Protocol::TaggedSymbol + ) + ) + end + attr_reader :protocol + + sig do + params( + protocol: + Imagekit::UploadPostTransformErrorEvent::Request::Transformation::Protocol::OrSymbol + ).void + end + attr_writer :protocol + + # Value for the requested transformation type. + sig { returns(T.nilable(String)) } + attr_reader :value + + sig { params(value: String).void } + attr_writer :value + + sig do + params( + type: + Imagekit::UploadPostTransformErrorEvent::Request::Transformation::Type::OrSymbol, + protocol: + Imagekit::UploadPostTransformErrorEvent::Request::Transformation::Protocol::OrSymbol, + value: String + ).returns(T.attached_class) + end + def self.new( + # Type of the requested post-transformation. + type:, + # Only applicable if transformation type is 'abs'. Streaming protocol used. + protocol: nil, + # Value for the requested transformation type. + value: nil + ) + end + + sig do + override.returns( + { + type: + Imagekit::UploadPostTransformErrorEvent::Request::Transformation::Type::TaggedSymbol, + protocol: + Imagekit::UploadPostTransformErrorEvent::Request::Transformation::Protocol::TaggedSymbol, + value: String + } + ) + end + def to_hash + end + + # Type of the requested post-transformation. + module Type + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekit::UploadPostTransformErrorEvent::Request::Transformation::Type + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + TRANSFORMATION = + T.let( + :transformation, + Imagekit::UploadPostTransformErrorEvent::Request::Transformation::Type::TaggedSymbol + ) + ABS = + T.let( + :abs, + Imagekit::UploadPostTransformErrorEvent::Request::Transformation::Type::TaggedSymbol + ) + GIF_TO_VIDEO = + T.let( + :"gif-to-video", + Imagekit::UploadPostTransformErrorEvent::Request::Transformation::Type::TaggedSymbol + ) + THUMBNAIL = + T.let( + :thumbnail, + Imagekit::UploadPostTransformErrorEvent::Request::Transformation::Type::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekit::UploadPostTransformErrorEvent::Request::Transformation::Type::TaggedSymbol + ] + ) + end + def self.values + end + end + + # Only applicable if transformation type is 'abs'. Streaming protocol used. + module Protocol + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekit::UploadPostTransformErrorEvent::Request::Transformation::Protocol + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + HLS = + T.let( + :hls, + Imagekit::UploadPostTransformErrorEvent::Request::Transformation::Protocol::TaggedSymbol + ) + DASH = + T.let( + :dash, + Imagekit::UploadPostTransformErrorEvent::Request::Transformation::Protocol::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekit::UploadPostTransformErrorEvent::Request::Transformation::Protocol::TaggedSymbol + ] + ) + end + def self.values + end + end + end + end + end + end +end diff --git a/rbi/imagekit/models/upload_post_transform_success_event.rbi b/rbi/imagekit/models/upload_post_transform_success_event.rbi new file mode 100644 index 00000000..c86f6212 --- /dev/null +++ b/rbi/imagekit/models/upload_post_transform_success_event.rbi @@ -0,0 +1,327 @@ +# typed: strong + +module Imagekit + module Models + class UploadPostTransformSuccessEvent < Imagekit::Models::BaseWebhookEvent + OrHash = + T.type_alias do + T.any( + Imagekit::UploadPostTransformSuccessEvent, + Imagekit::Internal::AnyHash + ) + end + + # Timestamp of when the event occurred in ISO8601 format. + sig { returns(Time) } + attr_accessor :created_at + + sig { returns(Imagekit::UploadPostTransformSuccessEvent::Data) } + attr_reader :data + + sig do + params( + data: Imagekit::UploadPostTransformSuccessEvent::Data::OrHash + ).void + end + attr_writer :data + + sig { returns(Imagekit::UploadPostTransformSuccessEvent::Request) } + attr_reader :request + + sig do + params( + request: Imagekit::UploadPostTransformSuccessEvent::Request::OrHash + ).void + end + attr_writer :request + + sig { returns(Symbol) } + attr_accessor :type + + # Triggered when a post-transformation completes successfully. The transformed + # version of the file is now ready and can be accessed via the provided URL. Note + # that each post-transformation generates a separate webhook event. + sig do + params( + created_at: Time, + data: Imagekit::UploadPostTransformSuccessEvent::Data::OrHash, + request: Imagekit::UploadPostTransformSuccessEvent::Request::OrHash, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Timestamp of when the event occurred in ISO8601 format. + created_at:, + data:, + request:, + type: :"upload.post-transform.success" + ) + end + + sig do + override.returns( + { + created_at: Time, + data: Imagekit::UploadPostTransformSuccessEvent::Data, + request: Imagekit::UploadPostTransformSuccessEvent::Request, + type: Symbol + } + ) + end + def to_hash + end + + class Data < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::UploadPostTransformSuccessEvent::Data, + Imagekit::Internal::AnyHash + ) + end + + # Unique identifier of the originally uploaded file. + sig { returns(String) } + attr_accessor :file_id + + # Name of the file. + sig { returns(String) } + attr_accessor :name + + # URL of the generated post-transformation. + sig { returns(String) } + attr_accessor :url + + sig do + params(file_id: String, name: String, url: String).returns( + T.attached_class + ) + end + def self.new( + # Unique identifier of the originally uploaded file. + file_id:, + # Name of the file. + name:, + # URL of the generated post-transformation. + url: + ) + end + + sig { override.returns({ file_id: String, name: String, url: String }) } + def to_hash + end + end + + class Request < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::UploadPostTransformSuccessEvent::Request, + Imagekit::Internal::AnyHash + ) + end + + sig do + returns( + Imagekit::UploadPostTransformSuccessEvent::Request::Transformation + ) + end + attr_reader :transformation + + sig do + params( + transformation: + Imagekit::UploadPostTransformSuccessEvent::Request::Transformation::OrHash + ).void + end + attr_writer :transformation + + # Unique identifier for the originating request. + sig { returns(String) } + attr_accessor :x_request_id + + sig do + params( + transformation: + Imagekit::UploadPostTransformSuccessEvent::Request::Transformation::OrHash, + x_request_id: String + ).returns(T.attached_class) + end + def self.new( + transformation:, + # Unique identifier for the originating request. + x_request_id: + ) + end + + sig do + override.returns( + { + transformation: + Imagekit::UploadPostTransformSuccessEvent::Request::Transformation, + x_request_id: String + } + ) + end + def to_hash + end + + class Transformation < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::UploadPostTransformSuccessEvent::Request::Transformation, + Imagekit::Internal::AnyHash + ) + end + + # Type of the requested post-transformation. + sig do + returns( + Imagekit::UploadPostTransformSuccessEvent::Request::Transformation::Type::TaggedSymbol + ) + end + attr_accessor :type + + # Only applicable if transformation type is 'abs'. Streaming protocol used. + sig do + returns( + T.nilable( + Imagekit::UploadPostTransformSuccessEvent::Request::Transformation::Protocol::TaggedSymbol + ) + ) + end + attr_reader :protocol + + sig do + params( + protocol: + Imagekit::UploadPostTransformSuccessEvent::Request::Transformation::Protocol::OrSymbol + ).void + end + attr_writer :protocol + + # Value for the requested transformation type. + sig { returns(T.nilable(String)) } + attr_reader :value + + sig { params(value: String).void } + attr_writer :value + + sig do + params( + type: + Imagekit::UploadPostTransformSuccessEvent::Request::Transformation::Type::OrSymbol, + protocol: + Imagekit::UploadPostTransformSuccessEvent::Request::Transformation::Protocol::OrSymbol, + value: String + ).returns(T.attached_class) + end + def self.new( + # Type of the requested post-transformation. + type:, + # Only applicable if transformation type is 'abs'. Streaming protocol used. + protocol: nil, + # Value for the requested transformation type. + value: nil + ) + end + + sig do + override.returns( + { + type: + Imagekit::UploadPostTransformSuccessEvent::Request::Transformation::Type::TaggedSymbol, + protocol: + Imagekit::UploadPostTransformSuccessEvent::Request::Transformation::Protocol::TaggedSymbol, + value: String + } + ) + end + def to_hash + end + + # Type of the requested post-transformation. + module Type + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekit::UploadPostTransformSuccessEvent::Request::Transformation::Type + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + TRANSFORMATION = + T.let( + :transformation, + Imagekit::UploadPostTransformSuccessEvent::Request::Transformation::Type::TaggedSymbol + ) + ABS = + T.let( + :abs, + Imagekit::UploadPostTransformSuccessEvent::Request::Transformation::Type::TaggedSymbol + ) + GIF_TO_VIDEO = + T.let( + :"gif-to-video", + Imagekit::UploadPostTransformSuccessEvent::Request::Transformation::Type::TaggedSymbol + ) + THUMBNAIL = + T.let( + :thumbnail, + Imagekit::UploadPostTransformSuccessEvent::Request::Transformation::Type::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekit::UploadPostTransformSuccessEvent::Request::Transformation::Type::TaggedSymbol + ] + ) + end + def self.values + end + end + + # Only applicable if transformation type is 'abs'. Streaming protocol used. + module Protocol + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekit::UploadPostTransformSuccessEvent::Request::Transformation::Protocol + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + HLS = + T.let( + :hls, + Imagekit::UploadPostTransformSuccessEvent::Request::Transformation::Protocol::TaggedSymbol + ) + DASH = + T.let( + :dash, + Imagekit::UploadPostTransformSuccessEvent::Request::Transformation::Protocol::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekit::UploadPostTransformSuccessEvent::Request::Transformation::Protocol::TaggedSymbol + ] + ) + end + def self.values + end + end + end + end + end + end +end diff --git a/rbi/imagekit/models/upload_pre_transform_error_event.rbi b/rbi/imagekit/models/upload_pre_transform_error_event.rbi new file mode 100644 index 00000000..d95f5534 --- /dev/null +++ b/rbi/imagekit/models/upload_pre_transform_error_event.rbi @@ -0,0 +1,240 @@ +# typed: strong + +module Imagekit + module Models + class UploadPreTransformErrorEvent < Imagekit::Models::BaseWebhookEvent + OrHash = + T.type_alias do + T.any( + Imagekit::UploadPreTransformErrorEvent, + Imagekit::Internal::AnyHash + ) + end + + # Timestamp of when the event occurred in ISO8601 format. + sig { returns(Time) } + attr_accessor :created_at + + sig { returns(Imagekit::UploadPreTransformErrorEvent::Data) } + attr_reader :data + + sig do + params(data: Imagekit::UploadPreTransformErrorEvent::Data::OrHash).void + end + attr_writer :data + + sig { returns(Imagekit::UploadPreTransformErrorEvent::Request) } + attr_reader :request + + sig do + params( + request: Imagekit::UploadPreTransformErrorEvent::Request::OrHash + ).void + end + attr_writer :request + + sig { returns(Symbol) } + attr_accessor :type + + # Triggered when a pre-transformation fails. The file upload may have been + # accepted, but the requested transformation could not be applied. + sig do + params( + created_at: Time, + data: Imagekit::UploadPreTransformErrorEvent::Data::OrHash, + request: Imagekit::UploadPreTransformErrorEvent::Request::OrHash, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Timestamp of when the event occurred in ISO8601 format. + created_at:, + data:, + request:, + type: :"upload.pre-transform.error" + ) + end + + sig do + override.returns( + { + created_at: Time, + data: Imagekit::UploadPreTransformErrorEvent::Data, + request: Imagekit::UploadPreTransformErrorEvent::Request, + type: Symbol + } + ) + end + def to_hash + end + + class Data < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::UploadPreTransformErrorEvent::Data, + Imagekit::Internal::AnyHash + ) + end + + # Name of the file. + sig { returns(String) } + attr_accessor :name + + # Path of the file. + sig { returns(String) } + attr_accessor :path + + sig do + returns(Imagekit::UploadPreTransformErrorEvent::Data::Transformation) + end + attr_reader :transformation + + sig do + params( + transformation: + Imagekit::UploadPreTransformErrorEvent::Data::Transformation::OrHash + ).void + end + attr_writer :transformation + + sig do + params( + name: String, + path: String, + transformation: + Imagekit::UploadPreTransformErrorEvent::Data::Transformation::OrHash + ).returns(T.attached_class) + end + def self.new( + # Name of the file. + name:, + # Path of the file. + path:, + transformation: + ) + end + + sig do + override.returns( + { + name: String, + path: String, + transformation: + Imagekit::UploadPreTransformErrorEvent::Data::Transformation + } + ) + end + def to_hash + end + + class Transformation < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::UploadPreTransformErrorEvent::Data::Transformation, + Imagekit::Internal::AnyHash + ) + end + + sig do + returns( + Imagekit::UploadPreTransformErrorEvent::Data::Transformation::Error + ) + end + attr_reader :error + + sig do + params( + error: + Imagekit::UploadPreTransformErrorEvent::Data::Transformation::Error::OrHash + ).void + end + attr_writer :error + + sig do + params( + error: + Imagekit::UploadPreTransformErrorEvent::Data::Transformation::Error::OrHash + ).returns(T.attached_class) + end + def self.new(error:) + end + + sig do + override.returns( + { + error: + Imagekit::UploadPreTransformErrorEvent::Data::Transformation::Error + } + ) + end + def to_hash + end + + class Error < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::UploadPreTransformErrorEvent::Data::Transformation::Error, + Imagekit::Internal::AnyHash + ) + end + + # Reason for the pre-transformation failure. + sig { returns(String) } + attr_accessor :reason + + sig { params(reason: String).returns(T.attached_class) } + def self.new( + # Reason for the pre-transformation failure. + reason: + ) + end + + sig { override.returns({ reason: String }) } + def to_hash + end + end + end + end + + class Request < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::UploadPreTransformErrorEvent::Request, + Imagekit::Internal::AnyHash + ) + end + + # The requested pre-transformation string. + sig { returns(String) } + attr_accessor :transformation + + # Unique identifier for the originating request. + sig { returns(String) } + attr_accessor :x_request_id + + sig do + params(transformation: String, x_request_id: String).returns( + T.attached_class + ) + end + def self.new( + # The requested pre-transformation string. + transformation:, + # Unique identifier for the originating request. + x_request_id: + ) + end + + sig do + override.returns({ transformation: String, x_request_id: String }) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekit/models/upload_pre_transform_success_event.rbi b/rbi/imagekit/models/upload_pre_transform_success_event.rbi new file mode 100644 index 00000000..b5d15c02 --- /dev/null +++ b/rbi/imagekit/models/upload_pre_transform_success_event.rbi @@ -0,0 +1,869 @@ +# typed: strong + +module Imagekit + module Models + class UploadPreTransformSuccessEvent < Imagekit::Models::BaseWebhookEvent + OrHash = + T.type_alias do + T.any( + Imagekit::UploadPreTransformSuccessEvent, + Imagekit::Internal::AnyHash + ) + end + + # Timestamp of when the event occurred in ISO8601 format. + sig { returns(Time) } + attr_accessor :created_at + + # Object containing details of a successful upload. + sig { returns(Imagekit::UploadPreTransformSuccessEvent::Data) } + attr_reader :data + + sig do + params( + data: Imagekit::UploadPreTransformSuccessEvent::Data::OrHash + ).void + end + attr_writer :data + + sig { returns(Imagekit::UploadPreTransformSuccessEvent::Request) } + attr_reader :request + + sig do + params( + request: Imagekit::UploadPreTransformSuccessEvent::Request::OrHash + ).void + end + attr_writer :request + + sig { returns(Symbol) } + attr_accessor :type + + # Triggered when a pre-transformation completes successfully. The file has been + # processed with the requested transformation and is now available in the Media + # Library. + sig do + params( + created_at: Time, + data: Imagekit::UploadPreTransformSuccessEvent::Data::OrHash, + request: Imagekit::UploadPreTransformSuccessEvent::Request::OrHash, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Timestamp of when the event occurred in ISO8601 format. + created_at:, + # Object containing details of a successful upload. + data:, + request:, + type: :"upload.pre-transform.success" + ) + end + + sig do + override.returns( + { + created_at: Time, + data: Imagekit::UploadPreTransformSuccessEvent::Data, + request: Imagekit::UploadPreTransformSuccessEvent::Request, + type: Symbol + } + ) + end + def to_hash + end + + class Data < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::UploadPreTransformSuccessEvent::Data, + Imagekit::Internal::AnyHash + ) + end + + # An array of tags assigned to the uploaded file by auto tagging. + sig do + returns( + T.nilable( + T::Array[Imagekit::UploadPreTransformSuccessEvent::Data::AITag] + ) + ) + end + attr_accessor :ai_tags + + # The audio codec used in the video (only for video). + sig { returns(T.nilable(String)) } + attr_reader :audio_codec + + sig { params(audio_codec: String).void } + attr_writer :audio_codec + + # The bit rate of the video in kbps (only for video). + sig { returns(T.nilable(Integer)) } + attr_reader :bit_rate + + sig { params(bit_rate: Integer).void } + attr_writer :bit_rate + + # Value of custom coordinates associated with the image in the format + # `x,y,width,height`. If `customCoordinates` are not defined, then it is `null`. + # Send `customCoordinates` in `responseFields` in API request to get the value of + # this field. + sig { returns(T.nilable(String)) } + attr_accessor :custom_coordinates + + # A key-value data associated with the asset. Use `responseField` in API request + # to get `customMetadata` in the upload API response. Before setting any custom + # metadata on an asset, you have to create the field using custom metadata fields + # API. Send `customMetadata` in `responseFields` in API request to get the value + # of this field. + sig { returns(T.nilable(T::Hash[Symbol, T.anything])) } + attr_reader :custom_metadata + + sig { params(custom_metadata: T::Hash[Symbol, T.anything]).void } + attr_writer :custom_metadata + + # Optional text to describe the contents of the file. Can be set by the user or + # the ai-auto-description extension. + sig { returns(T.nilable(String)) } + attr_reader :description + + sig { params(description: String).void } + attr_writer :description + + # The duration of the video in seconds (only for video). + sig { returns(T.nilable(Integer)) } + attr_reader :duration + + sig { params(duration: Integer).void } + attr_writer :duration + + # Consolidated embedded metadata associated with the file. It includes exif, iptc, + # and xmp data. Send `embeddedMetadata` in `responseFields` in API request to get + # embeddedMetadata in the upload API response. + sig { returns(T.nilable(T::Hash[Symbol, T.anything])) } + attr_reader :embedded_metadata + + sig { params(embedded_metadata: T::Hash[Symbol, T.anything]).void } + attr_writer :embedded_metadata + + # Extension names with their processing status at the time of completion of the + # request. It could have one of the following status values: + # + # `success`: The extension has been successfully applied. `failed`: The extension + # has failed and will not be retried. `pending`: The extension will finish + # processing in some time. On completion, the final status (success / failed) will + # be sent to the `webhookUrl` provided. + # + # If no extension was requested, then this parameter is not returned. + sig do + returns( + T.nilable( + Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus + ) + ) + end + attr_reader :extension_status + + sig do + params( + extension_status: + Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus::OrHash + ).void + end + attr_writer :extension_status + + # Unique fileId. Store this fileld in your database, as this will be used to + # perform update action on this file. + sig { returns(T.nilable(String)) } + attr_reader :file_id + + sig { params(file_id: String).void } + attr_writer :file_id + + # The relative path of the file in the media library e.g. + # `/marketing-assets/new-banner.jpg`. + sig { returns(T.nilable(String)) } + attr_reader :file_path + + sig { params(file_path: String).void } + attr_writer :file_path + + # Type of the uploaded file. Possible values are `image`, `non-image`. + sig { returns(T.nilable(String)) } + attr_reader :file_type + + sig { params(file_type: String).void } + attr_writer :file_type + + # Height of the image in pixels (Only for images) + sig { returns(T.nilable(Float)) } + attr_reader :height + + sig { params(height: Float).void } + attr_writer :height + + # Is the file marked as private. It can be either `true` or `false`. Send + # `isPrivateFile` in `responseFields` in API request to get the value of this + # field. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :is_private_file + + sig { params(is_private_file: T::Boolean).void } + attr_writer :is_private_file + + # Is the file published or in draft state. It can be either `true` or `false`. + # Send `isPublished` in `responseFields` in API request to get the value of this + # field. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :is_published + + sig { params(is_published: T::Boolean).void } + attr_writer :is_published + + # Legacy metadata. Send `metadata` in `responseFields` in API request to get + # metadata in the upload API response. + sig { returns(T.nilable(Imagekit::Metadata)) } + attr_reader :metadata + + sig { params(metadata: Imagekit::Metadata::OrHash).void } + attr_writer :metadata + + # Name of the asset. + sig { returns(T.nilable(String)) } + attr_reader :name + + sig { params(name: String).void } + attr_writer :name + + # Size of the image file in Bytes. + sig { returns(T.nilable(Float)) } + attr_reader :size + + sig { params(size: Float).void } + attr_writer :size + + # The array of tags associated with the asset. If no tags are set, it will be + # `null`. Send `tags` in `responseFields` in API request to get the value of this + # field. + sig { returns(T.nilable(T::Array[String])) } + attr_accessor :tags + + # In the case of an image, a small thumbnail URL. + sig { returns(T.nilable(String)) } + attr_reader :thumbnail_url + + sig { params(thumbnail_url: String).void } + attr_writer :thumbnail_url + + # A publicly accessible URL of the file. + sig { returns(T.nilable(String)) } + attr_reader :url + + sig { params(url: String).void } + attr_writer :url + + # An object containing the file or file version's `id` (versionId) and `name`. + sig do + returns( + T.nilable( + Imagekit::UploadPreTransformSuccessEvent::Data::VersionInfo + ) + ) + end + attr_reader :version_info + + sig do + params( + version_info: + Imagekit::UploadPreTransformSuccessEvent::Data::VersionInfo::OrHash + ).void + end + attr_writer :version_info + + # The video codec used in the video (only for video). + sig { returns(T.nilable(String)) } + attr_reader :video_codec + + sig { params(video_codec: String).void } + attr_writer :video_codec + + # Width of the image in pixels (Only for Images) + sig { returns(T.nilable(Float)) } + attr_reader :width + + sig { params(width: Float).void } + attr_writer :width + + # Object containing details of a successful upload. + sig do + params( + ai_tags: + T.nilable( + T::Array[ + Imagekit::UploadPreTransformSuccessEvent::Data::AITag::OrHash + ] + ), + audio_codec: String, + bit_rate: Integer, + custom_coordinates: T.nilable(String), + custom_metadata: T::Hash[Symbol, T.anything], + description: String, + duration: Integer, + embedded_metadata: T::Hash[Symbol, T.anything], + extension_status: + Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus::OrHash, + file_id: String, + file_path: String, + file_type: String, + height: Float, + is_private_file: T::Boolean, + is_published: T::Boolean, + metadata: Imagekit::Metadata::OrHash, + name: String, + size: Float, + tags: T.nilable(T::Array[String]), + thumbnail_url: String, + url: String, + version_info: + Imagekit::UploadPreTransformSuccessEvent::Data::VersionInfo::OrHash, + video_codec: String, + width: Float + ).returns(T.attached_class) + end + def self.new( + # An array of tags assigned to the uploaded file by auto tagging. + ai_tags: nil, + # The audio codec used in the video (only for video). + audio_codec: nil, + # The bit rate of the video in kbps (only for video). + bit_rate: nil, + # Value of custom coordinates associated with the image in the format + # `x,y,width,height`. If `customCoordinates` are not defined, then it is `null`. + # Send `customCoordinates` in `responseFields` in API request to get the value of + # this field. + custom_coordinates: nil, + # A key-value data associated with the asset. Use `responseField` in API request + # to get `customMetadata` in the upload API response. Before setting any custom + # metadata on an asset, you have to create the field using custom metadata fields + # API. Send `customMetadata` in `responseFields` in API request to get the value + # of this field. + custom_metadata: nil, + # Optional text to describe the contents of the file. Can be set by the user or + # the ai-auto-description extension. + description: nil, + # The duration of the video in seconds (only for video). + duration: nil, + # Consolidated embedded metadata associated with the file. It includes exif, iptc, + # and xmp data. Send `embeddedMetadata` in `responseFields` in API request to get + # embeddedMetadata in the upload API response. + embedded_metadata: nil, + # Extension names with their processing status at the time of completion of the + # request. It could have one of the following status values: + # + # `success`: The extension has been successfully applied. `failed`: The extension + # has failed and will not be retried. `pending`: The extension will finish + # processing in some time. On completion, the final status (success / failed) will + # be sent to the `webhookUrl` provided. + # + # If no extension was requested, then this parameter is not returned. + extension_status: nil, + # Unique fileId. Store this fileld in your database, as this will be used to + # perform update action on this file. + file_id: nil, + # The relative path of the file in the media library e.g. + # `/marketing-assets/new-banner.jpg`. + file_path: nil, + # Type of the uploaded file. Possible values are `image`, `non-image`. + file_type: nil, + # Height of the image in pixels (Only for images) + height: nil, + # Is the file marked as private. It can be either `true` or `false`. Send + # `isPrivateFile` in `responseFields` in API request to get the value of this + # field. + is_private_file: nil, + # Is the file published or in draft state. It can be either `true` or `false`. + # Send `isPublished` in `responseFields` in API request to get the value of this + # field. + is_published: nil, + # Legacy metadata. Send `metadata` in `responseFields` in API request to get + # metadata in the upload API response. + metadata: nil, + # Name of the asset. + name: nil, + # Size of the image file in Bytes. + size: nil, + # The array of tags associated with the asset. If no tags are set, it will be + # `null`. Send `tags` in `responseFields` in API request to get the value of this + # field. + tags: nil, + # In the case of an image, a small thumbnail URL. + thumbnail_url: nil, + # A publicly accessible URL of the file. + url: nil, + # An object containing the file or file version's `id` (versionId) and `name`. + version_info: nil, + # The video codec used in the video (only for video). + video_codec: nil, + # Width of the image in pixels (Only for Images) + width: nil + ) + end + + sig do + override.returns( + { + ai_tags: + T.nilable( + T::Array[ + Imagekit::UploadPreTransformSuccessEvent::Data::AITag + ] + ), + audio_codec: String, + bit_rate: Integer, + custom_coordinates: T.nilable(String), + custom_metadata: T::Hash[Symbol, T.anything], + description: String, + duration: Integer, + embedded_metadata: T::Hash[Symbol, T.anything], + extension_status: + Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus, + file_id: String, + file_path: String, + file_type: String, + height: Float, + is_private_file: T::Boolean, + is_published: T::Boolean, + metadata: Imagekit::Metadata, + name: String, + size: Float, + tags: T.nilable(T::Array[String]), + thumbnail_url: String, + url: String, + version_info: + Imagekit::UploadPreTransformSuccessEvent::Data::VersionInfo, + video_codec: String, + width: Float + } + ) + end + def to_hash + end + + class AITag < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::UploadPreTransformSuccessEvent::Data::AITag, + Imagekit::Internal::AnyHash + ) + end + + # Confidence score of the tag. + sig { returns(T.nilable(Float)) } + attr_reader :confidence + + sig { params(confidence: Float).void } + attr_writer :confidence + + # Name of the tag. + sig { returns(T.nilable(String)) } + attr_reader :name + + sig { params(name: String).void } + attr_writer :name + + # Array of `AITags` associated with the image. If no `AITags` are set, it will be + # null. These tags can be added using the `google-auto-tagging` or + # `aws-auto-tagging` extensions. + sig { returns(T.nilable(String)) } + attr_reader :source + + sig { params(source: String).void } + attr_writer :source + + sig do + params(confidence: Float, name: String, source: String).returns( + T.attached_class + ) + end + def self.new( + # Confidence score of the tag. + confidence: nil, + # Name of the tag. + name: nil, + # Array of `AITags` associated with the image. If no `AITags` are set, it will be + # null. These tags can be added using the `google-auto-tagging` or + # `aws-auto-tagging` extensions. + source: nil + ) + end + + sig do + override.returns( + { confidence: Float, name: String, source: String } + ) + end + def to_hash + end + end + + class ExtensionStatus < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus, + Imagekit::Internal::AnyHash + ) + end + + sig do + returns( + T.nilable( + Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus::AIAutoDescription::TaggedSymbol + ) + ) + end + attr_reader :ai_auto_description + + sig do + params( + ai_auto_description: + Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus::AIAutoDescription::OrSymbol + ).void + end + attr_writer :ai_auto_description + + sig do + returns( + T.nilable( + Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus::AwsAutoTagging::TaggedSymbol + ) + ) + end + attr_reader :aws_auto_tagging + + sig do + params( + aws_auto_tagging: + Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus::AwsAutoTagging::OrSymbol + ).void + end + attr_writer :aws_auto_tagging + + sig do + returns( + T.nilable( + Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus::GoogleAutoTagging::TaggedSymbol + ) + ) + end + attr_reader :google_auto_tagging + + sig do + params( + google_auto_tagging: + Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus::GoogleAutoTagging::OrSymbol + ).void + end + attr_writer :google_auto_tagging + + sig do + returns( + T.nilable( + Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus::RemoveBg::TaggedSymbol + ) + ) + end + attr_reader :remove_bg + + sig do + params( + remove_bg: + Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus::RemoveBg::OrSymbol + ).void + end + attr_writer :remove_bg + + # Extension names with their processing status at the time of completion of the + # request. It could have one of the following status values: + # + # `success`: The extension has been successfully applied. `failed`: The extension + # has failed and will not be retried. `pending`: The extension will finish + # processing in some time. On completion, the final status (success / failed) will + # be sent to the `webhookUrl` provided. + # + # If no extension was requested, then this parameter is not returned. + sig do + params( + ai_auto_description: + Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus::AIAutoDescription::OrSymbol, + aws_auto_tagging: + Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus::AwsAutoTagging::OrSymbol, + google_auto_tagging: + Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus::GoogleAutoTagging::OrSymbol, + remove_bg: + Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus::RemoveBg::OrSymbol + ).returns(T.attached_class) + end + def self.new( + ai_auto_description: nil, + aws_auto_tagging: nil, + google_auto_tagging: nil, + remove_bg: nil + ) + end + + sig do + override.returns( + { + ai_auto_description: + Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus::AIAutoDescription::TaggedSymbol, + aws_auto_tagging: + Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus::AwsAutoTagging::TaggedSymbol, + google_auto_tagging: + Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus::GoogleAutoTagging::TaggedSymbol, + remove_bg: + Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus::RemoveBg::TaggedSymbol + } + ) + end + def to_hash + end + + module AIAutoDescription + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus::AIAutoDescription + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + SUCCESS = + T.let( + :success, + Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus::AIAutoDescription::TaggedSymbol + ) + PENDING = + T.let( + :pending, + Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus::AIAutoDescription::TaggedSymbol + ) + FAILED = + T.let( + :failed, + Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus::AIAutoDescription::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus::AIAutoDescription::TaggedSymbol + ] + ) + end + def self.values + end + end + + module AwsAutoTagging + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus::AwsAutoTagging + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + SUCCESS = + T.let( + :success, + Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus::AwsAutoTagging::TaggedSymbol + ) + PENDING = + T.let( + :pending, + Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus::AwsAutoTagging::TaggedSymbol + ) + FAILED = + T.let( + :failed, + Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus::AwsAutoTagging::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus::AwsAutoTagging::TaggedSymbol + ] + ) + end + def self.values + end + end + + module GoogleAutoTagging + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus::GoogleAutoTagging + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + SUCCESS = + T.let( + :success, + Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus::GoogleAutoTagging::TaggedSymbol + ) + PENDING = + T.let( + :pending, + Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus::GoogleAutoTagging::TaggedSymbol + ) + FAILED = + T.let( + :failed, + Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus::GoogleAutoTagging::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus::GoogleAutoTagging::TaggedSymbol + ] + ) + end + def self.values + end + end + + module RemoveBg + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus::RemoveBg + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + SUCCESS = + T.let( + :success, + Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus::RemoveBg::TaggedSymbol + ) + PENDING = + T.let( + :pending, + Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus::RemoveBg::TaggedSymbol + ) + FAILED = + T.let( + :failed, + Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus::RemoveBg::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus::RemoveBg::TaggedSymbol + ] + ) + end + def self.values + end + end + end + + class VersionInfo < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::UploadPreTransformSuccessEvent::Data::VersionInfo, + Imagekit::Internal::AnyHash + ) + end + + # Unique identifier of the file version. + sig { returns(T.nilable(String)) } + attr_reader :id + + sig { params(id: String).void } + attr_writer :id + + # Name of the file version. + sig { returns(T.nilable(String)) } + attr_reader :name + + sig { params(name: String).void } + attr_writer :name + + # An object containing the file or file version's `id` (versionId) and `name`. + sig { params(id: String, name: String).returns(T.attached_class) } + def self.new( + # Unique identifier of the file version. + id: nil, + # Name of the file version. + name: nil + ) + end + + sig { override.returns({ id: String, name: String }) } + def to_hash + end + end + end + + class Request < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::UploadPreTransformSuccessEvent::Request, + Imagekit::Internal::AnyHash + ) + end + + # The requested pre-transformation string. + sig { returns(String) } + attr_accessor :transformation + + # Unique identifier for the originating request. + sig { returns(String) } + attr_accessor :x_request_id + + sig do + params(transformation: String, x_request_id: String).returns( + T.attached_class + ) + end + def self.new( + # The requested pre-transformation string. + transformation:, + # Unique identifier for the originating request. + x_request_id: + ) + end + + sig do + override.returns({ transformation: String, x_request_id: String }) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekit/models/video_overlay.rbi b/rbi/imagekit/models/video_overlay.rbi new file mode 100644 index 00000000..84c9aaed --- /dev/null +++ b/rbi/imagekit/models/video_overlay.rbi @@ -0,0 +1,102 @@ +# typed: strong + +module Imagekit + module Models + class VideoOverlay < Imagekit::Models::BaseOverlay + OrHash = + T.type_alias do + T.any(Imagekit::VideoOverlay, Imagekit::Internal::AnyHash) + end + + # Specifies the relative path to the video used as an overlay. + sig { returns(String) } + attr_accessor :input + + sig { returns(Symbol) } + attr_accessor :type + + # The input path can be included in the layer as either `i-{input}` or + # `ie-{base64_encoded_input}`. By default, the SDK determines the appropriate + # format automatically. To always use base64 encoding (`ie-{base64}`), set this + # parameter to `base64`. To always use plain text (`i-{input}`), set it to + # `plain`. + sig { returns(T.nilable(Imagekit::VideoOverlay::Encoding::OrSymbol)) } + attr_reader :encoding + + sig { params(encoding: Imagekit::VideoOverlay::Encoding::OrSymbol).void } + attr_writer :encoding + + # Array of transformation to be applied to the overlay video. Except + # `streamingResolutions`, all other video transformations are supported. See + # [Video transformations](https://imagekit.io/docs/video-transformation). + sig { returns(T.nilable(T::Array[Imagekit::Transformation])) } + attr_reader :transformation + + sig { params(transformation: T::Array[Imagekit::Transformation]).void } + attr_writer :transformation + + sig do + params( + input: String, + encoding: Imagekit::VideoOverlay::Encoding::OrSymbol, + transformation: T::Array[Imagekit::Transformation], + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Specifies the relative path to the video used as an overlay. + input:, + # The input path can be included in the layer as either `i-{input}` or + # `ie-{base64_encoded_input}`. By default, the SDK determines the appropriate + # format automatically. To always use base64 encoding (`ie-{base64}`), set this + # parameter to `base64`. To always use plain text (`i-{input}`), set it to + # `plain`. + encoding: nil, + # Array of transformation to be applied to the overlay video. Except + # `streamingResolutions`, all other video transformations are supported. See + # [Video transformations](https://imagekit.io/docs/video-transformation). + transformation: nil, + type: :video + ) + end + + sig do + override.returns( + { + input: String, + type: Symbol, + encoding: Imagekit::VideoOverlay::Encoding::OrSymbol, + transformation: T::Array[Imagekit::Transformation] + } + ) + end + def to_hash + end + + # The input path can be included in the layer as either `i-{input}` or + # `ie-{base64_encoded_input}`. By default, the SDK determines the appropriate + # format automatically. To always use base64 encoding (`ie-{base64}`), set this + # parameter to `base64`. To always use plain text (`i-{input}`), set it to + # `plain`. + module Encoding + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, Imagekit::VideoOverlay::Encoding) } + OrSymbol = T.type_alias { T.any(Symbol, String) } + + AUTO = T.let(:auto, Imagekit::VideoOverlay::Encoding::TaggedSymbol) + PLAIN = T.let(:plain, Imagekit::VideoOverlay::Encoding::TaggedSymbol) + BASE64 = T.let(:base64, Imagekit::VideoOverlay::Encoding::TaggedSymbol) + + sig do + override.returns( + T::Array[Imagekit::VideoOverlay::Encoding::TaggedSymbol] + ) + end + def self.values + end + end + end + end +end diff --git a/rbi/imagekit/models/video_transformation_accepted_event.rbi b/rbi/imagekit/models/video_transformation_accepted_event.rbi new file mode 100644 index 00000000..b6bb2056 --- /dev/null +++ b/rbi/imagekit/models/video_transformation_accepted_event.rbi @@ -0,0 +1,656 @@ +# typed: strong + +module Imagekit + module Models + class VideoTransformationAcceptedEvent < Imagekit::Models::BaseWebhookEvent + OrHash = + T.type_alias do + T.any( + Imagekit::VideoTransformationAcceptedEvent, + Imagekit::Internal::AnyHash + ) + end + + # Timestamp when the event was created in ISO8601 format. + sig { returns(Time) } + attr_accessor :created_at + + sig { returns(Imagekit::VideoTransformationAcceptedEvent::Data) } + attr_reader :data + + sig do + params( + data: Imagekit::VideoTransformationAcceptedEvent::Data::OrHash + ).void + end + attr_writer :data + + # Information about the original request that triggered the video transformation. + sig { returns(Imagekit::VideoTransformationAcceptedEvent::Request) } + attr_reader :request + + sig do + params( + request: Imagekit::VideoTransformationAcceptedEvent::Request::OrHash + ).void + end + attr_writer :request + + sig { returns(Symbol) } + attr_accessor :type + + # Triggered when a new video transformation request is accepted for processing. + # This event confirms that ImageKit has received and queued your transformation + # request. Use this for debugging and tracking transformation lifecycle. + sig do + params( + created_at: Time, + data: Imagekit::VideoTransformationAcceptedEvent::Data::OrHash, + request: Imagekit::VideoTransformationAcceptedEvent::Request::OrHash, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Timestamp when the event was created in ISO8601 format. + created_at:, + data:, + # Information about the original request that triggered the video transformation. + request:, + type: :"video.transformation.accepted" + ) + end + + sig do + override.returns( + { + created_at: Time, + data: Imagekit::VideoTransformationAcceptedEvent::Data, + request: Imagekit::VideoTransformationAcceptedEvent::Request, + type: Symbol + } + ) + end + def to_hash + end + + class Data < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::VideoTransformationAcceptedEvent::Data, + Imagekit::Internal::AnyHash + ) + end + + # Information about the source video asset being transformed. + sig { returns(Imagekit::VideoTransformationAcceptedEvent::Data::Asset) } + attr_reader :asset + + sig do + params( + asset: + Imagekit::VideoTransformationAcceptedEvent::Data::Asset::OrHash + ).void + end + attr_writer :asset + + # Base information about a video transformation request. + sig do + returns( + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation + ) + end + attr_reader :transformation + + sig do + params( + transformation: + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::OrHash + ).void + end + attr_writer :transformation + + sig do + params( + asset: + Imagekit::VideoTransformationAcceptedEvent::Data::Asset::OrHash, + transformation: + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::OrHash + ).returns(T.attached_class) + end + def self.new( + # Information about the source video asset being transformed. + asset:, + # Base information about a video transformation request. + transformation: + ) + end + + sig do + override.returns( + { + asset: Imagekit::VideoTransformationAcceptedEvent::Data::Asset, + transformation: + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation + } + ) + end + def to_hash + end + + class Asset < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::VideoTransformationAcceptedEvent::Data::Asset, + Imagekit::Internal::AnyHash + ) + end + + # URL to download or access the source video file. + sig { returns(String) } + attr_accessor :url + + # Information about the source video asset being transformed. + sig { params(url: String).returns(T.attached_class) } + def self.new( + # URL to download or access the source video file. + url: + ) + end + + sig { override.returns({ url: String }) } + def to_hash + end + end + + class Transformation < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation, + Imagekit::Internal::AnyHash + ) + end + + # Type of video transformation: + # + # - `video-transformation`: Standard video processing (resize, format conversion, + # etc.) + # - `gif-to-video`: Convert animated GIF to video format + # - `video-thumbnail`: Generate thumbnail image from video + sig do + returns( + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Type::TaggedSymbol + ) + end + attr_accessor :type + + # Configuration options for video transformations. + sig do + returns( + T.nilable( + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options + ) + ) + end + attr_reader :options + + sig do + params( + options: + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options::OrHash + ).void + end + attr_writer :options + + # Base information about a video transformation request. + sig do + params( + type: + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Type::OrSymbol, + options: + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options::OrHash + ).returns(T.attached_class) + end + def self.new( + # Type of video transformation: + # + # - `video-transformation`: Standard video processing (resize, format conversion, + # etc.) + # - `gif-to-video`: Convert animated GIF to video format + # - `video-thumbnail`: Generate thumbnail image from video + type:, + # Configuration options for video transformations. + options: nil + ) + end + + sig do + override.returns( + { + type: + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Type::TaggedSymbol, + options: + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options + } + ) + end + def to_hash + end + + # Type of video transformation: + # + # - `video-transformation`: Standard video processing (resize, format conversion, + # etc.) + # - `gif-to-video`: Convert animated GIF to video format + # - `video-thumbnail`: Generate thumbnail image from video + module Type + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Type + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + VIDEO_TRANSFORMATION = + T.let( + :"video-transformation", + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Type::TaggedSymbol + ) + GIF_TO_VIDEO = + T.let( + :"gif-to-video", + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Type::TaggedSymbol + ) + VIDEO_THUMBNAIL = + T.let( + :"video-thumbnail", + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Type::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Type::TaggedSymbol + ] + ) + end + def self.values + end + end + + class Options < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options, + Imagekit::Internal::AnyHash + ) + end + + # Audio codec used for encoding (aac or opus). + sig do + returns( + T.nilable( + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options::AudioCodec::TaggedSymbol + ) + ) + end + attr_reader :audio_codec + + sig do + params( + audio_codec: + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options::AudioCodec::OrSymbol + ).void + end + attr_writer :audio_codec + + # Whether to automatically rotate the video based on metadata. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :auto_rotate + + sig { params(auto_rotate: T::Boolean).void } + attr_writer :auto_rotate + + # Output format for the transformed video or thumbnail. + sig do + returns( + T.nilable( + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options::Format::TaggedSymbol + ) + ) + end + attr_reader :format_ + + sig do + params( + format_: + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options::Format::OrSymbol + ).void + end + attr_writer :format_ + + # Quality setting for the output video. + sig { returns(T.nilable(Integer)) } + attr_reader :quality + + sig { params(quality: Integer).void } + attr_writer :quality + + # Streaming protocol for adaptive bitrate streaming. + sig do + returns( + T.nilable( + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options::StreamProtocol::TaggedSymbol + ) + ) + end + attr_reader :stream_protocol + + sig do + params( + stream_protocol: + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options::StreamProtocol::OrSymbol + ).void + end + attr_writer :stream_protocol + + # Array of quality representations for adaptive bitrate streaming. + sig { returns(T.nilable(T::Array[String])) } + attr_reader :variants + + sig { params(variants: T::Array[String]).void } + attr_writer :variants + + # Video codec used for encoding (h264, vp9, or av1). + sig do + returns( + T.nilable( + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options::VideoCodec::TaggedSymbol + ) + ) + end + attr_reader :video_codec + + sig do + params( + video_codec: + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options::VideoCodec::OrSymbol + ).void + end + attr_writer :video_codec + + # Configuration options for video transformations. + sig do + params( + audio_codec: + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options::AudioCodec::OrSymbol, + auto_rotate: T::Boolean, + format_: + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options::Format::OrSymbol, + quality: Integer, + stream_protocol: + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options::StreamProtocol::OrSymbol, + variants: T::Array[String], + video_codec: + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options::VideoCodec::OrSymbol + ).returns(T.attached_class) + end + def self.new( + # Audio codec used for encoding (aac or opus). + audio_codec: nil, + # Whether to automatically rotate the video based on metadata. + auto_rotate: nil, + # Output format for the transformed video or thumbnail. + format_: nil, + # Quality setting for the output video. + quality: nil, + # Streaming protocol for adaptive bitrate streaming. + stream_protocol: nil, + # Array of quality representations for adaptive bitrate streaming. + variants: nil, + # Video codec used for encoding (h264, vp9, or av1). + video_codec: nil + ) + end + + sig do + override.returns( + { + audio_codec: + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options::AudioCodec::TaggedSymbol, + auto_rotate: T::Boolean, + format_: + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options::Format::TaggedSymbol, + quality: Integer, + stream_protocol: + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options::StreamProtocol::TaggedSymbol, + variants: T::Array[String], + video_codec: + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options::VideoCodec::TaggedSymbol + } + ) + end + def to_hash + end + + # Audio codec used for encoding (aac or opus). + module AudioCodec + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options::AudioCodec + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + AAC = + T.let( + :aac, + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options::AudioCodec::TaggedSymbol + ) + OPUS = + T.let( + :opus, + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options::AudioCodec::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options::AudioCodec::TaggedSymbol + ] + ) + end + def self.values + end + end + + # Output format for the transformed video or thumbnail. + module Format + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options::Format + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + MP4 = + T.let( + :mp4, + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options::Format::TaggedSymbol + ) + WEBM = + T.let( + :webm, + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options::Format::TaggedSymbol + ) + JPG = + T.let( + :jpg, + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options::Format::TaggedSymbol + ) + PNG = + T.let( + :png, + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options::Format::TaggedSymbol + ) + WEBP = + T.let( + :webp, + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options::Format::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options::Format::TaggedSymbol + ] + ) + end + def self.values + end + end + + # Streaming protocol for adaptive bitrate streaming. + module StreamProtocol + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options::StreamProtocol + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + HLS = + T.let( + :HLS, + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options::StreamProtocol::TaggedSymbol + ) + DASH = + T.let( + :DASH, + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options::StreamProtocol::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options::StreamProtocol::TaggedSymbol + ] + ) + end + def self.values + end + end + + # Video codec used for encoding (h264, vp9, or av1). + module VideoCodec + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options::VideoCodec + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + H264 = + T.let( + :h264, + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options::VideoCodec::TaggedSymbol + ) + VP9 = + T.let( + :vp9, + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options::VideoCodec::TaggedSymbol + ) + AV1 = + T.let( + :av1, + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options::VideoCodec::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options::VideoCodec::TaggedSymbol + ] + ) + end + def self.values + end + end + end + end + end + + class Request < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::VideoTransformationAcceptedEvent::Request, + Imagekit::Internal::AnyHash + ) + end + + # Full URL of the transformation request that was submitted. + sig { returns(String) } + attr_accessor :url + + # Unique identifier for the originating transformation request. + sig { returns(String) } + attr_accessor :x_request_id + + # User-Agent header from the original request that triggered the transformation. + sig { returns(T.nilable(String)) } + attr_reader :user_agent + + sig { params(user_agent: String).void } + attr_writer :user_agent + + # Information about the original request that triggered the video transformation. + sig do + params(url: String, x_request_id: String, user_agent: String).returns( + T.attached_class + ) + end + def self.new( + # Full URL of the transformation request that was submitted. + url:, + # Unique identifier for the originating transformation request. + x_request_id:, + # User-Agent header from the original request that triggered the transformation. + user_agent: nil + ) + end + + sig do + override.returns( + { url: String, x_request_id: String, user_agent: String } + ) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekit/models/video_transformation_error_event.rbi b/rbi/imagekit/models/video_transformation_error_event.rbi new file mode 100644 index 00000000..3c9c19d2 --- /dev/null +++ b/rbi/imagekit/models/video_transformation_error_event.rbi @@ -0,0 +1,766 @@ +# typed: strong + +module Imagekit + module Models + class VideoTransformationErrorEvent < Imagekit::Models::BaseWebhookEvent + OrHash = + T.type_alias do + T.any( + Imagekit::VideoTransformationErrorEvent, + Imagekit::Internal::AnyHash + ) + end + + # Timestamp when the event was created in ISO8601 format. + sig { returns(Time) } + attr_accessor :created_at + + sig { returns(Imagekit::VideoTransformationErrorEvent::Data) } + attr_reader :data + + sig do + params(data: Imagekit::VideoTransformationErrorEvent::Data::OrHash).void + end + attr_writer :data + + # Information about the original request that triggered the video transformation. + sig { returns(Imagekit::VideoTransformationErrorEvent::Request) } + attr_reader :request + + sig do + params( + request: Imagekit::VideoTransformationErrorEvent::Request::OrHash + ).void + end + attr_writer :request + + sig { returns(Symbol) } + attr_accessor :type + + # Triggered when an error occurs during video encoding. Listen to this webhook to + # log error reasons and debug issues. Check your origin and URL endpoint settings + # if the reason is related to download failure. For other errors, contact ImageKit + # support. + sig do + params( + created_at: Time, + data: Imagekit::VideoTransformationErrorEvent::Data::OrHash, + request: Imagekit::VideoTransformationErrorEvent::Request::OrHash, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Timestamp when the event was created in ISO8601 format. + created_at:, + data:, + # Information about the original request that triggered the video transformation. + request:, + type: :"video.transformation.error" + ) + end + + sig do + override.returns( + { + created_at: Time, + data: Imagekit::VideoTransformationErrorEvent::Data, + request: Imagekit::VideoTransformationErrorEvent::Request, + type: Symbol + } + ) + end + def to_hash + end + + class Data < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::VideoTransformationErrorEvent::Data, + Imagekit::Internal::AnyHash + ) + end + + # Information about the source video asset being transformed. + sig { returns(Imagekit::VideoTransformationErrorEvent::Data::Asset) } + attr_reader :asset + + sig do + params( + asset: Imagekit::VideoTransformationErrorEvent::Data::Asset::OrHash + ).void + end + attr_writer :asset + + sig do + returns(Imagekit::VideoTransformationErrorEvent::Data::Transformation) + end + attr_reader :transformation + + sig do + params( + transformation: + Imagekit::VideoTransformationErrorEvent::Data::Transformation::OrHash + ).void + end + attr_writer :transformation + + sig do + params( + asset: Imagekit::VideoTransformationErrorEvent::Data::Asset::OrHash, + transformation: + Imagekit::VideoTransformationErrorEvent::Data::Transformation::OrHash + ).returns(T.attached_class) + end + def self.new( + # Information about the source video asset being transformed. + asset:, + transformation: + ) + end + + sig do + override.returns( + { + asset: Imagekit::VideoTransformationErrorEvent::Data::Asset, + transformation: + Imagekit::VideoTransformationErrorEvent::Data::Transformation + } + ) + end + def to_hash + end + + class Asset < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::VideoTransformationErrorEvent::Data::Asset, + Imagekit::Internal::AnyHash + ) + end + + # URL to download or access the source video file. + sig { returns(String) } + attr_accessor :url + + # Information about the source video asset being transformed. + sig { params(url: String).returns(T.attached_class) } + def self.new( + # URL to download or access the source video file. + url: + ) + end + + sig { override.returns({ url: String }) } + def to_hash + end + end + + class Transformation < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::VideoTransformationErrorEvent::Data::Transformation, + Imagekit::Internal::AnyHash + ) + end + + # Type of video transformation: + # + # - `video-transformation`: Standard video processing (resize, format conversion, + # etc.) + # - `gif-to-video`: Convert animated GIF to video format + # - `video-thumbnail`: Generate thumbnail image from video + sig do + returns( + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Type::TaggedSymbol + ) + end + attr_accessor :type + + # Details about the transformation error. + sig do + returns( + T.nilable( + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Error + ) + ) + end + attr_reader :error + + sig do + params( + error: + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Error::OrHash + ).void + end + attr_writer :error + + # Configuration options for video transformations. + sig do + returns( + T.nilable( + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options + ) + ) + end + attr_reader :options + + sig do + params( + options: + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options::OrHash + ).void + end + attr_writer :options + + sig do + params( + type: + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Type::OrSymbol, + error: + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Error::OrHash, + options: + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options::OrHash + ).returns(T.attached_class) + end + def self.new( + # Type of video transformation: + # + # - `video-transformation`: Standard video processing (resize, format conversion, + # etc.) + # - `gif-to-video`: Convert animated GIF to video format + # - `video-thumbnail`: Generate thumbnail image from video + type:, + # Details about the transformation error. + error: nil, + # Configuration options for video transformations. + options: nil + ) + end + + sig do + override.returns( + { + type: + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Type::TaggedSymbol, + error: + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Error, + options: + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options + } + ) + end + def to_hash + end + + # Type of video transformation: + # + # - `video-transformation`: Standard video processing (resize, format conversion, + # etc.) + # - `gif-to-video`: Convert animated GIF to video format + # - `video-thumbnail`: Generate thumbnail image from video + module Type + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Type + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + VIDEO_TRANSFORMATION = + T.let( + :"video-transformation", + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Type::TaggedSymbol + ) + GIF_TO_VIDEO = + T.let( + :"gif-to-video", + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Type::TaggedSymbol + ) + VIDEO_THUMBNAIL = + T.let( + :"video-thumbnail", + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Type::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Type::TaggedSymbol + ] + ) + end + def self.values + end + end + + class Error < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Error, + Imagekit::Internal::AnyHash + ) + end + + # Specific reason for the transformation failure: + # + # - `encoding_failed`: Error during video encoding process + # - `download_failed`: Could not download source video + # - `internal_server_error`: Unexpected server error + sig do + returns( + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Error::Reason::TaggedSymbol + ) + end + attr_accessor :reason + + # Details about the transformation error. + sig do + params( + reason: + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Error::Reason::OrSymbol + ).returns(T.attached_class) + end + def self.new( + # Specific reason for the transformation failure: + # + # - `encoding_failed`: Error during video encoding process + # - `download_failed`: Could not download source video + # - `internal_server_error`: Unexpected server error + reason: + ) + end + + sig do + override.returns( + { + reason: + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Error::Reason::TaggedSymbol + } + ) + end + def to_hash + end + + # Specific reason for the transformation failure: + # + # - `encoding_failed`: Error during video encoding process + # - `download_failed`: Could not download source video + # - `internal_server_error`: Unexpected server error + module Reason + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Error::Reason + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + ENCODING_FAILED = + T.let( + :encoding_failed, + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Error::Reason::TaggedSymbol + ) + DOWNLOAD_FAILED = + T.let( + :download_failed, + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Error::Reason::TaggedSymbol + ) + INTERNAL_SERVER_ERROR = + T.let( + :internal_server_error, + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Error::Reason::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Error::Reason::TaggedSymbol + ] + ) + end + def self.values + end + end + end + + class Options < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options, + Imagekit::Internal::AnyHash + ) + end + + # Audio codec used for encoding (aac or opus). + sig do + returns( + T.nilable( + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options::AudioCodec::TaggedSymbol + ) + ) + end + attr_reader :audio_codec + + sig do + params( + audio_codec: + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options::AudioCodec::OrSymbol + ).void + end + attr_writer :audio_codec + + # Whether to automatically rotate the video based on metadata. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :auto_rotate + + sig { params(auto_rotate: T::Boolean).void } + attr_writer :auto_rotate + + # Output format for the transformed video or thumbnail. + sig do + returns( + T.nilable( + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options::Format::TaggedSymbol + ) + ) + end + attr_reader :format_ + + sig do + params( + format_: + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options::Format::OrSymbol + ).void + end + attr_writer :format_ + + # Quality setting for the output video. + sig { returns(T.nilable(Integer)) } + attr_reader :quality + + sig { params(quality: Integer).void } + attr_writer :quality + + # Streaming protocol for adaptive bitrate streaming. + sig do + returns( + T.nilable( + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options::StreamProtocol::TaggedSymbol + ) + ) + end + attr_reader :stream_protocol + + sig do + params( + stream_protocol: + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options::StreamProtocol::OrSymbol + ).void + end + attr_writer :stream_protocol + + # Array of quality representations for adaptive bitrate streaming. + sig { returns(T.nilable(T::Array[String])) } + attr_reader :variants + + sig { params(variants: T::Array[String]).void } + attr_writer :variants + + # Video codec used for encoding (h264, vp9, or av1). + sig do + returns( + T.nilable( + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options::VideoCodec::TaggedSymbol + ) + ) + end + attr_reader :video_codec + + sig do + params( + video_codec: + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options::VideoCodec::OrSymbol + ).void + end + attr_writer :video_codec + + # Configuration options for video transformations. + sig do + params( + audio_codec: + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options::AudioCodec::OrSymbol, + auto_rotate: T::Boolean, + format_: + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options::Format::OrSymbol, + quality: Integer, + stream_protocol: + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options::StreamProtocol::OrSymbol, + variants: T::Array[String], + video_codec: + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options::VideoCodec::OrSymbol + ).returns(T.attached_class) + end + def self.new( + # Audio codec used for encoding (aac or opus). + audio_codec: nil, + # Whether to automatically rotate the video based on metadata. + auto_rotate: nil, + # Output format for the transformed video or thumbnail. + format_: nil, + # Quality setting for the output video. + quality: nil, + # Streaming protocol for adaptive bitrate streaming. + stream_protocol: nil, + # Array of quality representations for adaptive bitrate streaming. + variants: nil, + # Video codec used for encoding (h264, vp9, or av1). + video_codec: nil + ) + end + + sig do + override.returns( + { + audio_codec: + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options::AudioCodec::TaggedSymbol, + auto_rotate: T::Boolean, + format_: + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options::Format::TaggedSymbol, + quality: Integer, + stream_protocol: + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options::StreamProtocol::TaggedSymbol, + variants: T::Array[String], + video_codec: + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options::VideoCodec::TaggedSymbol + } + ) + end + def to_hash + end + + # Audio codec used for encoding (aac or opus). + module AudioCodec + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options::AudioCodec + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + AAC = + T.let( + :aac, + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options::AudioCodec::TaggedSymbol + ) + OPUS = + T.let( + :opus, + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options::AudioCodec::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options::AudioCodec::TaggedSymbol + ] + ) + end + def self.values + end + end + + # Output format for the transformed video or thumbnail. + module Format + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options::Format + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + MP4 = + T.let( + :mp4, + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options::Format::TaggedSymbol + ) + WEBM = + T.let( + :webm, + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options::Format::TaggedSymbol + ) + JPG = + T.let( + :jpg, + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options::Format::TaggedSymbol + ) + PNG = + T.let( + :png, + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options::Format::TaggedSymbol + ) + WEBP = + T.let( + :webp, + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options::Format::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options::Format::TaggedSymbol + ] + ) + end + def self.values + end + end + + # Streaming protocol for adaptive bitrate streaming. + module StreamProtocol + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options::StreamProtocol + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + HLS = + T.let( + :HLS, + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options::StreamProtocol::TaggedSymbol + ) + DASH = + T.let( + :DASH, + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options::StreamProtocol::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options::StreamProtocol::TaggedSymbol + ] + ) + end + def self.values + end + end + + # Video codec used for encoding (h264, vp9, or av1). + module VideoCodec + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options::VideoCodec + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + H264 = + T.let( + :h264, + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options::VideoCodec::TaggedSymbol + ) + VP9 = + T.let( + :vp9, + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options::VideoCodec::TaggedSymbol + ) + AV1 = + T.let( + :av1, + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options::VideoCodec::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options::VideoCodec::TaggedSymbol + ] + ) + end + def self.values + end + end + end + end + end + + class Request < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::VideoTransformationErrorEvent::Request, + Imagekit::Internal::AnyHash + ) + end + + # Full URL of the transformation request that was submitted. + sig { returns(String) } + attr_accessor :url + + # Unique identifier for the originating transformation request. + sig { returns(String) } + attr_accessor :x_request_id + + # User-Agent header from the original request that triggered the transformation. + sig { returns(T.nilable(String)) } + attr_reader :user_agent + + sig { params(user_agent: String).void } + attr_writer :user_agent + + # Information about the original request that triggered the video transformation. + sig do + params(url: String, x_request_id: String, user_agent: String).returns( + T.attached_class + ) + end + def self.new( + # Full URL of the transformation request that was submitted. + url:, + # Unique identifier for the originating transformation request. + x_request_id:, + # User-Agent header from the original request that triggered the transformation. + user_agent: nil + ) + end + + sig do + override.returns( + { url: String, x_request_id: String, user_agent: String } + ) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekit/models/video_transformation_ready_event.rbi b/rbi/imagekit/models/video_transformation_ready_event.rbi new file mode 100644 index 00000000..75a934d1 --- /dev/null +++ b/rbi/imagekit/models/video_transformation_ready_event.rbi @@ -0,0 +1,858 @@ +# typed: strong + +module Imagekit + module Models + class VideoTransformationReadyEvent < Imagekit::Models::BaseWebhookEvent + OrHash = + T.type_alias do + T.any( + Imagekit::VideoTransformationReadyEvent, + Imagekit::Internal::AnyHash + ) + end + + # Timestamp when the event was created in ISO8601 format. + sig { returns(Time) } + attr_accessor :created_at + + sig { returns(Imagekit::VideoTransformationReadyEvent::Data) } + attr_reader :data + + sig do + params(data: Imagekit::VideoTransformationReadyEvent::Data::OrHash).void + end + attr_writer :data + + # Information about the original request that triggered the video transformation. + sig { returns(Imagekit::VideoTransformationReadyEvent::Request) } + attr_reader :request + + sig do + params( + request: Imagekit::VideoTransformationReadyEvent::Request::OrHash + ).void + end + attr_writer :request + + sig { returns(Symbol) } + attr_accessor :type + + # Performance metrics for the transformation process. + sig do + returns(T.nilable(Imagekit::VideoTransformationReadyEvent::Timings)) + end + attr_reader :timings + + sig do + params( + timings: Imagekit::VideoTransformationReadyEvent::Timings::OrHash + ).void + end + attr_writer :timings + + # Triggered when video encoding is finished and the transformed resource is ready + # to be served. This is the key event to listen for - update your database or CMS + # flags when you receive this so your application can start showing the + # transformed video to users. + sig do + params( + created_at: Time, + data: Imagekit::VideoTransformationReadyEvent::Data::OrHash, + request: Imagekit::VideoTransformationReadyEvent::Request::OrHash, + timings: Imagekit::VideoTransformationReadyEvent::Timings::OrHash, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Timestamp when the event was created in ISO8601 format. + created_at:, + data:, + # Information about the original request that triggered the video transformation. + request:, + # Performance metrics for the transformation process. + timings: nil, + type: :"video.transformation.ready" + ) + end + + sig do + override.returns( + { + created_at: Time, + data: Imagekit::VideoTransformationReadyEvent::Data, + request: Imagekit::VideoTransformationReadyEvent::Request, + type: Symbol, + timings: Imagekit::VideoTransformationReadyEvent::Timings + } + ) + end + def to_hash + end + + class Data < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::VideoTransformationReadyEvent::Data, + Imagekit::Internal::AnyHash + ) + end + + # Information about the source video asset being transformed. + sig { returns(Imagekit::VideoTransformationReadyEvent::Data::Asset) } + attr_reader :asset + + sig do + params( + asset: Imagekit::VideoTransformationReadyEvent::Data::Asset::OrHash + ).void + end + attr_writer :asset + + sig do + returns(Imagekit::VideoTransformationReadyEvent::Data::Transformation) + end + attr_reader :transformation + + sig do + params( + transformation: + Imagekit::VideoTransformationReadyEvent::Data::Transformation::OrHash + ).void + end + attr_writer :transformation + + sig do + params( + asset: Imagekit::VideoTransformationReadyEvent::Data::Asset::OrHash, + transformation: + Imagekit::VideoTransformationReadyEvent::Data::Transformation::OrHash + ).returns(T.attached_class) + end + def self.new( + # Information about the source video asset being transformed. + asset:, + transformation: + ) + end + + sig do + override.returns( + { + asset: Imagekit::VideoTransformationReadyEvent::Data::Asset, + transformation: + Imagekit::VideoTransformationReadyEvent::Data::Transformation + } + ) + end + def to_hash + end + + class Asset < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::VideoTransformationReadyEvent::Data::Asset, + Imagekit::Internal::AnyHash + ) + end + + # URL to download or access the source video file. + sig { returns(String) } + attr_accessor :url + + # Information about the source video asset being transformed. + sig { params(url: String).returns(T.attached_class) } + def self.new( + # URL to download or access the source video file. + url: + ) + end + + sig { override.returns({ url: String }) } + def to_hash + end + end + + class Transformation < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::VideoTransformationReadyEvent::Data::Transformation, + Imagekit::Internal::AnyHash + ) + end + + # Type of video transformation: + # + # - `video-transformation`: Standard video processing (resize, format conversion, + # etc.) + # - `gif-to-video`: Convert animated GIF to video format + # - `video-thumbnail`: Generate thumbnail image from video + sig do + returns( + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Type::TaggedSymbol + ) + end + attr_accessor :type + + # Configuration options for video transformations. + sig do + returns( + T.nilable( + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options + ) + ) + end + attr_reader :options + + sig do + params( + options: + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options::OrHash + ).void + end + attr_writer :options + + # Information about the transformed output video. + sig do + returns( + T.nilable( + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Output + ) + ) + end + attr_reader :output + + sig do + params( + output: + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Output::OrHash + ).void + end + attr_writer :output + + sig do + params( + type: + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Type::OrSymbol, + options: + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options::OrHash, + output: + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Output::OrHash + ).returns(T.attached_class) + end + def self.new( + # Type of video transformation: + # + # - `video-transformation`: Standard video processing (resize, format conversion, + # etc.) + # - `gif-to-video`: Convert animated GIF to video format + # - `video-thumbnail`: Generate thumbnail image from video + type:, + # Configuration options for video transformations. + options: nil, + # Information about the transformed output video. + output: nil + ) + end + + sig do + override.returns( + { + type: + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Type::TaggedSymbol, + options: + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options, + output: + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Output + } + ) + end + def to_hash + end + + # Type of video transformation: + # + # - `video-transformation`: Standard video processing (resize, format conversion, + # etc.) + # - `gif-to-video`: Convert animated GIF to video format + # - `video-thumbnail`: Generate thumbnail image from video + module Type + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Type + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + VIDEO_TRANSFORMATION = + T.let( + :"video-transformation", + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Type::TaggedSymbol + ) + GIF_TO_VIDEO = + T.let( + :"gif-to-video", + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Type::TaggedSymbol + ) + VIDEO_THUMBNAIL = + T.let( + :"video-thumbnail", + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Type::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Type::TaggedSymbol + ] + ) + end + def self.values + end + end + + class Options < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options, + Imagekit::Internal::AnyHash + ) + end + + # Audio codec used for encoding (aac or opus). + sig do + returns( + T.nilable( + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options::AudioCodec::TaggedSymbol + ) + ) + end + attr_reader :audio_codec + + sig do + params( + audio_codec: + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options::AudioCodec::OrSymbol + ).void + end + attr_writer :audio_codec + + # Whether to automatically rotate the video based on metadata. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :auto_rotate + + sig { params(auto_rotate: T::Boolean).void } + attr_writer :auto_rotate + + # Output format for the transformed video or thumbnail. + sig do + returns( + T.nilable( + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options::Format::TaggedSymbol + ) + ) + end + attr_reader :format_ + + sig do + params( + format_: + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options::Format::OrSymbol + ).void + end + attr_writer :format_ + + # Quality setting for the output video. + sig { returns(T.nilable(Integer)) } + attr_reader :quality + + sig { params(quality: Integer).void } + attr_writer :quality + + # Streaming protocol for adaptive bitrate streaming. + sig do + returns( + T.nilable( + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options::StreamProtocol::TaggedSymbol + ) + ) + end + attr_reader :stream_protocol + + sig do + params( + stream_protocol: + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options::StreamProtocol::OrSymbol + ).void + end + attr_writer :stream_protocol + + # Array of quality representations for adaptive bitrate streaming. + sig { returns(T.nilable(T::Array[String])) } + attr_reader :variants + + sig { params(variants: T::Array[String]).void } + attr_writer :variants + + # Video codec used for encoding (h264, vp9, or av1). + sig do + returns( + T.nilable( + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options::VideoCodec::TaggedSymbol + ) + ) + end + attr_reader :video_codec + + sig do + params( + video_codec: + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options::VideoCodec::OrSymbol + ).void + end + attr_writer :video_codec + + # Configuration options for video transformations. + sig do + params( + audio_codec: + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options::AudioCodec::OrSymbol, + auto_rotate: T::Boolean, + format_: + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options::Format::OrSymbol, + quality: Integer, + stream_protocol: + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options::StreamProtocol::OrSymbol, + variants: T::Array[String], + video_codec: + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options::VideoCodec::OrSymbol + ).returns(T.attached_class) + end + def self.new( + # Audio codec used for encoding (aac or opus). + audio_codec: nil, + # Whether to automatically rotate the video based on metadata. + auto_rotate: nil, + # Output format for the transformed video or thumbnail. + format_: nil, + # Quality setting for the output video. + quality: nil, + # Streaming protocol for adaptive bitrate streaming. + stream_protocol: nil, + # Array of quality representations for adaptive bitrate streaming. + variants: nil, + # Video codec used for encoding (h264, vp9, or av1). + video_codec: nil + ) + end + + sig do + override.returns( + { + audio_codec: + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options::AudioCodec::TaggedSymbol, + auto_rotate: T::Boolean, + format_: + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options::Format::TaggedSymbol, + quality: Integer, + stream_protocol: + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options::StreamProtocol::TaggedSymbol, + variants: T::Array[String], + video_codec: + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options::VideoCodec::TaggedSymbol + } + ) + end + def to_hash + end + + # Audio codec used for encoding (aac or opus). + module AudioCodec + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options::AudioCodec + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + AAC = + T.let( + :aac, + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options::AudioCodec::TaggedSymbol + ) + OPUS = + T.let( + :opus, + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options::AudioCodec::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options::AudioCodec::TaggedSymbol + ] + ) + end + def self.values + end + end + + # Output format for the transformed video or thumbnail. + module Format + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options::Format + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + MP4 = + T.let( + :mp4, + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options::Format::TaggedSymbol + ) + WEBM = + T.let( + :webm, + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options::Format::TaggedSymbol + ) + JPG = + T.let( + :jpg, + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options::Format::TaggedSymbol + ) + PNG = + T.let( + :png, + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options::Format::TaggedSymbol + ) + WEBP = + T.let( + :webp, + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options::Format::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options::Format::TaggedSymbol + ] + ) + end + def self.values + end + end + + # Streaming protocol for adaptive bitrate streaming. + module StreamProtocol + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options::StreamProtocol + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + HLS = + T.let( + :HLS, + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options::StreamProtocol::TaggedSymbol + ) + DASH = + T.let( + :DASH, + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options::StreamProtocol::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options::StreamProtocol::TaggedSymbol + ] + ) + end + def self.values + end + end + + # Video codec used for encoding (h264, vp9, or av1). + module VideoCodec + extend Imagekit::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options::VideoCodec + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + H264 = + T.let( + :h264, + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options::VideoCodec::TaggedSymbol + ) + VP9 = + T.let( + :vp9, + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options::VideoCodec::TaggedSymbol + ) + AV1 = + T.let( + :av1, + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options::VideoCodec::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options::VideoCodec::TaggedSymbol + ] + ) + end + def self.values + end + end + end + + class Output < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Output, + Imagekit::Internal::AnyHash + ) + end + + # URL to access the transformed video. + sig { returns(String) } + attr_accessor :url + + # Metadata of the output video file. + sig do + returns( + T.nilable( + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Output::VideoMetadata + ) + ) + end + attr_reader :video_metadata + + sig do + params( + video_metadata: + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Output::VideoMetadata::OrHash + ).void + end + attr_writer :video_metadata + + # Information about the transformed output video. + sig do + params( + url: String, + video_metadata: + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Output::VideoMetadata::OrHash + ).returns(T.attached_class) + end + def self.new( + # URL to access the transformed video. + url:, + # Metadata of the output video file. + video_metadata: nil + ) + end + + sig do + override.returns( + { + url: String, + video_metadata: + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Output::VideoMetadata + } + ) + end + def to_hash + end + + class VideoMetadata < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Output::VideoMetadata, + Imagekit::Internal::AnyHash + ) + end + + # Bitrate of the output video in bits per second. + sig { returns(Integer) } + attr_accessor :bitrate + + # Duration of the output video in seconds. + sig { returns(Float) } + attr_accessor :duration + + # Height of the output video in pixels. + sig { returns(Integer) } + attr_accessor :height + + # Width of the output video in pixels. + sig { returns(Integer) } + attr_accessor :width + + # Metadata of the output video file. + sig do + params( + bitrate: Integer, + duration: Float, + height: Integer, + width: Integer + ).returns(T.attached_class) + end + def self.new( + # Bitrate of the output video in bits per second. + bitrate:, + # Duration of the output video in seconds. + duration:, + # Height of the output video in pixels. + height:, + # Width of the output video in pixels. + width: + ) + end + + sig do + override.returns( + { + bitrate: Integer, + duration: Float, + height: Integer, + width: Integer + } + ) + end + def to_hash + end + end + end + end + end + + class Request < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::VideoTransformationReadyEvent::Request, + Imagekit::Internal::AnyHash + ) + end + + # Full URL of the transformation request that was submitted. + sig { returns(String) } + attr_accessor :url + + # Unique identifier for the originating transformation request. + sig { returns(String) } + attr_accessor :x_request_id + + # User-Agent header from the original request that triggered the transformation. + sig { returns(T.nilable(String)) } + attr_reader :user_agent + + sig { params(user_agent: String).void } + attr_writer :user_agent + + # Information about the original request that triggered the video transformation. + sig do + params(url: String, x_request_id: String, user_agent: String).returns( + T.attached_class + ) + end + def self.new( + # Full URL of the transformation request that was submitted. + url:, + # Unique identifier for the originating transformation request. + x_request_id:, + # User-Agent header from the original request that triggered the transformation. + user_agent: nil + ) + end + + sig do + override.returns( + { url: String, x_request_id: String, user_agent: String } + ) + end + def to_hash + end + end + + class Timings < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekit::VideoTransformationReadyEvent::Timings, + Imagekit::Internal::AnyHash + ) + end + + # Time spent downloading the source video from your origin or media library, in + # milliseconds. + sig { returns(T.nilable(Integer)) } + attr_reader :download_duration + + sig { params(download_duration: Integer).void } + attr_writer :download_duration + + # Time spent encoding the video, in milliseconds. + sig { returns(T.nilable(Integer)) } + attr_reader :encoding_duration + + sig { params(encoding_duration: Integer).void } + attr_writer :encoding_duration + + # Performance metrics for the transformation process. + sig do + params( + download_duration: Integer, + encoding_duration: Integer + ).returns(T.attached_class) + end + def self.new( + # Time spent downloading the source video from your origin or media library, in + # milliseconds. + download_duration: nil, + # Time spent encoding the video, in milliseconds. + encoding_duration: nil + ) + end + + sig do + override.returns( + { download_duration: Integer, encoding_duration: Integer } + ) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekit/models/webhook_unsafe_unwrap_params.rbi b/rbi/imagekit/models/webhook_unsafe_unwrap_params.rbi new file mode 100644 index 00000000..60cbea60 --- /dev/null +++ b/rbi/imagekit/models/webhook_unsafe_unwrap_params.rbi @@ -0,0 +1,30 @@ +# typed: strong + +module Imagekit + module Models + class WebhookUnsafeUnwrapParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekit::WebhookUnsafeUnwrapParams, + Imagekit::Internal::AnyHash + ) + end + + sig do + params(request_options: Imagekit::RequestOptions::OrHash).returns( + T.attached_class + ) + end + def self.new(request_options: {}) + end + + sig { override.returns({ request_options: Imagekit::RequestOptions }) } + def to_hash + end + end + end +end diff --git a/rbi/imagekit/models/webhook_unwrap_params.rbi b/rbi/imagekit/models/webhook_unwrap_params.rbi new file mode 100644 index 00000000..b3db3d7b --- /dev/null +++ b/rbi/imagekit/models/webhook_unwrap_params.rbi @@ -0,0 +1,27 @@ +# typed: strong + +module Imagekit + module Models + class WebhookUnwrapParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any(Imagekit::WebhookUnwrapParams, Imagekit::Internal::AnyHash) + end + + sig do + params(request_options: Imagekit::RequestOptions::OrHash).returns( + T.attached_class + ) + end + def self.new(request_options: {}) + end + + sig { override.returns({ request_options: Imagekit::RequestOptions }) } + def to_hash + end + end + end +end diff --git a/rbi/imagekit/request_options.rbi b/rbi/imagekit/request_options.rbi new file mode 100644 index 00000000..8f934bd4 --- /dev/null +++ b/rbi/imagekit/request_options.rbi @@ -0,0 +1,59 @@ +# typed: strong + +module Imagekit + # Specify HTTP behaviour to use for a specific request. These options supplement + # or override those provided at the client level. + # + # When making a request, you can pass an actual {RequestOptions} instance, or + # simply pass a Hash with symbol keys matching the attributes on this class. + class RequestOptions < Imagekit::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any(Imagekit::RequestOptions, Imagekit::Internal::AnyHash) + end + + # @api private + sig { params(opts: Imagekit::RequestOptions::OrHash).void } + def self.validate!(opts) + end + + # Idempotency key to send with request and all associated retries. Will only be + # sent for write requests. + sig { returns(T.nilable(String)) } + attr_accessor :idempotency_key + + # Extra query params to send with the request. These are `.merge`’d into any + # `query` given at the client level. + sig do + returns( + T.nilable(T::Hash[String, T.nilable(T.any(T::Array[String], String))]) + ) + end + attr_accessor :extra_query + + # Extra headers to send with the request. These are `.merged`’d into any + # `extra_headers` given at the client level. + sig { returns(T.nilable(T::Hash[String, T.nilable(String)])) } + attr_accessor :extra_headers + + # Extra data to send with the request. These are deep merged into any data + # generated as part of the normal request. + sig { returns(T.nilable(T.anything)) } + attr_accessor :extra_body + + # Maximum number of retries to attempt after a failed initial request. + sig { returns(T.nilable(Integer)) } + attr_accessor :max_retries + + # Request timeout in seconds. + sig { returns(T.nilable(Float)) } + attr_accessor :timeout + + # Returns a new instance of RequestOptions. + sig do + params(values: Imagekit::Internal::AnyHash).returns(T.attached_class) + end + def self.new(values = {}) + end + end +end diff --git a/rbi/imagekit/resources/accounts.rbi b/rbi/imagekit/resources/accounts.rbi new file mode 100644 index 00000000..6a50dd49 --- /dev/null +++ b/rbi/imagekit/resources/accounts.rbi @@ -0,0 +1,21 @@ +# typed: strong + +module Imagekit + module Resources + class Accounts + sig { returns(Imagekit::Resources::Accounts::Usage) } + attr_reader :usage + + sig { returns(Imagekit::Resources::Accounts::Origins) } + attr_reader :origins + + sig { returns(Imagekit::Resources::Accounts::URLEndpoints) } + attr_reader :url_endpoints + + # @api private + sig { params(client: Imagekit::Client).returns(T.attached_class) } + def self.new(client:) + end + end + end +end diff --git a/rbi/imagekit/resources/accounts/origins.rbi b/rbi/imagekit/resources/accounts/origins.rbi new file mode 100644 index 00000000..d7489d06 --- /dev/null +++ b/rbi/imagekit/resources/accounts/origins.rbi @@ -0,0 +1,91 @@ +# typed: strong + +module Imagekit + module Resources + class Accounts + class Origins + # **Note:** This API is currently in beta. + # Creates a new origin and returns the origin object. + sig do + params( + origin_request: Imagekit::Accounts::OriginRequest, + request_options: Imagekit::RequestOptions::OrHash + ).returns(Imagekit::Accounts::OriginResponse::Variants) + end + def create( + # Schema for origin request resources. + origin_request:, + request_options: {} + ) + end + + # **Note:** This API is currently in beta. + # Updates the origin identified by `id` and returns the updated origin object. + sig do + params( + id: String, + origin_request: Imagekit::Accounts::OriginRequest, + request_options: Imagekit::RequestOptions::OrHash + ).returns(Imagekit::Accounts::OriginResponse::Variants) + end + def update( + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + id, + # Schema for origin request resources. + origin_request:, + request_options: {} + ) + end + + # **Note:** This API is currently in beta. + # Returns an array of all configured origins for the current account. + sig do + params(request_options: Imagekit::RequestOptions::OrHash).returns( + T::Array[Imagekit::Accounts::OriginResponse::Variants] + ) + end + def list(request_options: {}) + end + + # **Note:** This API is currently in beta. + # Permanently removes the origin identified by `id`. If the origin is in use by + # any URL‑endpoints, the API will return an error. + sig do + params( + id: String, + request_options: Imagekit::RequestOptions::OrHash + ).void + end + def delete( + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + id, + request_options: {} + ) + end + + # **Note:** This API is currently in beta. + # Retrieves the origin identified by `id`. + sig do + params( + id: String, + request_options: Imagekit::RequestOptions::OrHash + ).returns(Imagekit::Accounts::OriginResponse::Variants) + end + def get( + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + id, + request_options: {} + ) + end + + # @api private + sig { params(client: Imagekit::Client).returns(T.attached_class) } + def self.new(client:) + end + end + end + end +end diff --git a/rbi/imagekit/resources/accounts/url_endpoints.rbi b/rbi/imagekit/resources/accounts/url_endpoints.rbi new file mode 100644 index 00000000..46a2a571 --- /dev/null +++ b/rbi/imagekit/resources/accounts/url_endpoints.rbi @@ -0,0 +1,129 @@ +# typed: strong + +module Imagekit + module Resources + class Accounts + class URLEndpoints + # **Note:** This API is currently in beta. + # Creates a new URL‑endpoint and returns the resulting object. + sig do + params( + description: String, + origins: T::Array[String], + url_prefix: String, + url_rewriter: + T.any( + Imagekit::Accounts::URLEndpointRequest::URLRewriter::Cloudinary::OrHash, + Imagekit::Accounts::URLEndpointRequest::URLRewriter::Imgix::OrHash, + Imagekit::Accounts::URLEndpointRequest::URLRewriter::Akamai::OrHash + ), + request_options: Imagekit::RequestOptions::OrHash + ).returns(Imagekit::Accounts::URLEndpointResponse) + end + def create( + # Description of the URL endpoint. + description:, + # Ordered list of origin IDs to try when the file isn’t in the Media Library; + # ImageKit checks them in the sequence provided. Origin must be created before it + # can be used in a URL endpoint. + origins: nil, + # Path segment appended to your base URL to form the endpoint (letters, digits, + # and hyphens only — or empty for the default endpoint). + url_prefix: nil, + # Configuration for third-party URL rewriting. + url_rewriter: nil, + request_options: {} + ) + end + + # **Note:** This API is currently in beta. + # Updates the URL‑endpoint identified by `id` and returns the updated object. + sig do + params( + id: String, + description: String, + origins: T::Array[String], + url_prefix: String, + url_rewriter: + T.any( + Imagekit::Accounts::URLEndpointRequest::URLRewriter::Cloudinary::OrHash, + Imagekit::Accounts::URLEndpointRequest::URLRewriter::Imgix::OrHash, + Imagekit::Accounts::URLEndpointRequest::URLRewriter::Akamai::OrHash + ), + request_options: Imagekit::RequestOptions::OrHash + ).returns(Imagekit::Accounts::URLEndpointResponse) + end + def update( + # Unique identifier for the URL-endpoint. This is generated by ImageKit when you + # create a new URL-endpoint. For the default URL-endpoint, this is always + # `default`. + id, + # Description of the URL endpoint. + description:, + # Ordered list of origin IDs to try when the file isn’t in the Media Library; + # ImageKit checks them in the sequence provided. Origin must be created before it + # can be used in a URL endpoint. + origins: nil, + # Path segment appended to your base URL to form the endpoint (letters, digits, + # and hyphens only — or empty for the default endpoint). + url_prefix: nil, + # Configuration for third-party URL rewriting. + url_rewriter: nil, + request_options: {} + ) + end + + # **Note:** This API is currently in beta. + # Returns an array of all URL‑endpoints configured including the default + # URL-endpoint generated by ImageKit during account creation. + sig do + params(request_options: Imagekit::RequestOptions::OrHash).returns( + T::Array[Imagekit::Accounts::URLEndpointResponse] + ) + end + def list(request_options: {}) + end + + # **Note:** This API is currently in beta. + # Deletes the URL‑endpoint identified by `id`. You cannot delete the default + # URL‑endpoint created by ImageKit during account creation. + sig do + params( + id: String, + request_options: Imagekit::RequestOptions::OrHash + ).void + end + def delete( + # Unique identifier for the URL-endpoint. This is generated by ImageKit when you + # create a new URL-endpoint. For the default URL-endpoint, this is always + # `default`. + id, + request_options: {} + ) + end + + # **Note:** This API is currently in beta. + # Retrieves the URL‑endpoint identified by `id`. + sig do + params( + id: String, + request_options: Imagekit::RequestOptions::OrHash + ).returns(Imagekit::Accounts::URLEndpointResponse) + end + def get( + # Unique identifier for the URL-endpoint. This is generated by ImageKit when you + # create a new URL-endpoint. For the default URL-endpoint, this is always + # `default`. + id, + request_options: {} + ) + end + + # @api private + sig { params(client: Imagekit::Client).returns(T.attached_class) } + def self.new(client:) + end + end + end + end +end diff --git a/rbi/imagekit/resources/accounts/usage.rbi b/rbi/imagekit/resources/accounts/usage.rbi new file mode 100644 index 00000000..9efefba7 --- /dev/null +++ b/rbi/imagekit/resources/accounts/usage.rbi @@ -0,0 +1,36 @@ +# typed: strong + +module Imagekit + module Resources + class Accounts + class Usage + # Get the account usage information between two dates. Note that the API response + # includes data from the start date while excluding data from the end date. In + # other words, the data covers the period starting from the specified start date + # up to, but not including, the end date. + sig do + params( + end_date: Date, + start_date: Date, + request_options: Imagekit::RequestOptions::OrHash + ).returns(Imagekit::Models::Accounts::UsageGetResponse) + end + def get( + # Specify a `endDate` in `YYYY-MM-DD` format. It should be after the `startDate`. + # The difference between `startDate` and `endDate` should be less than 90 days. + end_date:, + # Specify a `startDate` in `YYYY-MM-DD` format. It should be before the `endDate`. + # The difference between `startDate` and `endDate` should be less than 90 days. + start_date:, + request_options: {} + ) + end + + # @api private + sig { params(client: Imagekit::Client).returns(T.attached_class) } + def self.new(client:) + end + end + end + end +end diff --git a/rbi/imagekit/resources/assets.rbi b/rbi/imagekit/resources/assets.rbi new file mode 100644 index 00000000..52e5efc0 --- /dev/null +++ b/rbi/imagekit/resources/assets.rbi @@ -0,0 +1,74 @@ +# typed: strong + +module Imagekit + module Resources + class Assets + # This API can list all the uploaded files and folders in your ImageKit.io media + # library. In addition, you can fine-tune your query by specifying various filters + # by generating a query string in a Lucene-like syntax and provide this generated + # string as the value of the `searchQuery`. + sig do + params( + file_type: Imagekit::AssetListParams::FileType::OrSymbol, + limit: Integer, + path: String, + search_query: String, + skip: Integer, + sort: Imagekit::AssetListParams::Sort::OrSymbol, + type: Imagekit::AssetListParams::Type::OrSymbol, + request_options: Imagekit::RequestOptions::OrHash + ).returns(T::Array[Imagekit::Models::AssetListResponseItem::Variants]) + end + def list( + # Filter results by file type. + # + # - `all` — include all file types + # - `image` — include only image files + # - `non-image` — include only non-image files (e.g., JS, CSS, video) + file_type: nil, + # The maximum number of results to return in response. + limit: nil, + # Folder path if you want to limit the search within a specific folder. For + # example, `/sales-banner/` will only search in folder sales-banner. + # + # Note : If your use case involves searching within a folder as well as its + # subfolders, you can use `path` parameter in `searchQuery` with appropriate + # operator. Checkout + # [Supported parameters](/docs/api-reference/digital-asset-management-dam/list-and-search-assets#supported-parameters) + # for more information. + path: nil, + # Query string in a Lucene-like query language e.g. `createdAt > "7d"`. + # + # Note : When the searchQuery parameter is present, the following query parameters + # will have no effect on the result: + # + # 1. `tags` + # 2. `type` + # 3. `name` + # + # [Learn more](/docs/api-reference/digital-asset-management-dam/list-and-search-assets#advanced-search-queries) + # from examples. + search_query: nil, + # The number of results to skip before returning results. + skip: nil, + # Sort the results by one of the supported fields in ascending or descending + # order. + sort: nil, + # Filter results by asset type. + # + # - `file` — returns only files + # - `file-version` — returns specific file versions + # - `folder` — returns only folders + # - `all` — returns both files and folders (excludes `file-version`) + type: nil, + request_options: {} + ) + end + + # @api private + sig { params(client: Imagekit::Client).returns(T.attached_class) } + def self.new(client:) + end + end + end +end diff --git a/rbi/imagekit/resources/beta.rbi b/rbi/imagekit/resources/beta.rbi new file mode 100644 index 00000000..6accb5af --- /dev/null +++ b/rbi/imagekit/resources/beta.rbi @@ -0,0 +1,15 @@ +# typed: strong + +module Imagekit + module Resources + class Beta + sig { returns(Imagekit::Resources::Beta::V2) } + attr_reader :v2 + + # @api private + sig { params(client: Imagekit::Client).returns(T.attached_class) } + def self.new(client:) + end + end + end +end diff --git a/rbi/imagekit/resources/beta/v2.rbi b/rbi/imagekit/resources/beta/v2.rbi new file mode 100644 index 00000000..829675dc --- /dev/null +++ b/rbi/imagekit/resources/beta/v2.rbi @@ -0,0 +1,17 @@ +# typed: strong + +module Imagekit + module Resources + class Beta + class V2 + sig { returns(Imagekit::Resources::Beta::V2::Files) } + attr_reader :files + + # @api private + sig { params(client: Imagekit::Client).returns(T.attached_class) } + def self.new(client:) + end + end + end + end +end diff --git a/rbi/imagekit/resources/beta/v2/files.rbi b/rbi/imagekit/resources/beta/v2/files.rbi new file mode 100644 index 00000000..b78dc1c3 --- /dev/null +++ b/rbi/imagekit/resources/beta/v2/files.rbi @@ -0,0 +1,193 @@ +# typed: strong + +module Imagekit + module Resources + class Beta + class V2 + class Files + # The V2 API enhances security by verifying the entire payload using JWT. This API + # is in beta. + # + # ImageKit.io allows you to upload files directly from both the server and client + # sides. For server-side uploads, private API key authentication is used. For + # client-side uploads, generate a one-time `token` from your secure backend using + # private API. + # [Learn more](/docs/api-reference/upload-file/upload-file-v2#how-to-implement-secure-client-side-file-upload) + # about how to implement secure client-side file upload. + # + # **File size limit** \ + # On the free plan, the maximum upload file sizes are 20MB for images, audio, and raw + # files, and 100MB for videos. On the paid plan, these limits increase to 40MB for + # images, audio, and raw files, and 2GB for videos. These limits can be further increased + # with higher-tier plans. + # + # **Version limit** \ + # A file can have a maximum of 100 versions. + # + # **Demo applications** + # + # - A full-fledged + # [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), + # supporting file selections from local storage, URL, Dropbox, Google Drive, + # Instagram, and more. + # - [Quick start guides](/docs/quick-start-guides) for various frameworks and + # technologies. + sig do + params( + file: Imagekit::Internal::FileInput, + file_name: String, + token: String, + checks: String, + custom_coordinates: String, + custom_metadata: T::Hash[Symbol, T.anything], + description: String, + extensions: + T::Array[ + T.any( + Imagekit::ExtensionItem::RemoveBg::OrHash, + Imagekit::ExtensionItem::AIAutoDescription::OrHash, + Imagekit::ExtensionItem::AutoTaggingExtension::OrHash + ) + ], + folder: String, + is_private_file: T::Boolean, + is_published: T::Boolean, + overwrite_ai_tags: T::Boolean, + overwrite_custom_metadata: T::Boolean, + overwrite_file: T::Boolean, + overwrite_tags: T::Boolean, + response_fields: + T::Array[ + Imagekit::Beta::V2::FileUploadParams::ResponseField::OrSymbol + ], + tags: T::Array[String], + transformation: + Imagekit::Beta::V2::FileUploadParams::Transformation::OrHash, + use_unique_file_name: T::Boolean, + webhook_url: String, + request_options: Imagekit::RequestOptions::OrHash + ).returns(Imagekit::Models::Beta::V2::FileUploadResponse) + end + def upload( + # The API accepts any of the following: + # + # - **Binary data** – send the raw bytes as `multipart/form-data`. + # - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can + # fetch. + # - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + # + # When supplying a URL, the server must receive the response headers within 8 + # seconds; otherwise the request fails with 400 Bad Request. + file:, + # The name with which the file has to be uploaded. + file_name:, + # This is the client-generated JSON Web Token (JWT). The ImageKit.io server uses + # it to authenticate and check that the upload request parameters have not been + # tampered with after the token has been generated. Learn how to create the token + # on the page below. This field is only required for authentication when uploading + # a file from the client side. + # + # **Note**: Sending a JWT that has been used in the past will result in a + # validation error. Even if your previous request resulted in an error, you should + # always send a new token. + # + # **⚠️Warning**: JWT must be generated on the server-side because it is generated + # using your account's private API key. This field is required for authentication + # when uploading a file from the client-side. + token: nil, + # Server-side checks to run on the asset. Read more about + # [Upload API checks](/docs/api-reference/upload-file/upload-file-v2#upload-api-checks). + checks: nil, + # Define an important area in the image. This is only relevant for image type + # files. + # + # - To be passed as a string with the x and y coordinates of the top-left corner, + # and width and height of the area of interest in the format `x,y,width,height`. + # For example - `10,10,100,100` + # - Can be used with fo-customtransformation. + # - If this field is not specified and the file is overwritten, then + # customCoordinates will be removed. + custom_coordinates: nil, + # JSON key-value pairs to associate with the asset. Create the custom metadata + # fields before setting these values. + custom_metadata: nil, + # Optional text to describe the contents of the file. + description: nil, + # Array of extensions to be applied to the asset. Each extension can be configured + # with specific parameters based on the extension type. + extensions: nil, + # The folder path in which the image has to be uploaded. If the folder(s) didn't + # exist before, a new folder(s) is created. Using multiple `/` creates a nested + # folder. + folder: nil, + # Whether to mark the file as private or not. + # + # If `true`, the file is marked as private and is accessible only using named + # transformation or signed URL. + is_private_file: nil, + # Whether to upload file as published or not. + # + # If `false`, the file is marked as unpublished, which restricts access to the + # file only via the media library. Files in draft or unpublished state can only be + # publicly accessed after being published. + # + # The option to upload in draft state is only available in custom enterprise + # pricing plans. + is_published: nil, + # If set to `true` and a file already exists at the exact location, its AITags + # will be removed. Set `overwriteAITags` to `false` to preserve AITags. + overwrite_ai_tags: nil, + # If the request does not have `customMetadata`, and a file already exists at the + # exact location, existing customMetadata will be removed. + overwrite_custom_metadata: nil, + # If `false` and `useUniqueFileName` is also `false`, and a file already exists at + # the exact location, upload API will return an error immediately. + overwrite_file: nil, + # If the request does not have `tags`, and a file already exists at the exact + # location, existing tags will be removed. + overwrite_tags: nil, + # Array of response field keys to include in the API response body. + response_fields: nil, + # Set the tags while uploading the file. Provide an array of tag strings (e.g. + # `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must not + # exceed 500, and the `%` character is not allowed. If this field is not specified + # and the file is overwritten, the existing tags will be removed. + tags: nil, + # Configure pre-processing (`pre`) and post-processing (`post`) transformations. + # + # - `pre` — applied before the file is uploaded to the Media Library. + # Useful for reducing file size or applying basic optimizations upfront (e.g., + # resize, compress). + # + # - `post` — applied immediately after upload. + # Ideal for generating transformed versions (like video encodes or thumbnails) + # in advance, so they're ready for delivery without delay. + # + # You can mix and match any combination of post-processing types. + transformation: nil, + # Whether to use a unique filename for this file or not. + # + # If `true`, ImageKit.io will add a unique suffix to the filename parameter to get + # a unique filename. + # + # If `false`, then the image is uploaded with the provided filename parameter, and + # any existing file with the same name is replaced. + use_unique_file_name: nil, + # The final status of extensions after they have completed execution will be + # delivered to this endpoint as a POST request. + # [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + # about the webhook payload structure. + webhook_url: nil, + request_options: {} + ) + end + + # @api private + sig { params(client: Imagekit::Client).returns(T.attached_class) } + def self.new(client:) + end + end + end + end + end +end diff --git a/rbi/imagekit/resources/cache.rbi b/rbi/imagekit/resources/cache.rbi new file mode 100644 index 00000000..5d9aa111 --- /dev/null +++ b/rbi/imagekit/resources/cache.rbi @@ -0,0 +1,15 @@ +# typed: strong + +module Imagekit + module Resources + class Cache + sig { returns(Imagekit::Resources::Cache::Invalidation) } + attr_reader :invalidation + + # @api private + sig { params(client: Imagekit::Client).returns(T.attached_class) } + def self.new(client:) + end + end + end +end diff --git a/rbi/imagekit/resources/cache/invalidation.rbi b/rbi/imagekit/resources/cache/invalidation.rbi new file mode 100644 index 00000000..e0aa6e8b --- /dev/null +++ b/rbi/imagekit/resources/cache/invalidation.rbi @@ -0,0 +1,44 @@ +# typed: strong + +module Imagekit + module Resources + class Cache + class Invalidation + # This API will purge CDN cache and ImageKit.io's internal cache for a file. Note: + # Purge cache is an asynchronous process and it may take some time to reflect the + # changes. + sig do + params( + url: String, + request_options: Imagekit::RequestOptions::OrHash + ).returns(Imagekit::Models::Cache::InvalidationCreateResponse) + end + def create( + # The full URL of the file to be purged. + url:, + request_options: {} + ) + end + + # This API returns the status of a purge cache request. + sig do + params( + request_id: String, + request_options: Imagekit::RequestOptions::OrHash + ).returns(Imagekit::Models::Cache::InvalidationGetResponse) + end + def get( + # Should be a valid requestId. + request_id, + request_options: {} + ) + end + + # @api private + sig { params(client: Imagekit::Client).returns(T.attached_class) } + def self.new(client:) + end + end + end + end +end diff --git a/rbi/imagekit/resources/custom_metadata_fields.rbi b/rbi/imagekit/resources/custom_metadata_fields.rbi new file mode 100644 index 00000000..ed2578c3 --- /dev/null +++ b/rbi/imagekit/resources/custom_metadata_fields.rbi @@ -0,0 +1,95 @@ +# typed: strong + +module Imagekit + module Resources + class CustomMetadataFields + # This API creates a new custom metadata field. Once a custom metadata field is + # created either through this API or using the dashboard UI, its value can be set + # on the assets. The value of a field for an asset can be set using the media + # library UI or programmatically through upload or update assets API. + sig do + params( + label: String, + name: String, + schema: Imagekit::CustomMetadataFieldCreateParams::Schema::OrHash, + request_options: Imagekit::RequestOptions::OrHash + ).returns(Imagekit::CustomMetadataField) + end + def create( + # Human readable name of the custom metadata field. This should be unique across + # all non deleted custom metadata fields. This name is displayed as form field + # label to the users while setting field value on an asset in the media library + # UI. + label:, + # API name of the custom metadata field. This should be unique across all + # (including deleted) custom metadata fields. + name:, + schema:, + request_options: {} + ) + end + + # This API updates the label or schema of an existing custom metadata field. + sig do + params( + id: String, + label: String, + schema: Imagekit::CustomMetadataFieldUpdateParams::Schema::OrHash, + request_options: Imagekit::RequestOptions::OrHash + ).returns(Imagekit::CustomMetadataField) + end + def update( + # Should be a valid custom metadata field id. + id, + # Human readable name of the custom metadata field. This should be unique across + # all non deleted custom metadata fields. This name is displayed as form field + # label to the users while setting field value on an asset in the media library + # UI. This parameter is required if `schema` is not provided. + label: nil, + # An object that describes the rules for the custom metadata key. This parameter + # is required if `label` is not provided. Note: `type` cannot be updated and will + # be ignored if sent with the `schema`. The schema will be validated as per the + # existing `type`. + schema: nil, + request_options: {} + ) + end + + # This API returns the array of created custom metadata field objects. By default + # the API returns only non deleted field objects, but you can include deleted + # fields in the API response. + sig do + params( + include_deleted: T::Boolean, + request_options: Imagekit::RequestOptions::OrHash + ).returns(T::Array[Imagekit::CustomMetadataField]) + end + def list( + # Set it to `true` to include deleted field objects in the API response. + include_deleted: nil, + request_options: {} + ) + end + + # This API deletes a custom metadata field. Even after deleting a custom metadata + # field, you cannot create any new custom metadata field with the same name. + sig do + params( + id: String, + request_options: Imagekit::RequestOptions::OrHash + ).returns(Imagekit::Models::CustomMetadataFieldDeleteResponse) + end + def delete( + # Should be a valid custom metadata field id. + id, + request_options: {} + ) + end + + # @api private + sig { params(client: Imagekit::Client).returns(T.attached_class) } + def self.new(client:) + end + end + end +end diff --git a/rbi/imagekit/resources/files.rbi b/rbi/imagekit/resources/files.rbi new file mode 100644 index 00000000..cec1cf6e --- /dev/null +++ b/rbi/imagekit/resources/files.rbi @@ -0,0 +1,364 @@ +# typed: strong + +module Imagekit + module Resources + class Files + sig { returns(Imagekit::Resources::Files::Bulk) } + attr_reader :bulk + + sig { returns(Imagekit::Resources::Files::Versions) } + attr_reader :versions + + sig { returns(Imagekit::Resources::Files::Metadata) } + attr_reader :metadata + + # This API updates the details or attributes of the current version of the file. + # You can update `tags`, `customCoordinates`, `customMetadata`, publication + # status, remove existing `AITags` and apply extensions using this API. + sig do + params( + file_id: String, + update_file_request: Imagekit::UpdateFileRequest, + request_options: Imagekit::RequestOptions::OrHash + ).returns(Imagekit::Models::FileUpdateResponse) + end + def update( + # The unique `fileId` of the uploaded file. `fileId` is returned in list and + # search assets API and upload API. + file_id, + # Schema for update file update request. + update_file_request:, + request_options: {} + ) + end + + # This API deletes the file and all its file versions permanently. + # + # Note: If a file or specific transformation has been requested in the past, then + # the response is cached. Deleting a file does not purge the cache. You can purge + # the cache using purge cache API. + sig do + params( + file_id: String, + request_options: Imagekit::RequestOptions::OrHash + ).void + end + def delete( + # The unique `fileId` of the uploaded file. `fileId` is returned in list and + # search assets API and upload API. + file_id, + request_options: {} + ) + end + + # This will copy a file from one folder to another. + # + # Note: If any file at the destination has the same name as the source file, then + # the source file and its versions (if `includeFileVersions` is set to true) will + # be appended to the destination file version history. + sig do + params( + destination_path: String, + source_file_path: String, + include_file_versions: T::Boolean, + request_options: Imagekit::RequestOptions::OrHash + ).returns(Imagekit::Models::FileCopyResponse) + end + def copy( + # Full path to the folder you want to copy the above file into. + destination_path:, + # The full path of the file you want to copy. + source_file_path:, + # Option to copy all versions of a file. By default, only the current version of + # the file is copied. When set to true, all versions of the file will be copied. + # Default value - `false`. + include_file_versions: nil, + request_options: {} + ) + end + + # This API returns an object with details or attributes about the current version + # of the file. + sig do + params( + file_id: String, + request_options: Imagekit::RequestOptions::OrHash + ).returns(Imagekit::File) + end + def get( + # The unique `fileId` of the uploaded file. `fileId` is returned in the list and + # search assets API and upload API. + file_id, + request_options: {} + ) + end + + # This will move a file and all its versions from one folder to another. + # + # Note: If any file at the destination has the same name as the source file, then + # the source file and its versions will be appended to the destination file. + sig do + params( + destination_path: String, + source_file_path: String, + request_options: Imagekit::RequestOptions::OrHash + ).returns(Imagekit::Models::FileMoveResponse) + end + def move( + # Full path to the folder you want to move the above file into. + destination_path:, + # The full path of the file you want to move. + source_file_path:, + request_options: {} + ) + end + + # You can rename an already existing file in the media library using rename file + # API. This operation would rename all file versions of the file. + # + # Note: The old URLs will stop working. The file/file version URLs cached on CDN + # will continue to work unless a purge is requested. + sig do + params( + file_path: String, + new_file_name: String, + purge_cache: T::Boolean, + request_options: Imagekit::RequestOptions::OrHash + ).returns(Imagekit::Models::FileRenameResponse) + end + def rename( + # The full path of the file you want to rename. + file_path:, + # The new name of the file. A filename can contain: + # + # Alphanumeric Characters: `a-z`, `A-Z`, `0-9` (including Unicode letters, marks, + # and numerals in other languages). Special Characters: `.`, `_`, and `-`. + # + # Any other character, including space, will be replaced by `_`. + new_file_name:, + # Option to purge cache for the old file and its versions' URLs. + # + # When set to true, it will internally issue a purge cache request on CDN to + # remove cached content of old file and its versions. This purge request is + # counted against your monthly purge quota. + # + # Note: If the old file were accessible at + # `https://ik.imagekit.io/demo/old-filename.jpg`, a purge cache request would be + # issued against `https://ik.imagekit.io/demo/old-filename.jpg*` (with a wildcard + # at the end). It will remove the file and its versions' URLs and any + # transformations made using query parameters on this file or its versions. + # However, the cache for file transformations made using path parameters will + # persist. You can purge them using the purge API. For more details, refer to the + # purge API documentation. + # + # Default value - `false` + purge_cache: nil, + request_options: {} + ) + end + + # ImageKit.io allows you to upload files directly from both the server and client + # sides. For server-side uploads, private API key authentication is used. For + # client-side uploads, generate a one-time `token`, `signature`, and `expire` from + # your secure backend using private API. + # [Learn more](/docs/api-reference/upload-file/upload-file#how-to-implement-client-side-file-upload) + # about how to implement client-side file upload. + # + # The [V2 API](/docs/api-reference/upload-file/upload-file-v2) enhances security + # by verifying the entire payload using JWT. + # + # **File size limit** \ + # On the free plan, the maximum upload file sizes are 20MB for images, audio, and raw + # files and 100MB for videos. On the paid plan, these limits increase to 40MB for images, + # audio, and raw files and 2GB for videos. These limits can be further increased with + # higher-tier plans. + # + # **Version limit** \ + # A file can have a maximum of 100 versions. + # + # **Demo applications** + # + # - A full-fledged + # [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), + # supporting file selections from local storage, URL, Dropbox, Google Drive, + # Instagram, and more. + # - [Quick start guides](/docs/quick-start-guides) for various frameworks and + # technologies. + sig do + params( + file: Imagekit::Internal::FileInput, + file_name: String, + token: String, + checks: String, + custom_coordinates: String, + custom_metadata: T::Hash[Symbol, T.anything], + description: String, + expire: Integer, + extensions: + T::Array[ + T.any( + Imagekit::ExtensionItem::RemoveBg::OrHash, + Imagekit::ExtensionItem::AIAutoDescription::OrHash, + Imagekit::ExtensionItem::AutoTaggingExtension::OrHash + ) + ], + folder: String, + is_private_file: T::Boolean, + is_published: T::Boolean, + overwrite_ai_tags: T::Boolean, + overwrite_custom_metadata: T::Boolean, + overwrite_file: T::Boolean, + overwrite_tags: T::Boolean, + public_key: String, + response_fields: + T::Array[Imagekit::FileUploadParams::ResponseField::OrSymbol], + signature: String, + tags: T::Array[String], + transformation: Imagekit::FileUploadParams::Transformation::OrHash, + use_unique_file_name: T::Boolean, + webhook_url: String, + request_options: Imagekit::RequestOptions::OrHash + ).returns(Imagekit::Models::FileUploadResponse) + end + def upload( + # The API accepts any of the following: + # + # - **Binary data** – send the raw bytes as `multipart/form-data`. + # - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can + # fetch. + # - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + # + # When supplying a URL, the server must receive the response headers within 8 + # seconds; otherwise the request fails with 400 Bad Request. + file:, + # The name with which the file has to be uploaded. The file name can contain: + # + # - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. + # - Special Characters: `.`, `-` + # + # Any other character including space will be replaced by `_` + file_name:, + # A unique value that the ImageKit.io server will use to recognize and prevent + # subsequent retries for the same request. We suggest using V4 UUIDs, or another + # random string with enough entropy to avoid collisions. This field is only + # required for authentication when uploading a file from the client side. + # + # **Note**: Sending a value that has been used in the past will result in a + # validation error. Even if your previous request resulted in an error, you should + # always send a new value for this field. + token: nil, + # Server-side checks to run on the asset. Read more about + # [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). + checks: nil, + # Define an important area in the image. This is only relevant for image type + # files. + # + # - To be passed as a string with the x and y coordinates of the top-left corner, + # and width and height of the area of interest in the format `x,y,width,height`. + # For example - `10,10,100,100` + # - Can be used with fo-customtransformation. + # - If this field is not specified and the file is overwritten, then + # customCoordinates will be removed. + custom_coordinates: nil, + # JSON key-value pairs to associate with the asset. Create the custom metadata + # fields before setting these values. + custom_metadata: nil, + # Optional text to describe the contents of the file. + description: nil, + # The time until your signature is valid. It must be a + # [Unix time](https://en.wikipedia.org/wiki/Unix_time) in less than 1 hour into + # the future. It should be in seconds. This field is only required for + # authentication when uploading a file from the client side. + expire: nil, + # Array of extensions to be applied to the asset. Each extension can be configured + # with specific parameters based on the extension type. + extensions: nil, + # The folder path in which the image has to be uploaded. If the folder(s) didn't + # exist before, a new folder(s) is created. + # + # The folder name can contain: + # + # - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` + # - Special Characters: `/` , `_` , `-` + # + # Using multiple `/` creates a nested folder. + folder: nil, + # Whether to mark the file as private or not. + # + # If `true`, the file is marked as private and is accessible only using named + # transformation or signed URL. + is_private_file: nil, + # Whether to upload file as published or not. + # + # If `false`, the file is marked as unpublished, which restricts access to the + # file only via the media library. Files in draft or unpublished state can only be + # publicly accessed after being published. + # + # The option to upload in draft state is only available in custom enterprise + # pricing plans. + is_published: nil, + # If set to `true` and a file already exists at the exact location, its AITags + # will be removed. Set `overwriteAITags` to `false` to preserve AITags. + overwrite_ai_tags: nil, + # If the request does not have `customMetadata`, and a file already exists at the + # exact location, existing customMetadata will be removed. + overwrite_custom_metadata: nil, + # If `false` and `useUniqueFileName` is also `false`, and a file already exists at + # the exact location, upload API will return an error immediately. + overwrite_file: nil, + # If the request does not have `tags`, and a file already exists at the exact + # location, existing tags will be removed. + overwrite_tags: nil, + # Your ImageKit.io public key. This field is only required for authentication when + # uploading a file from the client side. + public_key: nil, + # Array of response field keys to include in the API response body. + response_fields: nil, + # HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a + # key. Learn how to create a signature on the page below. This should be in + # lowercase. + # + # Signature must be calculated on the server-side. This field is only required for + # authentication when uploading a file from the client side. + signature: nil, + # Set the tags while uploading the file. Provide an array of tag strings (e.g. + # `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must not + # exceed 500, and the `%` character is not allowed. If this field is not specified + # and the file is overwritten, the existing tags will be removed. + tags: nil, + # Configure pre-processing (`pre`) and post-processing (`post`) transformations. + # + # - `pre` — applied before the file is uploaded to the Media Library. + # Useful for reducing file size or applying basic optimizations upfront (e.g., + # resize, compress). + # + # - `post` — applied immediately after upload. + # Ideal for generating transformed versions (like video encodes or thumbnails) + # in advance, so they're ready for delivery without delay. + # + # You can mix and match any combination of post-processing types. + transformation: nil, + # Whether to use a unique filename for this file or not. + # + # If `true`, ImageKit.io will add a unique suffix to the filename parameter to get + # a unique filename. + # + # If `false`, then the image is uploaded with the provided filename parameter, and + # any existing file with the same name is replaced. + use_unique_file_name: nil, + # The final status of extensions after they have completed execution will be + # delivered to this endpoint as a POST request. + # [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + # about the webhook payload structure. + webhook_url: nil, + request_options: {} + ) + end + + # @api private + sig { params(client: Imagekit::Client).returns(T.attached_class) } + def self.new(client:) + end + end + end +end diff --git a/rbi/imagekit/resources/files/bulk.rbi b/rbi/imagekit/resources/files/bulk.rbi new file mode 100644 index 00000000..44af2dfe --- /dev/null +++ b/rbi/imagekit/resources/files/bulk.rbi @@ -0,0 +1,88 @@ +# typed: strong + +module Imagekit + module Resources + class Files + class Bulk + # This API deletes multiple files and all their file versions permanently. + # + # Note: If a file or specific transformation has been requested in the past, then + # the response is cached. Deleting a file does not purge the cache. You can purge + # the cache using purge cache API. + # + # A maximum of 100 files can be deleted at a time. + sig do + params( + file_ids: T::Array[String], + request_options: Imagekit::RequestOptions::OrHash + ).returns(Imagekit::Models::Files::BulkDeleteResponse) + end + def delete( + # An array of fileIds which you want to delete. + file_ids:, + request_options: {} + ) + end + + # This API adds tags to multiple files in bulk. A maximum of 50 files can be + # specified at a time. + sig do + params( + file_ids: T::Array[String], + tags: T::Array[String], + request_options: Imagekit::RequestOptions::OrHash + ).returns(Imagekit::Models::Files::BulkAddTagsResponse) + end + def add_tags( + # An array of fileIds to which you want to add tags. + file_ids:, + # An array of tags that you want to add to the files. + tags:, + request_options: {} + ) + end + + # This API removes AITags from multiple files in bulk. A maximum of 50 files can + # be specified at a time. + sig do + params( + ai_tags: T::Array[String], + file_ids: T::Array[String], + request_options: Imagekit::RequestOptions::OrHash + ).returns(Imagekit::Models::Files::BulkRemoveAITagsResponse) + end + def remove_ai_tags( + # An array of AITags that you want to remove from the files. + ai_tags:, + # An array of fileIds from which you want to remove AITags. + file_ids:, + request_options: {} + ) + end + + # This API removes tags from multiple files in bulk. A maximum of 50 files can be + # specified at a time. + sig do + params( + file_ids: T::Array[String], + tags: T::Array[String], + request_options: Imagekit::RequestOptions::OrHash + ).returns(Imagekit::Models::Files::BulkRemoveTagsResponse) + end + def remove_tags( + # An array of fileIds from which you want to remove tags. + file_ids:, + # An array of tags that you want to remove from the files. + tags:, + request_options: {} + ) + end + + # @api private + sig { params(client: Imagekit::Client).returns(T.attached_class) } + def self.new(client:) + end + end + end + end +end diff --git a/rbi/imagekit/resources/files/metadata.rbi b/rbi/imagekit/resources/files/metadata.rbi new file mode 100644 index 00000000..34ecc601 --- /dev/null +++ b/rbi/imagekit/resources/files/metadata.rbi @@ -0,0 +1,49 @@ +# typed: strong + +module Imagekit + module Resources + class Files + class Metadata + # You can programmatically get image EXIF, pHash, and other metadata for uploaded + # files in the ImageKit.io media library using this API. + # + # You can also get the metadata in upload API response by passing `metadata` in + # `responseFields` parameter. + sig do + params( + file_id: String, + request_options: Imagekit::RequestOptions::OrHash + ).returns(Imagekit::Metadata) + end + def get( + # The unique `fileId` of the uploaded file. `fileId` is returned in the list and + # search assets API and upload API. + file_id, + request_options: {} + ) + end + + # Get image EXIF, pHash, and other metadata from ImageKit.io powered remote URL + # using this API. + sig do + params( + url: String, + request_options: Imagekit::RequestOptions::OrHash + ).returns(Imagekit::Metadata) + end + def get_from_url( + # Should be a valid file URL. It should be accessible using your ImageKit.io + # account. + url:, + request_options: {} + ) + end + + # @api private + sig { params(client: Imagekit::Client).returns(T.attached_class) } + def self.new(client:) + end + end + end + end +end diff --git a/rbi/imagekit/resources/files/versions.rbi b/rbi/imagekit/resources/files/versions.rbi new file mode 100644 index 00000000..c27aff5d --- /dev/null +++ b/rbi/imagekit/resources/files/versions.rbi @@ -0,0 +1,89 @@ +# typed: strong + +module Imagekit + module Resources + class Files + class Versions + # This API returns details of all versions of a file. + sig do + params( + file_id: String, + request_options: Imagekit::RequestOptions::OrHash + ).returns(T::Array[Imagekit::File]) + end + def list( + # The unique `fileId` of the uploaded file. `fileId` is returned in list and + # search assets API and upload API. + file_id, + request_options: {} + ) + end + + # This API deletes a non-current file version permanently. The API returns an + # empty response. + # + # Note: If you want to delete all versions of a file, use the delete file API. + sig do + params( + version_id: String, + file_id: String, + request_options: Imagekit::RequestOptions::OrHash + ).returns(Imagekit::Models::Files::VersionDeleteResponse) + end + def delete( + # The unique `versionId` of the uploaded file. `versionId` is returned in list and + # search assets API and upload API. + version_id, + # The unique `fileId` of the uploaded file. `fileId` is returned in list and + # search assets API and upload API. + file_id:, + request_options: {} + ) + end + + # This API returns an object with details or attributes of a file version. + sig do + params( + version_id: String, + file_id: String, + request_options: Imagekit::RequestOptions::OrHash + ).returns(Imagekit::File) + end + def get( + # The unique `versionId` of the uploaded file. `versionId` is returned in list and + # search assets API and upload API. + version_id, + # The unique `fileId` of the uploaded file. `fileId` is returned in list and + # search assets API and upload API. + file_id:, + request_options: {} + ) + end + + # This API restores a file version as the current file version. + sig do + params( + version_id: String, + file_id: String, + request_options: Imagekit::RequestOptions::OrHash + ).returns(Imagekit::File) + end + def restore( + # The unique `versionId` of the uploaded file. `versionId` is returned in list and + # search assets API and upload API. + version_id, + # The unique `fileId` of the uploaded file. `fileId` is returned in list and + # search assets API and upload API. + file_id:, + request_options: {} + ) + end + + # @api private + sig { params(client: Imagekit::Client).returns(T.attached_class) } + def self.new(client:) + end + end + end + end +end diff --git a/rbi/imagekit/resources/folders.rbi b/rbi/imagekit/resources/folders.rbi new file mode 100644 index 00000000..3fd9afd7 --- /dev/null +++ b/rbi/imagekit/resources/folders.rbi @@ -0,0 +1,146 @@ +# typed: strong + +module Imagekit + module Resources + class Folders + sig { returns(Imagekit::Resources::Folders::Job) } + attr_reader :job + + # This will create a new folder. You can specify the folder name and location of + # the parent folder where this new folder should be created. + sig do + params( + folder_name: String, + parent_folder_path: String, + request_options: Imagekit::RequestOptions::OrHash + ).returns(Imagekit::Models::FolderCreateResponse) + end + def create( + # The folder will be created with this name. + # + # All characters except alphabets and numbers (inclusive of unicode letters, + # marks, and numerals in other languages) will be replaced by an underscore i.e. + # `_`. + folder_name:, + # The folder where the new folder should be created, for root use `/` else the + # path e.g. `containing/folder/`. + # + # Note: If any folder(s) is not present in the parentFolderPath parameter, it will + # be automatically created. For example, if you pass `/product/images/summer`, + # then `product`, `images`, and `summer` folders will be created if they don't + # already exist. + parent_folder_path:, + request_options: {} + ) + end + + # This will delete a folder and all its contents permanently. The API returns an + # empty response. + sig do + params( + folder_path: String, + request_options: Imagekit::RequestOptions::OrHash + ).returns(Imagekit::Models::FolderDeleteResponse) + end + def delete( + # Full path to the folder you want to delete. For example `/folder/to/delete/`. + folder_path:, + request_options: {} + ) + end + + # This will copy one folder into another. The selected folder, its nested folders, + # files, and their versions (in `includeVersions` is set to true) are copied in + # this operation. Note: If any file at the destination has the same name as the + # source file, then the source file and its versions will be appended to the + # destination file version history. + sig do + params( + destination_path: String, + source_folder_path: String, + include_versions: T::Boolean, + request_options: Imagekit::RequestOptions::OrHash + ).returns(Imagekit::Models::FolderCopyResponse) + end + def copy( + # Full path to the destination folder where you want to copy the source folder + # into. + destination_path:, + # The full path to the source folder you want to copy. + source_folder_path:, + # Option to copy all versions of files that are nested inside the selected folder. + # By default, only the current version of each file will be copied. When set to + # true, all versions of each file will be copied. Default value - `false`. + include_versions: nil, + request_options: {} + ) + end + + # This will move one folder into another. The selected folder, its nested folders, + # files, and their versions are moved in this operation. Note: If any file at the + # destination has the same name as the source file, then the source file and its + # versions will be appended to the destination file version history. + sig do + params( + destination_path: String, + source_folder_path: String, + request_options: Imagekit::RequestOptions::OrHash + ).returns(Imagekit::Models::FolderMoveResponse) + end + def move( + # Full path to the destination folder where you want to move the source folder + # into. + destination_path:, + # The full path to the source folder you want to move. + source_folder_path:, + request_options: {} + ) + end + + # This API allows you to rename an existing folder. The folder and all its nested + # assets and sub-folders will remain unchanged, but their paths will be updated to + # reflect the new folder name. + sig do + params( + folder_path: String, + new_folder_name: String, + purge_cache: T::Boolean, + request_options: Imagekit::RequestOptions::OrHash + ).returns(Imagekit::Models::FolderRenameResponse) + end + def rename( + # The full path to the folder you want to rename. + folder_path:, + # The new name for the folder. + # + # All characters except alphabets and numbers (inclusive of unicode letters, + # marks, and numerals in other languages) and `-` will be replaced by an + # underscore i.e. `_`. + new_folder_name:, + # Option to purge cache for the old nested files and their versions' URLs. + # + # When set to true, it will internally issue a purge cache request on CDN to + # remove the cached content of the old nested files and their versions. There will + # only be one purge request for all the nested files, which will be counted + # against your monthly purge quota. + # + # Note: A purge cache request will be issued against + # `https://ik.imagekit.io/old/folder/path*` (with a wildcard at the end). This + # will remove all nested files, their versions' URLs, and any transformations made + # using query parameters on these files or their versions. However, the cache for + # file transformations made using path parameters will persist. You can purge them + # using the purge API. For more details, refer to the purge API documentation. + # + # Default value - `false` + purge_cache: nil, + request_options: {} + ) + end + + # @api private + sig { params(client: Imagekit::Client).returns(T.attached_class) } + def self.new(client:) + end + end + end +end diff --git a/rbi/imagekit/resources/folders/job.rbi b/rbi/imagekit/resources/folders/job.rbi new file mode 100644 index 00000000..f59139e4 --- /dev/null +++ b/rbi/imagekit/resources/folders/job.rbi @@ -0,0 +1,29 @@ +# typed: strong + +module Imagekit + module Resources + class Folders + class Job + # This API returns the status of a bulk job like copy and move folder operations. + sig do + params( + job_id: String, + request_options: Imagekit::RequestOptions::OrHash + ).returns(Imagekit::Models::Folders::JobGetResponse) + end + def get( + # The `jobId` is returned in the response of bulk job API e.g. copy folder or move + # folder API. + job_id, + request_options: {} + ) + end + + # @api private + sig { params(client: Imagekit::Client).returns(T.attached_class) } + def self.new(client:) + end + end + end + end +end diff --git a/rbi/imagekit/resources/webhooks.rbi b/rbi/imagekit/resources/webhooks.rbi new file mode 100644 index 00000000..76b48078 --- /dev/null +++ b/rbi/imagekit/resources/webhooks.rbi @@ -0,0 +1,50 @@ +# typed: strong + +module Imagekit + module Resources + class Webhooks + sig do + params(payload: String).returns( + T.any( + Imagekit::VideoTransformationAcceptedEvent, + Imagekit::VideoTransformationReadyEvent, + Imagekit::VideoTransformationErrorEvent, + Imagekit::UploadPreTransformSuccessEvent, + Imagekit::UploadPreTransformErrorEvent, + Imagekit::UploadPostTransformSuccessEvent, + Imagekit::UploadPostTransformErrorEvent + ) + ) + end + def unsafe_unwrap( + # The raw webhook payload as a string + payload + ) + end + + sig do + params(payload: String).returns( + T.any( + Imagekit::VideoTransformationAcceptedEvent, + Imagekit::VideoTransformationReadyEvent, + Imagekit::VideoTransformationErrorEvent, + Imagekit::UploadPreTransformSuccessEvent, + Imagekit::UploadPreTransformErrorEvent, + Imagekit::UploadPostTransformSuccessEvent, + Imagekit::UploadPostTransformErrorEvent + ) + ) + end + def unwrap( + # The raw webhook payload as a string + payload + ) + end + + # @api private + sig { params(client: Imagekit::Client).returns(T.attached_class) } + def self.new(client:) + end + end + end +end diff --git a/rbi/imagekit/version.rbi b/rbi/imagekit/version.rbi new file mode 100644 index 00000000..dd908e9e --- /dev/null +++ b/rbi/imagekit/version.rbi @@ -0,0 +1,5 @@ +# typed: strong + +module Imagekit + VERSION = T.let(T.unsafe(nil), String) +end diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 00000000..32536019 --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,70 @@ +{ + "packages": { + ".": {} + }, + "$schema": "https://raw.githubusercontent.com/stainless-api/release-please/main/schemas/config.json", + "include-v-in-tag": true, + "include-component-in-tag": false, + "versioning": "prerelease", + "prerelease": true, + "bump-minor-pre-major": true, + "bump-patch-for-minor-pre-major": false, + "pull-request-header": "Automated Release PR", + "pull-request-title-pattern": "release: ${version}", + "changelog-sections": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "perf", + "section": "Performance Improvements" + }, + { + "type": "revert", + "section": "Reverts" + }, + { + "type": "chore", + "section": "Chores" + }, + { + "type": "docs", + "section": "Documentation" + }, + { + "type": "style", + "section": "Styles" + }, + { + "type": "refactor", + "section": "Refactors" + }, + { + "type": "test", + "section": "Tests", + "hidden": true + }, + { + "type": "build", + "section": "Build System" + }, + { + "type": "ci", + "section": "Continuous Integration", + "hidden": true + } + ], + "release-type": "ruby", + "version-file": "lib/imagekit/version.rb", + "extra-files": [ + { + "type": "ruby-readme", + "path": "README.md" + } + ] +} \ No newline at end of file diff --git a/scripts/bootstrap b/scripts/bootstrap new file mode 100755 index 00000000..34878642 --- /dev/null +++ b/scripts/bootstrap @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +set -e + +cd -- "$(dirname -- "$0")/.." + +if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "$SKIP_BREW" != "1" ] && [ -t 0 ]; then + brew bundle check >/dev/null 2>&1 || { + echo -n "==> Install Homebrew dependencies? (y/N): " + read -r response + case "$response" in + [yY][eE][sS]|[yY]) + brew bundle + ;; + *) + ;; + esac + echo + } +fi + +echo "==> Installing Ruby dependencies…" + +exec -- bundle install "$@" diff --git a/scripts/format b/scripts/format new file mode 100755 index 00000000..177d1e63 --- /dev/null +++ b/scripts/format @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -e + +cd -- "$(dirname -- "$0")/.." + +echo "==> Running formatters" + +exec -- bundle exec rake format "$@" diff --git a/scripts/lint b/scripts/lint new file mode 100755 index 00000000..08b0dbeb --- /dev/null +++ b/scripts/lint @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -e + +cd -- "$(dirname -- "$0")/.." + +echo "==> Running linters" + +exec -- bundle exec rake lint "$@" diff --git a/scripts/mock b/scripts/mock new file mode 100755 index 00000000..0b28f6ea --- /dev/null +++ b/scripts/mock @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +if [[ -n "$1" && "$1" != '--'* ]]; then + URL="$1" + shift +else + URL="$(grep 'openapi_spec_url' .stats.yml | cut -d' ' -f2)" +fi + +# Check if the URL is empty +if [ -z "$URL" ]; then + echo "Error: No OpenAPI spec path/url provided or found in .stats.yml" + exit 1 +fi + +echo "==> Starting mock server with URL ${URL}" + +# Run prism mock on the given spec +if [ "$1" == "--daemon" ]; then + npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" &> .prism.log & + + # Wait for server to come online + echo -n "Waiting for server" + while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do + echo -n "." + sleep 0.1 + done + + if grep -q "✖ fatal" ".prism.log"; then + cat .prism.log + exit 1 + fi + + echo +else + npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" +fi diff --git a/scripts/test b/scripts/test new file mode 100755 index 00000000..e0dc1374 --- /dev/null +++ b/scripts/test @@ -0,0 +1,56 @@ +#!/usr/bin/env bash + +set -e + +cd -- "$(dirname -- "$0")/.." + +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[0;33m' +NC='\033[0m' # No Color + +function prism_is_running() { + curl --silent "http://localhost:4010" >/dev/null 2>&1 +} + +kill_server_on_port() { + pids=$(lsof -t -i tcp:"$1" || echo "") + if [ "$pids" != "" ]; then + kill "$pids" + echo "Stopped $pids." + fi +} + +function is_overriding_api_base_url() { + [ -n "$TEST_API_BASE_URL" ] +} + +if ! is_overriding_api_base_url && ! prism_is_running ; then + # When we exit this script, make sure to kill the background mock server process + trap 'kill_server_on_port 4010' EXIT + + # Start the dev server + ./scripts/mock --daemon +fi + +if is_overriding_api_base_url ; then + echo -e "${GREEN}✔ Running tests against ${TEST_API_BASE_URL}${NC}" + echo +elif ! prism_is_running ; then + echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Prism server" + echo -e "running against your OpenAPI spec." + echo + echo -e "To run the server, pass in the path or url of your OpenAPI" + echo -e "spec to the prism command:" + echo + echo -e " \$ ${YELLOW}npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock path/to/your.openapi.yml${NC}" + echo + + exit 1 +else + echo -e "${GREEN}✔ Mock prism server is running with your OpenAPI spec${NC}" + echo +fi + +echo "==> Running tests" +bundle exec rake test "$@" diff --git a/sig/imagekit/client.rbs b/sig/imagekit/client.rbs new file mode 100644 index 00000000..754fe43e --- /dev/null +++ b/sig/imagekit/client.rbs @@ -0,0 +1,45 @@ +module Imagekit + class Client < Imagekit::Internal::Transport::BaseClient + DEFAULT_MAX_RETRIES: 2 + + DEFAULT_TIMEOUT_IN_SECONDS: Float + + DEFAULT_INITIAL_RETRY_DELAY: Float + + DEFAULT_MAX_RETRY_DELAY: Float + + attr_reader private_key: String + + attr_reader password: String? + + attr_reader custom_metadata_fields: Imagekit::Resources::CustomMetadataFields + + attr_reader files: Imagekit::Resources::Files + + attr_reader assets: Imagekit::Resources::Assets + + attr_reader cache: Imagekit::Resources::Cache + + attr_reader folders: Imagekit::Resources::Folders + + attr_reader accounts: Imagekit::Resources::Accounts + + attr_reader beta: Imagekit::Resources::Beta + + attr_reader webhooks: Imagekit::Resources::Webhooks + + private def auth_headers: -> ::Hash[String, String] + + def base_url_overridden?: -> bool + + def initialize: ( + ?private_key: String?, + ?password: String?, + ?base_url: String?, + ?max_retries: Integer, + ?timeout: Float, + ?initial_retry_delay: Float, + ?max_retry_delay: Float + ) -> void + end +end diff --git a/sig/imagekit/errors.rbs b/sig/imagekit/errors.rbs new file mode 100644 index 00000000..c24034f6 --- /dev/null +++ b/sig/imagekit/errors.rbs @@ -0,0 +1,117 @@ +module Imagekit + module Errors + class Error < StandardError + attr_accessor cause: StandardError? + end + + class ConversionError < Imagekit::Errors::Error + def cause: -> StandardError? + + def initialize: ( + on: Class, + method: Symbol, + target: top, + value: top, + ?cause: StandardError? + ) -> void + end + + class APIError < Imagekit::Errors::Error + attr_accessor url: URI::Generic + + attr_accessor status: Integer? + + attr_accessor headers: ::Hash[String, String]? + + attr_accessor body: top? + + def initialize: ( + url: URI::Generic, + ?status: Integer?, + ?headers: ::Hash[String, String]?, + ?body: Object?, + ?request: nil, + ?response: nil, + ?message: String? + ) -> void + end + + class APIConnectionError < Imagekit::Errors::APIError + def initialize: ( + url: URI::Generic, + ?status: nil, + ?headers: ::Hash[String, String]?, + ?body: nil, + ?request: nil, + ?response: nil, + ?message: String? + ) -> void + end + + class APITimeoutError < Imagekit::Errors::APIConnectionError + def initialize: ( + url: URI::Generic, + ?status: nil, + ?headers: ::Hash[String, String]?, + ?body: nil, + ?request: nil, + ?response: nil, + ?message: String? + ) -> void + end + + class APIStatusError < Imagekit::Errors::APIError + def self.for: ( + url: URI::Generic, + status: Integer, + headers: ::Hash[String, String]?, + body: Object?, + request: nil, + response: nil, + ?message: String? + ) -> instance + + def initialize: ( + url: URI::Generic, + status: Integer, + headers: ::Hash[String, String]?, + body: Object?, + request: nil, + response: nil, + ?message: String? + ) -> void + end + + class BadRequestError < Imagekit::Errors::APIStatusError + HTTP_STATUS: 400 + end + + class AuthenticationError < Imagekit::Errors::APIStatusError + HTTP_STATUS: 401 + end + + class PermissionDeniedError < Imagekit::Errors::APIStatusError + HTTP_STATUS: 403 + end + + class NotFoundError < Imagekit::Errors::APIStatusError + HTTP_STATUS: 404 + end + + class ConflictError < Imagekit::Errors::APIStatusError + HTTP_STATUS: 409 + end + + class UnprocessableEntityError < Imagekit::Errors::APIStatusError + HTTP_STATUS: 422 + end + + class RateLimitError < Imagekit::Errors::APIStatusError + HTTP_STATUS: 429 + end + + class InternalServerError < Imagekit::Errors::APIStatusError + HTTP_STATUS: Range[Integer] + end + end +end diff --git a/sig/imagekit/file_part.rbs b/sig/imagekit/file_part.rbs new file mode 100644 index 00000000..3a8befa0 --- /dev/null +++ b/sig/imagekit/file_part.rbs @@ -0,0 +1,21 @@ +module Imagekit + class FilePart + attr_reader content: Pathname | StringIO | IO | String + + attr_reader content_type: String? + + attr_reader filename: String? + + private def read: -> String + + def to_json: (*top a) -> String + + def to_yaml: (*top a) -> String + + def initialize: ( + Pathname | StringIO | IO | String content, + ?filename: String?, + ?content_type: String? + ) -> void + end +end diff --git a/sig/imagekit/internal.rbs b/sig/imagekit/internal.rbs new file mode 100644 index 00000000..90664cb4 --- /dev/null +++ b/sig/imagekit/internal.rbs @@ -0,0 +1,9 @@ +module Imagekit + module Internal + extend Imagekit::Internal::Util::SorbetRuntimeSupport + + type file_input = Pathname | StringIO | IO | String | Imagekit::FilePart + + OMIT: Object + end +end diff --git a/sig/imagekit/internal/transport/base_client.rbs b/sig/imagekit/internal/transport/base_client.rbs new file mode 100644 index 00000000..420b711d --- /dev/null +++ b/sig/imagekit/internal/transport/base_client.rbs @@ -0,0 +1,131 @@ +module Imagekit + module Internal + module Transport + class BaseClient + extend Imagekit::Internal::Util::SorbetRuntimeSupport + + type request_components = + { + method: Symbol, + path: String | ::Array[String], + query: ::Hash[String, (::Array[String] | String)?]?, + headers: ::Hash[String, (String + | Integer + | ::Array[(String | Integer)?])?]?, + body: top?, + unwrap: (Symbol + | Integer + | ::Array[(Symbol | Integer)] + | (^(top arg0) -> top))?, + page: Class?, + stream: Class?, + model: Imagekit::Internal::Type::Converter::input?, + options: Imagekit::request_opts? + } + type request_input = + { + method: Symbol, + url: URI::Generic, + headers: ::Hash[String, String], + body: top, + max_retries: Integer, + timeout: Float + } + + MAX_REDIRECTS: 20 + + PLATFORM_HEADERS: ::Hash[String, String] + + def self.validate!: ( + Imagekit::Internal::Transport::BaseClient::request_components req + ) -> void + + def self.should_retry?: ( + Integer status, + headers: ::Hash[String, String] + ) -> bool + + def self.follow_redirect: ( + Imagekit::Internal::Transport::BaseClient::request_input request, + status: Integer, + response_headers: ::Hash[String, String] + ) -> Imagekit::Internal::Transport::BaseClient::request_input + + def self.reap_connection!: ( + Integer | Imagekit::Errors::APIConnectionError status, + stream: Enumerable[String]? + ) -> void + + attr_reader base_url: URI::Generic + + attr_reader timeout: Float + + attr_reader max_retries: Integer + + attr_reader initial_retry_delay: Float + + attr_reader max_retry_delay: Float + + attr_reader headers: ::Hash[String, String] + + attr_reader idempotency_header: String? + + # @api private + attr_reader requester: Imagekit::Internal::Transport::PooledNetRequester + + def initialize: ( + base_url: String, + ?timeout: Float, + ?max_retries: Integer, + ?initial_retry_delay: Float, + ?max_retry_delay: Float, + ?headers: ::Hash[String, (String + | Integer + | ::Array[(String | Integer)?])?], + ?idempotency_header: String? + ) -> void + + private def auth_headers: -> ::Hash[String, String] + + private def generate_idempotency_key: -> String + + private def build_request: ( + Imagekit::Internal::Transport::BaseClient::request_components req, + Imagekit::request_options opts + ) -> Imagekit::Internal::Transport::BaseClient::request_input + + private def retry_delay: ( + ::Hash[String, String] headers, + retry_count: Integer + ) -> Float + + def send_request: ( + Imagekit::Internal::Transport::BaseClient::request_input request, + redirect_count: Integer, + retry_count: Integer, + send_retry_header: bool + ) -> [Integer, top, Enumerable[String]] + + def request: ( + Symbol method, + String | ::Array[String] path, + ?query: ::Hash[String, (::Array[String] | String)?]?, + ?headers: ::Hash[String, (String + | Integer + | ::Array[(String | Integer)?])?]?, + ?body: top?, + ?unwrap: (Symbol + | Integer + | ::Array[(Symbol | Integer)] + | (^(top arg0) -> top))?, + ?page: Class?, + ?stream: Class?, + ?model: Imagekit::Internal::Type::Converter::input?, + ?options: Imagekit::request_opts? + ) -> top + + def inspect: -> String + end + end + end +end diff --git a/sig/imagekit/internal/transport/pooled_net_requester.rbs b/sig/imagekit/internal/transport/pooled_net_requester.rbs new file mode 100644 index 00000000..281ecf51 --- /dev/null +++ b/sig/imagekit/internal/transport/pooled_net_requester.rbs @@ -0,0 +1,45 @@ +module Imagekit + module Internal + module Transport + class PooledNetRequester + extend Imagekit::Internal::Util::SorbetRuntimeSupport + + type request = + { + method: Symbol, + url: URI::Generic, + headers: ::Hash[String, String], + body: top, + deadline: Float + } + + KEEP_ALIVE_TIMEOUT: 30 + + DEFAULT_MAX_CONNECTIONS: Integer + + def self.connect: (URI::Generic url) -> top + + def self.calibrate_socket_timeout: (top conn, Float deadline) -> void + + def self.build_request: ( + Imagekit::Internal::Transport::PooledNetRequester::request request + ) { + (String arg0) -> void + } -> [top, (^-> void)] + + private def with_pool: ( + URI::Generic url, + deadline: Float + ) { + (top arg0) -> void + } -> void + + def execute: ( + Imagekit::Internal::Transport::PooledNetRequester::request request + ) -> [Integer, top, Enumerable[String]] + + def initialize: (?size: Integer) -> void + end + end + end +end diff --git a/sig/imagekit/internal/type/array_of.rbs b/sig/imagekit/internal/type/array_of.rbs new file mode 100644 index 00000000..53ceaa09 --- /dev/null +++ b/sig/imagekit/internal/type/array_of.rbs @@ -0,0 +1,48 @@ +module Imagekit + module Internal + module Type + class ArrayOf[Elem] + include Imagekit::Internal::Type::Converter + include Imagekit::Internal::Util::SorbetRuntimeSupport + + def self.[]: ( + ::Hash[Symbol, top] + | ^-> Imagekit::Internal::Type::Converter::input + | Imagekit::Internal::Type::Converter::input type_info, + ?::Hash[Symbol, top] spec + ) -> instance + + def ===: (top other) -> bool + + def ==: (top other) -> bool + + def hash: -> Integer + + def coerce: ( + ::Array[top] | top value, + state: Imagekit::Internal::Type::Converter::coerce_state + ) -> (::Array[top] | top) + + def dump: ( + ::Array[top] | top value, + state: Imagekit::Internal::Type::Converter::dump_state + ) -> (::Array[top] | top) + + def to_sorbet_type: -> top + + def item_type: -> Elem + + def nilable?: -> bool + + def initialize: ( + ::Hash[Symbol, top] + | ^-> Imagekit::Internal::Type::Converter::input + | Imagekit::Internal::Type::Converter::input type_info, + ?::Hash[Symbol, top] spec + ) -> void + + def inspect: (?depth: Integer) -> String + end + end + end +end diff --git a/sig/imagekit/internal/type/base_model.rbs b/sig/imagekit/internal/type/base_model.rbs new file mode 100644 index 00000000..81e90505 --- /dev/null +++ b/sig/imagekit/internal/type/base_model.rbs @@ -0,0 +1,102 @@ +module Imagekit + module Internal + module Type + class BaseModel + extend Imagekit::Internal::Type::Converter + extend Imagekit::Internal::Util::SorbetRuntimeSupport + + type known_field = + { mode: (:coerce | :dump)?, required: bool, nilable: bool } + + def self.inherited: (self child) -> void + + def self.known_fields: -> ::Hash[Symbol, (Imagekit::Internal::Type::BaseModel::known_field + & { type_fn: (^-> Imagekit::Internal::Type::Converter::input) })] + + def self.fields: -> ::Hash[Symbol, (Imagekit::Internal::Type::BaseModel::known_field + & { type: Imagekit::Internal::Type::Converter::input })] + + private def self.add_field: ( + Symbol name_sym, + required: bool, + type_info: { + const: (nil | bool | Integer | Float | Symbol)?, + enum: ^-> Imagekit::Internal::Type::Converter::input?, + union: ^-> Imagekit::Internal::Type::Converter::input?, + api_name: Symbol + } + | ^-> Imagekit::Internal::Type::Converter::input + | Imagekit::Internal::Type::Converter::input, + spec: ::Hash[Symbol, top] + ) -> void + + def self.required: ( + Symbol name_sym, + ::Hash[Symbol, top] + | ^-> Imagekit::Internal::Type::Converter::input + | Imagekit::Internal::Type::Converter::input type_info, + ?::Hash[Symbol, top] spec + ) -> void + + def self.optional: ( + Symbol name_sym, + ::Hash[Symbol, top] + | ^-> Imagekit::Internal::Type::Converter::input + | Imagekit::Internal::Type::Converter::input type_info, + ?::Hash[Symbol, top] spec + ) -> void + + private def self.request_only: { -> void } -> void + + private def self.response_only: { -> void } -> void + + def self.==: (top other) -> bool + + def self.hash: -> Integer + + def ==: (top other) -> bool + + def hash: -> Integer + + def self.coerce: ( + Imagekit::Internal::Type::BaseModel | ::Hash[top, top] | top value, + state: Imagekit::Internal::Type::Converter::coerce_state + ) -> (instance | top) + + def self.dump: ( + instance | top value, + state: Imagekit::Internal::Type::Converter::dump_state + ) -> (::Hash[top, top] | top) + + def self.to_sorbet_type: -> top + + def self.recursively_to_h: ( + Imagekit::Internal::Type::BaseModel model, + convert: bool + ) -> ::Hash[Symbol, top] + + def []: (Symbol key) -> top? + + def to_h: -> ::Hash[Symbol, top] + + alias to_hash to_h + + def deep_to_h: -> ::Hash[Symbol, top] + + def deconstruct_keys: (::Array[Symbol]? keys) -> ::Hash[Symbol, top] + + def to_json: (*top a) -> String + + def to_yaml: (*top a) -> String + + def initialize: (?::Hash[Symbol, top] | instance data) -> void + + def self.inspect: (?depth: Integer) -> String + + def to_s: -> String + + def inspect: -> String + end + end + end +end diff --git a/sig/imagekit/internal/type/base_page.rbs b/sig/imagekit/internal/type/base_page.rbs new file mode 100644 index 00000000..cec13b1b --- /dev/null +++ b/sig/imagekit/internal/type/base_page.rbs @@ -0,0 +1,24 @@ +module Imagekit + module Internal + module Type + module BasePage[Elem] + def next_page?: -> bool + + def next_page: -> instance + + def auto_paging_each: { (Elem arg0) -> void } -> void + + def to_enum: -> Enumerable[Elem] + + alias enum_for to_enum + + def initialize: ( + client: Imagekit::Internal::Transport::BaseClient, + req: Imagekit::Internal::Transport::BaseClient::request_components, + headers: ::Hash[String, String], + page_data: top + ) -> void + end + end + end +end diff --git a/sig/imagekit/internal/type/boolean.rbs b/sig/imagekit/internal/type/boolean.rbs new file mode 100644 index 00000000..8ff7e123 --- /dev/null +++ b/sig/imagekit/internal/type/boolean.rbs @@ -0,0 +1,26 @@ +module Imagekit + module Internal + module Type + class Boolean + extend Imagekit::Internal::Type::Converter + extend Imagekit::Internal::Util::SorbetRuntimeSupport + + def self.===: (top other) -> bool + + def self.==: (top other) -> bool + + def self.coerce: ( + bool | top value, + state: Imagekit::Internal::Type::Converter::coerce_state + ) -> (bool | top) + + def self.dump: ( + bool | top value, + state: Imagekit::Internal::Type::Converter::dump_state + ) -> (bool | top) + + def self.to_sorbet_type: -> top + end + end + end +end diff --git a/sig/imagekit/internal/type/converter.rbs b/sig/imagekit/internal/type/converter.rbs new file mode 100644 index 00000000..30d3221f --- /dev/null +++ b/sig/imagekit/internal/type/converter.rbs @@ -0,0 +1,79 @@ +module Imagekit + module Internal + module Type + module Converter + extend Imagekit::Internal::Util::SorbetRuntimeSupport + + type input = Imagekit::Internal::Type::Converter | Class + + type coerce_state = + { + translate_names: bool, + strictness: bool, + exactness: { yes: Integer, no: Integer, maybe: Integer }, + error: Class, + branched: Integer + } + + type dump_state = { can_retry: bool } + + def coerce: ( + top value, + state: Imagekit::Internal::Type::Converter::coerce_state + ) -> top + + def dump: ( + top value, + state: Imagekit::Internal::Type::Converter::dump_state + ) -> top + + def inspect: (?depth: Integer) -> String + + def self.type_info: ( + { + const: (nil | bool | Integer | Float | Symbol)?, + enum: ^-> Imagekit::Internal::Type::Converter::input?, + union: ^-> Imagekit::Internal::Type::Converter::input? + } + | ^-> Imagekit::Internal::Type::Converter::input + | Imagekit::Internal::Type::Converter::input spec + ) -> (^-> top) + + def self.meta_info: ( + { + const: (nil | bool | Integer | Float | Symbol)?, + enum: ^-> Imagekit::Internal::Type::Converter::input?, + union: ^-> Imagekit::Internal::Type::Converter::input? + } + | ^-> Imagekit::Internal::Type::Converter::input + | Imagekit::Internal::Type::Converter::input type_info, + { + const: (nil | bool | Integer | Float | Symbol)?, + enum: ^-> Imagekit::Internal::Type::Converter::input?, + union: ^-> Imagekit::Internal::Type::Converter::input? + } + | ^-> Imagekit::Internal::Type::Converter::input + | Imagekit::Internal::Type::Converter::input spec + ) -> ::Hash[Symbol, top] + + def self.new_coerce_state: ( + ?translate_names: bool + ) -> Imagekit::Internal::Type::Converter::coerce_state + + def self.coerce: ( + Imagekit::Internal::Type::Converter::input target, + top value, + ?state: Imagekit::Internal::Type::Converter::coerce_state + ) -> top + + def self.dump: ( + Imagekit::Internal::Type::Converter::input target, + top value, + ?state: Imagekit::Internal::Type::Converter::dump_state + ) -> top + + def self.inspect: (top target, depth: Integer) -> String + end + end + end +end diff --git a/sig/imagekit/internal/type/enum.rbs b/sig/imagekit/internal/type/enum.rbs new file mode 100644 index 00000000..19825e23 --- /dev/null +++ b/sig/imagekit/internal/type/enum.rbs @@ -0,0 +1,32 @@ +module Imagekit + module Internal + module Type + module Enum + include Imagekit::Internal::Type::Converter + include Imagekit::Internal::Util::SorbetRuntimeSupport + + def self.values: -> ::Array[(nil | bool | Integer | Float | Symbol)] + + def ===: (top other) -> bool + + def ==: (top other) -> bool + + def hash: -> Integer + + def coerce: ( + String | Symbol | top value, + state: Imagekit::Internal::Type::Converter::coerce_state + ) -> (Symbol | top) + + def dump: ( + Symbol | top value, + state: Imagekit::Internal::Type::Converter::dump_state + ) -> (Symbol | top) + + def to_sorbet_type: -> top + + def inspect: (?depth: Integer) -> String + end + end + end +end diff --git a/sig/imagekit/internal/type/file_input.rbs b/sig/imagekit/internal/type/file_input.rbs new file mode 100644 index 00000000..2047a19e --- /dev/null +++ b/sig/imagekit/internal/type/file_input.rbs @@ -0,0 +1,25 @@ +module Imagekit + module Internal + module Type + class FileInput + extend Imagekit::Internal::Type::Converter + + def self.===: (top other) -> bool + + def self.==: (top other) -> bool + + def self.coerce: ( + StringIO | String | top value, + state: Imagekit::Internal::Type::Converter::coerce_state + ) -> (StringIO | top) + + def self.dump: ( + Pathname | StringIO | IO | String | top value, + state: Imagekit::Internal::Type::Converter::dump_state + ) -> (Pathname | StringIO | IO | String | top) + + def self.to_sorbet_type: -> top + end + end + end +end diff --git a/sig/imagekit/internal/type/hash_of.rbs b/sig/imagekit/internal/type/hash_of.rbs new file mode 100644 index 00000000..898a3566 --- /dev/null +++ b/sig/imagekit/internal/type/hash_of.rbs @@ -0,0 +1,48 @@ +module Imagekit + module Internal + module Type + class HashOf[Elem] + include Imagekit::Internal::Type::Converter + include Imagekit::Internal::Util::SorbetRuntimeSupport + + def self.[]: ( + ::Hash[Symbol, top] + | ^-> Imagekit::Internal::Type::Converter::input + | Imagekit::Internal::Type::Converter::input type_info, + ?::Hash[Symbol, top] spec + ) -> instance + + def ===: (top other) -> bool + + def ==: (top other) -> bool + + def hash: -> Integer + + def coerce: ( + ::Hash[top, top] | top value, + state: Imagekit::Internal::Type::Converter::coerce_state + ) -> (::Hash[Symbol, top] | top) + + def dump: ( + ::Hash[top, top] | top value, + state: Imagekit::Internal::Type::Converter::dump_state + ) -> (::Hash[Symbol, top] | top) + + def to_sorbet_type: -> top + + def item_type: -> Elem + + def nilable?: -> bool + + def initialize: ( + ::Hash[Symbol, top] + | ^-> Imagekit::Internal::Type::Converter::input + | Imagekit::Internal::Type::Converter::input type_info, + ?::Hash[Symbol, top] spec + ) -> void + + def inspect: (?depth: Integer) -> String + end + end + end +end diff --git a/sig/imagekit/internal/type/request_parameters.rbs b/sig/imagekit/internal/type/request_parameters.rbs new file mode 100644 index 00000000..33e5d91c --- /dev/null +++ b/sig/imagekit/internal/type/request_parameters.rbs @@ -0,0 +1,17 @@ +module Imagekit + module Internal + module Type + type request_parameters = { request_options: Imagekit::request_opts } + + module RequestParameters + attr_reader request_options: Imagekit::request_opts + + def request_options=: (Imagekit::request_opts) -> Imagekit::request_opts + + module Converter + def dump_request: (top params) -> [top, ::Hash[Symbol, top]] + end + end + end + end +end diff --git a/sig/imagekit/internal/type/union.rbs b/sig/imagekit/internal/type/union.rbs new file mode 100644 index 00000000..1dcd9350 --- /dev/null +++ b/sig/imagekit/internal/type/union.rbs @@ -0,0 +1,52 @@ +module Imagekit + module Internal + module Type + module Union + include Imagekit::Internal::Type::Converter + include Imagekit::Internal::Util::SorbetRuntimeSupport + + private def self.known_variants: -> ::Array[[Symbol?, (^-> Imagekit::Internal::Type::Converter::input), ::Hash[Symbol, top]]] + + def self.derefed_variants: -> ::Array[[Symbol?, top, ::Hash[Symbol, top]]] + + def self.variants: -> ::Array[top] + + private def self.discriminator: (Symbol property) -> void + + private def self.variant: ( + Symbol + | ::Hash[Symbol, top] + | ^-> Imagekit::Internal::Type::Converter::input + | Imagekit::Internal::Type::Converter::input key, + ?::Hash[Symbol, top] + | ^-> Imagekit::Internal::Type::Converter::input + | Imagekit::Internal::Type::Converter::input spec + ) -> void + + private def self.resolve_variant: ( + top value + ) -> Imagekit::Internal::Type::Converter::input? + + def ===: (top other) -> bool + + def ==: (top other) -> bool + + def hash: -> Integer + + def coerce: ( + top value, + state: Imagekit::Internal::Type::Converter::coerce_state + ) -> top + + def dump: ( + top value, + state: Imagekit::Internal::Type::Converter::dump_state + ) -> top + + def to_sorbet_type: -> top + + def inspect: (?depth: Integer) -> String + end + end + end +end diff --git a/sig/imagekit/internal/type/unknown.rbs b/sig/imagekit/internal/type/unknown.rbs new file mode 100644 index 00000000..79647fe7 --- /dev/null +++ b/sig/imagekit/internal/type/unknown.rbs @@ -0,0 +1,26 @@ +module Imagekit + module Internal + module Type + class Unknown + extend Imagekit::Internal::Type::Converter + extend Imagekit::Internal::Util::SorbetRuntimeSupport + + def self.===: (top other) -> bool + + def self.==: (top other) -> bool + + def self.coerce: ( + top value, + state: Imagekit::Internal::Type::Converter::coerce_state + ) -> top + + def self.dump: ( + top value, + state: Imagekit::Internal::Type::Converter::dump_state + ) -> top + + def self.to_sorbet_type: -> top + end + end + end +end diff --git a/sig/imagekit/internal/util.rbs b/sig/imagekit/internal/util.rbs new file mode 100644 index 00000000..4440cd2b --- /dev/null +++ b/sig/imagekit/internal/util.rbs @@ -0,0 +1,185 @@ +module Imagekit + module Internal + module Util + extend Imagekit::Internal::Util::SorbetRuntimeSupport + + def self?.monotonic_secs: -> Float + + def self?.walk_namespaces: ( + Module | Class ns + ) -> Enumerable[(Module | Class)] + + def self?.arch: -> String + + def self?.os: -> String + + def self?.primitive?: (top input) -> bool + + def self?.coerce_boolean: (String | bool input) -> (bool | top) + + def self?.coerce_boolean!: (String | bool input) -> bool? + + def self?.coerce_integer: (String | Integer input) -> (Integer | top) + + def self?.coerce_float: (String | Integer | Float input) -> (Float | top) + + def self?.coerce_hash: (top input) -> (::Hash[top, top] | top) + + def self?.coerce_hash!: (top input) -> ::Hash[top, top]? + + def self?.deep_merge_lr: (top lhs, top rhs, ?concat: bool) -> top + + def self?.deep_merge: ( + *::Array[top] values, + ?sentinel: top?, + ?concat: bool + ) -> top + + def self?.dig: ( + ::Hash[Symbol, top] | ::Array[top] | top data, + (Symbol + | Integer + | ::Array[(Symbol | Integer)] + | (^(top arg0) -> top))? pick + ) { + -> top? + } -> top? + + def self?.uri_origin: (URI::Generic uri) -> String + + def self?.interpolate_path: (String | ::Array[String] path) -> String + + def self?.decode_query: (String? query) -> ::Hash[String, ::Array[String]] + + def self?.encode_query: ( + ::Hash[String, (::Array[String] | String)?]? query + ) -> String? + + type parsed_uri = + { + scheme: String?, + host: String?, + port: Integer?, + path: String?, + query: ::Hash[String, ::Array[String]] + } + + def self?.parse_uri: ( + URI::Generic | String url + ) -> Imagekit::Internal::Util::parsed_uri + + def self?.unparse_uri: ( + Imagekit::Internal::Util::parsed_uri parsed + ) -> URI::Generic + + def self?.join_parsed_uri: ( + Imagekit::Internal::Util::parsed_uri lhs, + Imagekit::Internal::Util::parsed_uri rhs + ) -> URI::Generic + + def self?.normalized_headers: ( + *::Hash[String, (String + | Integer + | ::Array[(String | Integer)?])?] headers + ) -> ::Hash[String, String] + + class ReadIOAdapter + def close?: -> bool? + + def close: -> void + + private def read_enum: (Integer? max_len) -> String + + def read: (?Integer? max_len, ?String? out_string) -> String? + + def initialize: ( + String | Pathname | StringIO | Enumerable[String] src + ) { + (String arg0) -> void + } -> void + end + + def self?.writable_enum: { + (Enumerator::Yielder y) -> void + } -> Enumerable[String] + + JSON_CONTENT: Regexp + JSONL_CONTENT: Regexp + + def self?.write_multipart_content: ( + Enumerator::Yielder y, + val: top, + closing: ::Array[^-> void], + ?content_type: String? + ) -> void + + def self?.write_multipart_chunk: ( + Enumerator::Yielder y, + boundary: String, + key: Symbol | String, + val: top, + closing: ::Array[^-> void] + ) -> void + + def self?.encode_multipart_streaming: ( + top body + ) -> [String, Enumerable[String]] + + def self?.encode_content: ( + ::Hash[String, String] headers, + top body + ) -> top + + def self?.force_charset!: (String content_type, text: String) -> void + + def self?.decode_content: ( + ::Hash[String, String] headers, + stream: Enumerable[String], + ?suppress_error: bool + ) -> top + + def self?.fused_enum: ( + Enumerable[top] enum, + ?external: bool + ) { + -> void + } -> Enumerable[top] + + def self?.close_fused!: (Enumerable[top]? enum) -> void + + def self?.chain_fused: ( + Enumerable[top]? enum + ) { + (Enumerator::Yielder arg0) -> void + } -> Enumerable[top] + + type server_sent_event = + { event: String?, data: String?, id: String?, retry: Integer? } + + def self?.decode_lines: (Enumerable[String] enum) -> Enumerable[String] + + def self?.decode_sse: ( + Enumerable[String] lines + ) -> Enumerable[Imagekit::Internal::Util::server_sent_event] + + module SorbetRuntimeSupport + class MissingSorbetRuntimeError < ::RuntimeError + end + + private def sorbet_runtime_constants: -> ::Hash[Symbol, top] + + def const_missing: (Symbol name) -> void + + def sorbet_constant_defined?: (Symbol name) -> bool + + def define_sorbet_constant!: (Symbol name) { -> top } -> void + + def to_sorbet_type: -> top + + def self.to_sorbet_type: ( + Imagekit::Internal::Util::SorbetRuntimeSupport | top `type` + ) -> top + end + end + end +end diff --git a/sig/imagekit/models.rbs b/sig/imagekit/models.rbs new file mode 100644 index 00000000..bd520b8e --- /dev/null +++ b/sig/imagekit/models.rbs @@ -0,0 +1,115 @@ +module Imagekit + module Accounts = Imagekit::Models::Accounts + + class AssetListParams = Imagekit::Models::AssetListParams + + class BaseOverlay = Imagekit::Models::BaseOverlay + + class BaseWebhookEvent = Imagekit::Models::BaseWebhookEvent + + module Beta = Imagekit::Models::Beta + + module Cache = Imagekit::Models::Cache + + class CustomMetadataField = Imagekit::Models::CustomMetadataField + + class CustomMetadataFieldCreateParams = Imagekit::Models::CustomMetadataFieldCreateParams + + class CustomMetadataFieldDeleteParams = Imagekit::Models::CustomMetadataFieldDeleteParams + + class CustomMetadataFieldListParams = Imagekit::Models::CustomMetadataFieldListParams + + class CustomMetadataFieldUpdateParams = Imagekit::Models::CustomMetadataFieldUpdateParams + + type extension_item = Imagekit::Models::extension_item + + Extensions: Imagekit::Internal::Type::Converter + + class File = Imagekit::Models::File + + class FileCopyParams = Imagekit::Models::FileCopyParams + + class FileDeleteParams = Imagekit::Models::FileDeleteParams + + class FileGetParams = Imagekit::Models::FileGetParams + + class FileMoveParams = Imagekit::Models::FileMoveParams + + class FileRenameParams = Imagekit::Models::FileRenameParams + + module Files = Imagekit::Models::Files + + class FileUpdateParams = Imagekit::Models::FileUpdateParams + + class FileUploadParams = Imagekit::Models::FileUploadParams + + class Folder = Imagekit::Models::Folder + + class FolderCopyParams = Imagekit::Models::FolderCopyParams + + class FolderCreateParams = Imagekit::Models::FolderCreateParams + + class FolderDeleteParams = Imagekit::Models::FolderDeleteParams + + class FolderMoveParams = Imagekit::Models::FolderMoveParams + + class FolderRenameParams = Imagekit::Models::FolderRenameParams + + module Folders = Imagekit::Models::Folders + + class ImageOverlay = Imagekit::Models::ImageOverlay + + class Metadata = Imagekit::Models::Metadata + + module Overlay = Imagekit::Models::Overlay + + class OverlayPosition = Imagekit::Models::OverlayPosition + + class OverlayTiming = Imagekit::Models::OverlayTiming + + class SolidColorOverlay = Imagekit::Models::SolidColorOverlay + + class SolidColorOverlayTransformation = Imagekit::Models::SolidColorOverlayTransformation + + class SrcOptions = Imagekit::Models::SrcOptions + + module StreamingResolution = Imagekit::Models::StreamingResolution + + class SubtitleOverlay = Imagekit::Models::SubtitleOverlay + + class SubtitleOverlayTransformation = Imagekit::Models::SubtitleOverlayTransformation + + class TextOverlay = Imagekit::Models::TextOverlay + + class TextOverlayTransformation = Imagekit::Models::TextOverlayTransformation + + class Transformation = Imagekit::Models::Transformation + + module TransformationPosition = Imagekit::Models::TransformationPosition + + module UnsafeUnwrapWebhookEvent = Imagekit::Models::UnsafeUnwrapWebhookEvent + + module UnwrapWebhookEvent = Imagekit::Models::UnwrapWebhookEvent + + module UpdateFileRequest = Imagekit::Models::UpdateFileRequest + + class UploadPostTransformErrorEvent = Imagekit::Models::UploadPostTransformErrorEvent + + class UploadPostTransformSuccessEvent = Imagekit::Models::UploadPostTransformSuccessEvent + + class UploadPreTransformErrorEvent = Imagekit::Models::UploadPreTransformErrorEvent + + class UploadPreTransformSuccessEvent = Imagekit::Models::UploadPreTransformSuccessEvent + + class VideoOverlay = Imagekit::Models::VideoOverlay + + class VideoTransformationAcceptedEvent = Imagekit::Models::VideoTransformationAcceptedEvent + + class VideoTransformationErrorEvent = Imagekit::Models::VideoTransformationErrorEvent + + class VideoTransformationReadyEvent = Imagekit::Models::VideoTransformationReadyEvent + + class WebhookUnsafeUnwrapParams = Imagekit::Models::WebhookUnsafeUnwrapParams + + class WebhookUnwrapParams = Imagekit::Models::WebhookUnwrapParams +end diff --git a/sig/imagekit/models/accounts/origin_create_params.rbs b/sig/imagekit/models/accounts/origin_create_params.rbs new file mode 100644 index 00000000..a51e6472 --- /dev/null +++ b/sig/imagekit/models/accounts/origin_create_params.rbs @@ -0,0 +1,30 @@ +module Imagekit + module Models + module Accounts + type origin_create_params = + { origin_request: Imagekit::Models::Accounts::origin_request } + & Imagekit::Internal::Type::request_parameters + + class OriginCreateParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + def origin_request: -> Imagekit::Models::Accounts::origin_request + + def origin_request=: ( + Imagekit::Models::Accounts::origin_request _ + ) -> Imagekit::Models::Accounts::origin_request + + def initialize: ( + origin_request: Imagekit::Models::Accounts::origin_request, + ?request_options: Imagekit::request_opts + ) -> void + + def to_hash: -> { + origin_request: Imagekit::Models::Accounts::origin_request, + request_options: Imagekit::RequestOptions + } + end + end + end +end diff --git a/sig/imagekit/models/accounts/origin_delete_params.rbs b/sig/imagekit/models/accounts/origin_delete_params.rbs new file mode 100644 index 00000000..da2cff14 --- /dev/null +++ b/sig/imagekit/models/accounts/origin_delete_params.rbs @@ -0,0 +1,17 @@ +module Imagekit + module Models + module Accounts + type origin_delete_params = + { } & Imagekit::Internal::Type::request_parameters + + class OriginDeleteParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + def initialize: (?request_options: Imagekit::request_opts) -> void + + def to_hash: -> { request_options: Imagekit::RequestOptions } + end + end + end +end diff --git a/sig/imagekit/models/accounts/origin_get_params.rbs b/sig/imagekit/models/accounts/origin_get_params.rbs new file mode 100644 index 00000000..b80c072e --- /dev/null +++ b/sig/imagekit/models/accounts/origin_get_params.rbs @@ -0,0 +1,17 @@ +module Imagekit + module Models + module Accounts + type origin_get_params = + { } & Imagekit::Internal::Type::request_parameters + + class OriginGetParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + def initialize: (?request_options: Imagekit::request_opts) -> void + + def to_hash: -> { request_options: Imagekit::RequestOptions } + end + end + end +end diff --git a/sig/imagekit/models/accounts/origin_list_params.rbs b/sig/imagekit/models/accounts/origin_list_params.rbs new file mode 100644 index 00000000..ea2e0350 --- /dev/null +++ b/sig/imagekit/models/accounts/origin_list_params.rbs @@ -0,0 +1,17 @@ +module Imagekit + module Models + module Accounts + type origin_list_params = + { } & Imagekit::Internal::Type::request_parameters + + class OriginListParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + def initialize: (?request_options: Imagekit::request_opts) -> void + + def to_hash: -> { request_options: Imagekit::RequestOptions } + end + end + end +end diff --git a/sig/imagekit/models/accounts/origin_list_response.rbs b/sig/imagekit/models/accounts/origin_list_response.rbs new file mode 100644 index 00000000..e689073a --- /dev/null +++ b/sig/imagekit/models/accounts/origin_list_response.rbs @@ -0,0 +1,10 @@ +module Imagekit + module Models + module Accounts + type origin_list_response = + ::Array[Imagekit::Models::Accounts::origin_response] + + OriginListResponse: Imagekit::Internal::Type::Converter + end + end +end diff --git a/sig/imagekit/models/accounts/origin_request.rbs b/sig/imagekit/models/accounts/origin_request.rbs new file mode 100644 index 00000000..2e5e7916 --- /dev/null +++ b/sig/imagekit/models/accounts/origin_request.rbs @@ -0,0 +1,468 @@ +module Imagekit + module Models + module Accounts + type origin_request = + Imagekit::Accounts::OriginRequest::S3 + | Imagekit::Accounts::OriginRequest::S3Compatible + | Imagekit::Accounts::OriginRequest::CloudinaryBackup + | Imagekit::Accounts::OriginRequest::WebFolder + | Imagekit::Accounts::OriginRequest::WebProxy + | Imagekit::Accounts::OriginRequest::Gcs + | Imagekit::Accounts::OriginRequest::AzureBlob + | Imagekit::Accounts::OriginRequest::AkeneoPim + + module OriginRequest + extend Imagekit::Internal::Type::Union + + type s3 = + { + access_key: String, + bucket: String, + name: String, + secret_key: String, + type: :S3, + base_url_for_canonical_header: String, + include_canonical_header: bool, + prefix: String + } + + class S3 < Imagekit::Internal::Type::BaseModel + attr_accessor access_key: String + + attr_accessor bucket: String + + attr_accessor name: String + + attr_accessor secret_key: String + + attr_accessor type: :S3 + + attr_reader base_url_for_canonical_header: String? + + def base_url_for_canonical_header=: (String) -> String + + attr_reader include_canonical_header: bool? + + def include_canonical_header=: (bool) -> bool + + attr_reader prefix: String? + + def prefix=: (String) -> String + + def initialize: ( + access_key: String, + bucket: String, + name: String, + secret_key: String, + ?base_url_for_canonical_header: String, + ?include_canonical_header: bool, + ?prefix: String, + ?type: :S3 + ) -> void + + def to_hash: -> { + access_key: String, + bucket: String, + name: String, + secret_key: String, + type: :S3, + base_url_for_canonical_header: String, + include_canonical_header: bool, + prefix: String + } + end + + type s3_compatible = + { + access_key: String, + bucket: String, + endpoint: String, + name: String, + secret_key: String, + type: :S3_COMPATIBLE, + base_url_for_canonical_header: String, + include_canonical_header: bool, + prefix: String, + :s3_force_path_style => bool + } + + class S3Compatible < Imagekit::Internal::Type::BaseModel + attr_accessor access_key: String + + attr_accessor bucket: String + + attr_accessor endpoint: String + + attr_accessor name: String + + attr_accessor secret_key: String + + attr_accessor type: :S3_COMPATIBLE + + attr_reader base_url_for_canonical_header: String? + + def base_url_for_canonical_header=: (String) -> String + + attr_reader include_canonical_header: bool? + + def include_canonical_header=: (bool) -> bool + + attr_reader prefix: String? + + def prefix=: (String) -> String + + attr_reader s3_force_path_style: bool? + + def s3_force_path_style=: (bool) -> bool + + def initialize: ( + access_key: String, + bucket: String, + endpoint: String, + name: String, + secret_key: String, + ?base_url_for_canonical_header: String, + ?include_canonical_header: bool, + ?prefix: String, + ?s3_force_path_style: bool, + ?type: :S3_COMPATIBLE + ) -> void + + def to_hash: -> { + access_key: String, + bucket: String, + endpoint: String, + name: String, + secret_key: String, + type: :S3_COMPATIBLE, + base_url_for_canonical_header: String, + include_canonical_header: bool, + prefix: String, + :s3_force_path_style => bool + } + end + + type cloudinary_backup = + { + access_key: String, + bucket: String, + name: String, + secret_key: String, + type: :CLOUDINARY_BACKUP, + base_url_for_canonical_header: String, + include_canonical_header: bool, + prefix: String + } + + class CloudinaryBackup < Imagekit::Internal::Type::BaseModel + attr_accessor access_key: String + + attr_accessor bucket: String + + attr_accessor name: String + + attr_accessor secret_key: String + + attr_accessor type: :CLOUDINARY_BACKUP + + attr_reader base_url_for_canonical_header: String? + + def base_url_for_canonical_header=: (String) -> String + + attr_reader include_canonical_header: bool? + + def include_canonical_header=: (bool) -> bool + + attr_reader prefix: String? + + def prefix=: (String) -> String + + def initialize: ( + access_key: String, + bucket: String, + name: String, + secret_key: String, + ?base_url_for_canonical_header: String, + ?include_canonical_header: bool, + ?prefix: String, + ?type: :CLOUDINARY_BACKUP + ) -> void + + def to_hash: -> { + access_key: String, + bucket: String, + name: String, + secret_key: String, + type: :CLOUDINARY_BACKUP, + base_url_for_canonical_header: String, + include_canonical_header: bool, + prefix: String + } + end + + type web_folder = + { + base_url: String, + name: String, + type: :WEB_FOLDER, + base_url_for_canonical_header: String, + forward_host_header_to_origin: bool, + include_canonical_header: bool + } + + class WebFolder < Imagekit::Internal::Type::BaseModel + attr_accessor base_url: String + + attr_accessor name: String + + attr_accessor type: :WEB_FOLDER + + attr_reader base_url_for_canonical_header: String? + + def base_url_for_canonical_header=: (String) -> String + + attr_reader forward_host_header_to_origin: bool? + + def forward_host_header_to_origin=: (bool) -> bool + + attr_reader include_canonical_header: bool? + + def include_canonical_header=: (bool) -> bool + + def initialize: ( + base_url: String, + name: String, + ?base_url_for_canonical_header: String, + ?forward_host_header_to_origin: bool, + ?include_canonical_header: bool, + ?type: :WEB_FOLDER + ) -> void + + def to_hash: -> { + base_url: String, + name: String, + type: :WEB_FOLDER, + base_url_for_canonical_header: String, + forward_host_header_to_origin: bool, + include_canonical_header: bool + } + end + + type web_proxy = + { + name: String, + type: :WEB_PROXY, + base_url_for_canonical_header: String, + include_canonical_header: bool + } + + class WebProxy < Imagekit::Internal::Type::BaseModel + attr_accessor name: String + + attr_accessor type: :WEB_PROXY + + attr_reader base_url_for_canonical_header: String? + + def base_url_for_canonical_header=: (String) -> String + + attr_reader include_canonical_header: bool? + + def include_canonical_header=: (bool) -> bool + + def initialize: ( + name: String, + ?base_url_for_canonical_header: String, + ?include_canonical_header: bool, + ?type: :WEB_PROXY + ) -> void + + def to_hash: -> { + name: String, + type: :WEB_PROXY, + base_url_for_canonical_header: String, + include_canonical_header: bool + } + end + + type gcs = + { + bucket: String, + client_email: String, + name: String, + private_key: String, + type: :GCS, + base_url_for_canonical_header: String, + include_canonical_header: bool, + prefix: String + } + + class Gcs < Imagekit::Internal::Type::BaseModel + attr_accessor bucket: String + + attr_accessor client_email: String + + attr_accessor name: String + + attr_accessor private_key: String + + attr_accessor type: :GCS + + attr_reader base_url_for_canonical_header: String? + + def base_url_for_canonical_header=: (String) -> String + + attr_reader include_canonical_header: bool? + + def include_canonical_header=: (bool) -> bool + + attr_reader prefix: String? + + def prefix=: (String) -> String + + def initialize: ( + bucket: String, + client_email: String, + name: String, + private_key: String, + ?base_url_for_canonical_header: String, + ?include_canonical_header: bool, + ?prefix: String, + ?type: :GCS + ) -> void + + def to_hash: -> { + bucket: String, + client_email: String, + name: String, + private_key: String, + type: :GCS, + base_url_for_canonical_header: String, + include_canonical_header: bool, + prefix: String + } + end + + type azure_blob = + { + account_name: String, + container: String, + name: String, + sas_token: String, + type: :AZURE_BLOB, + base_url_for_canonical_header: String, + include_canonical_header: bool, + prefix: String + } + + class AzureBlob < Imagekit::Internal::Type::BaseModel + attr_accessor account_name: String + + attr_accessor container: String + + attr_accessor name: String + + attr_accessor sas_token: String + + attr_accessor type: :AZURE_BLOB + + attr_reader base_url_for_canonical_header: String? + + def base_url_for_canonical_header=: (String) -> String + + attr_reader include_canonical_header: bool? + + def include_canonical_header=: (bool) -> bool + + attr_reader prefix: String? + + def prefix=: (String) -> String + + def initialize: ( + account_name: String, + container: String, + name: String, + sas_token: String, + ?base_url_for_canonical_header: String, + ?include_canonical_header: bool, + ?prefix: String, + ?type: :AZURE_BLOB + ) -> void + + def to_hash: -> { + account_name: String, + container: String, + name: String, + sas_token: String, + type: :AZURE_BLOB, + base_url_for_canonical_header: String, + include_canonical_header: bool, + prefix: String + } + end + + type akeneo_pim = + { + base_url: String, + client_id: String, + client_secret: String, + name: String, + password: String, + type: :AKENEO_PIM, + username: String, + base_url_for_canonical_header: String, + include_canonical_header: bool + } + + class AkeneoPim < Imagekit::Internal::Type::BaseModel + attr_accessor base_url: String + + attr_accessor client_id: String + + attr_accessor client_secret: String + + attr_accessor name: String + + attr_accessor password: String + + attr_accessor type: :AKENEO_PIM + + attr_accessor username: String + + attr_reader base_url_for_canonical_header: String? + + def base_url_for_canonical_header=: (String) -> String + + attr_reader include_canonical_header: bool? + + def include_canonical_header=: (bool) -> bool + + def initialize: ( + base_url: String, + client_id: String, + client_secret: String, + name: String, + password: String, + username: String, + ?base_url_for_canonical_header: String, + ?include_canonical_header: bool, + ?type: :AKENEO_PIM + ) -> void + + def to_hash: -> { + base_url: String, + client_id: String, + client_secret: String, + name: String, + password: String, + type: :AKENEO_PIM, + username: String, + base_url_for_canonical_header: String, + include_canonical_header: bool + } + end + + def self?.variants: -> ::Array[Imagekit::Models::Accounts::origin_request] + end + end + end +end diff --git a/sig/imagekit/models/accounts/origin_response.rbs b/sig/imagekit/models/accounts/origin_response.rbs new file mode 100644 index 00000000..bca52d65 --- /dev/null +++ b/sig/imagekit/models/accounts/origin_response.rbs @@ -0,0 +1,418 @@ +module Imagekit + module Models + module Accounts + type origin_response = + Imagekit::Accounts::OriginResponse::S3 + | Imagekit::Accounts::OriginResponse::S3Compatible + | Imagekit::Accounts::OriginResponse::CloudinaryBackup + | Imagekit::Accounts::OriginResponse::WebFolder + | Imagekit::Accounts::OriginResponse::WebProxy + | Imagekit::Accounts::OriginResponse::Gcs + | Imagekit::Accounts::OriginResponse::AzureBlob + | Imagekit::Accounts::OriginResponse::AkeneoPim + + module OriginResponse + extend Imagekit::Internal::Type::Union + + type s3 = + { + id: String, + bucket: String, + include_canonical_header: bool, + name: String, + prefix: String, + type: :S3, + base_url_for_canonical_header: String + } + + class S3 < Imagekit::Internal::Type::BaseModel + attr_accessor bucket: String + + attr_accessor include_canonical_header: bool + + attr_accessor name: String + + attr_accessor prefix: String + + attr_accessor type: :S3 + + attr_reader base_url_for_canonical_header: String? + + def base_url_for_canonical_header=: (String) -> String + + attr_accessor id: String + + def initialize: ( + id: String, + bucket: String, + include_canonical_header: bool, + name: String, + prefix: String, + ?base_url_for_canonical_header: String, + ?type: :S3 + ) -> void + + def to_hash: -> { + id: String, + bucket: String, + include_canonical_header: bool, + name: String, + prefix: String, + type: :S3, + base_url_for_canonical_header: String + } + end + + type s3_compatible = + { + id: String, + bucket: String, + endpoint: String, + include_canonical_header: bool, + name: String, + prefix: String, + :s3_force_path_style => bool, + type: :S3_COMPATIBLE, + base_url_for_canonical_header: String + } + + class S3Compatible < Imagekit::Internal::Type::BaseModel + attr_accessor bucket: String + + attr_accessor endpoint: String + + attr_accessor include_canonical_header: bool + + attr_accessor name: String + + attr_accessor prefix: String + + attr_accessor s3_force_path_style: bool + + attr_accessor type: :S3_COMPATIBLE + + attr_reader base_url_for_canonical_header: String? + + def base_url_for_canonical_header=: (String) -> String + + attr_accessor id: String + + def initialize: ( + id: String, + bucket: String, + endpoint: String, + include_canonical_header: bool, + name: String, + prefix: String, + s3_force_path_style: bool, + ?base_url_for_canonical_header: String, + ?type: :S3_COMPATIBLE + ) -> void + + def to_hash: -> { + id: String, + bucket: String, + endpoint: String, + include_canonical_header: bool, + name: String, + prefix: String, + :s3_force_path_style => bool, + type: :S3_COMPATIBLE, + base_url_for_canonical_header: String + } + end + + type cloudinary_backup = + { + id: String, + bucket: String, + include_canonical_header: bool, + name: String, + prefix: String, + type: :CLOUDINARY_BACKUP, + base_url_for_canonical_header: String + } + + class CloudinaryBackup < Imagekit::Internal::Type::BaseModel + attr_accessor bucket: String + + attr_accessor include_canonical_header: bool + + attr_accessor name: String + + attr_accessor prefix: String + + attr_accessor type: :CLOUDINARY_BACKUP + + attr_reader base_url_for_canonical_header: String? + + def base_url_for_canonical_header=: (String) -> String + + attr_accessor id: String + + def initialize: ( + id: String, + bucket: String, + include_canonical_header: bool, + name: String, + prefix: String, + ?base_url_for_canonical_header: String, + ?type: :CLOUDINARY_BACKUP + ) -> void + + def to_hash: -> { + id: String, + bucket: String, + include_canonical_header: bool, + name: String, + prefix: String, + type: :CLOUDINARY_BACKUP, + base_url_for_canonical_header: String + } + end + + type web_folder = + { + id: String, + base_url: String, + forward_host_header_to_origin: bool, + include_canonical_header: bool, + name: String, + type: :WEB_FOLDER, + base_url_for_canonical_header: String + } + + class WebFolder < Imagekit::Internal::Type::BaseModel + attr_accessor base_url: String + + attr_accessor forward_host_header_to_origin: bool + + attr_accessor include_canonical_header: bool + + attr_accessor name: String + + attr_accessor type: :WEB_FOLDER + + attr_reader base_url_for_canonical_header: String? + + def base_url_for_canonical_header=: (String) -> String + + attr_accessor id: String + + def initialize: ( + id: String, + base_url: String, + forward_host_header_to_origin: bool, + include_canonical_header: bool, + name: String, + ?base_url_for_canonical_header: String, + ?type: :WEB_FOLDER + ) -> void + + def to_hash: -> { + id: String, + base_url: String, + forward_host_header_to_origin: bool, + include_canonical_header: bool, + name: String, + type: :WEB_FOLDER, + base_url_for_canonical_header: String + } + end + + type web_proxy = + { + id: String, + include_canonical_header: bool, + name: String, + type: :WEB_PROXY, + base_url_for_canonical_header: String + } + + class WebProxy < Imagekit::Internal::Type::BaseModel + attr_accessor include_canonical_header: bool + + attr_accessor name: String + + attr_accessor type: :WEB_PROXY + + attr_reader base_url_for_canonical_header: String? + + def base_url_for_canonical_header=: (String) -> String + + attr_accessor id: String + + def initialize: ( + id: String, + include_canonical_header: bool, + name: String, + ?base_url_for_canonical_header: String, + ?type: :WEB_PROXY + ) -> void + + def to_hash: -> { + id: String, + include_canonical_header: bool, + name: String, + type: :WEB_PROXY, + base_url_for_canonical_header: String + } + end + + type gcs = + { + id: String, + bucket: String, + client_email: String, + include_canonical_header: bool, + name: String, + prefix: String, + type: :GCS, + base_url_for_canonical_header: String + } + + class Gcs < Imagekit::Internal::Type::BaseModel + attr_accessor bucket: String + + attr_accessor client_email: String + + attr_accessor include_canonical_header: bool + + attr_accessor name: String + + attr_accessor prefix: String + + attr_accessor type: :GCS + + attr_reader base_url_for_canonical_header: String? + + def base_url_for_canonical_header=: (String) -> String + + attr_accessor id: String + + def initialize: ( + id: String, + bucket: String, + client_email: String, + include_canonical_header: bool, + name: String, + prefix: String, + ?base_url_for_canonical_header: String, + ?type: :GCS + ) -> void + + def to_hash: -> { + id: String, + bucket: String, + client_email: String, + include_canonical_header: bool, + name: String, + prefix: String, + type: :GCS, + base_url_for_canonical_header: String + } + end + + type azure_blob = + { + id: String, + account_name: String, + container: String, + include_canonical_header: bool, + name: String, + prefix: String, + type: :AZURE_BLOB, + base_url_for_canonical_header: String + } + + class AzureBlob < Imagekit::Internal::Type::BaseModel + attr_accessor account_name: String + + attr_accessor container: String + + attr_accessor include_canonical_header: bool + + attr_accessor name: String + + attr_accessor prefix: String + + attr_accessor type: :AZURE_BLOB + + attr_reader base_url_for_canonical_header: String? + + def base_url_for_canonical_header=: (String) -> String + + attr_accessor id: String + + def initialize: ( + id: String, + account_name: String, + container: String, + include_canonical_header: bool, + name: String, + prefix: String, + ?base_url_for_canonical_header: String, + ?type: :AZURE_BLOB + ) -> void + + def to_hash: -> { + id: String, + account_name: String, + container: String, + include_canonical_header: bool, + name: String, + prefix: String, + type: :AZURE_BLOB, + base_url_for_canonical_header: String + } + end + + type akeneo_pim = + { + id: String, + base_url: String, + include_canonical_header: bool, + name: String, + type: :AKENEO_PIM, + base_url_for_canonical_header: String + } + + class AkeneoPim < Imagekit::Internal::Type::BaseModel + attr_accessor base_url: String + + attr_accessor include_canonical_header: bool + + attr_accessor name: String + + attr_accessor type: :AKENEO_PIM + + attr_reader base_url_for_canonical_header: String? + + def base_url_for_canonical_header=: (String) -> String + + attr_accessor id: String + + def initialize: ( + id: String, + base_url: String, + include_canonical_header: bool, + name: String, + ?base_url_for_canonical_header: String, + ?type: :AKENEO_PIM + ) -> void + + def to_hash: -> { + id: String, + base_url: String, + include_canonical_header: bool, + name: String, + type: :AKENEO_PIM, + base_url_for_canonical_header: String + } + end + + def self?.variants: -> ::Array[Imagekit::Models::Accounts::origin_response] + end + end + end +end diff --git a/sig/imagekit/models/accounts/origin_update_params.rbs b/sig/imagekit/models/accounts/origin_update_params.rbs new file mode 100644 index 00000000..e6e08583 --- /dev/null +++ b/sig/imagekit/models/accounts/origin_update_params.rbs @@ -0,0 +1,30 @@ +module Imagekit + module Models + module Accounts + type origin_update_params = + { origin_request: Imagekit::Models::Accounts::origin_request } + & Imagekit::Internal::Type::request_parameters + + class OriginUpdateParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + def origin_request: -> Imagekit::Models::Accounts::origin_request + + def origin_request=: ( + Imagekit::Models::Accounts::origin_request _ + ) -> Imagekit::Models::Accounts::origin_request + + def initialize: ( + origin_request: Imagekit::Models::Accounts::origin_request, + ?request_options: Imagekit::request_opts + ) -> void + + def to_hash: -> { + origin_request: Imagekit::Models::Accounts::origin_request, + request_options: Imagekit::RequestOptions + } + end + end + end +end diff --git a/sig/imagekit/models/accounts/url_endpoint_create_params.rbs b/sig/imagekit/models/accounts/url_endpoint_create_params.rbs new file mode 100644 index 00000000..d657e79d --- /dev/null +++ b/sig/imagekit/models/accounts/url_endpoint_create_params.rbs @@ -0,0 +1,17 @@ +module Imagekit + module Models + module Accounts + type url_endpoint_create_params = + { } & Imagekit::Internal::Type::request_parameters + + class URLEndpointCreateParams < Imagekit::Models::Accounts::URLEndpointRequest + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + def initialize: (?request_options: Imagekit::request_opts) -> void + + def to_hash: -> { request_options: Imagekit::RequestOptions } + end + end + end +end diff --git a/sig/imagekit/models/accounts/url_endpoint_delete_params.rbs b/sig/imagekit/models/accounts/url_endpoint_delete_params.rbs new file mode 100644 index 00000000..ea88292a --- /dev/null +++ b/sig/imagekit/models/accounts/url_endpoint_delete_params.rbs @@ -0,0 +1,17 @@ +module Imagekit + module Models + module Accounts + type url_endpoint_delete_params = + { } & Imagekit::Internal::Type::request_parameters + + class URLEndpointDeleteParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + def initialize: (?request_options: Imagekit::request_opts) -> void + + def to_hash: -> { request_options: Imagekit::RequestOptions } + end + end + end +end diff --git a/sig/imagekit/models/accounts/url_endpoint_get_params.rbs b/sig/imagekit/models/accounts/url_endpoint_get_params.rbs new file mode 100644 index 00000000..f13c5bf6 --- /dev/null +++ b/sig/imagekit/models/accounts/url_endpoint_get_params.rbs @@ -0,0 +1,17 @@ +module Imagekit + module Models + module Accounts + type url_endpoint_get_params = + { } & Imagekit::Internal::Type::request_parameters + + class URLEndpointGetParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + def initialize: (?request_options: Imagekit::request_opts) -> void + + def to_hash: -> { request_options: Imagekit::RequestOptions } + end + end + end +end diff --git a/sig/imagekit/models/accounts/url_endpoint_list_params.rbs b/sig/imagekit/models/accounts/url_endpoint_list_params.rbs new file mode 100644 index 00000000..f90a121a --- /dev/null +++ b/sig/imagekit/models/accounts/url_endpoint_list_params.rbs @@ -0,0 +1,17 @@ +module Imagekit + module Models + module Accounts + type url_endpoint_list_params = + { } & Imagekit::Internal::Type::request_parameters + + class URLEndpointListParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + def initialize: (?request_options: Imagekit::request_opts) -> void + + def to_hash: -> { request_options: Imagekit::RequestOptions } + end + end + end +end diff --git a/sig/imagekit/models/accounts/url_endpoint_list_response.rbs b/sig/imagekit/models/accounts/url_endpoint_list_response.rbs new file mode 100644 index 00000000..01943b07 --- /dev/null +++ b/sig/imagekit/models/accounts/url_endpoint_list_response.rbs @@ -0,0 +1,10 @@ +module Imagekit + module Models + module Accounts + type url_endpoint_list_response = + ::Array[Imagekit::Accounts::URLEndpointResponse] + + URLEndpointListResponse: Imagekit::Internal::Type::Converter + end + end +end diff --git a/sig/imagekit/models/accounts/url_endpoint_request.rbs b/sig/imagekit/models/accounts/url_endpoint_request.rbs new file mode 100644 index 00000000..de0983f1 --- /dev/null +++ b/sig/imagekit/models/accounts/url_endpoint_request.rbs @@ -0,0 +1,97 @@ +module Imagekit + module Models + module Accounts + type url_endpoint_request = + { + description: String, + origins: ::Array[String], + url_prefix: String, + url_rewriter: Imagekit::Models::Accounts::URLEndpointRequest::url_rewriter + } + + class URLEndpointRequest < Imagekit::Internal::Type::BaseModel + attr_accessor description: String + + attr_reader origins: ::Array[String]? + + def origins=: (::Array[String]) -> ::Array[String] + + attr_reader url_prefix: String? + + def url_prefix=: (String) -> String + + attr_reader url_rewriter: Imagekit::Models::Accounts::URLEndpointRequest::url_rewriter? + + def url_rewriter=: ( + Imagekit::Models::Accounts::URLEndpointRequest::url_rewriter + ) -> Imagekit::Models::Accounts::URLEndpointRequest::url_rewriter + + def initialize: ( + description: String, + ?origins: ::Array[String], + ?url_prefix: String, + ?url_rewriter: Imagekit::Models::Accounts::URLEndpointRequest::url_rewriter + ) -> void + + def to_hash: -> { + description: String, + origins: ::Array[String], + url_prefix: String, + url_rewriter: Imagekit::Models::Accounts::URLEndpointRequest::url_rewriter + } + + type url_rewriter = + Imagekit::Accounts::URLEndpointRequest::URLRewriter::Cloudinary + | Imagekit::Accounts::URLEndpointRequest::URLRewriter::Imgix + | Imagekit::Accounts::URLEndpointRequest::URLRewriter::Akamai + + module URLRewriter + extend Imagekit::Internal::Type::Union + + type cloudinary = + { type: :CLOUDINARY, preserve_asset_delivery_types: bool } + + class Cloudinary < Imagekit::Internal::Type::BaseModel + attr_accessor type: :CLOUDINARY + + attr_reader preserve_asset_delivery_types: bool? + + def preserve_asset_delivery_types=: (bool) -> bool + + def initialize: ( + ?preserve_asset_delivery_types: bool, + ?type: :CLOUDINARY + ) -> void + + def to_hash: -> { + type: :CLOUDINARY, + preserve_asset_delivery_types: bool + } + end + + type imgix = { type: :IMGIX } + + class Imgix < Imagekit::Internal::Type::BaseModel + attr_accessor type: :IMGIX + + def initialize: (?type: :IMGIX) -> void + + def to_hash: -> { type: :IMGIX } + end + + type akamai = { type: :AKAMAI } + + class Akamai < Imagekit::Internal::Type::BaseModel + attr_accessor type: :AKAMAI + + def initialize: (?type: :AKAMAI) -> void + + def to_hash: -> { type: :AKAMAI } + end + + def self?.variants: -> ::Array[Imagekit::Models::Accounts::URLEndpointRequest::url_rewriter] + end + end + end + end +end diff --git a/sig/imagekit/models/accounts/url_endpoint_response.rbs b/sig/imagekit/models/accounts/url_endpoint_response.rbs new file mode 100644 index 00000000..8c2da016 --- /dev/null +++ b/sig/imagekit/models/accounts/url_endpoint_response.rbs @@ -0,0 +1,96 @@ +module Imagekit + module Models + module Accounts + type url_endpoint_response = + { + id: String, + description: String, + origins: ::Array[String], + url_prefix: String, + url_rewriter: Imagekit::Models::Accounts::URLEndpointResponse::url_rewriter + } + + class URLEndpointResponse < Imagekit::Internal::Type::BaseModel + attr_accessor description: String + + attr_accessor origins: ::Array[String] + + attr_accessor url_prefix: String + + attr_reader url_rewriter: Imagekit::Models::Accounts::URLEndpointResponse::url_rewriter? + + def url_rewriter=: ( + Imagekit::Models::Accounts::URLEndpointResponse::url_rewriter + ) -> Imagekit::Models::Accounts::URLEndpointResponse::url_rewriter + + attr_accessor id: String + + def initialize: ( + id: String, + description: String, + origins: ::Array[String], + url_prefix: String, + ?url_rewriter: Imagekit::Models::Accounts::URLEndpointResponse::url_rewriter + ) -> void + + def to_hash: -> { + id: String, + description: String, + origins: ::Array[String], + url_prefix: String, + url_rewriter: Imagekit::Models::Accounts::URLEndpointResponse::url_rewriter + } + + type url_rewriter = + Imagekit::Accounts::URLEndpointResponse::URLRewriter::Cloudinary + | Imagekit::Accounts::URLEndpointResponse::URLRewriter::Imgix + | Imagekit::Accounts::URLEndpointResponse::URLRewriter::Akamai + + module URLRewriter + extend Imagekit::Internal::Type::Union + + type cloudinary = + { preserve_asset_delivery_types: bool, type: :CLOUDINARY } + + class Cloudinary < Imagekit::Internal::Type::BaseModel + attr_accessor preserve_asset_delivery_types: bool + + attr_accessor type: :CLOUDINARY + + def initialize: ( + preserve_asset_delivery_types: bool, + ?type: :CLOUDINARY + ) -> void + + def to_hash: -> { + preserve_asset_delivery_types: bool, + type: :CLOUDINARY + } + end + + type imgix = { type: :IMGIX } + + class Imgix < Imagekit::Internal::Type::BaseModel + attr_accessor type: :IMGIX + + def initialize: (?type: :IMGIX) -> void + + def to_hash: -> { type: :IMGIX } + end + + type akamai = { type: :AKAMAI } + + class Akamai < Imagekit::Internal::Type::BaseModel + attr_accessor type: :AKAMAI + + def initialize: (?type: :AKAMAI) -> void + + def to_hash: -> { type: :AKAMAI } + end + + def self?.variants: -> ::Array[Imagekit::Models::Accounts::URLEndpointResponse::url_rewriter] + end + end + end + end +end diff --git a/sig/imagekit/models/accounts/url_endpoint_update_params.rbs b/sig/imagekit/models/accounts/url_endpoint_update_params.rbs new file mode 100644 index 00000000..0989d858 --- /dev/null +++ b/sig/imagekit/models/accounts/url_endpoint_update_params.rbs @@ -0,0 +1,17 @@ +module Imagekit + module Models + module Accounts + type url_endpoint_update_params = + { } & Imagekit::Internal::Type::request_parameters + + class URLEndpointUpdateParams < Imagekit::Models::Accounts::URLEndpointRequest + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + def initialize: (?request_options: Imagekit::request_opts) -> void + + def to_hash: -> { request_options: Imagekit::RequestOptions } + end + end + end +end diff --git a/sig/imagekit/models/accounts/usage_get_params.rbs b/sig/imagekit/models/accounts/usage_get_params.rbs new file mode 100644 index 00000000..b5ea8183 --- /dev/null +++ b/sig/imagekit/models/accounts/usage_get_params.rbs @@ -0,0 +1,30 @@ +module Imagekit + module Models + module Accounts + type usage_get_params = + { end_date: Date, start_date: Date } + & Imagekit::Internal::Type::request_parameters + + class UsageGetParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + attr_accessor end_date: Date + + attr_accessor start_date: Date + + def initialize: ( + end_date: Date, + start_date: Date, + ?request_options: Imagekit::request_opts + ) -> void + + def to_hash: -> { + end_date: Date, + start_date: Date, + request_options: Imagekit::RequestOptions + } + end + end + end +end diff --git a/sig/imagekit/models/accounts/usage_get_response.rbs b/sig/imagekit/models/accounts/usage_get_response.rbs new file mode 100644 index 00000000..8b11aae0 --- /dev/null +++ b/sig/imagekit/models/accounts/usage_get_response.rbs @@ -0,0 +1,52 @@ +module Imagekit + module Models + module Accounts + type usage_get_response = + { + bandwidth_bytes: Integer, + extension_units_count: Integer, + media_library_storage_bytes: Integer, + original_cache_storage_bytes: Integer, + video_processing_units_count: Integer + } + + class UsageGetResponse < Imagekit::Internal::Type::BaseModel + attr_reader bandwidth_bytes: Integer? + + def bandwidth_bytes=: (Integer) -> Integer + + attr_reader extension_units_count: Integer? + + def extension_units_count=: (Integer) -> Integer + + attr_reader media_library_storage_bytes: Integer? + + def media_library_storage_bytes=: (Integer) -> Integer + + attr_reader original_cache_storage_bytes: Integer? + + def original_cache_storage_bytes=: (Integer) -> Integer + + attr_reader video_processing_units_count: Integer? + + def video_processing_units_count=: (Integer) -> Integer + + def initialize: ( + ?bandwidth_bytes: Integer, + ?extension_units_count: Integer, + ?media_library_storage_bytes: Integer, + ?original_cache_storage_bytes: Integer, + ?video_processing_units_count: Integer + ) -> void + + def to_hash: -> { + bandwidth_bytes: Integer, + extension_units_count: Integer, + media_library_storage_bytes: Integer, + original_cache_storage_bytes: Integer, + video_processing_units_count: Integer + } + end + end + end +end diff --git a/sig/imagekit/models/asset_list_params.rbs b/sig/imagekit/models/asset_list_params.rbs new file mode 100644 index 00000000..21cd33ef --- /dev/null +++ b/sig/imagekit/models/asset_list_params.rbs @@ -0,0 +1,138 @@ +module Imagekit + module Models + type asset_list_params = + { + file_type: Imagekit::Models::AssetListParams::file_type, + limit: Integer, + path: String, + search_query: String, + skip: Integer, + sort: Imagekit::Models::AssetListParams::sort, + type: Imagekit::Models::AssetListParams::type_ + } + & Imagekit::Internal::Type::request_parameters + + class AssetListParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + attr_reader file_type: Imagekit::Models::AssetListParams::file_type? + + def file_type=: ( + Imagekit::Models::AssetListParams::file_type + ) -> Imagekit::Models::AssetListParams::file_type + + attr_reader limit: Integer? + + def limit=: (Integer) -> Integer + + attr_reader path: String? + + def path=: (String) -> String + + attr_reader search_query: String? + + def search_query=: (String) -> String + + attr_reader skip: Integer? + + def skip=: (Integer) -> Integer + + attr_reader sort: Imagekit::Models::AssetListParams::sort? + + def sort=: ( + Imagekit::Models::AssetListParams::sort + ) -> Imagekit::Models::AssetListParams::sort + + attr_reader type: Imagekit::Models::AssetListParams::type_? + + def type=: ( + Imagekit::Models::AssetListParams::type_ + ) -> Imagekit::Models::AssetListParams::type_ + + def initialize: ( + ?file_type: Imagekit::Models::AssetListParams::file_type, + ?limit: Integer, + ?path: String, + ?search_query: String, + ?skip: Integer, + ?sort: Imagekit::Models::AssetListParams::sort, + ?type: Imagekit::Models::AssetListParams::type_, + ?request_options: Imagekit::request_opts + ) -> void + + def to_hash: -> { + file_type: Imagekit::Models::AssetListParams::file_type, + limit: Integer, + path: String, + search_query: String, + skip: Integer, + sort: Imagekit::Models::AssetListParams::sort, + type: Imagekit::Models::AssetListParams::type_, + request_options: Imagekit::RequestOptions + } + + type file_type = :all | :image | :"non-image" + + module FileType + extend Imagekit::Internal::Type::Enum + + ALL: :all + IMAGE: :image + NON_IMAGE: :"non-image" + + def self?.values: -> ::Array[Imagekit::Models::AssetListParams::file_type] + end + + type sort = + :ASC_NAME + | :DESC_NAME + | :ASC_CREATED + | :DESC_CREATED + | :ASC_UPDATED + | :DESC_UPDATED + | :ASC_HEIGHT + | :DESC_HEIGHT + | :ASC_WIDTH + | :DESC_WIDTH + | :ASC_SIZE + | :DESC_SIZE + | :ASC_RELEVANCE + | :DESC_RELEVANCE + + module Sort + extend Imagekit::Internal::Type::Enum + + ASC_NAME: :ASC_NAME + DESC_NAME: :DESC_NAME + ASC_CREATED: :ASC_CREATED + DESC_CREATED: :DESC_CREATED + ASC_UPDATED: :ASC_UPDATED + DESC_UPDATED: :DESC_UPDATED + ASC_HEIGHT: :ASC_HEIGHT + DESC_HEIGHT: :DESC_HEIGHT + ASC_WIDTH: :ASC_WIDTH + DESC_WIDTH: :DESC_WIDTH + ASC_SIZE: :ASC_SIZE + DESC_SIZE: :DESC_SIZE + ASC_RELEVANCE: :ASC_RELEVANCE + DESC_RELEVANCE: :DESC_RELEVANCE + + def self?.values: -> ::Array[Imagekit::Models::AssetListParams::sort] + end + + type type_ = :file | :"file-version" | :folder | :all + + module Type + extend Imagekit::Internal::Type::Enum + + FILE: :file + FILE_VERSION: :"file-version" + FOLDER: :folder + ALL: :all + + def self?.values: -> ::Array[Imagekit::Models::AssetListParams::type_] + end + end + end +end diff --git a/sig/imagekit/models/asset_list_response.rbs b/sig/imagekit/models/asset_list_response.rbs new file mode 100644 index 00000000..f60e52fd --- /dev/null +++ b/sig/imagekit/models/asset_list_response.rbs @@ -0,0 +1,16 @@ +module Imagekit + module Models + type asset_list_response_item = Imagekit::Folder | Imagekit::File + + module AssetListResponseItem + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::asset_list_response_item] + end + + type asset_list_response = + ::Array[Imagekit::Models::asset_list_response_item] + + AssetListResponse: Imagekit::Internal::Type::Converter + end +end diff --git a/sig/imagekit/models/base_overlay.rbs b/sig/imagekit/models/base_overlay.rbs new file mode 100644 index 00000000..5b012352 --- /dev/null +++ b/sig/imagekit/models/base_overlay.rbs @@ -0,0 +1,26 @@ +module Imagekit + module Models + type base_overlay = + { position: Imagekit::OverlayPosition, timing: Imagekit::OverlayTiming } + + class BaseOverlay < Imagekit::Internal::Type::BaseModel + attr_reader position: Imagekit::OverlayPosition? + + def position=: (Imagekit::OverlayPosition) -> Imagekit::OverlayPosition + + attr_reader timing: Imagekit::OverlayTiming? + + def timing=: (Imagekit::OverlayTiming) -> Imagekit::OverlayTiming + + def initialize: ( + ?position: Imagekit::OverlayPosition, + ?timing: Imagekit::OverlayTiming + ) -> void + + def to_hash: -> { + position: Imagekit::OverlayPosition, + timing: Imagekit::OverlayTiming + } + end + end +end diff --git a/sig/imagekit/models/base_webhook_event.rbs b/sig/imagekit/models/base_webhook_event.rbs new file mode 100644 index 00000000..287ff9cc --- /dev/null +++ b/sig/imagekit/models/base_webhook_event.rbs @@ -0,0 +1,15 @@ +module Imagekit + module Models + type base_webhook_event = { id: String, type: String } + + class BaseWebhookEvent < Imagekit::Internal::Type::BaseModel + attr_accessor id: String + + attr_accessor type: String + + def initialize: (id: String, type: String) -> void + + def to_hash: -> { id: String, type: String } + end + end +end diff --git a/sig/imagekit/models/beta/v2/file_upload_params.rbs b/sig/imagekit/models/beta/v2/file_upload_params.rbs new file mode 100644 index 00000000..d9f7ef7f --- /dev/null +++ b/sig/imagekit/models/beta/v2/file_upload_params.rbs @@ -0,0 +1,308 @@ +module Imagekit + module Models + module Beta + module V2 + type file_upload_params = + { + file: Imagekit::Internal::file_input, + file_name: String, + token: String, + checks: String, + custom_coordinates: String, + custom_metadata: ::Hash[Symbol, top], + description: String, + extensions: Imagekit::Models::extensions, + folder: String, + is_private_file: bool, + is_published: bool, + overwrite_ai_tags: bool, + overwrite_custom_metadata: bool, + overwrite_file: bool, + overwrite_tags: bool, + response_fields: ::Array[Imagekit::Models::Beta::V2::FileUploadParams::response_field], + tags: ::Array[String], + transformation: Imagekit::Beta::V2::FileUploadParams::Transformation, + use_unique_file_name: bool, + webhook_url: String + } + & Imagekit::Internal::Type::request_parameters + + class FileUploadParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + attr_accessor file: Imagekit::Internal::file_input + + attr_accessor file_name: String + + attr_reader token: String? + + def token=: (String) -> String + + attr_reader checks: String? + + def checks=: (String) -> String + + attr_reader custom_coordinates: String? + + def custom_coordinates=: (String) -> String + + attr_reader custom_metadata: ::Hash[Symbol, top]? + + def custom_metadata=: (::Hash[Symbol, top]) -> ::Hash[Symbol, top] + + attr_reader description: String? + + def description=: (String) -> String + + attr_reader extensions: Imagekit::Models::extensions? + + def extensions=: ( + Imagekit::Models::extensions + ) -> Imagekit::Models::extensions + + attr_reader folder: String? + + def folder=: (String) -> String + + attr_reader is_private_file: bool? + + def is_private_file=: (bool) -> bool + + attr_reader is_published: bool? + + def is_published=: (bool) -> bool + + attr_reader overwrite_ai_tags: bool? + + def overwrite_ai_tags=: (bool) -> bool + + attr_reader overwrite_custom_metadata: bool? + + def overwrite_custom_metadata=: (bool) -> bool + + attr_reader overwrite_file: bool? + + def overwrite_file=: (bool) -> bool + + attr_reader overwrite_tags: bool? + + def overwrite_tags=: (bool) -> bool + + attr_reader response_fields: ::Array[Imagekit::Models::Beta::V2::FileUploadParams::response_field]? + + def response_fields=: ( + ::Array[Imagekit::Models::Beta::V2::FileUploadParams::response_field] + ) -> ::Array[Imagekit::Models::Beta::V2::FileUploadParams::response_field] + + attr_reader tags: ::Array[String]? + + def tags=: (::Array[String]) -> ::Array[String] + + attr_reader transformation: Imagekit::Beta::V2::FileUploadParams::Transformation? + + def transformation=: ( + Imagekit::Beta::V2::FileUploadParams::Transformation + ) -> Imagekit::Beta::V2::FileUploadParams::Transformation + + attr_reader use_unique_file_name: bool? + + def use_unique_file_name=: (bool) -> bool + + attr_reader webhook_url: String? + + def webhook_url=: (String) -> String + + def initialize: ( + file: Imagekit::Internal::file_input, + file_name: String, + ?token: String, + ?checks: String, + ?custom_coordinates: String, + ?custom_metadata: ::Hash[Symbol, top], + ?description: String, + ?extensions: Imagekit::Models::extensions, + ?folder: String, + ?is_private_file: bool, + ?is_published: bool, + ?overwrite_ai_tags: bool, + ?overwrite_custom_metadata: bool, + ?overwrite_file: bool, + ?overwrite_tags: bool, + ?response_fields: ::Array[Imagekit::Models::Beta::V2::FileUploadParams::response_field], + ?tags: ::Array[String], + ?transformation: Imagekit::Beta::V2::FileUploadParams::Transformation, + ?use_unique_file_name: bool, + ?webhook_url: String, + ?request_options: Imagekit::request_opts + ) -> void + + def to_hash: -> { + file: Imagekit::Internal::file_input, + file_name: String, + token: String, + checks: String, + custom_coordinates: String, + custom_metadata: ::Hash[Symbol, top], + description: String, + extensions: Imagekit::Models::extensions, + folder: String, + is_private_file: bool, + is_published: bool, + overwrite_ai_tags: bool, + overwrite_custom_metadata: bool, + overwrite_file: bool, + overwrite_tags: bool, + response_fields: ::Array[Imagekit::Models::Beta::V2::FileUploadParams::response_field], + tags: ::Array[String], + transformation: Imagekit::Beta::V2::FileUploadParams::Transformation, + use_unique_file_name: bool, + webhook_url: String, + request_options: Imagekit::RequestOptions + } + + type response_field = + :tags + | :customCoordinates + | :isPrivateFile + | :embeddedMetadata + | :isPublished + | :customMetadata + | :metadata + + module ResponseField + extend Imagekit::Internal::Type::Enum + + TAGS: :tags + CUSTOM_COORDINATES: :customCoordinates + IS_PRIVATE_FILE: :isPrivateFile + EMBEDDED_METADATA: :embeddedMetadata + IS_PUBLISHED: :isPublished + CUSTOM_METADATA: :customMetadata + METADATA: :metadata + + def self?.values: -> ::Array[Imagekit::Models::Beta::V2::FileUploadParams::response_field] + end + + type transformation = + { + post: ::Array[Imagekit::Models::Beta::V2::FileUploadParams::Transformation::post], + pre: String + } + + class Transformation < Imagekit::Internal::Type::BaseModel + attr_reader post: ::Array[Imagekit::Models::Beta::V2::FileUploadParams::Transformation::post]? + + def post=: ( + ::Array[Imagekit::Models::Beta::V2::FileUploadParams::Transformation::post] + ) -> ::Array[Imagekit::Models::Beta::V2::FileUploadParams::Transformation::post] + + attr_reader pre: String? + + def pre=: (String) -> String + + def initialize: ( + ?post: ::Array[Imagekit::Models::Beta::V2::FileUploadParams::Transformation::post], + ?pre: String + ) -> void + + def to_hash: -> { + post: ::Array[Imagekit::Models::Beta::V2::FileUploadParams::Transformation::post], + pre: String + } + + type post = + Imagekit::Beta::V2::FileUploadParams::Transformation::Post::Transformation + | Imagekit::Beta::V2::FileUploadParams::Transformation::Post::GifToVideo + | Imagekit::Beta::V2::FileUploadParams::Transformation::Post::Thumbnail + | Imagekit::Beta::V2::FileUploadParams::Transformation::Post::Abs + + module Post + extend Imagekit::Internal::Type::Union + + type transformation = { type: :transformation, value: String } + + class Transformation < Imagekit::Internal::Type::BaseModel + attr_accessor type: :transformation + + attr_accessor value: String + + def initialize: (value: String, ?type: :transformation) -> void + + def to_hash: -> { type: :transformation, value: String } + end + + type gif_to_video = { type: :"gif-to-video", value: String } + + class GifToVideo < Imagekit::Internal::Type::BaseModel + attr_accessor type: :"gif-to-video" + + attr_reader value: String? + + def value=: (String) -> String + + def initialize: (?value: String, ?type: :"gif-to-video") -> void + + def to_hash: -> { type: :"gif-to-video", value: String } + end + + type thumbnail = { type: :thumbnail, value: String } + + class Thumbnail < Imagekit::Internal::Type::BaseModel + attr_accessor type: :thumbnail + + attr_reader value: String? + + def value=: (String) -> String + + def initialize: (?value: String, ?type: :thumbnail) -> void + + def to_hash: -> { type: :thumbnail, value: String } + end + + type abs = + { + protocol: Imagekit::Models::Beta::V2::FileUploadParams::Transformation::Post::Abs::protocol, + type: :abs, + value: String + } + + class Abs < Imagekit::Internal::Type::BaseModel + attr_accessor protocol: Imagekit::Models::Beta::V2::FileUploadParams::Transformation::Post::Abs::protocol + + attr_accessor type: :abs + + attr_accessor value: String + + def initialize: ( + protocol: Imagekit::Models::Beta::V2::FileUploadParams::Transformation::Post::Abs::protocol, + value: String, + ?type: :abs + ) -> void + + def to_hash: -> { + protocol: Imagekit::Models::Beta::V2::FileUploadParams::Transformation::Post::Abs::protocol, + type: :abs, + value: String + } + + type protocol = :hls | :dash + + module Protocol + extend Imagekit::Internal::Type::Enum + + HLS: :hls + DASH: :dash + + def self?.values: -> ::Array[Imagekit::Models::Beta::V2::FileUploadParams::Transformation::Post::Abs::protocol] + end + end + + def self?.variants: -> ::Array[Imagekit::Models::Beta::V2::FileUploadParams::Transformation::post] + end + end + end + end + end + end +end diff --git a/sig/imagekit/models/beta/v2/file_upload_response.rbs b/sig/imagekit/models/beta/v2/file_upload_response.rbs new file mode 100644 index 00000000..3955ca0d --- /dev/null +++ b/sig/imagekit/models/beta/v2/file_upload_response.rbs @@ -0,0 +1,321 @@ +module Imagekit + module Models + module Beta + module V2 + type file_upload_response = + { + ai_tags: ::Array[Imagekit::Models::Beta::V2::FileUploadResponse::AITag]?, + audio_codec: String, + bit_rate: Integer, + custom_coordinates: String?, + custom_metadata: ::Hash[Symbol, top], + description: String, + duration: Integer, + embedded_metadata: ::Hash[Symbol, top], + extension_status: Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus, + file_id: String, + file_path: String, + file_type: String, + height: Float, + is_private_file: bool, + is_published: bool, + metadata: Imagekit::Metadata, + name: String, + size: Float, + tags: ::Array[String]?, + thumbnail_url: String, + url: String, + version_info: Imagekit::Models::Beta::V2::FileUploadResponse::VersionInfo, + video_codec: String, + width: Float + } + + class FileUploadResponse < Imagekit::Internal::Type::BaseModel + attr_accessor ai_tags: ::Array[Imagekit::Models::Beta::V2::FileUploadResponse::AITag]? + + attr_reader audio_codec: String? + + def audio_codec=: (String) -> String + + attr_reader bit_rate: Integer? + + def bit_rate=: (Integer) -> Integer + + attr_accessor custom_coordinates: String? + + attr_reader custom_metadata: ::Hash[Symbol, top]? + + def custom_metadata=: (::Hash[Symbol, top]) -> ::Hash[Symbol, top] + + attr_reader description: String? + + def description=: (String) -> String + + attr_reader duration: Integer? + + def duration=: (Integer) -> Integer + + attr_reader embedded_metadata: ::Hash[Symbol, top]? + + def embedded_metadata=: (::Hash[Symbol, top]) -> ::Hash[Symbol, top] + + attr_reader extension_status: Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus? + + def extension_status=: ( + Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus + ) -> Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus + + attr_reader file_id: String? + + def file_id=: (String) -> String + + attr_reader file_path: String? + + def file_path=: (String) -> String + + attr_reader file_type: String? + + def file_type=: (String) -> String + + attr_reader height: Float? + + def height=: (Float) -> Float + + attr_reader is_private_file: bool? + + def is_private_file=: (bool) -> bool + + attr_reader is_published: bool? + + def is_published=: (bool) -> bool + + attr_reader metadata: Imagekit::Metadata? + + def metadata=: (Imagekit::Metadata) -> Imagekit::Metadata + + attr_reader name: String? + + def name=: (String) -> String + + attr_reader size: Float? + + def size=: (Float) -> Float + + attr_accessor tags: ::Array[String]? + + attr_reader thumbnail_url: String? + + def thumbnail_url=: (String) -> String + + attr_reader url: String? + + def url=: (String) -> String + + attr_reader version_info: Imagekit::Models::Beta::V2::FileUploadResponse::VersionInfo? + + def version_info=: ( + Imagekit::Models::Beta::V2::FileUploadResponse::VersionInfo + ) -> Imagekit::Models::Beta::V2::FileUploadResponse::VersionInfo + + attr_reader video_codec: String? + + def video_codec=: (String) -> String + + attr_reader width: Float? + + def width=: (Float) -> Float + + def initialize: ( + ?ai_tags: ::Array[Imagekit::Models::Beta::V2::FileUploadResponse::AITag]?, + ?audio_codec: String, + ?bit_rate: Integer, + ?custom_coordinates: String?, + ?custom_metadata: ::Hash[Symbol, top], + ?description: String, + ?duration: Integer, + ?embedded_metadata: ::Hash[Symbol, top], + ?extension_status: Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus, + ?file_id: String, + ?file_path: String, + ?file_type: String, + ?height: Float, + ?is_private_file: bool, + ?is_published: bool, + ?metadata: Imagekit::Metadata, + ?name: String, + ?size: Float, + ?tags: ::Array[String]?, + ?thumbnail_url: String, + ?url: String, + ?version_info: Imagekit::Models::Beta::V2::FileUploadResponse::VersionInfo, + ?video_codec: String, + ?width: Float + ) -> void + + def to_hash: -> { + ai_tags: ::Array[Imagekit::Models::Beta::V2::FileUploadResponse::AITag]?, + audio_codec: String, + bit_rate: Integer, + custom_coordinates: String?, + custom_metadata: ::Hash[Symbol, top], + description: String, + duration: Integer, + embedded_metadata: ::Hash[Symbol, top], + extension_status: Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus, + file_id: String, + file_path: String, + file_type: String, + height: Float, + is_private_file: bool, + is_published: bool, + metadata: Imagekit::Metadata, + name: String, + size: Float, + tags: ::Array[String]?, + thumbnail_url: String, + url: String, + version_info: Imagekit::Models::Beta::V2::FileUploadResponse::VersionInfo, + video_codec: String, + width: Float + } + + type ai_tag = { confidence: Float, name: String, source: String } + + class AITag < Imagekit::Internal::Type::BaseModel + attr_reader confidence: Float? + + def confidence=: (Float) -> Float + + attr_reader name: String? + + def name=: (String) -> String + + attr_reader source: String? + + def source=: (String) -> String + + def initialize: ( + ?confidence: Float, + ?name: String, + ?source: String + ) -> void + + def to_hash: -> { confidence: Float, name: String, source: String } + end + + type extension_status = + { + ai_auto_description: Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::ai_auto_description, + aws_auto_tagging: Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::aws_auto_tagging, + google_auto_tagging: Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::google_auto_tagging, + remove_bg: Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::remove_bg + } + + class ExtensionStatus < Imagekit::Internal::Type::BaseModel + attr_reader ai_auto_description: Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::ai_auto_description? + + def ai_auto_description=: ( + Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::ai_auto_description + ) -> Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::ai_auto_description + + attr_reader aws_auto_tagging: Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::aws_auto_tagging? + + def aws_auto_tagging=: ( + Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::aws_auto_tagging + ) -> Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::aws_auto_tagging + + attr_reader google_auto_tagging: Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::google_auto_tagging? + + def google_auto_tagging=: ( + Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::google_auto_tagging + ) -> Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::google_auto_tagging + + attr_reader remove_bg: Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::remove_bg? + + def remove_bg=: ( + Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::remove_bg + ) -> Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::remove_bg + + def initialize: ( + ?ai_auto_description: Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::ai_auto_description, + ?aws_auto_tagging: Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::aws_auto_tagging, + ?google_auto_tagging: Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::google_auto_tagging, + ?remove_bg: Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::remove_bg + ) -> void + + def to_hash: -> { + ai_auto_description: Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::ai_auto_description, + aws_auto_tagging: Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::aws_auto_tagging, + google_auto_tagging: Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::google_auto_tagging, + remove_bg: Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::remove_bg + } + + type ai_auto_description = :success | :pending | :failed + + module AIAutoDescription + extend Imagekit::Internal::Type::Enum + + SUCCESS: :success + PENDING: :pending + FAILED: :failed + + def self?.values: -> ::Array[Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::ai_auto_description] + end + + type aws_auto_tagging = :success | :pending | :failed + + module AwsAutoTagging + extend Imagekit::Internal::Type::Enum + + SUCCESS: :success + PENDING: :pending + FAILED: :failed + + def self?.values: -> ::Array[Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::aws_auto_tagging] + end + + type google_auto_tagging = :success | :pending | :failed + + module GoogleAutoTagging + extend Imagekit::Internal::Type::Enum + + SUCCESS: :success + PENDING: :pending + FAILED: :failed + + def self?.values: -> ::Array[Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::google_auto_tagging] + end + + type remove_bg = :success | :pending | :failed + + module RemoveBg + extend Imagekit::Internal::Type::Enum + + SUCCESS: :success + PENDING: :pending + FAILED: :failed + + def self?.values: -> ::Array[Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus::remove_bg] + end + end + + type version_info = { id: String, name: String } + + class VersionInfo < Imagekit::Internal::Type::BaseModel + attr_reader id: String? + + def id=: (String) -> String + + attr_reader name: String? + + def name=: (String) -> String + + def initialize: (?id: String, ?name: String) -> void + + def to_hash: -> { id: String, name: String } + end + end + end + end + end +end diff --git a/sig/imagekit/models/cache/invalidation_create_params.rbs b/sig/imagekit/models/cache/invalidation_create_params.rbs new file mode 100644 index 00000000..6bd7b3d4 --- /dev/null +++ b/sig/imagekit/models/cache/invalidation_create_params.rbs @@ -0,0 +1,25 @@ +module Imagekit + module Models + module Cache + type invalidation_create_params = + { url: String } & Imagekit::Internal::Type::request_parameters + + class InvalidationCreateParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + attr_accessor url: String + + def initialize: ( + url: String, + ?request_options: Imagekit::request_opts + ) -> void + + def to_hash: -> { + url: String, + request_options: Imagekit::RequestOptions + } + end + end + end +end diff --git a/sig/imagekit/models/cache/invalidation_create_response.rbs b/sig/imagekit/models/cache/invalidation_create_response.rbs new file mode 100644 index 00000000..9e40cc12 --- /dev/null +++ b/sig/imagekit/models/cache/invalidation_create_response.rbs @@ -0,0 +1,17 @@ +module Imagekit + module Models + module Cache + type invalidation_create_response = { request_id: String } + + class InvalidationCreateResponse < Imagekit::Internal::Type::BaseModel + attr_reader request_id: String? + + def request_id=: (String) -> String + + def initialize: (?request_id: String) -> void + + def to_hash: -> { request_id: String } + end + end + end +end diff --git a/sig/imagekit/models/cache/invalidation_get_params.rbs b/sig/imagekit/models/cache/invalidation_get_params.rbs new file mode 100644 index 00000000..ff6bb012 --- /dev/null +++ b/sig/imagekit/models/cache/invalidation_get_params.rbs @@ -0,0 +1,17 @@ +module Imagekit + module Models + module Cache + type invalidation_get_params = + { } & Imagekit::Internal::Type::request_parameters + + class InvalidationGetParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + def initialize: (?request_options: Imagekit::request_opts) -> void + + def to_hash: -> { request_options: Imagekit::RequestOptions } + end + end + end +end diff --git a/sig/imagekit/models/cache/invalidation_get_response.rbs b/sig/imagekit/models/cache/invalidation_get_response.rbs new file mode 100644 index 00000000..0c937b59 --- /dev/null +++ b/sig/imagekit/models/cache/invalidation_get_response.rbs @@ -0,0 +1,35 @@ +module Imagekit + module Models + module Cache + type invalidation_get_response = + { status: Imagekit::Models::Cache::InvalidationGetResponse::status } + + class InvalidationGetResponse < Imagekit::Internal::Type::BaseModel + attr_reader status: Imagekit::Models::Cache::InvalidationGetResponse::status? + + def status=: ( + Imagekit::Models::Cache::InvalidationGetResponse::status + ) -> Imagekit::Models::Cache::InvalidationGetResponse::status + + def initialize: ( + ?status: Imagekit::Models::Cache::InvalidationGetResponse::status + ) -> void + + def to_hash: -> { + status: Imagekit::Models::Cache::InvalidationGetResponse::status + } + + type status = :Pending | :Completed + + module Status + extend Imagekit::Internal::Type::Enum + + PENDING: :Pending + COMPLETED: :Completed + + def self?.values: -> ::Array[Imagekit::Models::Cache::InvalidationGetResponse::status] + end + end + end + end +end diff --git a/sig/imagekit/models/custom_metadata_field.rbs b/sig/imagekit/models/custom_metadata_field.rbs new file mode 100644 index 00000000..c141a507 --- /dev/null +++ b/sig/imagekit/models/custom_metadata_field.rbs @@ -0,0 +1,178 @@ +module Imagekit + module Models + type custom_metadata_field = + { + id: String, + label: String, + name: String, + schema: Imagekit::CustomMetadataField::Schema + } + + class CustomMetadataField < Imagekit::Internal::Type::BaseModel + attr_accessor id: String + + attr_accessor label: String + + attr_accessor name: String + + attr_accessor schema: Imagekit::CustomMetadataField::Schema + + def initialize: ( + id: String, + label: String, + name: String, + schema: Imagekit::CustomMetadataField::Schema + ) -> void + + def to_hash: -> { + id: String, + label: String, + name: String, + schema: Imagekit::CustomMetadataField::Schema + } + + type schema = + { + type: Imagekit::Models::CustomMetadataField::Schema::type_, + default_value: Imagekit::Models::CustomMetadataField::Schema::default_value, + is_value_required: bool, + max_length: Float, + max_value: Imagekit::Models::CustomMetadataField::Schema::max_value, + min_length: Float, + min_value: Imagekit::Models::CustomMetadataField::Schema::min_value, + select_options: ::Array[Imagekit::Models::CustomMetadataField::Schema::select_option] + } + + class Schema < Imagekit::Internal::Type::BaseModel + attr_accessor type: Imagekit::Models::CustomMetadataField::Schema::type_ + + attr_reader default_value: Imagekit::Models::CustomMetadataField::Schema::default_value? + + def default_value=: ( + Imagekit::Models::CustomMetadataField::Schema::default_value + ) -> Imagekit::Models::CustomMetadataField::Schema::default_value + + attr_reader is_value_required: bool? + + def is_value_required=: (bool) -> bool + + attr_reader max_length: Float? + + def max_length=: (Float) -> Float + + attr_reader max_value: Imagekit::Models::CustomMetadataField::Schema::max_value? + + def max_value=: ( + Imagekit::Models::CustomMetadataField::Schema::max_value + ) -> Imagekit::Models::CustomMetadataField::Schema::max_value + + attr_reader min_length: Float? + + def min_length=: (Float) -> Float + + attr_reader min_value: Imagekit::Models::CustomMetadataField::Schema::min_value? + + def min_value=: ( + Imagekit::Models::CustomMetadataField::Schema::min_value + ) -> Imagekit::Models::CustomMetadataField::Schema::min_value + + attr_reader select_options: ::Array[Imagekit::Models::CustomMetadataField::Schema::select_option]? + + def select_options=: ( + ::Array[Imagekit::Models::CustomMetadataField::Schema::select_option] + ) -> ::Array[Imagekit::Models::CustomMetadataField::Schema::select_option] + + def initialize: ( + type: Imagekit::Models::CustomMetadataField::Schema::type_, + ?default_value: Imagekit::Models::CustomMetadataField::Schema::default_value, + ?is_value_required: bool, + ?max_length: Float, + ?max_value: Imagekit::Models::CustomMetadataField::Schema::max_value, + ?min_length: Float, + ?min_value: Imagekit::Models::CustomMetadataField::Schema::min_value, + ?select_options: ::Array[Imagekit::Models::CustomMetadataField::Schema::select_option] + ) -> void + + def to_hash: -> { + type: Imagekit::Models::CustomMetadataField::Schema::type_, + default_value: Imagekit::Models::CustomMetadataField::Schema::default_value, + is_value_required: bool, + max_length: Float, + max_value: Imagekit::Models::CustomMetadataField::Schema::max_value, + min_length: Float, + min_value: Imagekit::Models::CustomMetadataField::Schema::min_value, + select_options: ::Array[Imagekit::Models::CustomMetadataField::Schema::select_option] + } + + type type_ = + :Text + | :Textarea + | :Number + | :Date + | :Boolean + | :SingleSelect + | :MultiSelect + + module Type + extend Imagekit::Internal::Type::Enum + + TEXT: :Text + TEXTAREA: :Textarea + NUMBER: :Number + DATE: :Date + BOOLEAN: :Boolean + SINGLE_SELECT: :SingleSelect + MULTI_SELECT: :MultiSelect + + def self?.values: -> ::Array[Imagekit::Models::CustomMetadataField::Schema::type_] + end + + type default_value = + String + | Float + | bool + | ::Array[Imagekit::Models::CustomMetadataField::Schema::DefaultValue::mixed] + + module DefaultValue + extend Imagekit::Internal::Type::Union + + type mixed = String | Float | bool + + module Mixed + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::CustomMetadataField::Schema::DefaultValue::mixed] + end + + def self?.variants: -> ::Array[Imagekit::Models::CustomMetadataField::Schema::default_value] + + MixedArray: Imagekit::Internal::Type::Converter + end + + type max_value = String | Float + + module MaxValue + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::CustomMetadataField::Schema::max_value] + end + + type min_value = String | Float + + module MinValue + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::CustomMetadataField::Schema::min_value] + end + + type select_option = String | Float | bool + + module SelectOption + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::CustomMetadataField::Schema::select_option] + end + end + end + end +end diff --git a/sig/imagekit/models/custom_metadata_field_create_params.rbs b/sig/imagekit/models/custom_metadata_field_create_params.rbs new file mode 100644 index 00000000..1d4f85db --- /dev/null +++ b/sig/imagekit/models/custom_metadata_field_create_params.rbs @@ -0,0 +1,179 @@ +module Imagekit + module Models + type custom_metadata_field_create_params = + { + label: String, + name: String, + schema: Imagekit::CustomMetadataFieldCreateParams::Schema + } + & Imagekit::Internal::Type::request_parameters + + class CustomMetadataFieldCreateParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + attr_accessor label: String + + attr_accessor name: String + + attr_accessor schema: Imagekit::CustomMetadataFieldCreateParams::Schema + + def initialize: ( + label: String, + name: String, + schema: Imagekit::CustomMetadataFieldCreateParams::Schema, + ?request_options: Imagekit::request_opts + ) -> void + + def to_hash: -> { + label: String, + name: String, + schema: Imagekit::CustomMetadataFieldCreateParams::Schema, + request_options: Imagekit::RequestOptions + } + + type schema = + { + type: Imagekit::Models::CustomMetadataFieldCreateParams::Schema::type_, + default_value: Imagekit::Models::CustomMetadataFieldCreateParams::Schema::default_value, + is_value_required: bool, + max_length: Float, + max_value: Imagekit::Models::CustomMetadataFieldCreateParams::Schema::max_value, + min_length: Float, + min_value: Imagekit::Models::CustomMetadataFieldCreateParams::Schema::min_value, + select_options: ::Array[Imagekit::Models::CustomMetadataFieldCreateParams::Schema::select_option] + } + + class Schema < Imagekit::Internal::Type::BaseModel + attr_accessor type: Imagekit::Models::CustomMetadataFieldCreateParams::Schema::type_ + + attr_reader default_value: Imagekit::Models::CustomMetadataFieldCreateParams::Schema::default_value? + + def default_value=: ( + Imagekit::Models::CustomMetadataFieldCreateParams::Schema::default_value + ) -> Imagekit::Models::CustomMetadataFieldCreateParams::Schema::default_value + + attr_reader is_value_required: bool? + + def is_value_required=: (bool) -> bool + + attr_reader max_length: Float? + + def max_length=: (Float) -> Float + + attr_reader max_value: Imagekit::Models::CustomMetadataFieldCreateParams::Schema::max_value? + + def max_value=: ( + Imagekit::Models::CustomMetadataFieldCreateParams::Schema::max_value + ) -> Imagekit::Models::CustomMetadataFieldCreateParams::Schema::max_value + + attr_reader min_length: Float? + + def min_length=: (Float) -> Float + + attr_reader min_value: Imagekit::Models::CustomMetadataFieldCreateParams::Schema::min_value? + + def min_value=: ( + Imagekit::Models::CustomMetadataFieldCreateParams::Schema::min_value + ) -> Imagekit::Models::CustomMetadataFieldCreateParams::Schema::min_value + + attr_reader select_options: ::Array[Imagekit::Models::CustomMetadataFieldCreateParams::Schema::select_option]? + + def select_options=: ( + ::Array[Imagekit::Models::CustomMetadataFieldCreateParams::Schema::select_option] + ) -> ::Array[Imagekit::Models::CustomMetadataFieldCreateParams::Schema::select_option] + + def initialize: ( + type: Imagekit::Models::CustomMetadataFieldCreateParams::Schema::type_, + ?default_value: Imagekit::Models::CustomMetadataFieldCreateParams::Schema::default_value, + ?is_value_required: bool, + ?max_length: Float, + ?max_value: Imagekit::Models::CustomMetadataFieldCreateParams::Schema::max_value, + ?min_length: Float, + ?min_value: Imagekit::Models::CustomMetadataFieldCreateParams::Schema::min_value, + ?select_options: ::Array[Imagekit::Models::CustomMetadataFieldCreateParams::Schema::select_option] + ) -> void + + def to_hash: -> { + type: Imagekit::Models::CustomMetadataFieldCreateParams::Schema::type_, + default_value: Imagekit::Models::CustomMetadataFieldCreateParams::Schema::default_value, + is_value_required: bool, + max_length: Float, + max_value: Imagekit::Models::CustomMetadataFieldCreateParams::Schema::max_value, + min_length: Float, + min_value: Imagekit::Models::CustomMetadataFieldCreateParams::Schema::min_value, + select_options: ::Array[Imagekit::Models::CustomMetadataFieldCreateParams::Schema::select_option] + } + + type type_ = + :Text + | :Textarea + | :Number + | :Date + | :Boolean + | :SingleSelect + | :MultiSelect + + module Type + extend Imagekit::Internal::Type::Enum + + TEXT: :Text + TEXTAREA: :Textarea + NUMBER: :Number + DATE: :Date + BOOLEAN: :Boolean + SINGLE_SELECT: :SingleSelect + MULTI_SELECT: :MultiSelect + + def self?.values: -> ::Array[Imagekit::Models::CustomMetadataFieldCreateParams::Schema::type_] + end + + type default_value = + String + | Float + | bool + | ::Array[Imagekit::Models::CustomMetadataFieldCreateParams::Schema::DefaultValue::mixed] + + module DefaultValue + extend Imagekit::Internal::Type::Union + + type mixed = String | Float | bool + + module Mixed + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::CustomMetadataFieldCreateParams::Schema::DefaultValue::mixed] + end + + def self?.variants: -> ::Array[Imagekit::Models::CustomMetadataFieldCreateParams::Schema::default_value] + + MixedArray: Imagekit::Internal::Type::Converter + end + + type max_value = String | Float + + module MaxValue + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::CustomMetadataFieldCreateParams::Schema::max_value] + end + + type min_value = String | Float + + module MinValue + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::CustomMetadataFieldCreateParams::Schema::min_value] + end + + type select_option = String | Float | bool + + module SelectOption + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::CustomMetadataFieldCreateParams::Schema::select_option] + end + end + end + end +end diff --git a/sig/imagekit/models/custom_metadata_field_delete_params.rbs b/sig/imagekit/models/custom_metadata_field_delete_params.rbs new file mode 100644 index 00000000..567c6c64 --- /dev/null +++ b/sig/imagekit/models/custom_metadata_field_delete_params.rbs @@ -0,0 +1,15 @@ +module Imagekit + module Models + type custom_metadata_field_delete_params = + { } & Imagekit::Internal::Type::request_parameters + + class CustomMetadataFieldDeleteParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + def initialize: (?request_options: Imagekit::request_opts) -> void + + def to_hash: -> { request_options: Imagekit::RequestOptions } + end + end +end diff --git a/sig/imagekit/models/custom_metadata_field_delete_response.rbs b/sig/imagekit/models/custom_metadata_field_delete_response.rbs new file mode 100644 index 00000000..51fdebeb --- /dev/null +++ b/sig/imagekit/models/custom_metadata_field_delete_response.rbs @@ -0,0 +1,11 @@ +module Imagekit + module Models + type custom_metadata_field_delete_response = { } + + class CustomMetadataFieldDeleteResponse < Imagekit::Internal::Type::BaseModel + def initialize: -> void + + def to_hash: -> { } + end + end +end diff --git a/sig/imagekit/models/custom_metadata_field_list_params.rbs b/sig/imagekit/models/custom_metadata_field_list_params.rbs new file mode 100644 index 00000000..314b835e --- /dev/null +++ b/sig/imagekit/models/custom_metadata_field_list_params.rbs @@ -0,0 +1,25 @@ +module Imagekit + module Models + type custom_metadata_field_list_params = + { include_deleted: bool } & Imagekit::Internal::Type::request_parameters + + class CustomMetadataFieldListParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + attr_reader include_deleted: bool? + + def include_deleted=: (bool) -> bool + + def initialize: ( + ?include_deleted: bool, + ?request_options: Imagekit::request_opts + ) -> void + + def to_hash: -> { + include_deleted: bool, + request_options: Imagekit::RequestOptions + } + end + end +end diff --git a/sig/imagekit/models/custom_metadata_field_list_response.rbs b/sig/imagekit/models/custom_metadata_field_list_response.rbs new file mode 100644 index 00000000..7aa86e95 --- /dev/null +++ b/sig/imagekit/models/custom_metadata_field_list_response.rbs @@ -0,0 +1,8 @@ +module Imagekit + module Models + type custom_metadata_field_list_response = + ::Array[Imagekit::CustomMetadataField] + + CustomMetadataFieldListResponse: Imagekit::Internal::Type::Converter + end +end diff --git a/sig/imagekit/models/custom_metadata_field_update_params.rbs b/sig/imagekit/models/custom_metadata_field_update_params.rbs new file mode 100644 index 00000000..9da6ca07 --- /dev/null +++ b/sig/imagekit/models/custom_metadata_field_update_params.rbs @@ -0,0 +1,152 @@ +module Imagekit + module Models + type custom_metadata_field_update_params = + { + label: String, + schema: Imagekit::CustomMetadataFieldUpdateParams::Schema + } + & Imagekit::Internal::Type::request_parameters + + class CustomMetadataFieldUpdateParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + attr_reader label: String? + + def label=: (String) -> String + + attr_reader schema: Imagekit::CustomMetadataFieldUpdateParams::Schema? + + def schema=: ( + Imagekit::CustomMetadataFieldUpdateParams::Schema + ) -> Imagekit::CustomMetadataFieldUpdateParams::Schema + + def initialize: ( + ?label: String, + ?schema: Imagekit::CustomMetadataFieldUpdateParams::Schema, + ?request_options: Imagekit::request_opts + ) -> void + + def to_hash: -> { + label: String, + schema: Imagekit::CustomMetadataFieldUpdateParams::Schema, + request_options: Imagekit::RequestOptions + } + + type schema = + { + default_value: Imagekit::Models::CustomMetadataFieldUpdateParams::Schema::default_value, + is_value_required: bool, + max_length: Float, + max_value: Imagekit::Models::CustomMetadataFieldUpdateParams::Schema::max_value, + min_length: Float, + min_value: Imagekit::Models::CustomMetadataFieldUpdateParams::Schema::min_value, + select_options: ::Array[Imagekit::Models::CustomMetadataFieldUpdateParams::Schema::select_option] + } + + class Schema < Imagekit::Internal::Type::BaseModel + attr_reader default_value: Imagekit::Models::CustomMetadataFieldUpdateParams::Schema::default_value? + + def default_value=: ( + Imagekit::Models::CustomMetadataFieldUpdateParams::Schema::default_value + ) -> Imagekit::Models::CustomMetadataFieldUpdateParams::Schema::default_value + + attr_reader is_value_required: bool? + + def is_value_required=: (bool) -> bool + + attr_reader max_length: Float? + + def max_length=: (Float) -> Float + + attr_reader max_value: Imagekit::Models::CustomMetadataFieldUpdateParams::Schema::max_value? + + def max_value=: ( + Imagekit::Models::CustomMetadataFieldUpdateParams::Schema::max_value + ) -> Imagekit::Models::CustomMetadataFieldUpdateParams::Schema::max_value + + attr_reader min_length: Float? + + def min_length=: (Float) -> Float + + attr_reader min_value: Imagekit::Models::CustomMetadataFieldUpdateParams::Schema::min_value? + + def min_value=: ( + Imagekit::Models::CustomMetadataFieldUpdateParams::Schema::min_value + ) -> Imagekit::Models::CustomMetadataFieldUpdateParams::Schema::min_value + + attr_reader select_options: ::Array[Imagekit::Models::CustomMetadataFieldUpdateParams::Schema::select_option]? + + def select_options=: ( + ::Array[Imagekit::Models::CustomMetadataFieldUpdateParams::Schema::select_option] + ) -> ::Array[Imagekit::Models::CustomMetadataFieldUpdateParams::Schema::select_option] + + def initialize: ( + ?default_value: Imagekit::Models::CustomMetadataFieldUpdateParams::Schema::default_value, + ?is_value_required: bool, + ?max_length: Float, + ?max_value: Imagekit::Models::CustomMetadataFieldUpdateParams::Schema::max_value, + ?min_length: Float, + ?min_value: Imagekit::Models::CustomMetadataFieldUpdateParams::Schema::min_value, + ?select_options: ::Array[Imagekit::Models::CustomMetadataFieldUpdateParams::Schema::select_option] + ) -> void + + def to_hash: -> { + default_value: Imagekit::Models::CustomMetadataFieldUpdateParams::Schema::default_value, + is_value_required: bool, + max_length: Float, + max_value: Imagekit::Models::CustomMetadataFieldUpdateParams::Schema::max_value, + min_length: Float, + min_value: Imagekit::Models::CustomMetadataFieldUpdateParams::Schema::min_value, + select_options: ::Array[Imagekit::Models::CustomMetadataFieldUpdateParams::Schema::select_option] + } + + type default_value = + String + | Float + | bool + | ::Array[Imagekit::Models::CustomMetadataFieldUpdateParams::Schema::DefaultValue::mixed] + + module DefaultValue + extend Imagekit::Internal::Type::Union + + type mixed = String | Float | bool + + module Mixed + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::CustomMetadataFieldUpdateParams::Schema::DefaultValue::mixed] + end + + def self?.variants: -> ::Array[Imagekit::Models::CustomMetadataFieldUpdateParams::Schema::default_value] + + MixedArray: Imagekit::Internal::Type::Converter + end + + type max_value = String | Float + + module MaxValue + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::CustomMetadataFieldUpdateParams::Schema::max_value] + end + + type min_value = String | Float + + module MinValue + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::CustomMetadataFieldUpdateParams::Schema::min_value] + end + + type select_option = String | Float | bool + + module SelectOption + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::CustomMetadataFieldUpdateParams::Schema::select_option] + end + end + end + end +end diff --git a/sig/imagekit/models/extensions.rbs b/sig/imagekit/models/extensions.rbs new file mode 100644 index 00000000..783d12ea --- /dev/null +++ b/sig/imagekit/models/extensions.rbs @@ -0,0 +1,132 @@ +module Imagekit + module Models + type extension_item = + Imagekit::ExtensionItem::RemoveBg + | Imagekit::ExtensionItem::AIAutoDescription + | Imagekit::ExtensionItem::AutoTaggingExtension + + module ExtensionItem + extend Imagekit::Internal::Type::Union + + type remove_bg = + { + name: :"remove-bg", + options: Imagekit::ExtensionItem::RemoveBg::Options + } + + class RemoveBg < Imagekit::Internal::Type::BaseModel + attr_accessor name: :"remove-bg" + + attr_reader options: Imagekit::ExtensionItem::RemoveBg::Options? + + def options=: ( + Imagekit::ExtensionItem::RemoveBg::Options + ) -> Imagekit::ExtensionItem::RemoveBg::Options + + def initialize: ( + ?options: Imagekit::ExtensionItem::RemoveBg::Options, + ?name: :"remove-bg" + ) -> void + + def to_hash: -> { + name: :"remove-bg", + options: Imagekit::ExtensionItem::RemoveBg::Options + } + + type options = + { + add_shadow: bool, + bg_color: String, + bg_image_url: String, + semitransparency: bool + } + + class Options < Imagekit::Internal::Type::BaseModel + attr_reader add_shadow: bool? + + def add_shadow=: (bool) -> bool + + attr_reader bg_color: String? + + def bg_color=: (String) -> String + + attr_reader bg_image_url: String? + + def bg_image_url=: (String) -> String + + attr_reader semitransparency: bool? + + def semitransparency=: (bool) -> bool + + def initialize: ( + ?add_shadow: bool, + ?bg_color: String, + ?bg_image_url: String, + ?semitransparency: bool + ) -> void + + def to_hash: -> { + add_shadow: bool, + bg_color: String, + bg_image_url: String, + semitransparency: bool + } + end + end + + type auto_tagging_extension = + { + max_tags: Integer, + min_confidence: Integer, + name: Imagekit::Models::ExtensionItem::AutoTaggingExtension::name_ + } + + class AutoTaggingExtension < Imagekit::Internal::Type::BaseModel + attr_accessor max_tags: Integer + + attr_accessor min_confidence: Integer + + attr_accessor name: Imagekit::Models::ExtensionItem::AutoTaggingExtension::name_ + + def initialize: ( + max_tags: Integer, + min_confidence: Integer, + name: Imagekit::Models::ExtensionItem::AutoTaggingExtension::name_ + ) -> void + + def to_hash: -> { + max_tags: Integer, + min_confidence: Integer, + name: Imagekit::Models::ExtensionItem::AutoTaggingExtension::name_ + } + + type name_ = :"google-auto-tagging" | :"aws-auto-tagging" + + module Name + extend Imagekit::Internal::Type::Enum + + GOOGLE_AUTO_TAGGING: :"google-auto-tagging" + AWS_AUTO_TAGGING: :"aws-auto-tagging" + + def self?.values: -> ::Array[Imagekit::Models::ExtensionItem::AutoTaggingExtension::name_] + end + end + + type ai_auto_description = { name: :"ai-auto-description" } + + class AIAutoDescription < Imagekit::Internal::Type::BaseModel + attr_accessor name: :"ai-auto-description" + + def initialize: (?name: :"ai-auto-description") -> void + + def to_hash: -> { name: :"ai-auto-description" } + end + + def self?.variants: -> ::Array[Imagekit::Models::extension_item] + end + + type extensions = ::Array[Imagekit::Models::extension_item] + + Extensions: Imagekit::Internal::Type::Converter + end +end diff --git a/sig/imagekit/models/file.rbs b/sig/imagekit/models/file.rbs new file mode 100644 index 00000000..9331ad13 --- /dev/null +++ b/sig/imagekit/models/file.rbs @@ -0,0 +1,218 @@ +module Imagekit + module Models + type file = + { + ai_tags: ::Array[Imagekit::File::AITag]?, + created_at: Time, + custom_coordinates: String?, + custom_metadata: ::Hash[Symbol, top], + description: String, + file_id: String, + file_path: String, + file_type: String, + has_alpha: bool, + height: Float, + is_private_file: bool, + is_published: bool, + mime: String, + name: String, + size: Float, + tags: ::Array[String]?, + thumbnail: String, + type: Imagekit::Models::File::type_, + updated_at: Time, + url: String, + version_info: Imagekit::File::VersionInfo, + width: Float + } + + class File < Imagekit::Internal::Type::BaseModel + attr_accessor ai_tags: ::Array[Imagekit::File::AITag]? + + attr_reader created_at: Time? + + def created_at=: (Time) -> Time + + attr_accessor custom_coordinates: String? + + attr_reader custom_metadata: ::Hash[Symbol, top]? + + def custom_metadata=: (::Hash[Symbol, top]) -> ::Hash[Symbol, top] + + attr_reader description: String? + + def description=: (String) -> String + + attr_reader file_id: String? + + def file_id=: (String) -> String + + attr_reader file_path: String? + + def file_path=: (String) -> String + + attr_reader file_type: String? + + def file_type=: (String) -> String + + attr_reader has_alpha: bool? + + def has_alpha=: (bool) -> bool + + attr_reader height: Float? + + def height=: (Float) -> Float + + attr_reader is_private_file: bool? + + def is_private_file=: (bool) -> bool + + attr_reader is_published: bool? + + def is_published=: (bool) -> bool + + attr_reader mime: String? + + def mime=: (String) -> String + + attr_reader name: String? + + def name=: (String) -> String + + attr_reader size: Float? + + def size=: (Float) -> Float + + attr_accessor tags: ::Array[String]? + + attr_reader thumbnail: String? + + def thumbnail=: (String) -> String + + attr_reader type: Imagekit::Models::File::type_? + + def type=: ( + Imagekit::Models::File::type_ + ) -> Imagekit::Models::File::type_ + + attr_reader updated_at: Time? + + def updated_at=: (Time) -> Time + + attr_reader url: String? + + def url=: (String) -> String + + attr_reader version_info: Imagekit::File::VersionInfo? + + def version_info=: ( + Imagekit::File::VersionInfo + ) -> Imagekit::File::VersionInfo + + attr_reader width: Float? + + def width=: (Float) -> Float + + def initialize: ( + ?ai_tags: ::Array[Imagekit::File::AITag]?, + ?created_at: Time, + ?custom_coordinates: String?, + ?custom_metadata: ::Hash[Symbol, top], + ?description: String, + ?file_id: String, + ?file_path: String, + ?file_type: String, + ?has_alpha: bool, + ?height: Float, + ?is_private_file: bool, + ?is_published: bool, + ?mime: String, + ?name: String, + ?size: Float, + ?tags: ::Array[String]?, + ?thumbnail: String, + ?type: Imagekit::Models::File::type_, + ?updated_at: Time, + ?url: String, + ?version_info: Imagekit::File::VersionInfo, + ?width: Float + ) -> void + + def to_hash: -> { + ai_tags: ::Array[Imagekit::File::AITag]?, + created_at: Time, + custom_coordinates: String?, + custom_metadata: ::Hash[Symbol, top], + description: String, + file_id: String, + file_path: String, + file_type: String, + has_alpha: bool, + height: Float, + is_private_file: bool, + is_published: bool, + mime: String, + name: String, + size: Float, + tags: ::Array[String]?, + thumbnail: String, + type: Imagekit::Models::File::type_, + updated_at: Time, + url: String, + version_info: Imagekit::File::VersionInfo, + width: Float + } + + type ai_tag = { confidence: Float, name: String, source: String } + + class AITag < Imagekit::Internal::Type::BaseModel + attr_reader confidence: Float? + + def confidence=: (Float) -> Float + + attr_reader name: String? + + def name=: (String) -> String + + attr_reader source: String? + + def source=: (String) -> String + + def initialize: ( + ?confidence: Float, + ?name: String, + ?source: String + ) -> void + + def to_hash: -> { confidence: Float, name: String, source: String } + end + + type type_ = :file | :"file-version" + + module Type + extend Imagekit::Internal::Type::Enum + + FILE: :file + FILE_VERSION: :"file-version" + + def self?.values: -> ::Array[Imagekit::Models::File::type_] + end + + type version_info = { id: String, name: String } + + class VersionInfo < Imagekit::Internal::Type::BaseModel + attr_reader id: String? + + def id=: (String) -> String + + attr_reader name: String? + + def name=: (String) -> String + + def initialize: (?id: String, ?name: String) -> void + + def to_hash: -> { id: String, name: String } + end + end + end +end diff --git a/sig/imagekit/models/file_copy_params.rbs b/sig/imagekit/models/file_copy_params.rbs new file mode 100644 index 00000000..46bc8a75 --- /dev/null +++ b/sig/imagekit/models/file_copy_params.rbs @@ -0,0 +1,38 @@ +module Imagekit + module Models + type file_copy_params = + { + destination_path: String, + source_file_path: String, + include_file_versions: bool + } + & Imagekit::Internal::Type::request_parameters + + class FileCopyParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + attr_accessor destination_path: String + + attr_accessor source_file_path: String + + attr_reader include_file_versions: bool? + + def include_file_versions=: (bool) -> bool + + def initialize: ( + destination_path: String, + source_file_path: String, + ?include_file_versions: bool, + ?request_options: Imagekit::request_opts + ) -> void + + def to_hash: -> { + destination_path: String, + source_file_path: String, + include_file_versions: bool, + request_options: Imagekit::RequestOptions + } + end + end +end diff --git a/sig/imagekit/models/file_copy_response.rbs b/sig/imagekit/models/file_copy_response.rbs new file mode 100644 index 00000000..037e8a88 --- /dev/null +++ b/sig/imagekit/models/file_copy_response.rbs @@ -0,0 +1,11 @@ +module Imagekit + module Models + type file_copy_response = { } + + class FileCopyResponse < Imagekit::Internal::Type::BaseModel + def initialize: -> void + + def to_hash: -> { } + end + end +end diff --git a/sig/imagekit/models/file_delete_params.rbs b/sig/imagekit/models/file_delete_params.rbs new file mode 100644 index 00000000..4cd8aaa5 --- /dev/null +++ b/sig/imagekit/models/file_delete_params.rbs @@ -0,0 +1,15 @@ +module Imagekit + module Models + type file_delete_params = + { } & Imagekit::Internal::Type::request_parameters + + class FileDeleteParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + def initialize: (?request_options: Imagekit::request_opts) -> void + + def to_hash: -> { request_options: Imagekit::RequestOptions } + end + end +end diff --git a/sig/imagekit/models/file_get_params.rbs b/sig/imagekit/models/file_get_params.rbs new file mode 100644 index 00000000..1a204dfb --- /dev/null +++ b/sig/imagekit/models/file_get_params.rbs @@ -0,0 +1,14 @@ +module Imagekit + module Models + type file_get_params = { } & Imagekit::Internal::Type::request_parameters + + class FileGetParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + def initialize: (?request_options: Imagekit::request_opts) -> void + + def to_hash: -> { request_options: Imagekit::RequestOptions } + end + end +end diff --git a/sig/imagekit/models/file_move_params.rbs b/sig/imagekit/models/file_move_params.rbs new file mode 100644 index 00000000..c0d6f7f6 --- /dev/null +++ b/sig/imagekit/models/file_move_params.rbs @@ -0,0 +1,28 @@ +module Imagekit + module Models + type file_move_params = + { destination_path: String, source_file_path: String } + & Imagekit::Internal::Type::request_parameters + + class FileMoveParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + attr_accessor destination_path: String + + attr_accessor source_file_path: String + + def initialize: ( + destination_path: String, + source_file_path: String, + ?request_options: Imagekit::request_opts + ) -> void + + def to_hash: -> { + destination_path: String, + source_file_path: String, + request_options: Imagekit::RequestOptions + } + end + end +end diff --git a/sig/imagekit/models/file_move_response.rbs b/sig/imagekit/models/file_move_response.rbs new file mode 100644 index 00000000..6e5e95ee --- /dev/null +++ b/sig/imagekit/models/file_move_response.rbs @@ -0,0 +1,11 @@ +module Imagekit + module Models + type file_move_response = { } + + class FileMoveResponse < Imagekit::Internal::Type::BaseModel + def initialize: -> void + + def to_hash: -> { } + end + end +end diff --git a/sig/imagekit/models/file_rename_params.rbs b/sig/imagekit/models/file_rename_params.rbs new file mode 100644 index 00000000..f09beefd --- /dev/null +++ b/sig/imagekit/models/file_rename_params.rbs @@ -0,0 +1,34 @@ +module Imagekit + module Models + type file_rename_params = + { file_path: String, new_file_name: String, purge_cache: bool } + & Imagekit::Internal::Type::request_parameters + + class FileRenameParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + attr_accessor file_path: String + + attr_accessor new_file_name: String + + attr_reader purge_cache: bool? + + def purge_cache=: (bool) -> bool + + def initialize: ( + file_path: String, + new_file_name: String, + ?purge_cache: bool, + ?request_options: Imagekit::request_opts + ) -> void + + def to_hash: -> { + file_path: String, + new_file_name: String, + purge_cache: bool, + request_options: Imagekit::RequestOptions + } + end + end +end diff --git a/sig/imagekit/models/file_rename_response.rbs b/sig/imagekit/models/file_rename_response.rbs new file mode 100644 index 00000000..f19ba301 --- /dev/null +++ b/sig/imagekit/models/file_rename_response.rbs @@ -0,0 +1,15 @@ +module Imagekit + module Models + type file_rename_response = { purge_request_id: String } + + class FileRenameResponse < Imagekit::Internal::Type::BaseModel + attr_reader purge_request_id: String? + + def purge_request_id=: (String) -> String + + def initialize: (?purge_request_id: String) -> void + + def to_hash: -> { purge_request_id: String } + end + end +end diff --git a/sig/imagekit/models/file_update_params.rbs b/sig/imagekit/models/file_update_params.rbs new file mode 100644 index 00000000..be8da6ac --- /dev/null +++ b/sig/imagekit/models/file_update_params.rbs @@ -0,0 +1,28 @@ +module Imagekit + module Models + type file_update_params = + { update_file_request: Imagekit::Models::update_file_request } + & Imagekit::Internal::Type::request_parameters + + class FileUpdateParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + def update_file_request: -> Imagekit::Models::update_file_request + + def update_file_request=: ( + Imagekit::Models::update_file_request _ + ) -> Imagekit::Models::update_file_request + + def initialize: ( + update_file_request: Imagekit::Models::update_file_request, + ?request_options: Imagekit::request_opts + ) -> void + + def to_hash: -> { + update_file_request: Imagekit::Models::update_file_request, + request_options: Imagekit::RequestOptions + } + end + end +end diff --git a/sig/imagekit/models/file_update_response.rbs b/sig/imagekit/models/file_update_response.rbs new file mode 100644 index 00000000..5a223c95 --- /dev/null +++ b/sig/imagekit/models/file_update_response.rbs @@ -0,0 +1,120 @@ +module Imagekit + module Models + type file_update_response = + { + extension_status: Imagekit::Models::FileUpdateResponse::ExtensionStatus + } + + class FileUpdateResponse < Imagekit::Models::File + def extension_status: -> Imagekit::Models::FileUpdateResponse::ExtensionStatus? + + def extension_status=: ( + Imagekit::Models::FileUpdateResponse::ExtensionStatus _ + ) -> Imagekit::Models::FileUpdateResponse::ExtensionStatus + + def initialize: ( + ?extension_status: Imagekit::Models::FileUpdateResponse::ExtensionStatus + ) -> void + + def to_hash: -> { + extension_status: Imagekit::Models::FileUpdateResponse::ExtensionStatus + } + + type extension_status = + { + ai_auto_description: Imagekit::Models::FileUpdateResponse::ExtensionStatus::ai_auto_description, + aws_auto_tagging: Imagekit::Models::FileUpdateResponse::ExtensionStatus::aws_auto_tagging, + google_auto_tagging: Imagekit::Models::FileUpdateResponse::ExtensionStatus::google_auto_tagging, + remove_bg: Imagekit::Models::FileUpdateResponse::ExtensionStatus::remove_bg + } + + class ExtensionStatus < Imagekit::Internal::Type::BaseModel + attr_reader ai_auto_description: Imagekit::Models::FileUpdateResponse::ExtensionStatus::ai_auto_description? + + def ai_auto_description=: ( + Imagekit::Models::FileUpdateResponse::ExtensionStatus::ai_auto_description + ) -> Imagekit::Models::FileUpdateResponse::ExtensionStatus::ai_auto_description + + attr_reader aws_auto_tagging: Imagekit::Models::FileUpdateResponse::ExtensionStatus::aws_auto_tagging? + + def aws_auto_tagging=: ( + Imagekit::Models::FileUpdateResponse::ExtensionStatus::aws_auto_tagging + ) -> Imagekit::Models::FileUpdateResponse::ExtensionStatus::aws_auto_tagging + + attr_reader google_auto_tagging: Imagekit::Models::FileUpdateResponse::ExtensionStatus::google_auto_tagging? + + def google_auto_tagging=: ( + Imagekit::Models::FileUpdateResponse::ExtensionStatus::google_auto_tagging + ) -> Imagekit::Models::FileUpdateResponse::ExtensionStatus::google_auto_tagging + + attr_reader remove_bg: Imagekit::Models::FileUpdateResponse::ExtensionStatus::remove_bg? + + def remove_bg=: ( + Imagekit::Models::FileUpdateResponse::ExtensionStatus::remove_bg + ) -> Imagekit::Models::FileUpdateResponse::ExtensionStatus::remove_bg + + def initialize: ( + ?ai_auto_description: Imagekit::Models::FileUpdateResponse::ExtensionStatus::ai_auto_description, + ?aws_auto_tagging: Imagekit::Models::FileUpdateResponse::ExtensionStatus::aws_auto_tagging, + ?google_auto_tagging: Imagekit::Models::FileUpdateResponse::ExtensionStatus::google_auto_tagging, + ?remove_bg: Imagekit::Models::FileUpdateResponse::ExtensionStatus::remove_bg + ) -> void + + def to_hash: -> { + ai_auto_description: Imagekit::Models::FileUpdateResponse::ExtensionStatus::ai_auto_description, + aws_auto_tagging: Imagekit::Models::FileUpdateResponse::ExtensionStatus::aws_auto_tagging, + google_auto_tagging: Imagekit::Models::FileUpdateResponse::ExtensionStatus::google_auto_tagging, + remove_bg: Imagekit::Models::FileUpdateResponse::ExtensionStatus::remove_bg + } + + type ai_auto_description = :success | :pending | :failed + + module AIAutoDescription + extend Imagekit::Internal::Type::Enum + + SUCCESS: :success + PENDING: :pending + FAILED: :failed + + def self?.values: -> ::Array[Imagekit::Models::FileUpdateResponse::ExtensionStatus::ai_auto_description] + end + + type aws_auto_tagging = :success | :pending | :failed + + module AwsAutoTagging + extend Imagekit::Internal::Type::Enum + + SUCCESS: :success + PENDING: :pending + FAILED: :failed + + def self?.values: -> ::Array[Imagekit::Models::FileUpdateResponse::ExtensionStatus::aws_auto_tagging] + end + + type google_auto_tagging = :success | :pending | :failed + + module GoogleAutoTagging + extend Imagekit::Internal::Type::Enum + + SUCCESS: :success + PENDING: :pending + FAILED: :failed + + def self?.values: -> ::Array[Imagekit::Models::FileUpdateResponse::ExtensionStatus::google_auto_tagging] + end + + type remove_bg = :success | :pending | :failed + + module RemoveBg + extend Imagekit::Internal::Type::Enum + + SUCCESS: :success + PENDING: :pending + FAILED: :failed + + def self?.values: -> ::Array[Imagekit::Models::FileUpdateResponse::ExtensionStatus::remove_bg] + end + end + end + end +end diff --git a/sig/imagekit/models/file_upload_params.rbs b/sig/imagekit/models/file_upload_params.rbs new file mode 100644 index 00000000..62ca0281 --- /dev/null +++ b/sig/imagekit/models/file_upload_params.rbs @@ -0,0 +1,325 @@ +module Imagekit + module Models + type file_upload_params = + { + file: Imagekit::Internal::file_input, + file_name: String, + token: String, + checks: String, + custom_coordinates: String, + custom_metadata: ::Hash[Symbol, top], + description: String, + expire: Integer, + extensions: Imagekit::Models::extensions, + folder: String, + is_private_file: bool, + is_published: bool, + overwrite_ai_tags: bool, + overwrite_custom_metadata: bool, + overwrite_file: bool, + overwrite_tags: bool, + public_key: String, + response_fields: ::Array[Imagekit::Models::FileUploadParams::response_field], + signature: String, + tags: ::Array[String], + transformation: Imagekit::FileUploadParams::Transformation, + use_unique_file_name: bool, + webhook_url: String + } + & Imagekit::Internal::Type::request_parameters + + class FileUploadParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + attr_accessor file: Imagekit::Internal::file_input + + attr_accessor file_name: String + + attr_reader token: String? + + def token=: (String) -> String + + attr_reader checks: String? + + def checks=: (String) -> String + + attr_reader custom_coordinates: String? + + def custom_coordinates=: (String) -> String + + attr_reader custom_metadata: ::Hash[Symbol, top]? + + def custom_metadata=: (::Hash[Symbol, top]) -> ::Hash[Symbol, top] + + attr_reader description: String? + + def description=: (String) -> String + + attr_reader expire: Integer? + + def expire=: (Integer) -> Integer + + attr_reader extensions: Imagekit::Models::extensions? + + def extensions=: ( + Imagekit::Models::extensions + ) -> Imagekit::Models::extensions + + attr_reader folder: String? + + def folder=: (String) -> String + + attr_reader is_private_file: bool? + + def is_private_file=: (bool) -> bool + + attr_reader is_published: bool? + + def is_published=: (bool) -> bool + + attr_reader overwrite_ai_tags: bool? + + def overwrite_ai_tags=: (bool) -> bool + + attr_reader overwrite_custom_metadata: bool? + + def overwrite_custom_metadata=: (bool) -> bool + + attr_reader overwrite_file: bool? + + def overwrite_file=: (bool) -> bool + + attr_reader overwrite_tags: bool? + + def overwrite_tags=: (bool) -> bool + + attr_reader public_key: String? + + def public_key=: (String) -> String + + attr_reader response_fields: ::Array[Imagekit::Models::FileUploadParams::response_field]? + + def response_fields=: ( + ::Array[Imagekit::Models::FileUploadParams::response_field] + ) -> ::Array[Imagekit::Models::FileUploadParams::response_field] + + attr_reader signature: String? + + def signature=: (String) -> String + + attr_reader tags: ::Array[String]? + + def tags=: (::Array[String]) -> ::Array[String] + + attr_reader transformation: Imagekit::FileUploadParams::Transformation? + + def transformation=: ( + Imagekit::FileUploadParams::Transformation + ) -> Imagekit::FileUploadParams::Transformation + + attr_reader use_unique_file_name: bool? + + def use_unique_file_name=: (bool) -> bool + + attr_reader webhook_url: String? + + def webhook_url=: (String) -> String + + def initialize: ( + file: Imagekit::Internal::file_input, + file_name: String, + ?token: String, + ?checks: String, + ?custom_coordinates: String, + ?custom_metadata: ::Hash[Symbol, top], + ?description: String, + ?expire: Integer, + ?extensions: Imagekit::Models::extensions, + ?folder: String, + ?is_private_file: bool, + ?is_published: bool, + ?overwrite_ai_tags: bool, + ?overwrite_custom_metadata: bool, + ?overwrite_file: bool, + ?overwrite_tags: bool, + ?public_key: String, + ?response_fields: ::Array[Imagekit::Models::FileUploadParams::response_field], + ?signature: String, + ?tags: ::Array[String], + ?transformation: Imagekit::FileUploadParams::Transformation, + ?use_unique_file_name: bool, + ?webhook_url: String, + ?request_options: Imagekit::request_opts + ) -> void + + def to_hash: -> { + file: Imagekit::Internal::file_input, + file_name: String, + token: String, + checks: String, + custom_coordinates: String, + custom_metadata: ::Hash[Symbol, top], + description: String, + expire: Integer, + extensions: Imagekit::Models::extensions, + folder: String, + is_private_file: bool, + is_published: bool, + overwrite_ai_tags: bool, + overwrite_custom_metadata: bool, + overwrite_file: bool, + overwrite_tags: bool, + public_key: String, + response_fields: ::Array[Imagekit::Models::FileUploadParams::response_field], + signature: String, + tags: ::Array[String], + transformation: Imagekit::FileUploadParams::Transformation, + use_unique_file_name: bool, + webhook_url: String, + request_options: Imagekit::RequestOptions + } + + type response_field = + :tags + | :customCoordinates + | :isPrivateFile + | :embeddedMetadata + | :isPublished + | :customMetadata + | :metadata + + module ResponseField + extend Imagekit::Internal::Type::Enum + + TAGS: :tags + CUSTOM_COORDINATES: :customCoordinates + IS_PRIVATE_FILE: :isPrivateFile + EMBEDDED_METADATA: :embeddedMetadata + IS_PUBLISHED: :isPublished + CUSTOM_METADATA: :customMetadata + METADATA: :metadata + + def self?.values: -> ::Array[Imagekit::Models::FileUploadParams::response_field] + end + + type transformation = + { + post: ::Array[Imagekit::Models::FileUploadParams::Transformation::post], + pre: String + } + + class Transformation < Imagekit::Internal::Type::BaseModel + attr_reader post: ::Array[Imagekit::Models::FileUploadParams::Transformation::post]? + + def post=: ( + ::Array[Imagekit::Models::FileUploadParams::Transformation::post] + ) -> ::Array[Imagekit::Models::FileUploadParams::Transformation::post] + + attr_reader pre: String? + + def pre=: (String) -> String + + def initialize: ( + ?post: ::Array[Imagekit::Models::FileUploadParams::Transformation::post], + ?pre: String + ) -> void + + def to_hash: -> { + post: ::Array[Imagekit::Models::FileUploadParams::Transformation::post], + pre: String + } + + type post = + Imagekit::FileUploadParams::Transformation::Post::Transformation + | Imagekit::FileUploadParams::Transformation::Post::GifToVideo + | Imagekit::FileUploadParams::Transformation::Post::Thumbnail + | Imagekit::FileUploadParams::Transformation::Post::Abs + + module Post + extend Imagekit::Internal::Type::Union + + type transformation = { type: :transformation, value: String } + + class Transformation < Imagekit::Internal::Type::BaseModel + attr_accessor type: :transformation + + attr_accessor value: String + + def initialize: (value: String, ?type: :transformation) -> void + + def to_hash: -> { type: :transformation, value: String } + end + + type gif_to_video = { type: :"gif-to-video", value: String } + + class GifToVideo < Imagekit::Internal::Type::BaseModel + attr_accessor type: :"gif-to-video" + + attr_reader value: String? + + def value=: (String) -> String + + def initialize: (?value: String, ?type: :"gif-to-video") -> void + + def to_hash: -> { type: :"gif-to-video", value: String } + end + + type thumbnail = { type: :thumbnail, value: String } + + class Thumbnail < Imagekit::Internal::Type::BaseModel + attr_accessor type: :thumbnail + + attr_reader value: String? + + def value=: (String) -> String + + def initialize: (?value: String, ?type: :thumbnail) -> void + + def to_hash: -> { type: :thumbnail, value: String } + end + + type abs = + { + protocol: Imagekit::Models::FileUploadParams::Transformation::Post::Abs::protocol, + type: :abs, + value: String + } + + class Abs < Imagekit::Internal::Type::BaseModel + attr_accessor protocol: Imagekit::Models::FileUploadParams::Transformation::Post::Abs::protocol + + attr_accessor type: :abs + + attr_accessor value: String + + def initialize: ( + protocol: Imagekit::Models::FileUploadParams::Transformation::Post::Abs::protocol, + value: String, + ?type: :abs + ) -> void + + def to_hash: -> { + protocol: Imagekit::Models::FileUploadParams::Transformation::Post::Abs::protocol, + type: :abs, + value: String + } + + type protocol = :hls | :dash + + module Protocol + extend Imagekit::Internal::Type::Enum + + HLS: :hls + DASH: :dash + + def self?.values: -> ::Array[Imagekit::Models::FileUploadParams::Transformation::Post::Abs::protocol] + end + end + + def self?.variants: -> ::Array[Imagekit::Models::FileUploadParams::Transformation::post] + end + end + end + end +end diff --git a/sig/imagekit/models/file_upload_response.rbs b/sig/imagekit/models/file_upload_response.rbs new file mode 100644 index 00000000..10348f34 --- /dev/null +++ b/sig/imagekit/models/file_upload_response.rbs @@ -0,0 +1,317 @@ +module Imagekit + module Models + type file_upload_response = + { + ai_tags: ::Array[Imagekit::Models::FileUploadResponse::AITag]?, + audio_codec: String, + bit_rate: Integer, + custom_coordinates: String?, + custom_metadata: ::Hash[Symbol, top], + description: String, + duration: Integer, + embedded_metadata: ::Hash[Symbol, top], + extension_status: Imagekit::Models::FileUploadResponse::ExtensionStatus, + file_id: String, + file_path: String, + file_type: String, + height: Float, + is_private_file: bool, + is_published: bool, + metadata: Imagekit::Metadata, + name: String, + size: Float, + tags: ::Array[String]?, + thumbnail_url: String, + url: String, + version_info: Imagekit::Models::FileUploadResponse::VersionInfo, + video_codec: String, + width: Float + } + + class FileUploadResponse < Imagekit::Internal::Type::BaseModel + attr_accessor ai_tags: ::Array[Imagekit::Models::FileUploadResponse::AITag]? + + attr_reader audio_codec: String? + + def audio_codec=: (String) -> String + + attr_reader bit_rate: Integer? + + def bit_rate=: (Integer) -> Integer + + attr_accessor custom_coordinates: String? + + attr_reader custom_metadata: ::Hash[Symbol, top]? + + def custom_metadata=: (::Hash[Symbol, top]) -> ::Hash[Symbol, top] + + attr_reader description: String? + + def description=: (String) -> String + + attr_reader duration: Integer? + + def duration=: (Integer) -> Integer + + attr_reader embedded_metadata: ::Hash[Symbol, top]? + + def embedded_metadata=: (::Hash[Symbol, top]) -> ::Hash[Symbol, top] + + attr_reader extension_status: Imagekit::Models::FileUploadResponse::ExtensionStatus? + + def extension_status=: ( + Imagekit::Models::FileUploadResponse::ExtensionStatus + ) -> Imagekit::Models::FileUploadResponse::ExtensionStatus + + attr_reader file_id: String? + + def file_id=: (String) -> String + + attr_reader file_path: String? + + def file_path=: (String) -> String + + attr_reader file_type: String? + + def file_type=: (String) -> String + + attr_reader height: Float? + + def height=: (Float) -> Float + + attr_reader is_private_file: bool? + + def is_private_file=: (bool) -> bool + + attr_reader is_published: bool? + + def is_published=: (bool) -> bool + + attr_reader metadata: Imagekit::Metadata? + + def metadata=: (Imagekit::Metadata) -> Imagekit::Metadata + + attr_reader name: String? + + def name=: (String) -> String + + attr_reader size: Float? + + def size=: (Float) -> Float + + attr_accessor tags: ::Array[String]? + + attr_reader thumbnail_url: String? + + def thumbnail_url=: (String) -> String + + attr_reader url: String? + + def url=: (String) -> String + + attr_reader version_info: Imagekit::Models::FileUploadResponse::VersionInfo? + + def version_info=: ( + Imagekit::Models::FileUploadResponse::VersionInfo + ) -> Imagekit::Models::FileUploadResponse::VersionInfo + + attr_reader video_codec: String? + + def video_codec=: (String) -> String + + attr_reader width: Float? + + def width=: (Float) -> Float + + def initialize: ( + ?ai_tags: ::Array[Imagekit::Models::FileUploadResponse::AITag]?, + ?audio_codec: String, + ?bit_rate: Integer, + ?custom_coordinates: String?, + ?custom_metadata: ::Hash[Symbol, top], + ?description: String, + ?duration: Integer, + ?embedded_metadata: ::Hash[Symbol, top], + ?extension_status: Imagekit::Models::FileUploadResponse::ExtensionStatus, + ?file_id: String, + ?file_path: String, + ?file_type: String, + ?height: Float, + ?is_private_file: bool, + ?is_published: bool, + ?metadata: Imagekit::Metadata, + ?name: String, + ?size: Float, + ?tags: ::Array[String]?, + ?thumbnail_url: String, + ?url: String, + ?version_info: Imagekit::Models::FileUploadResponse::VersionInfo, + ?video_codec: String, + ?width: Float + ) -> void + + def to_hash: -> { + ai_tags: ::Array[Imagekit::Models::FileUploadResponse::AITag]?, + audio_codec: String, + bit_rate: Integer, + custom_coordinates: String?, + custom_metadata: ::Hash[Symbol, top], + description: String, + duration: Integer, + embedded_metadata: ::Hash[Symbol, top], + extension_status: Imagekit::Models::FileUploadResponse::ExtensionStatus, + file_id: String, + file_path: String, + file_type: String, + height: Float, + is_private_file: bool, + is_published: bool, + metadata: Imagekit::Metadata, + name: String, + size: Float, + tags: ::Array[String]?, + thumbnail_url: String, + url: String, + version_info: Imagekit::Models::FileUploadResponse::VersionInfo, + video_codec: String, + width: Float + } + + type ai_tag = { confidence: Float, name: String, source: String } + + class AITag < Imagekit::Internal::Type::BaseModel + attr_reader confidence: Float? + + def confidence=: (Float) -> Float + + attr_reader name: String? + + def name=: (String) -> String + + attr_reader source: String? + + def source=: (String) -> String + + def initialize: ( + ?confidence: Float, + ?name: String, + ?source: String + ) -> void + + def to_hash: -> { confidence: Float, name: String, source: String } + end + + type extension_status = + { + ai_auto_description: Imagekit::Models::FileUploadResponse::ExtensionStatus::ai_auto_description, + aws_auto_tagging: Imagekit::Models::FileUploadResponse::ExtensionStatus::aws_auto_tagging, + google_auto_tagging: Imagekit::Models::FileUploadResponse::ExtensionStatus::google_auto_tagging, + remove_bg: Imagekit::Models::FileUploadResponse::ExtensionStatus::remove_bg + } + + class ExtensionStatus < Imagekit::Internal::Type::BaseModel + attr_reader ai_auto_description: Imagekit::Models::FileUploadResponse::ExtensionStatus::ai_auto_description? + + def ai_auto_description=: ( + Imagekit::Models::FileUploadResponse::ExtensionStatus::ai_auto_description + ) -> Imagekit::Models::FileUploadResponse::ExtensionStatus::ai_auto_description + + attr_reader aws_auto_tagging: Imagekit::Models::FileUploadResponse::ExtensionStatus::aws_auto_tagging? + + def aws_auto_tagging=: ( + Imagekit::Models::FileUploadResponse::ExtensionStatus::aws_auto_tagging + ) -> Imagekit::Models::FileUploadResponse::ExtensionStatus::aws_auto_tagging + + attr_reader google_auto_tagging: Imagekit::Models::FileUploadResponse::ExtensionStatus::google_auto_tagging? + + def google_auto_tagging=: ( + Imagekit::Models::FileUploadResponse::ExtensionStatus::google_auto_tagging + ) -> Imagekit::Models::FileUploadResponse::ExtensionStatus::google_auto_tagging + + attr_reader remove_bg: Imagekit::Models::FileUploadResponse::ExtensionStatus::remove_bg? + + def remove_bg=: ( + Imagekit::Models::FileUploadResponse::ExtensionStatus::remove_bg + ) -> Imagekit::Models::FileUploadResponse::ExtensionStatus::remove_bg + + def initialize: ( + ?ai_auto_description: Imagekit::Models::FileUploadResponse::ExtensionStatus::ai_auto_description, + ?aws_auto_tagging: Imagekit::Models::FileUploadResponse::ExtensionStatus::aws_auto_tagging, + ?google_auto_tagging: Imagekit::Models::FileUploadResponse::ExtensionStatus::google_auto_tagging, + ?remove_bg: Imagekit::Models::FileUploadResponse::ExtensionStatus::remove_bg + ) -> void + + def to_hash: -> { + ai_auto_description: Imagekit::Models::FileUploadResponse::ExtensionStatus::ai_auto_description, + aws_auto_tagging: Imagekit::Models::FileUploadResponse::ExtensionStatus::aws_auto_tagging, + google_auto_tagging: Imagekit::Models::FileUploadResponse::ExtensionStatus::google_auto_tagging, + remove_bg: Imagekit::Models::FileUploadResponse::ExtensionStatus::remove_bg + } + + type ai_auto_description = :success | :pending | :failed + + module AIAutoDescription + extend Imagekit::Internal::Type::Enum + + SUCCESS: :success + PENDING: :pending + FAILED: :failed + + def self?.values: -> ::Array[Imagekit::Models::FileUploadResponse::ExtensionStatus::ai_auto_description] + end + + type aws_auto_tagging = :success | :pending | :failed + + module AwsAutoTagging + extend Imagekit::Internal::Type::Enum + + SUCCESS: :success + PENDING: :pending + FAILED: :failed + + def self?.values: -> ::Array[Imagekit::Models::FileUploadResponse::ExtensionStatus::aws_auto_tagging] + end + + type google_auto_tagging = :success | :pending | :failed + + module GoogleAutoTagging + extend Imagekit::Internal::Type::Enum + + SUCCESS: :success + PENDING: :pending + FAILED: :failed + + def self?.values: -> ::Array[Imagekit::Models::FileUploadResponse::ExtensionStatus::google_auto_tagging] + end + + type remove_bg = :success | :pending | :failed + + module RemoveBg + extend Imagekit::Internal::Type::Enum + + SUCCESS: :success + PENDING: :pending + FAILED: :failed + + def self?.values: -> ::Array[Imagekit::Models::FileUploadResponse::ExtensionStatus::remove_bg] + end + end + + type version_info = { id: String, name: String } + + class VersionInfo < Imagekit::Internal::Type::BaseModel + attr_reader id: String? + + def id=: (String) -> String + + attr_reader name: String? + + def name=: (String) -> String + + def initialize: (?id: String, ?name: String) -> void + + def to_hash: -> { id: String, name: String } + end + end + end +end diff --git a/sig/imagekit/models/files/bulk_add_tags_params.rbs b/sig/imagekit/models/files/bulk_add_tags_params.rbs new file mode 100644 index 00000000..756027fa --- /dev/null +++ b/sig/imagekit/models/files/bulk_add_tags_params.rbs @@ -0,0 +1,30 @@ +module Imagekit + module Models + module Files + type bulk_add_tags_params = + { file_ids: ::Array[String], tags: ::Array[String] } + & Imagekit::Internal::Type::request_parameters + + class BulkAddTagsParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + attr_accessor file_ids: ::Array[String] + + attr_accessor tags: ::Array[String] + + def initialize: ( + file_ids: ::Array[String], + tags: ::Array[String], + ?request_options: Imagekit::request_opts + ) -> void + + def to_hash: -> { + file_ids: ::Array[String], + tags: ::Array[String], + request_options: Imagekit::RequestOptions + } + end + end + end +end diff --git a/sig/imagekit/models/files/bulk_add_tags_response.rbs b/sig/imagekit/models/files/bulk_add_tags_response.rbs new file mode 100644 index 00000000..7d9309bc --- /dev/null +++ b/sig/imagekit/models/files/bulk_add_tags_response.rbs @@ -0,0 +1,20 @@ +module Imagekit + module Models + module Files + type bulk_add_tags_response = + { successfully_updated_file_ids: ::Array[String] } + + class BulkAddTagsResponse < Imagekit::Internal::Type::BaseModel + attr_reader successfully_updated_file_ids: ::Array[String]? + + def successfully_updated_file_ids=: (::Array[String]) -> ::Array[String] + + def initialize: ( + ?successfully_updated_file_ids: ::Array[String] + ) -> void + + def to_hash: -> { successfully_updated_file_ids: ::Array[String] } + end + end + end +end diff --git a/sig/imagekit/models/files/bulk_delete_params.rbs b/sig/imagekit/models/files/bulk_delete_params.rbs new file mode 100644 index 00000000..353a3add --- /dev/null +++ b/sig/imagekit/models/files/bulk_delete_params.rbs @@ -0,0 +1,26 @@ +module Imagekit + module Models + module Files + type bulk_delete_params = + { file_ids: ::Array[String] } + & Imagekit::Internal::Type::request_parameters + + class BulkDeleteParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + attr_accessor file_ids: ::Array[String] + + def initialize: ( + file_ids: ::Array[String], + ?request_options: Imagekit::request_opts + ) -> void + + def to_hash: -> { + file_ids: ::Array[String], + request_options: Imagekit::RequestOptions + } + end + end + end +end diff --git a/sig/imagekit/models/files/bulk_delete_response.rbs b/sig/imagekit/models/files/bulk_delete_response.rbs new file mode 100644 index 00000000..7a5933c1 --- /dev/null +++ b/sig/imagekit/models/files/bulk_delete_response.rbs @@ -0,0 +1,20 @@ +module Imagekit + module Models + module Files + type bulk_delete_response = + { successfully_deleted_file_ids: ::Array[String] } + + class BulkDeleteResponse < Imagekit::Internal::Type::BaseModel + attr_reader successfully_deleted_file_ids: ::Array[String]? + + def successfully_deleted_file_ids=: (::Array[String]) -> ::Array[String] + + def initialize: ( + ?successfully_deleted_file_ids: ::Array[String] + ) -> void + + def to_hash: -> { successfully_deleted_file_ids: ::Array[String] } + end + end + end +end diff --git a/sig/imagekit/models/files/bulk_remove_ai_tags_params.rbs b/sig/imagekit/models/files/bulk_remove_ai_tags_params.rbs new file mode 100644 index 00000000..b7d6122d --- /dev/null +++ b/sig/imagekit/models/files/bulk_remove_ai_tags_params.rbs @@ -0,0 +1,30 @@ +module Imagekit + module Models + module Files + type bulk_remove_ai_tags_params = + { ai_tags: ::Array[String], file_ids: ::Array[String] } + & Imagekit::Internal::Type::request_parameters + + class BulkRemoveAITagsParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + attr_accessor ai_tags: ::Array[String] + + attr_accessor file_ids: ::Array[String] + + def initialize: ( + ai_tags: ::Array[String], + file_ids: ::Array[String], + ?request_options: Imagekit::request_opts + ) -> void + + def to_hash: -> { + ai_tags: ::Array[String], + file_ids: ::Array[String], + request_options: Imagekit::RequestOptions + } + end + end + end +end diff --git a/sig/imagekit/models/files/bulk_remove_ai_tags_response.rbs b/sig/imagekit/models/files/bulk_remove_ai_tags_response.rbs new file mode 100644 index 00000000..ffe753ea --- /dev/null +++ b/sig/imagekit/models/files/bulk_remove_ai_tags_response.rbs @@ -0,0 +1,20 @@ +module Imagekit + module Models + module Files + type bulk_remove_ai_tags_response = + { successfully_updated_file_ids: ::Array[String] } + + class BulkRemoveAITagsResponse < Imagekit::Internal::Type::BaseModel + attr_reader successfully_updated_file_ids: ::Array[String]? + + def successfully_updated_file_ids=: (::Array[String]) -> ::Array[String] + + def initialize: ( + ?successfully_updated_file_ids: ::Array[String] + ) -> void + + def to_hash: -> { successfully_updated_file_ids: ::Array[String] } + end + end + end +end diff --git a/sig/imagekit/models/files/bulk_remove_tags_params.rbs b/sig/imagekit/models/files/bulk_remove_tags_params.rbs new file mode 100644 index 00000000..020cfb2b --- /dev/null +++ b/sig/imagekit/models/files/bulk_remove_tags_params.rbs @@ -0,0 +1,30 @@ +module Imagekit + module Models + module Files + type bulk_remove_tags_params = + { file_ids: ::Array[String], tags: ::Array[String] } + & Imagekit::Internal::Type::request_parameters + + class BulkRemoveTagsParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + attr_accessor file_ids: ::Array[String] + + attr_accessor tags: ::Array[String] + + def initialize: ( + file_ids: ::Array[String], + tags: ::Array[String], + ?request_options: Imagekit::request_opts + ) -> void + + def to_hash: -> { + file_ids: ::Array[String], + tags: ::Array[String], + request_options: Imagekit::RequestOptions + } + end + end + end +end diff --git a/sig/imagekit/models/files/bulk_remove_tags_response.rbs b/sig/imagekit/models/files/bulk_remove_tags_response.rbs new file mode 100644 index 00000000..ab915fda --- /dev/null +++ b/sig/imagekit/models/files/bulk_remove_tags_response.rbs @@ -0,0 +1,20 @@ +module Imagekit + module Models + module Files + type bulk_remove_tags_response = + { successfully_updated_file_ids: ::Array[String] } + + class BulkRemoveTagsResponse < Imagekit::Internal::Type::BaseModel + attr_reader successfully_updated_file_ids: ::Array[String]? + + def successfully_updated_file_ids=: (::Array[String]) -> ::Array[String] + + def initialize: ( + ?successfully_updated_file_ids: ::Array[String] + ) -> void + + def to_hash: -> { successfully_updated_file_ids: ::Array[String] } + end + end + end +end diff --git a/sig/imagekit/models/files/metadata_get_from_url_params.rbs b/sig/imagekit/models/files/metadata_get_from_url_params.rbs new file mode 100644 index 00000000..9a87d773 --- /dev/null +++ b/sig/imagekit/models/files/metadata_get_from_url_params.rbs @@ -0,0 +1,25 @@ +module Imagekit + module Models + module Files + type metadata_get_from_url_params = + { url: String } & Imagekit::Internal::Type::request_parameters + + class MetadataGetFromURLParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + attr_accessor url: String + + def initialize: ( + url: String, + ?request_options: Imagekit::request_opts + ) -> void + + def to_hash: -> { + url: String, + request_options: Imagekit::RequestOptions + } + end + end + end +end diff --git a/sig/imagekit/models/files/metadata_get_params.rbs b/sig/imagekit/models/files/metadata_get_params.rbs new file mode 100644 index 00000000..61c39d07 --- /dev/null +++ b/sig/imagekit/models/files/metadata_get_params.rbs @@ -0,0 +1,17 @@ +module Imagekit + module Models + module Files + type metadata_get_params = + { } & Imagekit::Internal::Type::request_parameters + + class MetadataGetParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + def initialize: (?request_options: Imagekit::request_opts) -> void + + def to_hash: -> { request_options: Imagekit::RequestOptions } + end + end + end +end diff --git a/sig/imagekit/models/files/version_delete_params.rbs b/sig/imagekit/models/files/version_delete_params.rbs new file mode 100644 index 00000000..9a480932 --- /dev/null +++ b/sig/imagekit/models/files/version_delete_params.rbs @@ -0,0 +1,25 @@ +module Imagekit + module Models + module Files + type version_delete_params = + { file_id: String } & Imagekit::Internal::Type::request_parameters + + class VersionDeleteParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + attr_accessor file_id: String + + def initialize: ( + file_id: String, + ?request_options: Imagekit::request_opts + ) -> void + + def to_hash: -> { + file_id: String, + request_options: Imagekit::RequestOptions + } + end + end + end +end diff --git a/sig/imagekit/models/files/version_delete_response.rbs b/sig/imagekit/models/files/version_delete_response.rbs new file mode 100644 index 00000000..6c5f6681 --- /dev/null +++ b/sig/imagekit/models/files/version_delete_response.rbs @@ -0,0 +1,13 @@ +module Imagekit + module Models + module Files + type version_delete_response = { } + + class VersionDeleteResponse < Imagekit::Internal::Type::BaseModel + def initialize: -> void + + def to_hash: -> { } + end + end + end +end diff --git a/sig/imagekit/models/files/version_get_params.rbs b/sig/imagekit/models/files/version_get_params.rbs new file mode 100644 index 00000000..9944b0e5 --- /dev/null +++ b/sig/imagekit/models/files/version_get_params.rbs @@ -0,0 +1,25 @@ +module Imagekit + module Models + module Files + type version_get_params = + { file_id: String } & Imagekit::Internal::Type::request_parameters + + class VersionGetParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + attr_accessor file_id: String + + def initialize: ( + file_id: String, + ?request_options: Imagekit::request_opts + ) -> void + + def to_hash: -> { + file_id: String, + request_options: Imagekit::RequestOptions + } + end + end + end +end diff --git a/sig/imagekit/models/files/version_list_params.rbs b/sig/imagekit/models/files/version_list_params.rbs new file mode 100644 index 00000000..2a67793e --- /dev/null +++ b/sig/imagekit/models/files/version_list_params.rbs @@ -0,0 +1,17 @@ +module Imagekit + module Models + module Files + type version_list_params = + { } & Imagekit::Internal::Type::request_parameters + + class VersionListParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + def initialize: (?request_options: Imagekit::request_opts) -> void + + def to_hash: -> { request_options: Imagekit::RequestOptions } + end + end + end +end diff --git a/sig/imagekit/models/files/version_list_response.rbs b/sig/imagekit/models/files/version_list_response.rbs new file mode 100644 index 00000000..48c5bd45 --- /dev/null +++ b/sig/imagekit/models/files/version_list_response.rbs @@ -0,0 +1,9 @@ +module Imagekit + module Models + module Files + type version_list_response = ::Array[Imagekit::File] + + VersionListResponse: Imagekit::Internal::Type::Converter + end + end +end diff --git a/sig/imagekit/models/files/version_restore_params.rbs b/sig/imagekit/models/files/version_restore_params.rbs new file mode 100644 index 00000000..22ed3a7e --- /dev/null +++ b/sig/imagekit/models/files/version_restore_params.rbs @@ -0,0 +1,25 @@ +module Imagekit + module Models + module Files + type version_restore_params = + { file_id: String } & Imagekit::Internal::Type::request_parameters + + class VersionRestoreParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + attr_accessor file_id: String + + def initialize: ( + file_id: String, + ?request_options: Imagekit::request_opts + ) -> void + + def to_hash: -> { + file_id: String, + request_options: Imagekit::RequestOptions + } + end + end + end +end diff --git a/sig/imagekit/models/folder.rbs b/sig/imagekit/models/folder.rbs new file mode 100644 index 00000000..23c781ba --- /dev/null +++ b/sig/imagekit/models/folder.rbs @@ -0,0 +1,69 @@ +module Imagekit + module Models + type folder = + { + created_at: Time, + folder_id: String, + folder_path: String, + name: String, + type: Imagekit::Models::Folder::type_, + updated_at: Time + } + + class Folder < Imagekit::Internal::Type::BaseModel + attr_reader created_at: Time? + + def created_at=: (Time) -> Time + + attr_reader folder_id: String? + + def folder_id=: (String) -> String + + attr_reader folder_path: String? + + def folder_path=: (String) -> String + + attr_reader name: String? + + def name=: (String) -> String + + attr_reader type: Imagekit::Models::Folder::type_? + + def type=: ( + Imagekit::Models::Folder::type_ + ) -> Imagekit::Models::Folder::type_ + + attr_reader updated_at: Time? + + def updated_at=: (Time) -> Time + + def initialize: ( + ?created_at: Time, + ?folder_id: String, + ?folder_path: String, + ?name: String, + ?type: Imagekit::Models::Folder::type_, + ?updated_at: Time + ) -> void + + def to_hash: -> { + created_at: Time, + folder_id: String, + folder_path: String, + name: String, + type: Imagekit::Models::Folder::type_, + updated_at: Time + } + + type type_ = :folder + + module Type + extend Imagekit::Internal::Type::Enum + + FOLDER: :folder + + def self?.values: -> ::Array[Imagekit::Models::Folder::type_] + end + end + end +end diff --git a/sig/imagekit/models/folder_copy_params.rbs b/sig/imagekit/models/folder_copy_params.rbs new file mode 100644 index 00000000..90f19170 --- /dev/null +++ b/sig/imagekit/models/folder_copy_params.rbs @@ -0,0 +1,38 @@ +module Imagekit + module Models + type folder_copy_params = + { + destination_path: String, + source_folder_path: String, + include_versions: bool + } + & Imagekit::Internal::Type::request_parameters + + class FolderCopyParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + attr_accessor destination_path: String + + attr_accessor source_folder_path: String + + attr_reader include_versions: bool? + + def include_versions=: (bool) -> bool + + def initialize: ( + destination_path: String, + source_folder_path: String, + ?include_versions: bool, + ?request_options: Imagekit::request_opts + ) -> void + + def to_hash: -> { + destination_path: String, + source_folder_path: String, + include_versions: bool, + request_options: Imagekit::RequestOptions + } + end + end +end diff --git a/sig/imagekit/models/folder_copy_response.rbs b/sig/imagekit/models/folder_copy_response.rbs new file mode 100644 index 00000000..3baef44d --- /dev/null +++ b/sig/imagekit/models/folder_copy_response.rbs @@ -0,0 +1,13 @@ +module Imagekit + module Models + type folder_copy_response = { job_id: String } + + class FolderCopyResponse < Imagekit::Internal::Type::BaseModel + attr_accessor job_id: String + + def initialize: (job_id: String) -> void + + def to_hash: -> { job_id: String } + end + end +end diff --git a/sig/imagekit/models/folder_create_params.rbs b/sig/imagekit/models/folder_create_params.rbs new file mode 100644 index 00000000..3dff4c00 --- /dev/null +++ b/sig/imagekit/models/folder_create_params.rbs @@ -0,0 +1,28 @@ +module Imagekit + module Models + type folder_create_params = + { folder_name: String, parent_folder_path: String } + & Imagekit::Internal::Type::request_parameters + + class FolderCreateParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + attr_accessor folder_name: String + + attr_accessor parent_folder_path: String + + def initialize: ( + folder_name: String, + parent_folder_path: String, + ?request_options: Imagekit::request_opts + ) -> void + + def to_hash: -> { + folder_name: String, + parent_folder_path: String, + request_options: Imagekit::RequestOptions + } + end + end +end diff --git a/sig/imagekit/models/folder_create_response.rbs b/sig/imagekit/models/folder_create_response.rbs new file mode 100644 index 00000000..4cc3bed8 --- /dev/null +++ b/sig/imagekit/models/folder_create_response.rbs @@ -0,0 +1,11 @@ +module Imagekit + module Models + type folder_create_response = { } + + class FolderCreateResponse < Imagekit::Internal::Type::BaseModel + def initialize: -> void + + def to_hash: -> { } + end + end +end diff --git a/sig/imagekit/models/folder_delete_params.rbs b/sig/imagekit/models/folder_delete_params.rbs new file mode 100644 index 00000000..ffc943b5 --- /dev/null +++ b/sig/imagekit/models/folder_delete_params.rbs @@ -0,0 +1,23 @@ +module Imagekit + module Models + type folder_delete_params = + { folder_path: String } & Imagekit::Internal::Type::request_parameters + + class FolderDeleteParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + attr_accessor folder_path: String + + def initialize: ( + folder_path: String, + ?request_options: Imagekit::request_opts + ) -> void + + def to_hash: -> { + folder_path: String, + request_options: Imagekit::RequestOptions + } + end + end +end diff --git a/sig/imagekit/models/folder_delete_response.rbs b/sig/imagekit/models/folder_delete_response.rbs new file mode 100644 index 00000000..9dcdda77 --- /dev/null +++ b/sig/imagekit/models/folder_delete_response.rbs @@ -0,0 +1,11 @@ +module Imagekit + module Models + type folder_delete_response = { } + + class FolderDeleteResponse < Imagekit::Internal::Type::BaseModel + def initialize: -> void + + def to_hash: -> { } + end + end +end diff --git a/sig/imagekit/models/folder_move_params.rbs b/sig/imagekit/models/folder_move_params.rbs new file mode 100644 index 00000000..50d1d68a --- /dev/null +++ b/sig/imagekit/models/folder_move_params.rbs @@ -0,0 +1,28 @@ +module Imagekit + module Models + type folder_move_params = + { destination_path: String, source_folder_path: String } + & Imagekit::Internal::Type::request_parameters + + class FolderMoveParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + attr_accessor destination_path: String + + attr_accessor source_folder_path: String + + def initialize: ( + destination_path: String, + source_folder_path: String, + ?request_options: Imagekit::request_opts + ) -> void + + def to_hash: -> { + destination_path: String, + source_folder_path: String, + request_options: Imagekit::RequestOptions + } + end + end +end diff --git a/sig/imagekit/models/folder_move_response.rbs b/sig/imagekit/models/folder_move_response.rbs new file mode 100644 index 00000000..dd788a3e --- /dev/null +++ b/sig/imagekit/models/folder_move_response.rbs @@ -0,0 +1,13 @@ +module Imagekit + module Models + type folder_move_response = { job_id: String } + + class FolderMoveResponse < Imagekit::Internal::Type::BaseModel + attr_accessor job_id: String + + def initialize: (job_id: String) -> void + + def to_hash: -> { job_id: String } + end + end +end diff --git a/sig/imagekit/models/folder_rename_params.rbs b/sig/imagekit/models/folder_rename_params.rbs new file mode 100644 index 00000000..ddb509d9 --- /dev/null +++ b/sig/imagekit/models/folder_rename_params.rbs @@ -0,0 +1,34 @@ +module Imagekit + module Models + type folder_rename_params = + { folder_path: String, new_folder_name: String, purge_cache: bool } + & Imagekit::Internal::Type::request_parameters + + class FolderRenameParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + attr_accessor folder_path: String + + attr_accessor new_folder_name: String + + attr_reader purge_cache: bool? + + def purge_cache=: (bool) -> bool + + def initialize: ( + folder_path: String, + new_folder_name: String, + ?purge_cache: bool, + ?request_options: Imagekit::request_opts + ) -> void + + def to_hash: -> { + folder_path: String, + new_folder_name: String, + purge_cache: bool, + request_options: Imagekit::RequestOptions + } + end + end +end diff --git a/sig/imagekit/models/folder_rename_response.rbs b/sig/imagekit/models/folder_rename_response.rbs new file mode 100644 index 00000000..8b24b6dd --- /dev/null +++ b/sig/imagekit/models/folder_rename_response.rbs @@ -0,0 +1,13 @@ +module Imagekit + module Models + type folder_rename_response = { job_id: String } + + class FolderRenameResponse < Imagekit::Internal::Type::BaseModel + attr_accessor job_id: String + + def initialize: (job_id: String) -> void + + def to_hash: -> { job_id: String } + end + end +end diff --git a/sig/imagekit/models/folders/job_get_params.rbs b/sig/imagekit/models/folders/job_get_params.rbs new file mode 100644 index 00000000..ea747749 --- /dev/null +++ b/sig/imagekit/models/folders/job_get_params.rbs @@ -0,0 +1,16 @@ +module Imagekit + module Models + module Folders + type job_get_params = { } & Imagekit::Internal::Type::request_parameters + + class JobGetParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + def initialize: (?request_options: Imagekit::request_opts) -> void + + def to_hash: -> { request_options: Imagekit::RequestOptions } + end + end + end +end diff --git a/sig/imagekit/models/folders/job_get_response.rbs b/sig/imagekit/models/folders/job_get_response.rbs new file mode 100644 index 00000000..dcda6269 --- /dev/null +++ b/sig/imagekit/models/folders/job_get_response.rbs @@ -0,0 +1,72 @@ +module Imagekit + module Models + module Folders + type job_get_response = + { + job_id: String, + purge_request_id: String, + status: Imagekit::Models::Folders::JobGetResponse::status, + type: Imagekit::Models::Folders::JobGetResponse::type_ + } + + class JobGetResponse < Imagekit::Internal::Type::BaseModel + attr_reader job_id: String? + + def job_id=: (String) -> String + + attr_reader purge_request_id: String? + + def purge_request_id=: (String) -> String + + attr_reader status: Imagekit::Models::Folders::JobGetResponse::status? + + def status=: ( + Imagekit::Models::Folders::JobGetResponse::status + ) -> Imagekit::Models::Folders::JobGetResponse::status + + attr_reader type: Imagekit::Models::Folders::JobGetResponse::type_? + + def type=: ( + Imagekit::Models::Folders::JobGetResponse::type_ + ) -> Imagekit::Models::Folders::JobGetResponse::type_ + + def initialize: ( + ?job_id: String, + ?purge_request_id: String, + ?status: Imagekit::Models::Folders::JobGetResponse::status, + ?type: Imagekit::Models::Folders::JobGetResponse::type_ + ) -> void + + def to_hash: -> { + job_id: String, + purge_request_id: String, + status: Imagekit::Models::Folders::JobGetResponse::status, + type: Imagekit::Models::Folders::JobGetResponse::type_ + } + + type status = :Pending | :Completed + + module Status + extend Imagekit::Internal::Type::Enum + + PENDING: :Pending + COMPLETED: :Completed + + def self?.values: -> ::Array[Imagekit::Models::Folders::JobGetResponse::status] + end + + type type_ = :COPY_FOLDER | :MOVE_FOLDER | :RENAME_FOLDER + + module Type + extend Imagekit::Internal::Type::Enum + + COPY_FOLDER: :COPY_FOLDER + MOVE_FOLDER: :MOVE_FOLDER + RENAME_FOLDER: :RENAME_FOLDER + + def self?.values: -> ::Array[Imagekit::Models::Folders::JobGetResponse::type_] + end + end + end + end +end diff --git a/sig/imagekit/models/image_overlay.rbs b/sig/imagekit/models/image_overlay.rbs new file mode 100644 index 00000000..83313253 --- /dev/null +++ b/sig/imagekit/models/image_overlay.rbs @@ -0,0 +1,59 @@ +module Imagekit + module Models + type image_overlay = + { + input: String, + type: :image, + encoding: Imagekit::Models::ImageOverlay::encoding, + transformation: ::Array[Imagekit::Transformation] + } + + class ImageOverlay < Imagekit::Models::BaseOverlay + def input: -> String + + def input=: (String _) -> String + + def `type`: -> :image + + def type=: (:image _) -> :image + + def encoding: -> Imagekit::Models::ImageOverlay::encoding? + + def encoding=: ( + Imagekit::Models::ImageOverlay::encoding _ + ) -> Imagekit::Models::ImageOverlay::encoding + + def transformation: -> ::Array[Imagekit::Transformation]? + + def transformation=: ( + ::Array[Imagekit::Transformation] _ + ) -> ::Array[Imagekit::Transformation] + + def initialize: ( + input: String, + ?encoding: Imagekit::Models::ImageOverlay::encoding, + ?transformation: ::Array[Imagekit::Transformation], + ?type: :image + ) -> void + + def to_hash: -> { + input: String, + type: :image, + encoding: Imagekit::Models::ImageOverlay::encoding, + transformation: ::Array[Imagekit::Transformation] + } + + type encoding = :auto | :plain | :base64 + + module Encoding + extend Imagekit::Internal::Type::Enum + + AUTO: :auto + PLAIN: :plain + BASE64: :base64 + + def self?.values: -> ::Array[Imagekit::Models::ImageOverlay::encoding] + end + end + end +end diff --git a/sig/imagekit/models/metadata.rbs b/sig/imagekit/models/metadata.rbs new file mode 100644 index 00000000..789a9376 --- /dev/null +++ b/sig/imagekit/models/metadata.rbs @@ -0,0 +1,546 @@ +module Imagekit + module Models + type metadata = + { + audio_codec: String, + bit_rate: Integer, + density: Integer, + duration: Integer, + exif: Imagekit::Metadata::Exif, + format_: String, + has_color_profile: bool, + has_transparency: bool, + height: Integer, + p_hash: String, + quality: Integer, + size: Integer, + video_codec: String, + width: Integer + } + + class Metadata < Imagekit::Internal::Type::BaseModel + attr_reader audio_codec: String? + + def audio_codec=: (String) -> String + + attr_reader bit_rate: Integer? + + def bit_rate=: (Integer) -> Integer + + attr_reader density: Integer? + + def density=: (Integer) -> Integer + + attr_reader duration: Integer? + + def duration=: (Integer) -> Integer + + attr_reader exif: Imagekit::Metadata::Exif? + + def exif=: (Imagekit::Metadata::Exif) -> Imagekit::Metadata::Exif + + attr_reader format_: String? + + def format_=: (String) -> String + + attr_reader has_color_profile: bool? + + def has_color_profile=: (bool) -> bool + + attr_reader has_transparency: bool? + + def has_transparency=: (bool) -> bool + + attr_reader height: Integer? + + def height=: (Integer) -> Integer + + attr_reader p_hash: String? + + def p_hash=: (String) -> String + + attr_reader quality: Integer? + + def quality=: (Integer) -> Integer + + attr_reader size: Integer? + + def size=: (Integer) -> Integer + + attr_reader video_codec: String? + + def video_codec=: (String) -> String + + attr_reader width: Integer? + + def width=: (Integer) -> Integer + + def initialize: ( + ?audio_codec: String, + ?bit_rate: Integer, + ?density: Integer, + ?duration: Integer, + ?exif: Imagekit::Metadata::Exif, + ?format_: String, + ?has_color_profile: bool, + ?has_transparency: bool, + ?height: Integer, + ?p_hash: String, + ?quality: Integer, + ?size: Integer, + ?video_codec: String, + ?width: Integer + ) -> void + + def to_hash: -> { + audio_codec: String, + bit_rate: Integer, + density: Integer, + duration: Integer, + exif: Imagekit::Metadata::Exif, + format_: String, + has_color_profile: bool, + has_transparency: bool, + height: Integer, + p_hash: String, + quality: Integer, + size: Integer, + video_codec: String, + width: Integer + } + + type exif = + { + exif: Imagekit::Metadata::Exif::Exif, + gps: Imagekit::Metadata::Exif::Gps, + image: Imagekit::Metadata::Exif::Image, + interoperability: Imagekit::Metadata::Exif::Interoperability, + makernote: ::Hash[Symbol, top], + thumbnail: Imagekit::Metadata::Exif::Thumbnail + } + + class Exif < Imagekit::Internal::Type::BaseModel + attr_reader exif: Imagekit::Metadata::Exif::Exif? + + def exif=: ( + Imagekit::Metadata::Exif::Exif + ) -> Imagekit::Metadata::Exif::Exif + + attr_reader gps: Imagekit::Metadata::Exif::Gps? + + def gps=: ( + Imagekit::Metadata::Exif::Gps + ) -> Imagekit::Metadata::Exif::Gps + + attr_reader image: Imagekit::Metadata::Exif::Image? + + def image=: ( + Imagekit::Metadata::Exif::Image + ) -> Imagekit::Metadata::Exif::Image + + attr_reader interoperability: Imagekit::Metadata::Exif::Interoperability? + + def interoperability=: ( + Imagekit::Metadata::Exif::Interoperability + ) -> Imagekit::Metadata::Exif::Interoperability + + attr_reader makernote: ::Hash[Symbol, top]? + + def makernote=: (::Hash[Symbol, top]) -> ::Hash[Symbol, top] + + attr_reader thumbnail: Imagekit::Metadata::Exif::Thumbnail? + + def thumbnail=: ( + Imagekit::Metadata::Exif::Thumbnail + ) -> Imagekit::Metadata::Exif::Thumbnail + + def initialize: ( + ?exif: Imagekit::Metadata::Exif::Exif, + ?gps: Imagekit::Metadata::Exif::Gps, + ?image: Imagekit::Metadata::Exif::Image, + ?interoperability: Imagekit::Metadata::Exif::Interoperability, + ?makernote: ::Hash[Symbol, top], + ?thumbnail: Imagekit::Metadata::Exif::Thumbnail + ) -> void + + def to_hash: -> { + exif: Imagekit::Metadata::Exif::Exif, + gps: Imagekit::Metadata::Exif::Gps, + image: Imagekit::Metadata::Exif::Image, + interoperability: Imagekit::Metadata::Exif::Interoperability, + makernote: ::Hash[Symbol, top], + thumbnail: Imagekit::Metadata::Exif::Thumbnail + } + + type exif = + { + aperture_value: Float, + color_space: Integer, + create_date: String, + custom_rendered: Integer, + date_time_original: String, + exif_image_height: Integer, + exif_image_width: Integer, + exif_version: String, + exposure_compensation: Float, + exposure_mode: Integer, + exposure_program: Integer, + exposure_time: Float, + flash: Integer, + flashpix_version: String, + f_number: Float, + focal_length: Integer, + focal_plane_resolution_unit: Integer, + focal_plane_x_resolution: Float, + focal_plane_y_resolution: Float, + interop_offset: Integer, + iso: Integer, + metering_mode: Integer, + scene_capture_type: Integer, + shutter_speed_value: Float, + sub_sec_time: String, + white_balance: Integer + } + + class Exif < Imagekit::Internal::Type::BaseModel + attr_reader aperture_value: Float? + + def aperture_value=: (Float) -> Float + + attr_reader color_space: Integer? + + def color_space=: (Integer) -> Integer + + attr_reader create_date: String? + + def create_date=: (String) -> String + + attr_reader custom_rendered: Integer? + + def custom_rendered=: (Integer) -> Integer + + attr_reader date_time_original: String? + + def date_time_original=: (String) -> String + + attr_reader exif_image_height: Integer? + + def exif_image_height=: (Integer) -> Integer + + attr_reader exif_image_width: Integer? + + def exif_image_width=: (Integer) -> Integer + + attr_reader exif_version: String? + + def exif_version=: (String) -> String + + attr_reader exposure_compensation: Float? + + def exposure_compensation=: (Float) -> Float + + attr_reader exposure_mode: Integer? + + def exposure_mode=: (Integer) -> Integer + + attr_reader exposure_program: Integer? + + def exposure_program=: (Integer) -> Integer + + attr_reader exposure_time: Float? + + def exposure_time=: (Float) -> Float + + attr_reader flash: Integer? + + def flash=: (Integer) -> Integer + + attr_reader flashpix_version: String? + + def flashpix_version=: (String) -> String + + attr_reader f_number: Float? + + def f_number=: (Float) -> Float + + attr_reader focal_length: Integer? + + def focal_length=: (Integer) -> Integer + + attr_reader focal_plane_resolution_unit: Integer? + + def focal_plane_resolution_unit=: (Integer) -> Integer + + attr_reader focal_plane_x_resolution: Float? + + def focal_plane_x_resolution=: (Float) -> Float + + attr_reader focal_plane_y_resolution: Float? + + def focal_plane_y_resolution=: (Float) -> Float + + attr_reader interop_offset: Integer? + + def interop_offset=: (Integer) -> Integer + + attr_reader iso: Integer? + + def iso=: (Integer) -> Integer + + attr_reader metering_mode: Integer? + + def metering_mode=: (Integer) -> Integer + + attr_reader scene_capture_type: Integer? + + def scene_capture_type=: (Integer) -> Integer + + attr_reader shutter_speed_value: Float? + + def shutter_speed_value=: (Float) -> Float + + attr_reader sub_sec_time: String? + + def sub_sec_time=: (String) -> String + + attr_reader white_balance: Integer? + + def white_balance=: (Integer) -> Integer + + def initialize: ( + ?aperture_value: Float, + ?color_space: Integer, + ?create_date: String, + ?custom_rendered: Integer, + ?date_time_original: String, + ?exif_image_height: Integer, + ?exif_image_width: Integer, + ?exif_version: String, + ?exposure_compensation: Float, + ?exposure_mode: Integer, + ?exposure_program: Integer, + ?exposure_time: Float, + ?flash: Integer, + ?flashpix_version: String, + ?f_number: Float, + ?focal_length: Integer, + ?focal_plane_resolution_unit: Integer, + ?focal_plane_x_resolution: Float, + ?focal_plane_y_resolution: Float, + ?interop_offset: Integer, + ?iso: Integer, + ?metering_mode: Integer, + ?scene_capture_type: Integer, + ?shutter_speed_value: Float, + ?sub_sec_time: String, + ?white_balance: Integer + ) -> void + + def to_hash: -> { + aperture_value: Float, + color_space: Integer, + create_date: String, + custom_rendered: Integer, + date_time_original: String, + exif_image_height: Integer, + exif_image_width: Integer, + exif_version: String, + exposure_compensation: Float, + exposure_mode: Integer, + exposure_program: Integer, + exposure_time: Float, + flash: Integer, + flashpix_version: String, + f_number: Float, + focal_length: Integer, + focal_plane_resolution_unit: Integer, + focal_plane_x_resolution: Float, + focal_plane_y_resolution: Float, + interop_offset: Integer, + iso: Integer, + metering_mode: Integer, + scene_capture_type: Integer, + shutter_speed_value: Float, + sub_sec_time: String, + white_balance: Integer + } + end + + type gps = { gps_version_id: ::Array[Integer] } + + class Gps < Imagekit::Internal::Type::BaseModel + attr_reader gps_version_id: ::Array[Integer]? + + def gps_version_id=: (::Array[Integer]) -> ::Array[Integer] + + def initialize: (?gps_version_id: ::Array[Integer]) -> void + + def to_hash: -> { gps_version_id: ::Array[Integer] } + end + + type image = + { + exif_offset: Integer, + gps_info: Integer, + make: String, + model: String, + modify_date: String, + orientation: Integer, + resolution_unit: Integer, + software: String, + x_resolution: Integer, + y_cb_cr_positioning: Integer, + y_resolution: Integer + } + + class Image < Imagekit::Internal::Type::BaseModel + attr_reader exif_offset: Integer? + + def exif_offset=: (Integer) -> Integer + + attr_reader gps_info: Integer? + + def gps_info=: (Integer) -> Integer + + attr_reader make: String? + + def make=: (String) -> String + + attr_reader model: String? + + def model=: (String) -> String + + attr_reader modify_date: String? + + def modify_date=: (String) -> String + + attr_reader orientation: Integer? + + def orientation=: (Integer) -> Integer + + attr_reader resolution_unit: Integer? + + def resolution_unit=: (Integer) -> Integer + + attr_reader software: String? + + def software=: (String) -> String + + attr_reader x_resolution: Integer? + + def x_resolution=: (Integer) -> Integer + + attr_reader y_cb_cr_positioning: Integer? + + def y_cb_cr_positioning=: (Integer) -> Integer + + attr_reader y_resolution: Integer? + + def y_resolution=: (Integer) -> Integer + + def initialize: ( + ?exif_offset: Integer, + ?gps_info: Integer, + ?make: String, + ?model: String, + ?modify_date: String, + ?orientation: Integer, + ?resolution_unit: Integer, + ?software: String, + ?x_resolution: Integer, + ?y_cb_cr_positioning: Integer, + ?y_resolution: Integer + ) -> void + + def to_hash: -> { + exif_offset: Integer, + gps_info: Integer, + make: String, + model: String, + modify_date: String, + orientation: Integer, + resolution_unit: Integer, + software: String, + x_resolution: Integer, + y_cb_cr_positioning: Integer, + y_resolution: Integer + } + end + + type interoperability = + { interop_index: String, interop_version: String } + + class Interoperability < Imagekit::Internal::Type::BaseModel + attr_reader interop_index: String? + + def interop_index=: (String) -> String + + attr_reader interop_version: String? + + def interop_version=: (String) -> String + + def initialize: ( + ?interop_index: String, + ?interop_version: String + ) -> void + + def to_hash: -> { interop_index: String, interop_version: String } + end + + type thumbnail = + { + compression: Integer, + resolution_unit: Integer, + thumbnail_length: Integer, + thumbnail_offset: Integer, + x_resolution: Integer, + y_resolution: Integer + } + + class Thumbnail < Imagekit::Internal::Type::BaseModel + attr_reader compression: Integer? + + def compression=: (Integer) -> Integer + + attr_reader resolution_unit: Integer? + + def resolution_unit=: (Integer) -> Integer + + attr_reader thumbnail_length: Integer? + + def thumbnail_length=: (Integer) -> Integer + + attr_reader thumbnail_offset: Integer? + + def thumbnail_offset=: (Integer) -> Integer + + attr_reader x_resolution: Integer? + + def x_resolution=: (Integer) -> Integer + + attr_reader y_resolution: Integer? + + def y_resolution=: (Integer) -> Integer + + def initialize: ( + ?compression: Integer, + ?resolution_unit: Integer, + ?thumbnail_length: Integer, + ?thumbnail_offset: Integer, + ?x_resolution: Integer, + ?y_resolution: Integer + ) -> void + + def to_hash: -> { + compression: Integer, + resolution_unit: Integer, + thumbnail_length: Integer, + thumbnail_offset: Integer, + x_resolution: Integer, + y_resolution: Integer + } + end + end + end + end +end diff --git a/sig/imagekit/models/overlay.rbs b/sig/imagekit/models/overlay.rbs new file mode 100644 index 00000000..2172be0b --- /dev/null +++ b/sig/imagekit/models/overlay.rbs @@ -0,0 +1,16 @@ +module Imagekit + module Models + type overlay = + Imagekit::TextOverlay + | Imagekit::ImageOverlay + | Imagekit::VideoOverlay + | Imagekit::SubtitleOverlay + | Imagekit::SolidColorOverlay + + module Overlay + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::overlay] + end + end +end diff --git a/sig/imagekit/models/overlay_position.rbs b/sig/imagekit/models/overlay_position.rbs new file mode 100644 index 00000000..8576502e --- /dev/null +++ b/sig/imagekit/models/overlay_position.rbs @@ -0,0 +1,85 @@ +module Imagekit + module Models + type overlay_position = + { + focus: Imagekit::Models::OverlayPosition::focus, + x: Imagekit::Models::OverlayPosition::x, + y_: Imagekit::Models::OverlayPosition::y_ + } + + class OverlayPosition < Imagekit::Internal::Type::BaseModel + attr_reader focus: Imagekit::Models::OverlayPosition::focus? + + def focus=: ( + Imagekit::Models::OverlayPosition::focus + ) -> Imagekit::Models::OverlayPosition::focus + + attr_reader x: Imagekit::Models::OverlayPosition::x? + + def x=: ( + Imagekit::Models::OverlayPosition::x + ) -> Imagekit::Models::OverlayPosition::x + + attr_reader y_: Imagekit::Models::OverlayPosition::y_? + + def y_=: ( + Imagekit::Models::OverlayPosition::y_ + ) -> Imagekit::Models::OverlayPosition::y_ + + def initialize: ( + ?focus: Imagekit::Models::OverlayPosition::focus, + ?x: Imagekit::Models::OverlayPosition::x, + ?y_: Imagekit::Models::OverlayPosition::y_ + ) -> void + + def to_hash: -> { + focus: Imagekit::Models::OverlayPosition::focus, + x: Imagekit::Models::OverlayPosition::x, + y_: Imagekit::Models::OverlayPosition::y_ + } + + type focus = + :center + | :top + | :left + | :bottom + | :right + | :top_left + | :top_right + | :bottom_left + | :bottom_right + + module Focus + extend Imagekit::Internal::Type::Enum + + CENTER: :center + TOP: :top + LEFT: :left + BOTTOM: :bottom + RIGHT: :right + TOP_LEFT: :top_left + TOP_RIGHT: :top_right + BOTTOM_LEFT: :bottom_left + BOTTOM_RIGHT: :bottom_right + + def self?.values: -> ::Array[Imagekit::Models::OverlayPosition::focus] + end + + type x = Float | String + + module X + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::OverlayPosition::x] + end + + type y_ = Float | String + + module Y + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::OverlayPosition::y_] + end + end + end +end diff --git a/sig/imagekit/models/overlay_timing.rbs b/sig/imagekit/models/overlay_timing.rbs new file mode 100644 index 00000000..4cafca16 --- /dev/null +++ b/sig/imagekit/models/overlay_timing.rbs @@ -0,0 +1,66 @@ +module Imagekit + module Models + type overlay_timing = + { + duration: Imagekit::Models::OverlayTiming::duration, + end_: Imagekit::Models::OverlayTiming::end_, + start: Imagekit::Models::OverlayTiming::start + } + + class OverlayTiming < Imagekit::Internal::Type::BaseModel + attr_reader duration: Imagekit::Models::OverlayTiming::duration? + + def duration=: ( + Imagekit::Models::OverlayTiming::duration + ) -> Imagekit::Models::OverlayTiming::duration + + attr_reader end_: Imagekit::Models::OverlayTiming::end_? + + def end_=: ( + Imagekit::Models::OverlayTiming::end_ + ) -> Imagekit::Models::OverlayTiming::end_ + + attr_reader start: Imagekit::Models::OverlayTiming::start? + + def start=: ( + Imagekit::Models::OverlayTiming::start + ) -> Imagekit::Models::OverlayTiming::start + + def initialize: ( + ?duration: Imagekit::Models::OverlayTiming::duration, + ?end_: Imagekit::Models::OverlayTiming::end_, + ?start: Imagekit::Models::OverlayTiming::start + ) -> void + + def to_hash: -> { + duration: Imagekit::Models::OverlayTiming::duration, + end_: Imagekit::Models::OverlayTiming::end_, + start: Imagekit::Models::OverlayTiming::start + } + + type duration = Float | String + + module Duration + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::OverlayTiming::duration] + end + + type end_ = Float | String + + module End + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::OverlayTiming::end_] + end + + type start = Float | String + + module Start + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::OverlayTiming::start] + end + end + end +end diff --git a/sig/imagekit/models/solid_color_overlay.rbs b/sig/imagekit/models/solid_color_overlay.rbs new file mode 100644 index 00000000..1b4271e4 --- /dev/null +++ b/sig/imagekit/models/solid_color_overlay.rbs @@ -0,0 +1,38 @@ +module Imagekit + module Models + type solid_color_overlay = + { + color: String, + type: :solidColor, + transformation: ::Array[Imagekit::SolidColorOverlayTransformation] + } + + class SolidColorOverlay < Imagekit::Models::BaseOverlay + def color: -> String + + def color=: (String _) -> String + + def `type`: -> :solidColor + + def type=: (:solidColor _) -> :solidColor + + def transformation: -> ::Array[Imagekit::SolidColorOverlayTransformation]? + + def transformation=: ( + ::Array[Imagekit::SolidColorOverlayTransformation] _ + ) -> ::Array[Imagekit::SolidColorOverlayTransformation] + + def initialize: ( + color: String, + ?transformation: ::Array[Imagekit::SolidColorOverlayTransformation], + ?type: :solidColor + ) -> void + + def to_hash: -> { + color: String, + type: :solidColor, + transformation: ::Array[Imagekit::SolidColorOverlayTransformation] + } + end + end +end diff --git a/sig/imagekit/models/solid_color_overlay_transformation.rbs b/sig/imagekit/models/solid_color_overlay_transformation.rbs new file mode 100644 index 00000000..3e664364 --- /dev/null +++ b/sig/imagekit/models/solid_color_overlay_transformation.rbs @@ -0,0 +1,97 @@ +module Imagekit + module Models + type solid_color_overlay_transformation = + { + alpha: Float, + background: String, + gradient: Imagekit::Models::SolidColorOverlayTransformation::gradient, + height: Imagekit::Models::SolidColorOverlayTransformation::height, + radius: Imagekit::Models::SolidColorOverlayTransformation::radius, + width: Imagekit::Models::SolidColorOverlayTransformation::width + } + + class SolidColorOverlayTransformation < Imagekit::Internal::Type::BaseModel + attr_reader alpha: Float? + + def alpha=: (Float) -> Float + + attr_reader background: String? + + def background=: (String) -> String + + attr_reader gradient: Imagekit::Models::SolidColorOverlayTransformation::gradient? + + def gradient=: ( + Imagekit::Models::SolidColorOverlayTransformation::gradient + ) -> Imagekit::Models::SolidColorOverlayTransformation::gradient + + attr_reader height: Imagekit::Models::SolidColorOverlayTransformation::height? + + def height=: ( + Imagekit::Models::SolidColorOverlayTransformation::height + ) -> Imagekit::Models::SolidColorOverlayTransformation::height + + attr_reader radius: Imagekit::Models::SolidColorOverlayTransformation::radius? + + def radius=: ( + Imagekit::Models::SolidColorOverlayTransformation::radius + ) -> Imagekit::Models::SolidColorOverlayTransformation::radius + + attr_reader width: Imagekit::Models::SolidColorOverlayTransformation::width? + + def width=: ( + Imagekit::Models::SolidColorOverlayTransformation::width + ) -> Imagekit::Models::SolidColorOverlayTransformation::width + + def initialize: ( + ?alpha: Float, + ?background: String, + ?gradient: Imagekit::Models::SolidColorOverlayTransformation::gradient, + ?height: Imagekit::Models::SolidColorOverlayTransformation::height, + ?radius: Imagekit::Models::SolidColorOverlayTransformation::radius, + ?width: Imagekit::Models::SolidColorOverlayTransformation::width + ) -> void + + def to_hash: -> { + alpha: Float, + background: String, + gradient: Imagekit::Models::SolidColorOverlayTransformation::gradient, + height: Imagekit::Models::SolidColorOverlayTransformation::height, + radius: Imagekit::Models::SolidColorOverlayTransformation::radius, + width: Imagekit::Models::SolidColorOverlayTransformation::width + } + + type gradient = true | String + + module Gradient + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::SolidColorOverlayTransformation::gradient] + end + + type height = Float | String + + module Height + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::SolidColorOverlayTransformation::height] + end + + type radius = Float | :max + + module Radius + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::SolidColorOverlayTransformation::radius] + end + + type width = Float | String + + module Width + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::SolidColorOverlayTransformation::width] + end + end + end +end diff --git a/sig/imagekit/models/src_options.rbs b/sig/imagekit/models/src_options.rbs new file mode 100644 index 00000000..185f2522 --- /dev/null +++ b/sig/imagekit/models/src_options.rbs @@ -0,0 +1,64 @@ +module Imagekit + module Models + type src_options = + { + src: String, + url_endpoint: String, + expires_in: Float, + query_parameters: ::Hash[Symbol, String], + signed: bool, + transformation: ::Array[Imagekit::Transformation], + transformation_position: Imagekit::Models::transformation_position + } + + class SrcOptions < Imagekit::Internal::Type::BaseModel + attr_accessor src: String + + attr_accessor url_endpoint: String + + attr_reader expires_in: Float? + + def expires_in=: (Float) -> Float + + attr_reader query_parameters: ::Hash[Symbol, String]? + + def query_parameters=: (::Hash[Symbol, String]) -> ::Hash[Symbol, String] + + attr_reader signed: bool? + + def signed=: (bool) -> bool + + attr_reader transformation: ::Array[Imagekit::Transformation]? + + def transformation=: ( + ::Array[Imagekit::Transformation] + ) -> ::Array[Imagekit::Transformation] + + attr_reader transformation_position: Imagekit::Models::transformation_position? + + def transformation_position=: ( + Imagekit::Models::transformation_position + ) -> Imagekit::Models::transformation_position + + def initialize: ( + src: String, + url_endpoint: String, + ?expires_in: Float, + ?query_parameters: ::Hash[Symbol, String], + ?signed: bool, + ?transformation: ::Array[Imagekit::Transformation], + ?transformation_position: Imagekit::Models::transformation_position + ) -> void + + def to_hash: -> { + src: String, + url_endpoint: String, + expires_in: Float, + query_parameters: ::Hash[Symbol, String], + signed: bool, + transformation: ::Array[Imagekit::Transformation], + transformation_position: Imagekit::Models::transformation_position + } + end + end +end diff --git a/sig/imagekit/models/streaming_resolution.rbs b/sig/imagekit/models/streaming_resolution.rbs new file mode 100644 index 00000000..7892c2cf --- /dev/null +++ b/sig/imagekit/models/streaming_resolution.rbs @@ -0,0 +1,20 @@ +module Imagekit + module Models + type streaming_resolution = + :"240" | :"360" | :"480" | :"720" | :"1080" | :"1440" | :"2160" + + module StreamingResolution + extend Imagekit::Internal::Type::Enum + + STREAMING_RESOLUTION_240: :"240" + STREAMING_RESOLUTION_360: :"360" + STREAMING_RESOLUTION_480: :"480" + STREAMING_RESOLUTION_720: :"720" + STREAMING_RESOLUTION_1080: :"1080" + STREAMING_RESOLUTION_1440: :"1440" + STREAMING_RESOLUTION_2160: :"2160" + + def self?.values: -> ::Array[Imagekit::Models::streaming_resolution] + end + end +end diff --git a/sig/imagekit/models/subtitle_overlay.rbs b/sig/imagekit/models/subtitle_overlay.rbs new file mode 100644 index 00000000..ce4b25d9 --- /dev/null +++ b/sig/imagekit/models/subtitle_overlay.rbs @@ -0,0 +1,59 @@ +module Imagekit + module Models + type subtitle_overlay = + { + input: String, + type: :subtitle, + encoding: Imagekit::Models::SubtitleOverlay::encoding, + transformation: ::Array[Imagekit::SubtitleOverlayTransformation] + } + + class SubtitleOverlay < Imagekit::Models::BaseOverlay + def input: -> String + + def input=: (String _) -> String + + def `type`: -> :subtitle + + def type=: (:subtitle _) -> :subtitle + + def encoding: -> Imagekit::Models::SubtitleOverlay::encoding? + + def encoding=: ( + Imagekit::Models::SubtitleOverlay::encoding _ + ) -> Imagekit::Models::SubtitleOverlay::encoding + + def transformation: -> ::Array[Imagekit::SubtitleOverlayTransformation]? + + def transformation=: ( + ::Array[Imagekit::SubtitleOverlayTransformation] _ + ) -> ::Array[Imagekit::SubtitleOverlayTransformation] + + def initialize: ( + input: String, + ?encoding: Imagekit::Models::SubtitleOverlay::encoding, + ?transformation: ::Array[Imagekit::SubtitleOverlayTransformation], + ?type: :subtitle + ) -> void + + def to_hash: -> { + input: String, + type: :subtitle, + encoding: Imagekit::Models::SubtitleOverlay::encoding, + transformation: ::Array[Imagekit::SubtitleOverlayTransformation] + } + + type encoding = :auto | :plain | :base64 + + module Encoding + extend Imagekit::Internal::Type::Enum + + AUTO: :auto + PLAIN: :plain + BASE64: :base64 + + def self?.values: -> ::Array[Imagekit::Models::SubtitleOverlay::encoding] + end + end + end +end diff --git a/sig/imagekit/models/subtitle_overlay_transformation.rbs b/sig/imagekit/models/subtitle_overlay_transformation.rbs new file mode 100644 index 00000000..21d04177 --- /dev/null +++ b/sig/imagekit/models/subtitle_overlay_transformation.rbs @@ -0,0 +1,78 @@ +module Imagekit + module Models + type subtitle_overlay_transformation = + { + background: String, + color: String, + font_family: String, + font_outline: String, + font_shadow: String, + font_size: Float, + typography: Imagekit::Models::SubtitleOverlayTransformation::typography + } + + class SubtitleOverlayTransformation < Imagekit::Internal::Type::BaseModel + attr_reader background: String? + + def background=: (String) -> String + + attr_reader color: String? + + def color=: (String) -> String + + attr_reader font_family: String? + + def font_family=: (String) -> String + + attr_reader font_outline: String? + + def font_outline=: (String) -> String + + attr_reader font_shadow: String? + + def font_shadow=: (String) -> String + + attr_reader font_size: Float? + + def font_size=: (Float) -> Float + + attr_reader typography: Imagekit::Models::SubtitleOverlayTransformation::typography? + + def typography=: ( + Imagekit::Models::SubtitleOverlayTransformation::typography + ) -> Imagekit::Models::SubtitleOverlayTransformation::typography + + def initialize: ( + ?background: String, + ?color: String, + ?font_family: String, + ?font_outline: String, + ?font_shadow: String, + ?font_size: Float, + ?typography: Imagekit::Models::SubtitleOverlayTransformation::typography + ) -> void + + def to_hash: -> { + background: String, + color: String, + font_family: String, + font_outline: String, + font_shadow: String, + font_size: Float, + typography: Imagekit::Models::SubtitleOverlayTransformation::typography + } + + type typography = :b | :i | :b_i + + module Typography + extend Imagekit::Internal::Type::Enum + + B: :b + I: :i + B_I: :b_i + + def self?.values: -> ::Array[Imagekit::Models::SubtitleOverlayTransformation::typography] + end + end + end +end diff --git a/sig/imagekit/models/text_overlay.rbs b/sig/imagekit/models/text_overlay.rbs new file mode 100644 index 00000000..ae294eef --- /dev/null +++ b/sig/imagekit/models/text_overlay.rbs @@ -0,0 +1,59 @@ +module Imagekit + module Models + type text_overlay = + { + text: String, + type: :text, + encoding: Imagekit::Models::TextOverlay::encoding, + transformation: ::Array[Imagekit::TextOverlayTransformation] + } + + class TextOverlay < Imagekit::Models::BaseOverlay + def text: -> String + + def text=: (String _) -> String + + def `type`: -> :text + + def type=: (:text _) -> :text + + def encoding: -> Imagekit::Models::TextOverlay::encoding? + + def encoding=: ( + Imagekit::Models::TextOverlay::encoding _ + ) -> Imagekit::Models::TextOverlay::encoding + + def transformation: -> ::Array[Imagekit::TextOverlayTransformation]? + + def transformation=: ( + ::Array[Imagekit::TextOverlayTransformation] _ + ) -> ::Array[Imagekit::TextOverlayTransformation] + + def initialize: ( + text: String, + ?encoding: Imagekit::Models::TextOverlay::encoding, + ?transformation: ::Array[Imagekit::TextOverlayTransformation], + ?type: :text + ) -> void + + def to_hash: -> { + text: String, + type: :text, + encoding: Imagekit::Models::TextOverlay::encoding, + transformation: ::Array[Imagekit::TextOverlayTransformation] + } + + type encoding = :auto | :plain | :base64 + + module Encoding + extend Imagekit::Internal::Type::Enum + + AUTO: :auto + PLAIN: :plain + BASE64: :base64 + + def self?.values: -> ::Array[Imagekit::Models::TextOverlay::encoding] + end + end + end +end diff --git a/sig/imagekit/models/text_overlay_transformation.rbs b/sig/imagekit/models/text_overlay_transformation.rbs new file mode 100644 index 00000000..db0f4c8b --- /dev/null +++ b/sig/imagekit/models/text_overlay_transformation.rbs @@ -0,0 +1,195 @@ +module Imagekit + module Models + type text_overlay_transformation = + { + alpha: Float, + background: String, + flip: Imagekit::Models::TextOverlayTransformation::flip, + font_color: String, + font_family: String, + font_size: Imagekit::Models::TextOverlayTransformation::font_size, + inner_alignment: Imagekit::Models::TextOverlayTransformation::inner_alignment, + line_height: Imagekit::Models::TextOverlayTransformation::line_height, + padding: Imagekit::Models::TextOverlayTransformation::padding, + radius: Imagekit::Models::TextOverlayTransformation::radius, + rotation: Imagekit::Models::TextOverlayTransformation::rotation, + typography: String, + width: Imagekit::Models::TextOverlayTransformation::width + } + + class TextOverlayTransformation < Imagekit::Internal::Type::BaseModel + attr_reader alpha: Float? + + def alpha=: (Float) -> Float + + attr_reader background: String? + + def background=: (String) -> String + + attr_reader flip: Imagekit::Models::TextOverlayTransformation::flip? + + def flip=: ( + Imagekit::Models::TextOverlayTransformation::flip + ) -> Imagekit::Models::TextOverlayTransformation::flip + + attr_reader font_color: String? + + def font_color=: (String) -> String + + attr_reader font_family: String? + + def font_family=: (String) -> String + + attr_reader font_size: Imagekit::Models::TextOverlayTransformation::font_size? + + def font_size=: ( + Imagekit::Models::TextOverlayTransformation::font_size + ) -> Imagekit::Models::TextOverlayTransformation::font_size + + attr_reader inner_alignment: Imagekit::Models::TextOverlayTransformation::inner_alignment? + + def inner_alignment=: ( + Imagekit::Models::TextOverlayTransformation::inner_alignment + ) -> Imagekit::Models::TextOverlayTransformation::inner_alignment + + attr_reader line_height: Imagekit::Models::TextOverlayTransformation::line_height? + + def line_height=: ( + Imagekit::Models::TextOverlayTransformation::line_height + ) -> Imagekit::Models::TextOverlayTransformation::line_height + + attr_reader padding: Imagekit::Models::TextOverlayTransformation::padding? + + def padding=: ( + Imagekit::Models::TextOverlayTransformation::padding + ) -> Imagekit::Models::TextOverlayTransformation::padding + + attr_reader radius: Imagekit::Models::TextOverlayTransformation::radius? + + def radius=: ( + Imagekit::Models::TextOverlayTransformation::radius + ) -> Imagekit::Models::TextOverlayTransformation::radius + + attr_reader rotation: Imagekit::Models::TextOverlayTransformation::rotation? + + def rotation=: ( + Imagekit::Models::TextOverlayTransformation::rotation + ) -> Imagekit::Models::TextOverlayTransformation::rotation + + attr_reader typography: String? + + def typography=: (String) -> String + + attr_reader width: Imagekit::Models::TextOverlayTransformation::width? + + def width=: ( + Imagekit::Models::TextOverlayTransformation::width + ) -> Imagekit::Models::TextOverlayTransformation::width + + def initialize: ( + ?alpha: Float, + ?background: String, + ?flip: Imagekit::Models::TextOverlayTransformation::flip, + ?font_color: String, + ?font_family: String, + ?font_size: Imagekit::Models::TextOverlayTransformation::font_size, + ?inner_alignment: Imagekit::Models::TextOverlayTransformation::inner_alignment, + ?line_height: Imagekit::Models::TextOverlayTransformation::line_height, + ?padding: Imagekit::Models::TextOverlayTransformation::padding, + ?radius: Imagekit::Models::TextOverlayTransformation::radius, + ?rotation: Imagekit::Models::TextOverlayTransformation::rotation, + ?typography: String, + ?width: Imagekit::Models::TextOverlayTransformation::width + ) -> void + + def to_hash: -> { + alpha: Float, + background: String, + flip: Imagekit::Models::TextOverlayTransformation::flip, + font_color: String, + font_family: String, + font_size: Imagekit::Models::TextOverlayTransformation::font_size, + inner_alignment: Imagekit::Models::TextOverlayTransformation::inner_alignment, + line_height: Imagekit::Models::TextOverlayTransformation::line_height, + padding: Imagekit::Models::TextOverlayTransformation::padding, + radius: Imagekit::Models::TextOverlayTransformation::radius, + rotation: Imagekit::Models::TextOverlayTransformation::rotation, + typography: String, + width: Imagekit::Models::TextOverlayTransformation::width + } + + type flip = :h | :v | :h_v | :v_h + + module Flip + extend Imagekit::Internal::Type::Enum + + H: :h + V: :v + H_V: :h_v + V_H: :v_h + + def self?.values: -> ::Array[Imagekit::Models::TextOverlayTransformation::flip] + end + + type font_size = Float | String + + module FontSize + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::TextOverlayTransformation::font_size] + end + + type inner_alignment = :left | :right | :center + + module InnerAlignment + extend Imagekit::Internal::Type::Enum + + LEFT: :left + RIGHT: :right + CENTER: :center + + def self?.values: -> ::Array[Imagekit::Models::TextOverlayTransformation::inner_alignment] + end + + type line_height = Float | String + + module LineHeight + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::TextOverlayTransformation::line_height] + end + + type padding = Float | String + + module Padding + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::TextOverlayTransformation::padding] + end + + type radius = Float | :max + + module Radius + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::TextOverlayTransformation::radius] + end + + type rotation = Float | String + + module Rotation + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::TextOverlayTransformation::rotation] + end + + type width = Float | String + + module Width + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::TextOverlayTransformation::width] + end + end + end +end diff --git a/sig/imagekit/models/transformation.rbs b/sig/imagekit/models/transformation.rbs new file mode 100644 index 00000000..afbf4af0 --- /dev/null +++ b/sig/imagekit/models/transformation.rbs @@ -0,0 +1,763 @@ +module Imagekit + module Models + type transformation = + { + ai_change_background: String, + ai_drop_shadow: Imagekit::Models::Transformation::ai_drop_shadow, + ai_edit: String, + ai_remove_background: Imagekit::Models::Transformation::ai_remove_background, + ai_remove_background_external: Imagekit::Models::Transformation::ai_remove_background_external, + ai_retouch: Imagekit::Models::Transformation::ai_retouch, + ai_upscale: Imagekit::Models::Transformation::ai_upscale, + ai_variation: Imagekit::Models::Transformation::ai_variation, + aspect_ratio: Imagekit::Models::Transformation::aspect_ratio, + audio_codec: Imagekit::Models::Transformation::audio_codec, + background: String, + blur: Float, + border: String, + color_profile: bool, + contrast_stretch: Imagekit::Models::Transformation::contrast_stretch, + crop: Imagekit::Models::Transformation::crop, + crop_mode: Imagekit::Models::Transformation::crop_mode, + default_image: String, + dpr: Float, + duration: Imagekit::Models::Transformation::duration, + end_offset: Imagekit::Models::Transformation::end_offset, + flip: Imagekit::Models::Transformation::flip, + focus: String, + format_: Imagekit::Models::Transformation::format_, + gradient: Imagekit::Models::Transformation::gradient, + grayscale: Imagekit::Models::Transformation::grayscale, + height: Imagekit::Models::Transformation::height, + lossless: bool, + metadata: bool, + named: String, + opacity: Float, + original: bool, + overlay: Imagekit::Models::overlay, + page: Imagekit::Models::Transformation::page, + progressive: bool, + quality: Float, + radius: Imagekit::Models::Transformation::radius, + raw: String, + rotation: Imagekit::Models::Transformation::rotation, + shadow: Imagekit::Models::Transformation::shadow, + sharpen: Imagekit::Models::Transformation::sharpen, + start_offset: Imagekit::Models::Transformation::start_offset, + streaming_resolutions: ::Array[Imagekit::Models::streaming_resolution], + trim: Imagekit::Models::Transformation::trim, + unsharp_mask: Imagekit::Models::Transformation::unsharp_mask, + video_codec: Imagekit::Models::Transformation::video_codec, + width: Imagekit::Models::Transformation::width, + x: Imagekit::Models::Transformation::x, + x_center: Imagekit::Models::Transformation::x_center, + y_: Imagekit::Models::Transformation::y_, + y_center: Imagekit::Models::Transformation::y_center, + zoom: Float + } + + class Transformation < Imagekit::Internal::Type::BaseModel + attr_reader ai_change_background: String? + + def ai_change_background=: (String) -> String + + attr_reader ai_drop_shadow: Imagekit::Models::Transformation::ai_drop_shadow? + + def ai_drop_shadow=: ( + Imagekit::Models::Transformation::ai_drop_shadow + ) -> Imagekit::Models::Transformation::ai_drop_shadow + + attr_reader ai_edit: String? + + def ai_edit=: (String) -> String + + attr_reader ai_remove_background: Imagekit::Models::Transformation::ai_remove_background? + + def ai_remove_background=: ( + Imagekit::Models::Transformation::ai_remove_background + ) -> Imagekit::Models::Transformation::ai_remove_background + + attr_reader ai_remove_background_external: Imagekit::Models::Transformation::ai_remove_background_external? + + def ai_remove_background_external=: ( + Imagekit::Models::Transformation::ai_remove_background_external + ) -> Imagekit::Models::Transformation::ai_remove_background_external + + attr_reader ai_retouch: Imagekit::Models::Transformation::ai_retouch? + + def ai_retouch=: ( + Imagekit::Models::Transformation::ai_retouch + ) -> Imagekit::Models::Transformation::ai_retouch + + attr_reader ai_upscale: Imagekit::Models::Transformation::ai_upscale? + + def ai_upscale=: ( + Imagekit::Models::Transformation::ai_upscale + ) -> Imagekit::Models::Transformation::ai_upscale + + attr_reader ai_variation: Imagekit::Models::Transformation::ai_variation? + + def ai_variation=: ( + Imagekit::Models::Transformation::ai_variation + ) -> Imagekit::Models::Transformation::ai_variation + + attr_reader aspect_ratio: Imagekit::Models::Transformation::aspect_ratio? + + def aspect_ratio=: ( + Imagekit::Models::Transformation::aspect_ratio + ) -> Imagekit::Models::Transformation::aspect_ratio + + attr_reader audio_codec: Imagekit::Models::Transformation::audio_codec? + + def audio_codec=: ( + Imagekit::Models::Transformation::audio_codec + ) -> Imagekit::Models::Transformation::audio_codec + + attr_reader background: String? + + def background=: (String) -> String + + attr_reader blur: Float? + + def blur=: (Float) -> Float + + attr_reader border: String? + + def border=: (String) -> String + + attr_reader color_profile: bool? + + def color_profile=: (bool) -> bool + + attr_reader contrast_stretch: Imagekit::Models::Transformation::contrast_stretch? + + def contrast_stretch=: ( + Imagekit::Models::Transformation::contrast_stretch + ) -> Imagekit::Models::Transformation::contrast_stretch + + attr_reader crop: Imagekit::Models::Transformation::crop? + + def crop=: ( + Imagekit::Models::Transformation::crop + ) -> Imagekit::Models::Transformation::crop + + attr_reader crop_mode: Imagekit::Models::Transformation::crop_mode? + + def crop_mode=: ( + Imagekit::Models::Transformation::crop_mode + ) -> Imagekit::Models::Transformation::crop_mode + + attr_reader default_image: String? + + def default_image=: (String) -> String + + attr_reader dpr: Float? + + def dpr=: (Float) -> Float + + attr_reader duration: Imagekit::Models::Transformation::duration? + + def duration=: ( + Imagekit::Models::Transformation::duration + ) -> Imagekit::Models::Transformation::duration + + attr_reader end_offset: Imagekit::Models::Transformation::end_offset? + + def end_offset=: ( + Imagekit::Models::Transformation::end_offset + ) -> Imagekit::Models::Transformation::end_offset + + attr_reader flip: Imagekit::Models::Transformation::flip? + + def flip=: ( + Imagekit::Models::Transformation::flip + ) -> Imagekit::Models::Transformation::flip + + attr_reader focus: String? + + def focus=: (String) -> String + + attr_reader format_: Imagekit::Models::Transformation::format_? + + def format_=: ( + Imagekit::Models::Transformation::format_ + ) -> Imagekit::Models::Transformation::format_ + + attr_reader gradient: Imagekit::Models::Transformation::gradient? + + def gradient=: ( + Imagekit::Models::Transformation::gradient + ) -> Imagekit::Models::Transformation::gradient + + attr_reader grayscale: Imagekit::Models::Transformation::grayscale? + + def grayscale=: ( + Imagekit::Models::Transformation::grayscale + ) -> Imagekit::Models::Transformation::grayscale + + attr_reader height: Imagekit::Models::Transformation::height? + + def height=: ( + Imagekit::Models::Transformation::height + ) -> Imagekit::Models::Transformation::height + + attr_reader lossless: bool? + + def lossless=: (bool) -> bool + + attr_reader metadata: bool? + + def metadata=: (bool) -> bool + + attr_reader named: String? + + def named=: (String) -> String + + attr_reader opacity: Float? + + def opacity=: (Float) -> Float + + attr_reader original: bool? + + def original=: (bool) -> bool + + attr_reader overlay: Imagekit::Models::overlay? + + def overlay=: (Imagekit::Models::overlay) -> Imagekit::Models::overlay + + attr_reader page: Imagekit::Models::Transformation::page? + + def page=: ( + Imagekit::Models::Transformation::page + ) -> Imagekit::Models::Transformation::page + + attr_reader progressive: bool? + + def progressive=: (bool) -> bool + + attr_reader quality: Float? + + def quality=: (Float) -> Float + + attr_reader radius: Imagekit::Models::Transformation::radius? + + def radius=: ( + Imagekit::Models::Transformation::radius + ) -> Imagekit::Models::Transformation::radius + + attr_reader raw: String? + + def raw=: (String) -> String + + attr_reader rotation: Imagekit::Models::Transformation::rotation? + + def rotation=: ( + Imagekit::Models::Transformation::rotation + ) -> Imagekit::Models::Transformation::rotation + + attr_reader shadow: Imagekit::Models::Transformation::shadow? + + def shadow=: ( + Imagekit::Models::Transformation::shadow + ) -> Imagekit::Models::Transformation::shadow + + attr_reader sharpen: Imagekit::Models::Transformation::sharpen? + + def sharpen=: ( + Imagekit::Models::Transformation::sharpen + ) -> Imagekit::Models::Transformation::sharpen + + attr_reader start_offset: Imagekit::Models::Transformation::start_offset? + + def start_offset=: ( + Imagekit::Models::Transformation::start_offset + ) -> Imagekit::Models::Transformation::start_offset + + attr_reader streaming_resolutions: ::Array[Imagekit::Models::streaming_resolution]? + + def streaming_resolutions=: ( + ::Array[Imagekit::Models::streaming_resolution] + ) -> ::Array[Imagekit::Models::streaming_resolution] + + attr_reader trim: Imagekit::Models::Transformation::trim? + + def trim=: ( + Imagekit::Models::Transformation::trim + ) -> Imagekit::Models::Transformation::trim + + attr_reader unsharp_mask: Imagekit::Models::Transformation::unsharp_mask? + + def unsharp_mask=: ( + Imagekit::Models::Transformation::unsharp_mask + ) -> Imagekit::Models::Transformation::unsharp_mask + + attr_reader video_codec: Imagekit::Models::Transformation::video_codec? + + def video_codec=: ( + Imagekit::Models::Transformation::video_codec + ) -> Imagekit::Models::Transformation::video_codec + + attr_reader width: Imagekit::Models::Transformation::width? + + def width=: ( + Imagekit::Models::Transformation::width + ) -> Imagekit::Models::Transformation::width + + attr_reader x: Imagekit::Models::Transformation::x? + + def x=: ( + Imagekit::Models::Transformation::x + ) -> Imagekit::Models::Transformation::x + + attr_reader x_center: Imagekit::Models::Transformation::x_center? + + def x_center=: ( + Imagekit::Models::Transformation::x_center + ) -> Imagekit::Models::Transformation::x_center + + attr_reader y_: Imagekit::Models::Transformation::y_? + + def y_=: ( + Imagekit::Models::Transformation::y_ + ) -> Imagekit::Models::Transformation::y_ + + attr_reader y_center: Imagekit::Models::Transformation::y_center? + + def y_center=: ( + Imagekit::Models::Transformation::y_center + ) -> Imagekit::Models::Transformation::y_center + + attr_reader zoom: Float? + + def zoom=: (Float) -> Float + + def initialize: ( + ?ai_change_background: String, + ?ai_drop_shadow: Imagekit::Models::Transformation::ai_drop_shadow, + ?ai_edit: String, + ?ai_remove_background: Imagekit::Models::Transformation::ai_remove_background, + ?ai_remove_background_external: Imagekit::Models::Transformation::ai_remove_background_external, + ?ai_retouch: Imagekit::Models::Transformation::ai_retouch, + ?ai_upscale: Imagekit::Models::Transformation::ai_upscale, + ?ai_variation: Imagekit::Models::Transformation::ai_variation, + ?aspect_ratio: Imagekit::Models::Transformation::aspect_ratio, + ?audio_codec: Imagekit::Models::Transformation::audio_codec, + ?background: String, + ?blur: Float, + ?border: String, + ?color_profile: bool, + ?contrast_stretch: Imagekit::Models::Transformation::contrast_stretch, + ?crop: Imagekit::Models::Transformation::crop, + ?crop_mode: Imagekit::Models::Transformation::crop_mode, + ?default_image: String, + ?dpr: Float, + ?duration: Imagekit::Models::Transformation::duration, + ?end_offset: Imagekit::Models::Transformation::end_offset, + ?flip: Imagekit::Models::Transformation::flip, + ?focus: String, + ?format_: Imagekit::Models::Transformation::format_, + ?gradient: Imagekit::Models::Transformation::gradient, + ?grayscale: Imagekit::Models::Transformation::grayscale, + ?height: Imagekit::Models::Transformation::height, + ?lossless: bool, + ?metadata: bool, + ?named: String, + ?opacity: Float, + ?original: bool, + ?overlay: Imagekit::Models::overlay, + ?page: Imagekit::Models::Transformation::page, + ?progressive: bool, + ?quality: Float, + ?radius: Imagekit::Models::Transformation::radius, + ?raw: String, + ?rotation: Imagekit::Models::Transformation::rotation, + ?shadow: Imagekit::Models::Transformation::shadow, + ?sharpen: Imagekit::Models::Transformation::sharpen, + ?start_offset: Imagekit::Models::Transformation::start_offset, + ?streaming_resolutions: ::Array[Imagekit::Models::streaming_resolution], + ?trim: Imagekit::Models::Transformation::trim, + ?unsharp_mask: Imagekit::Models::Transformation::unsharp_mask, + ?video_codec: Imagekit::Models::Transformation::video_codec, + ?width: Imagekit::Models::Transformation::width, + ?x: Imagekit::Models::Transformation::x, + ?x_center: Imagekit::Models::Transformation::x_center, + ?y_: Imagekit::Models::Transformation::y_, + ?y_center: Imagekit::Models::Transformation::y_center, + ?zoom: Float + ) -> void + + def to_hash: -> { + ai_change_background: String, + ai_drop_shadow: Imagekit::Models::Transformation::ai_drop_shadow, + ai_edit: String, + ai_remove_background: Imagekit::Models::Transformation::ai_remove_background, + ai_remove_background_external: Imagekit::Models::Transformation::ai_remove_background_external, + ai_retouch: Imagekit::Models::Transformation::ai_retouch, + ai_upscale: Imagekit::Models::Transformation::ai_upscale, + ai_variation: Imagekit::Models::Transformation::ai_variation, + aspect_ratio: Imagekit::Models::Transformation::aspect_ratio, + audio_codec: Imagekit::Models::Transformation::audio_codec, + background: String, + blur: Float, + border: String, + color_profile: bool, + contrast_stretch: Imagekit::Models::Transformation::contrast_stretch, + crop: Imagekit::Models::Transformation::crop, + crop_mode: Imagekit::Models::Transformation::crop_mode, + default_image: String, + dpr: Float, + duration: Imagekit::Models::Transformation::duration, + end_offset: Imagekit::Models::Transformation::end_offset, + flip: Imagekit::Models::Transformation::flip, + focus: String, + format_: Imagekit::Models::Transformation::format_, + gradient: Imagekit::Models::Transformation::gradient, + grayscale: Imagekit::Models::Transformation::grayscale, + height: Imagekit::Models::Transformation::height, + lossless: bool, + metadata: bool, + named: String, + opacity: Float, + original: bool, + overlay: Imagekit::Models::overlay, + page: Imagekit::Models::Transformation::page, + progressive: bool, + quality: Float, + radius: Imagekit::Models::Transformation::radius, + raw: String, + rotation: Imagekit::Models::Transformation::rotation, + shadow: Imagekit::Models::Transformation::shadow, + sharpen: Imagekit::Models::Transformation::sharpen, + start_offset: Imagekit::Models::Transformation::start_offset, + streaming_resolutions: ::Array[Imagekit::Models::streaming_resolution], + trim: Imagekit::Models::Transformation::trim, + unsharp_mask: Imagekit::Models::Transformation::unsharp_mask, + video_codec: Imagekit::Models::Transformation::video_codec, + width: Imagekit::Models::Transformation::width, + x: Imagekit::Models::Transformation::x, + x_center: Imagekit::Models::Transformation::x_center, + y_: Imagekit::Models::Transformation::y_, + y_center: Imagekit::Models::Transformation::y_center, + zoom: Float + } + + type ai_drop_shadow = true | String + + module AIDropShadow + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::Transformation::ai_drop_shadow] + end + + type ai_remove_background = true + + module AIRemoveBackground + extend Imagekit::Internal::Type::Enum + + TRUE: true + + def self?.values: -> ::Array[Imagekit::Models::Transformation::ai_remove_background] + end + + type ai_remove_background_external = true + + module AIRemoveBackgroundExternal + extend Imagekit::Internal::Type::Enum + + TRUE: true + + def self?.values: -> ::Array[Imagekit::Models::Transformation::ai_remove_background_external] + end + + type ai_retouch = true + + module AIRetouch + extend Imagekit::Internal::Type::Enum + + TRUE: true + + def self?.values: -> ::Array[Imagekit::Models::Transformation::ai_retouch] + end + + type ai_upscale = true + + module AIUpscale + extend Imagekit::Internal::Type::Enum + + TRUE: true + + def self?.values: -> ::Array[Imagekit::Models::Transformation::ai_upscale] + end + + type ai_variation = true + + module AIVariation + extend Imagekit::Internal::Type::Enum + + TRUE: true + + def self?.values: -> ::Array[Imagekit::Models::Transformation::ai_variation] + end + + type aspect_ratio = Float | String + + module AspectRatio + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::Transformation::aspect_ratio] + end + + type audio_codec = :aac | :opus | :none + + module AudioCodec + extend Imagekit::Internal::Type::Enum + + AAC: :aac + OPUS: :opus + NONE: :none + + def self?.values: -> ::Array[Imagekit::Models::Transformation::audio_codec] + end + + type contrast_stretch = true + + module ContrastStretch + extend Imagekit::Internal::Type::Enum + + TRUE: true + + def self?.values: -> ::Array[Imagekit::Models::Transformation::contrast_stretch] + end + + type crop = + :force | :at_max | :at_max_enlarge | :at_least | :maintain_ratio + + module Crop + extend Imagekit::Internal::Type::Enum + + FORCE: :force + AT_MAX: :at_max + AT_MAX_ENLARGE: :at_max_enlarge + AT_LEAST: :at_least + MAINTAIN_RATIO: :maintain_ratio + + def self?.values: -> ::Array[Imagekit::Models::Transformation::crop] + end + + type crop_mode = :pad_resize | :extract | :pad_extract + + module CropMode + extend Imagekit::Internal::Type::Enum + + PAD_RESIZE: :pad_resize + EXTRACT: :extract + PAD_EXTRACT: :pad_extract + + def self?.values: -> ::Array[Imagekit::Models::Transformation::crop_mode] + end + + type duration = Float | String + + module Duration + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::Transformation::duration] + end + + type end_offset = Float | String + + module EndOffset + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::Transformation::end_offset] + end + + type flip = :h | :v | :h_v | :v_h + + module Flip + extend Imagekit::Internal::Type::Enum + + H: :h + V: :v + H_V: :h_v + V_H: :v_h + + def self?.values: -> ::Array[Imagekit::Models::Transformation::flip] + end + + type format_ = + :auto + | :webp + | :jpg + | :jpeg + | :png + | :gif + | :svg + | :mp4 + | :webm + | :avif + | :orig + + module Format + extend Imagekit::Internal::Type::Enum + + AUTO: :auto + WEBP: :webp + JPG: :jpg + JPEG: :jpeg + PNG: :png + GIF: :gif + SVG: :svg + MP4: :mp4 + WEBM: :webm + AVIF: :avif + ORIG: :orig + + def self?.values: -> ::Array[Imagekit::Models::Transformation::format_] + end + + type gradient = true | String + + module Gradient + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::Transformation::gradient] + end + + type grayscale = true + + module Grayscale + extend Imagekit::Internal::Type::Enum + + TRUE: true + + def self?.values: -> ::Array[Imagekit::Models::Transformation::grayscale] + end + + type height = Float | String + + module Height + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::Transformation::height] + end + + type page = Float | String + + module Page + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::Transformation::page] + end + + type radius = Float | :max + + module Radius + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::Transformation::radius] + end + + type rotation = Float | String + + module Rotation + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::Transformation::rotation] + end + + type shadow = true | String + + module Shadow + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::Transformation::shadow] + end + + type sharpen = true | Float + + module Sharpen + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::Transformation::sharpen] + end + + type start_offset = Float | String + + module StartOffset + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::Transformation::start_offset] + end + + type trim = true | Float + + module Trim + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::Transformation::trim] + end + + type unsharp_mask = true | String + + module UnsharpMask + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::Transformation::unsharp_mask] + end + + type video_codec = :h264 | :vp9 | :av1 | :none + + module VideoCodec + extend Imagekit::Internal::Type::Enum + + H264: :h264 + VP9: :vp9 + AV1: :av1 + NONE: :none + + def self?.values: -> ::Array[Imagekit::Models::Transformation::video_codec] + end + + type width = Float | String + + module Width + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::Transformation::width] + end + + type x = Float | String + + module X + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::Transformation::x] + end + + type x_center = Float | String + + module XCenter + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::Transformation::x_center] + end + + type y_ = Float | String + + module Y + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::Transformation::y_] + end + + type y_center = Float | String + + module YCenter + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::Transformation::y_center] + end + end + end +end diff --git a/sig/imagekit/models/transformation_position.rbs b/sig/imagekit/models/transformation_position.rbs new file mode 100644 index 00000000..60ed3513 --- /dev/null +++ b/sig/imagekit/models/transformation_position.rbs @@ -0,0 +1,14 @@ +module Imagekit + module Models + type transformation_position = :path | :query + + module TransformationPosition + extend Imagekit::Internal::Type::Enum + + PATH: :path + QUERY: :query + + def self?.values: -> ::Array[Imagekit::Models::transformation_position] + end + end +end diff --git a/sig/imagekit/models/unsafe_unwrap_webhook_event.rbs b/sig/imagekit/models/unsafe_unwrap_webhook_event.rbs new file mode 100644 index 00000000..b3cb218a --- /dev/null +++ b/sig/imagekit/models/unsafe_unwrap_webhook_event.rbs @@ -0,0 +1,18 @@ +module Imagekit + module Models + type unsafe_unwrap_webhook_event = + Imagekit::VideoTransformationAcceptedEvent + | Imagekit::VideoTransformationReadyEvent + | Imagekit::VideoTransformationErrorEvent + | Imagekit::UploadPreTransformSuccessEvent + | Imagekit::UploadPreTransformErrorEvent + | Imagekit::UploadPostTransformSuccessEvent + | Imagekit::UploadPostTransformErrorEvent + + module UnsafeUnwrapWebhookEvent + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::unsafe_unwrap_webhook_event] + end + end +end diff --git a/sig/imagekit/models/unwrap_webhook_event.rbs b/sig/imagekit/models/unwrap_webhook_event.rbs new file mode 100644 index 00000000..8c1551ec --- /dev/null +++ b/sig/imagekit/models/unwrap_webhook_event.rbs @@ -0,0 +1,18 @@ +module Imagekit + module Models + type unwrap_webhook_event = + Imagekit::VideoTransformationAcceptedEvent + | Imagekit::VideoTransformationReadyEvent + | Imagekit::VideoTransformationErrorEvent + | Imagekit::UploadPreTransformSuccessEvent + | Imagekit::UploadPreTransformErrorEvent + | Imagekit::UploadPostTransformSuccessEvent + | Imagekit::UploadPostTransformErrorEvent + + module UnwrapWebhookEvent + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::unwrap_webhook_event] + end + end +end diff --git a/sig/imagekit/models/update_file_request.rbs b/sig/imagekit/models/update_file_request.rbs new file mode 100644 index 00000000..68701252 --- /dev/null +++ b/sig/imagekit/models/update_file_request.rbs @@ -0,0 +1,122 @@ +module Imagekit + module Models + type update_file_request = + Imagekit::UpdateFileRequest::UpdateFileDetails + | Imagekit::UpdateFileRequest::ChangePublicationStatus + + module UpdateFileRequest + extend Imagekit::Internal::Type::Union + + type update_file_details = + { + custom_coordinates: String?, + custom_metadata: ::Hash[Symbol, top], + description: String, + extensions: Imagekit::Models::extensions, + remove_ai_tags: Imagekit::Models::UpdateFileRequest::UpdateFileDetails::remove_ai_tags, + tags: ::Array[String]?, + webhook_url: String + } + + class UpdateFileDetails < Imagekit::Internal::Type::BaseModel + attr_accessor custom_coordinates: String? + + attr_reader custom_metadata: ::Hash[Symbol, top]? + + def custom_metadata=: (::Hash[Symbol, top]) -> ::Hash[Symbol, top] + + attr_reader description: String? + + def description=: (String) -> String + + attr_reader extensions: Imagekit::Models::extensions? + + def extensions=: ( + Imagekit::Models::extensions + ) -> Imagekit::Models::extensions + + attr_reader remove_ai_tags: Imagekit::Models::UpdateFileRequest::UpdateFileDetails::remove_ai_tags? + + def remove_ai_tags=: ( + Imagekit::Models::UpdateFileRequest::UpdateFileDetails::remove_ai_tags + ) -> Imagekit::Models::UpdateFileRequest::UpdateFileDetails::remove_ai_tags + + attr_accessor tags: ::Array[String]? + + attr_reader webhook_url: String? + + def webhook_url=: (String) -> String + + def initialize: ( + ?custom_coordinates: String?, + ?custom_metadata: ::Hash[Symbol, top], + ?description: String, + ?extensions: Imagekit::Models::extensions, + ?remove_ai_tags: Imagekit::Models::UpdateFileRequest::UpdateFileDetails::remove_ai_tags, + ?tags: ::Array[String]?, + ?webhook_url: String + ) -> void + + def to_hash: -> { + custom_coordinates: String?, + custom_metadata: ::Hash[Symbol, top], + description: String, + extensions: Imagekit::Models::extensions, + remove_ai_tags: Imagekit::Models::UpdateFileRequest::UpdateFileDetails::remove_ai_tags, + tags: ::Array[String]?, + webhook_url: String + } + + type remove_ai_tags = ::Array[String] | :all + + module RemoveAITags + extend Imagekit::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekit::Models::UpdateFileRequest::UpdateFileDetails::remove_ai_tags] + + StringArray: Imagekit::Internal::Type::Converter + end + end + + type change_publication_status = + { + publish: Imagekit::UpdateFileRequest::ChangePublicationStatus::Publish + } + + class ChangePublicationStatus < Imagekit::Internal::Type::BaseModel + attr_reader publish: Imagekit::UpdateFileRequest::ChangePublicationStatus::Publish? + + def publish=: ( + Imagekit::UpdateFileRequest::ChangePublicationStatus::Publish + ) -> Imagekit::UpdateFileRequest::ChangePublicationStatus::Publish + + def initialize: ( + ?publish: Imagekit::UpdateFileRequest::ChangePublicationStatus::Publish + ) -> void + + def to_hash: -> { + publish: Imagekit::UpdateFileRequest::ChangePublicationStatus::Publish + } + + type publish = { is_published: bool, include_file_versions: bool } + + class Publish < Imagekit::Internal::Type::BaseModel + attr_accessor is_published: bool + + attr_reader include_file_versions: bool? + + def include_file_versions=: (bool) -> bool + + def initialize: ( + is_published: bool, + ?include_file_versions: bool + ) -> void + + def to_hash: -> { is_published: bool, include_file_versions: bool } + end + end + + def self?.variants: -> ::Array[Imagekit::Models::update_file_request] + end + end +end diff --git a/sig/imagekit/models/upload_post_transform_error_event.rbs b/sig/imagekit/models/upload_post_transform_error_event.rbs new file mode 100644 index 00000000..7ef7256c --- /dev/null +++ b/sig/imagekit/models/upload_post_transform_error_event.rbs @@ -0,0 +1,192 @@ +module Imagekit + module Models + type upload_post_transform_error_event = + { + created_at: Time, + data: Imagekit::UploadPostTransformErrorEvent::Data, + request: Imagekit::UploadPostTransformErrorEvent::Request, + type: :"upload.post-transform.error" + } + + class UploadPostTransformErrorEvent < Imagekit::Models::BaseWebhookEvent + def created_at: -> Time + + def created_at=: (Time _) -> Time + + def data: -> Imagekit::UploadPostTransformErrorEvent::Data + + def data=: ( + Imagekit::UploadPostTransformErrorEvent::Data _ + ) -> Imagekit::UploadPostTransformErrorEvent::Data + + def request: -> Imagekit::UploadPostTransformErrorEvent::Request + + def request=: ( + Imagekit::UploadPostTransformErrorEvent::Request _ + ) -> Imagekit::UploadPostTransformErrorEvent::Request + + def `type`: -> :"upload.post-transform.error" + + def type=: ( + :"upload.post-transform.error" _ + ) -> :"upload.post-transform.error" + + def initialize: ( + created_at: Time, + data: Imagekit::UploadPostTransformErrorEvent::Data, + request: Imagekit::UploadPostTransformErrorEvent::Request, + ?type: :"upload.post-transform.error" + ) -> void + + def to_hash: -> { + created_at: Time, + data: Imagekit::UploadPostTransformErrorEvent::Data, + request: Imagekit::UploadPostTransformErrorEvent::Request, + type: :"upload.post-transform.error" + } + + type data = + { + file_id: String, + name: String, + path: String, + transformation: Imagekit::UploadPostTransformErrorEvent::Data::Transformation, + url: String + } + + class Data < Imagekit::Internal::Type::BaseModel + attr_accessor file_id: String + + attr_accessor name: String + + attr_accessor path: String + + attr_accessor transformation: Imagekit::UploadPostTransformErrorEvent::Data::Transformation + + attr_accessor url: String + + def initialize: ( + file_id: String, + name: String, + path: String, + transformation: Imagekit::UploadPostTransformErrorEvent::Data::Transformation, + url: String + ) -> void + + def to_hash: -> { + file_id: String, + name: String, + path: String, + transformation: Imagekit::UploadPostTransformErrorEvent::Data::Transformation, + url: String + } + + type transformation = + { + error: Imagekit::UploadPostTransformErrorEvent::Data::Transformation::Error + } + + class Transformation < Imagekit::Internal::Type::BaseModel + attr_accessor error: Imagekit::UploadPostTransformErrorEvent::Data::Transformation::Error + + def initialize: ( + error: Imagekit::UploadPostTransformErrorEvent::Data::Transformation::Error + ) -> void + + def to_hash: -> { + error: Imagekit::UploadPostTransformErrorEvent::Data::Transformation::Error + } + + type error = { reason: String } + + class Error < Imagekit::Internal::Type::BaseModel + attr_accessor reason: String + + def initialize: (reason: String) -> void + + def to_hash: -> { reason: String } + end + end + end + + type request = + { + transformation: Imagekit::UploadPostTransformErrorEvent::Request::Transformation, + x_request_id: String + } + + class Request < Imagekit::Internal::Type::BaseModel + attr_accessor transformation: Imagekit::UploadPostTransformErrorEvent::Request::Transformation + + attr_accessor x_request_id: String + + def initialize: ( + transformation: Imagekit::UploadPostTransformErrorEvent::Request::Transformation, + x_request_id: String + ) -> void + + def to_hash: -> { + transformation: Imagekit::UploadPostTransformErrorEvent::Request::Transformation, + x_request_id: String + } + + type transformation = + { + type: Imagekit::Models::UploadPostTransformErrorEvent::Request::Transformation::type_, + protocol: Imagekit::Models::UploadPostTransformErrorEvent::Request::Transformation::protocol, + value: String + } + + class Transformation < Imagekit::Internal::Type::BaseModel + attr_accessor type: Imagekit::Models::UploadPostTransformErrorEvent::Request::Transformation::type_ + + attr_reader protocol: Imagekit::Models::UploadPostTransformErrorEvent::Request::Transformation::protocol? + + def protocol=: ( + Imagekit::Models::UploadPostTransformErrorEvent::Request::Transformation::protocol + ) -> Imagekit::Models::UploadPostTransformErrorEvent::Request::Transformation::protocol + + attr_reader value: String? + + def value=: (String) -> String + + def initialize: ( + type: Imagekit::Models::UploadPostTransformErrorEvent::Request::Transformation::type_, + ?protocol: Imagekit::Models::UploadPostTransformErrorEvent::Request::Transformation::protocol, + ?value: String + ) -> void + + def to_hash: -> { + type: Imagekit::Models::UploadPostTransformErrorEvent::Request::Transformation::type_, + protocol: Imagekit::Models::UploadPostTransformErrorEvent::Request::Transformation::protocol, + value: String + } + + type type_ = :transformation | :abs | :"gif-to-video" | :thumbnail + + module Type + extend Imagekit::Internal::Type::Enum + + TRANSFORMATION: :transformation + ABS: :abs + GIF_TO_VIDEO: :"gif-to-video" + THUMBNAIL: :thumbnail + + def self?.values: -> ::Array[Imagekit::Models::UploadPostTransformErrorEvent::Request::Transformation::type_] + end + + type protocol = :hls | :dash + + module Protocol + extend Imagekit::Internal::Type::Enum + + HLS: :hls + DASH: :dash + + def self?.values: -> ::Array[Imagekit::Models::UploadPostTransformErrorEvent::Request::Transformation::protocol] + end + end + end + end + end +end diff --git a/sig/imagekit/models/upload_post_transform_success_event.rbs b/sig/imagekit/models/upload_post_transform_success_event.rbs new file mode 100644 index 00000000..526a877f --- /dev/null +++ b/sig/imagekit/models/upload_post_transform_success_event.rbs @@ -0,0 +1,142 @@ +module Imagekit + module Models + type upload_post_transform_success_event = + { + created_at: Time, + data: Imagekit::UploadPostTransformSuccessEvent::Data, + request: Imagekit::UploadPostTransformSuccessEvent::Request, + type: :"upload.post-transform.success" + } + + class UploadPostTransformSuccessEvent < Imagekit::Models::BaseWebhookEvent + def created_at: -> Time + + def created_at=: (Time _) -> Time + + def data: -> Imagekit::UploadPostTransformSuccessEvent::Data + + def data=: ( + Imagekit::UploadPostTransformSuccessEvent::Data _ + ) -> Imagekit::UploadPostTransformSuccessEvent::Data + + def request: -> Imagekit::UploadPostTransformSuccessEvent::Request + + def request=: ( + Imagekit::UploadPostTransformSuccessEvent::Request _ + ) -> Imagekit::UploadPostTransformSuccessEvent::Request + + def `type`: -> :"upload.post-transform.success" + + def type=: ( + :"upload.post-transform.success" _ + ) -> :"upload.post-transform.success" + + def initialize: ( + created_at: Time, + data: Imagekit::UploadPostTransformSuccessEvent::Data, + request: Imagekit::UploadPostTransformSuccessEvent::Request, + ?type: :"upload.post-transform.success" + ) -> void + + def to_hash: -> { + created_at: Time, + data: Imagekit::UploadPostTransformSuccessEvent::Data, + request: Imagekit::UploadPostTransformSuccessEvent::Request, + type: :"upload.post-transform.success" + } + + type data = { file_id: String, name: String, url: String } + + class Data < Imagekit::Internal::Type::BaseModel + attr_accessor file_id: String + + attr_accessor name: String + + attr_accessor url: String + + def initialize: (file_id: String, name: String, url: String) -> void + + def to_hash: -> { file_id: String, name: String, url: String } + end + + type request = + { + transformation: Imagekit::UploadPostTransformSuccessEvent::Request::Transformation, + x_request_id: String + } + + class Request < Imagekit::Internal::Type::BaseModel + attr_accessor transformation: Imagekit::UploadPostTransformSuccessEvent::Request::Transformation + + attr_accessor x_request_id: String + + def initialize: ( + transformation: Imagekit::UploadPostTransformSuccessEvent::Request::Transformation, + x_request_id: String + ) -> void + + def to_hash: -> { + transformation: Imagekit::UploadPostTransformSuccessEvent::Request::Transformation, + x_request_id: String + } + + type transformation = + { + type: Imagekit::Models::UploadPostTransformSuccessEvent::Request::Transformation::type_, + protocol: Imagekit::Models::UploadPostTransformSuccessEvent::Request::Transformation::protocol, + value: String + } + + class Transformation < Imagekit::Internal::Type::BaseModel + attr_accessor type: Imagekit::Models::UploadPostTransformSuccessEvent::Request::Transformation::type_ + + attr_reader protocol: Imagekit::Models::UploadPostTransformSuccessEvent::Request::Transformation::protocol? + + def protocol=: ( + Imagekit::Models::UploadPostTransformSuccessEvent::Request::Transformation::protocol + ) -> Imagekit::Models::UploadPostTransformSuccessEvent::Request::Transformation::protocol + + attr_reader value: String? + + def value=: (String) -> String + + def initialize: ( + type: Imagekit::Models::UploadPostTransformSuccessEvent::Request::Transformation::type_, + ?protocol: Imagekit::Models::UploadPostTransformSuccessEvent::Request::Transformation::protocol, + ?value: String + ) -> void + + def to_hash: -> { + type: Imagekit::Models::UploadPostTransformSuccessEvent::Request::Transformation::type_, + protocol: Imagekit::Models::UploadPostTransformSuccessEvent::Request::Transformation::protocol, + value: String + } + + type type_ = :transformation | :abs | :"gif-to-video" | :thumbnail + + module Type + extend Imagekit::Internal::Type::Enum + + TRANSFORMATION: :transformation + ABS: :abs + GIF_TO_VIDEO: :"gif-to-video" + THUMBNAIL: :thumbnail + + def self?.values: -> ::Array[Imagekit::Models::UploadPostTransformSuccessEvent::Request::Transformation::type_] + end + + type protocol = :hls | :dash + + module Protocol + extend Imagekit::Internal::Type::Enum + + HLS: :hls + DASH: :dash + + def self?.values: -> ::Array[Imagekit::Models::UploadPostTransformSuccessEvent::Request::Transformation::protocol] + end + end + end + end + end +end diff --git a/sig/imagekit/models/upload_pre_transform_error_event.rbs b/sig/imagekit/models/upload_pre_transform_error_event.rbs new file mode 100644 index 00000000..6af7d3e6 --- /dev/null +++ b/sig/imagekit/models/upload_pre_transform_error_event.rbs @@ -0,0 +1,115 @@ +module Imagekit + module Models + type upload_pre_transform_error_event = + { + created_at: Time, + data: Imagekit::UploadPreTransformErrorEvent::Data, + request: Imagekit::UploadPreTransformErrorEvent::Request, + type: :"upload.pre-transform.error" + } + + class UploadPreTransformErrorEvent < Imagekit::Models::BaseWebhookEvent + def created_at: -> Time + + def created_at=: (Time _) -> Time + + def data: -> Imagekit::UploadPreTransformErrorEvent::Data + + def data=: ( + Imagekit::UploadPreTransformErrorEvent::Data _ + ) -> Imagekit::UploadPreTransformErrorEvent::Data + + def request: -> Imagekit::UploadPreTransformErrorEvent::Request + + def request=: ( + Imagekit::UploadPreTransformErrorEvent::Request _ + ) -> Imagekit::UploadPreTransformErrorEvent::Request + + def `type`: -> :"upload.pre-transform.error" + + def type=: ( + :"upload.pre-transform.error" _ + ) -> :"upload.pre-transform.error" + + def initialize: ( + created_at: Time, + data: Imagekit::UploadPreTransformErrorEvent::Data, + request: Imagekit::UploadPreTransformErrorEvent::Request, + ?type: :"upload.pre-transform.error" + ) -> void + + def to_hash: -> { + created_at: Time, + data: Imagekit::UploadPreTransformErrorEvent::Data, + request: Imagekit::UploadPreTransformErrorEvent::Request, + type: :"upload.pre-transform.error" + } + + type data = + { + name: String, + path: String, + transformation: Imagekit::UploadPreTransformErrorEvent::Data::Transformation + } + + class Data < Imagekit::Internal::Type::BaseModel + attr_accessor name: String + + attr_accessor path: String + + attr_accessor transformation: Imagekit::UploadPreTransformErrorEvent::Data::Transformation + + def initialize: ( + name: String, + path: String, + transformation: Imagekit::UploadPreTransformErrorEvent::Data::Transformation + ) -> void + + def to_hash: -> { + name: String, + path: String, + transformation: Imagekit::UploadPreTransformErrorEvent::Data::Transformation + } + + type transformation = + { + error: Imagekit::UploadPreTransformErrorEvent::Data::Transformation::Error + } + + class Transformation < Imagekit::Internal::Type::BaseModel + attr_accessor error: Imagekit::UploadPreTransformErrorEvent::Data::Transformation::Error + + def initialize: ( + error: Imagekit::UploadPreTransformErrorEvent::Data::Transformation::Error + ) -> void + + def to_hash: -> { + error: Imagekit::UploadPreTransformErrorEvent::Data::Transformation::Error + } + + type error = { reason: String } + + class Error < Imagekit::Internal::Type::BaseModel + attr_accessor reason: String + + def initialize: (reason: String) -> void + + def to_hash: -> { reason: String } + end + end + end + + type request = { transformation: String, x_request_id: String } + + class Request < Imagekit::Internal::Type::BaseModel + attr_accessor transformation: String + + attr_accessor x_request_id: String + + def initialize: (transformation: String, x_request_id: String) -> void + + def to_hash: -> { transformation: String, x_request_id: String } + end + end + end +end diff --git a/sig/imagekit/models/upload_pre_transform_success_event.rbs b/sig/imagekit/models/upload_pre_transform_success_event.rbs new file mode 100644 index 00000000..1efc8382 --- /dev/null +++ b/sig/imagekit/models/upload_pre_transform_success_event.rbs @@ -0,0 +1,375 @@ +module Imagekit + module Models + type upload_pre_transform_success_event = + { + created_at: Time, + data: Imagekit::UploadPreTransformSuccessEvent::Data, + request: Imagekit::UploadPreTransformSuccessEvent::Request, + type: :"upload.pre-transform.success" + } + + class UploadPreTransformSuccessEvent < Imagekit::Models::BaseWebhookEvent + def created_at: -> Time + + def created_at=: (Time _) -> Time + + def data: -> Imagekit::UploadPreTransformSuccessEvent::Data + + def data=: ( + Imagekit::UploadPreTransformSuccessEvent::Data _ + ) -> Imagekit::UploadPreTransformSuccessEvent::Data + + def request: -> Imagekit::UploadPreTransformSuccessEvent::Request + + def request=: ( + Imagekit::UploadPreTransformSuccessEvent::Request _ + ) -> Imagekit::UploadPreTransformSuccessEvent::Request + + def `type`: -> :"upload.pre-transform.success" + + def type=: ( + :"upload.pre-transform.success" _ + ) -> :"upload.pre-transform.success" + + def initialize: ( + created_at: Time, + data: Imagekit::UploadPreTransformSuccessEvent::Data, + request: Imagekit::UploadPreTransformSuccessEvent::Request, + ?type: :"upload.pre-transform.success" + ) -> void + + def to_hash: -> { + created_at: Time, + data: Imagekit::UploadPreTransformSuccessEvent::Data, + request: Imagekit::UploadPreTransformSuccessEvent::Request, + type: :"upload.pre-transform.success" + } + + type data = + { + ai_tags: ::Array[Imagekit::UploadPreTransformSuccessEvent::Data::AITag]?, + audio_codec: String, + bit_rate: Integer, + custom_coordinates: String?, + custom_metadata: ::Hash[Symbol, top], + description: String, + duration: Integer, + embedded_metadata: ::Hash[Symbol, top], + extension_status: Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus, + file_id: String, + file_path: String, + file_type: String, + height: Float, + is_private_file: bool, + is_published: bool, + metadata: Imagekit::Metadata, + name: String, + size: Float, + tags: ::Array[String]?, + thumbnail_url: String, + url: String, + version_info: Imagekit::UploadPreTransformSuccessEvent::Data::VersionInfo, + video_codec: String, + width: Float + } + + class Data < Imagekit::Internal::Type::BaseModel + attr_accessor ai_tags: ::Array[Imagekit::UploadPreTransformSuccessEvent::Data::AITag]? + + attr_reader audio_codec: String? + + def audio_codec=: (String) -> String + + attr_reader bit_rate: Integer? + + def bit_rate=: (Integer) -> Integer + + attr_accessor custom_coordinates: String? + + attr_reader custom_metadata: ::Hash[Symbol, top]? + + def custom_metadata=: (::Hash[Symbol, top]) -> ::Hash[Symbol, top] + + attr_reader description: String? + + def description=: (String) -> String + + attr_reader duration: Integer? + + def duration=: (Integer) -> Integer + + attr_reader embedded_metadata: ::Hash[Symbol, top]? + + def embedded_metadata=: (::Hash[Symbol, top]) -> ::Hash[Symbol, top] + + attr_reader extension_status: Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus? + + def extension_status=: ( + Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus + ) -> Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus + + attr_reader file_id: String? + + def file_id=: (String) -> String + + attr_reader file_path: String? + + def file_path=: (String) -> String + + attr_reader file_type: String? + + def file_type=: (String) -> String + + attr_reader height: Float? + + def height=: (Float) -> Float + + attr_reader is_private_file: bool? + + def is_private_file=: (bool) -> bool + + attr_reader is_published: bool? + + def is_published=: (bool) -> bool + + attr_reader metadata: Imagekit::Metadata? + + def metadata=: (Imagekit::Metadata) -> Imagekit::Metadata + + attr_reader name: String? + + def name=: (String) -> String + + attr_reader size: Float? + + def size=: (Float) -> Float + + attr_accessor tags: ::Array[String]? + + attr_reader thumbnail_url: String? + + def thumbnail_url=: (String) -> String + + attr_reader url: String? + + def url=: (String) -> String + + attr_reader version_info: Imagekit::UploadPreTransformSuccessEvent::Data::VersionInfo? + + def version_info=: ( + Imagekit::UploadPreTransformSuccessEvent::Data::VersionInfo + ) -> Imagekit::UploadPreTransformSuccessEvent::Data::VersionInfo + + attr_reader video_codec: String? + + def video_codec=: (String) -> String + + attr_reader width: Float? + + def width=: (Float) -> Float + + def initialize: ( + ?ai_tags: ::Array[Imagekit::UploadPreTransformSuccessEvent::Data::AITag]?, + ?audio_codec: String, + ?bit_rate: Integer, + ?custom_coordinates: String?, + ?custom_metadata: ::Hash[Symbol, top], + ?description: String, + ?duration: Integer, + ?embedded_metadata: ::Hash[Symbol, top], + ?extension_status: Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus, + ?file_id: String, + ?file_path: String, + ?file_type: String, + ?height: Float, + ?is_private_file: bool, + ?is_published: bool, + ?metadata: Imagekit::Metadata, + ?name: String, + ?size: Float, + ?tags: ::Array[String]?, + ?thumbnail_url: String, + ?url: String, + ?version_info: Imagekit::UploadPreTransformSuccessEvent::Data::VersionInfo, + ?video_codec: String, + ?width: Float + ) -> void + + def to_hash: -> { + ai_tags: ::Array[Imagekit::UploadPreTransformSuccessEvent::Data::AITag]?, + audio_codec: String, + bit_rate: Integer, + custom_coordinates: String?, + custom_metadata: ::Hash[Symbol, top], + description: String, + duration: Integer, + embedded_metadata: ::Hash[Symbol, top], + extension_status: Imagekit::UploadPreTransformSuccessEvent::Data::ExtensionStatus, + file_id: String, + file_path: String, + file_type: String, + height: Float, + is_private_file: bool, + is_published: bool, + metadata: Imagekit::Metadata, + name: String, + size: Float, + tags: ::Array[String]?, + thumbnail_url: String, + url: String, + version_info: Imagekit::UploadPreTransformSuccessEvent::Data::VersionInfo, + video_codec: String, + width: Float + } + + type ai_tag = { confidence: Float, name: String, source: String } + + class AITag < Imagekit::Internal::Type::BaseModel + attr_reader confidence: Float? + + def confidence=: (Float) -> Float + + attr_reader name: String? + + def name=: (String) -> String + + attr_reader source: String? + + def source=: (String) -> String + + def initialize: ( + ?confidence: Float, + ?name: String, + ?source: String + ) -> void + + def to_hash: -> { confidence: Float, name: String, source: String } + end + + type extension_status = + { + ai_auto_description: Imagekit::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::ai_auto_description, + aws_auto_tagging: Imagekit::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::aws_auto_tagging, + google_auto_tagging: Imagekit::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::google_auto_tagging, + remove_bg: Imagekit::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::remove_bg + } + + class ExtensionStatus < Imagekit::Internal::Type::BaseModel + attr_reader ai_auto_description: Imagekit::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::ai_auto_description? + + def ai_auto_description=: ( + Imagekit::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::ai_auto_description + ) -> Imagekit::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::ai_auto_description + + attr_reader aws_auto_tagging: Imagekit::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::aws_auto_tagging? + + def aws_auto_tagging=: ( + Imagekit::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::aws_auto_tagging + ) -> Imagekit::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::aws_auto_tagging + + attr_reader google_auto_tagging: Imagekit::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::google_auto_tagging? + + def google_auto_tagging=: ( + Imagekit::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::google_auto_tagging + ) -> Imagekit::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::google_auto_tagging + + attr_reader remove_bg: Imagekit::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::remove_bg? + + def remove_bg=: ( + Imagekit::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::remove_bg + ) -> Imagekit::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::remove_bg + + def initialize: ( + ?ai_auto_description: Imagekit::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::ai_auto_description, + ?aws_auto_tagging: Imagekit::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::aws_auto_tagging, + ?google_auto_tagging: Imagekit::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::google_auto_tagging, + ?remove_bg: Imagekit::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::remove_bg + ) -> void + + def to_hash: -> { + ai_auto_description: Imagekit::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::ai_auto_description, + aws_auto_tagging: Imagekit::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::aws_auto_tagging, + google_auto_tagging: Imagekit::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::google_auto_tagging, + remove_bg: Imagekit::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::remove_bg + } + + type ai_auto_description = :success | :pending | :failed + + module AIAutoDescription + extend Imagekit::Internal::Type::Enum + + SUCCESS: :success + PENDING: :pending + FAILED: :failed + + def self?.values: -> ::Array[Imagekit::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::ai_auto_description] + end + + type aws_auto_tagging = :success | :pending | :failed + + module AwsAutoTagging + extend Imagekit::Internal::Type::Enum + + SUCCESS: :success + PENDING: :pending + FAILED: :failed + + def self?.values: -> ::Array[Imagekit::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::aws_auto_tagging] + end + + type google_auto_tagging = :success | :pending | :failed + + module GoogleAutoTagging + extend Imagekit::Internal::Type::Enum + + SUCCESS: :success + PENDING: :pending + FAILED: :failed + + def self?.values: -> ::Array[Imagekit::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::google_auto_tagging] + end + + type remove_bg = :success | :pending | :failed + + module RemoveBg + extend Imagekit::Internal::Type::Enum + + SUCCESS: :success + PENDING: :pending + FAILED: :failed + + def self?.values: -> ::Array[Imagekit::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::remove_bg] + end + end + + type version_info = { id: String, name: String } + + class VersionInfo < Imagekit::Internal::Type::BaseModel + attr_reader id: String? + + def id=: (String) -> String + + attr_reader name: String? + + def name=: (String) -> String + + def initialize: (?id: String, ?name: String) -> void + + def to_hash: -> { id: String, name: String } + end + end + + type request = { transformation: String, x_request_id: String } + + class Request < Imagekit::Internal::Type::BaseModel + attr_accessor transformation: String + + attr_accessor x_request_id: String + + def initialize: (transformation: String, x_request_id: String) -> void + + def to_hash: -> { transformation: String, x_request_id: String } + end + end + end +end diff --git a/sig/imagekit/models/video_overlay.rbs b/sig/imagekit/models/video_overlay.rbs new file mode 100644 index 00000000..1c25b201 --- /dev/null +++ b/sig/imagekit/models/video_overlay.rbs @@ -0,0 +1,59 @@ +module Imagekit + module Models + type video_overlay = + { + input: String, + type: :video, + encoding: Imagekit::Models::VideoOverlay::encoding, + transformation: ::Array[Imagekit::Transformation] + } + + class VideoOverlay < Imagekit::Models::BaseOverlay + def input: -> String + + def input=: (String _) -> String + + def `type`: -> :video + + def type=: (:video _) -> :video + + def encoding: -> Imagekit::Models::VideoOverlay::encoding? + + def encoding=: ( + Imagekit::Models::VideoOverlay::encoding _ + ) -> Imagekit::Models::VideoOverlay::encoding + + def transformation: -> ::Array[Imagekit::Transformation]? + + def transformation=: ( + ::Array[Imagekit::Transformation] _ + ) -> ::Array[Imagekit::Transformation] + + def initialize: ( + input: String, + ?encoding: Imagekit::Models::VideoOverlay::encoding, + ?transformation: ::Array[Imagekit::Transformation], + ?type: :video + ) -> void + + def to_hash: -> { + input: String, + type: :video, + encoding: Imagekit::Models::VideoOverlay::encoding, + transformation: ::Array[Imagekit::Transformation] + } + + type encoding = :auto | :plain | :base64 + + module Encoding + extend Imagekit::Internal::Type::Enum + + AUTO: :auto + PLAIN: :plain + BASE64: :base64 + + def self?.values: -> ::Array[Imagekit::Models::VideoOverlay::encoding] + end + end + end +end diff --git a/sig/imagekit/models/video_transformation_accepted_event.rbs b/sig/imagekit/models/video_transformation_accepted_event.rbs new file mode 100644 index 00000000..f742ea55 --- /dev/null +++ b/sig/imagekit/models/video_transformation_accepted_event.rbs @@ -0,0 +1,261 @@ +module Imagekit + module Models + type video_transformation_accepted_event = + { + created_at: Time, + data: Imagekit::VideoTransformationAcceptedEvent::Data, + request: Imagekit::VideoTransformationAcceptedEvent::Request, + type: :"video.transformation.accepted" + } + + class VideoTransformationAcceptedEvent < Imagekit::Models::BaseWebhookEvent + def created_at: -> Time + + def created_at=: (Time _) -> Time + + def data: -> Imagekit::VideoTransformationAcceptedEvent::Data + + def data=: ( + Imagekit::VideoTransformationAcceptedEvent::Data _ + ) -> Imagekit::VideoTransformationAcceptedEvent::Data + + def request: -> Imagekit::VideoTransformationAcceptedEvent::Request + + def request=: ( + Imagekit::VideoTransformationAcceptedEvent::Request _ + ) -> Imagekit::VideoTransformationAcceptedEvent::Request + + def `type`: -> :"video.transformation.accepted" + + def type=: ( + :"video.transformation.accepted" _ + ) -> :"video.transformation.accepted" + + def initialize: ( + created_at: Time, + data: Imagekit::VideoTransformationAcceptedEvent::Data, + request: Imagekit::VideoTransformationAcceptedEvent::Request, + ?type: :"video.transformation.accepted" + ) -> void + + def to_hash: -> { + created_at: Time, + data: Imagekit::VideoTransformationAcceptedEvent::Data, + request: Imagekit::VideoTransformationAcceptedEvent::Request, + type: :"video.transformation.accepted" + } + + type data = + { + asset: Imagekit::VideoTransformationAcceptedEvent::Data::Asset, + transformation: Imagekit::VideoTransformationAcceptedEvent::Data::Transformation + } + + class Data < Imagekit::Internal::Type::BaseModel + attr_accessor asset: Imagekit::VideoTransformationAcceptedEvent::Data::Asset + + attr_accessor transformation: Imagekit::VideoTransformationAcceptedEvent::Data::Transformation + + def initialize: ( + asset: Imagekit::VideoTransformationAcceptedEvent::Data::Asset, + transformation: Imagekit::VideoTransformationAcceptedEvent::Data::Transformation + ) -> void + + def to_hash: -> { + asset: Imagekit::VideoTransformationAcceptedEvent::Data::Asset, + transformation: Imagekit::VideoTransformationAcceptedEvent::Data::Transformation + } + + type asset = { url: String } + + class Asset < Imagekit::Internal::Type::BaseModel + attr_accessor url: String + + def initialize: (url: String) -> void + + def to_hash: -> { url: String } + end + + type transformation = + { + type: Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::type_, + options: Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options + } + + class Transformation < Imagekit::Internal::Type::BaseModel + attr_accessor type: Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::type_ + + attr_reader options: Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options? + + def options=: ( + Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options + ) -> Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options + + def initialize: ( + type: Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::type_, + ?options: Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options + ) -> void + + def to_hash: -> { + type: Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::type_, + options: Imagekit::VideoTransformationAcceptedEvent::Data::Transformation::Options + } + + type type_ = + :"video-transformation" | :"gif-to-video" | :"video-thumbnail" + + module Type + extend Imagekit::Internal::Type::Enum + + VIDEO_TRANSFORMATION: :"video-transformation" + GIF_TO_VIDEO: :"gif-to-video" + VIDEO_THUMBNAIL: :"video-thumbnail" + + def self?.values: -> ::Array[Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::type_] + end + + type options = + { + audio_codec: Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::audio_codec, + auto_rotate: bool, + format_: Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::format_, + quality: Integer, + stream_protocol: Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::stream_protocol, + variants: ::Array[String], + video_codec: Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::video_codec + } + + class Options < Imagekit::Internal::Type::BaseModel + attr_reader audio_codec: Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::audio_codec? + + def audio_codec=: ( + Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::audio_codec + ) -> Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::audio_codec + + attr_reader auto_rotate: bool? + + def auto_rotate=: (bool) -> bool + + attr_reader format_: Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::format_? + + def format_=: ( + Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::format_ + ) -> Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::format_ + + attr_reader quality: Integer? + + def quality=: (Integer) -> Integer + + attr_reader stream_protocol: Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::stream_protocol? + + def stream_protocol=: ( + Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::stream_protocol + ) -> Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::stream_protocol + + attr_reader variants: ::Array[String]? + + def variants=: (::Array[String]) -> ::Array[String] + + attr_reader video_codec: Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::video_codec? + + def video_codec=: ( + Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::video_codec + ) -> Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::video_codec + + def initialize: ( + ?audio_codec: Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::audio_codec, + ?auto_rotate: bool, + ?format_: Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::format_, + ?quality: Integer, + ?stream_protocol: Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::stream_protocol, + ?variants: ::Array[String], + ?video_codec: Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::video_codec + ) -> void + + def to_hash: -> { + audio_codec: Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::audio_codec, + auto_rotate: bool, + format_: Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::format_, + quality: Integer, + stream_protocol: Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::stream_protocol, + variants: ::Array[String], + video_codec: Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::video_codec + } + + type audio_codec = :aac | :opus + + module AudioCodec + extend Imagekit::Internal::Type::Enum + + AAC: :aac + OPUS: :opus + + def self?.values: -> ::Array[Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::audio_codec] + end + + type format_ = :mp4 | :webm | :jpg | :png | :webp + + module Format + extend Imagekit::Internal::Type::Enum + + MP4: :mp4 + WEBM: :webm + JPG: :jpg + PNG: :png + WEBP: :webp + + def self?.values: -> ::Array[Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::format_] + end + + type stream_protocol = :HLS | :DASH + + module StreamProtocol + extend Imagekit::Internal::Type::Enum + + HLS: :HLS + DASH: :DASH + + def self?.values: -> ::Array[Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::stream_protocol] + end + + type video_codec = :h264 | :vp9 | :av1 + + module VideoCodec + extend Imagekit::Internal::Type::Enum + + H264: :h264 + VP9: :vp9 + AV1: :av1 + + def self?.values: -> ::Array[Imagekit::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::video_codec] + end + end + end + end + + type request = { url: String, x_request_id: String, user_agent: String } + + class Request < Imagekit::Internal::Type::BaseModel + attr_accessor url: String + + attr_accessor x_request_id: String + + attr_reader user_agent: String? + + def user_agent=: (String) -> String + + def initialize: ( + url: String, + x_request_id: String, + ?user_agent: String + ) -> void + + def to_hash: -> { + url: String, + x_request_id: String, + user_agent: String + } + end + end + end +end diff --git a/sig/imagekit/models/video_transformation_error_event.rbs b/sig/imagekit/models/video_transformation_error_event.rbs new file mode 100644 index 00000000..42a582dd --- /dev/null +++ b/sig/imagekit/models/video_transformation_error_event.rbs @@ -0,0 +1,300 @@ +module Imagekit + module Models + type video_transformation_error_event = + { + created_at: Time, + data: Imagekit::VideoTransformationErrorEvent::Data, + request: Imagekit::VideoTransformationErrorEvent::Request, + type: :"video.transformation.error" + } + + class VideoTransformationErrorEvent < Imagekit::Models::BaseWebhookEvent + def created_at: -> Time + + def created_at=: (Time _) -> Time + + def data: -> Imagekit::VideoTransformationErrorEvent::Data + + def data=: ( + Imagekit::VideoTransformationErrorEvent::Data _ + ) -> Imagekit::VideoTransformationErrorEvent::Data + + def request: -> Imagekit::VideoTransformationErrorEvent::Request + + def request=: ( + Imagekit::VideoTransformationErrorEvent::Request _ + ) -> Imagekit::VideoTransformationErrorEvent::Request + + def `type`: -> :"video.transformation.error" + + def type=: ( + :"video.transformation.error" _ + ) -> :"video.transformation.error" + + def initialize: ( + created_at: Time, + data: Imagekit::VideoTransformationErrorEvent::Data, + request: Imagekit::VideoTransformationErrorEvent::Request, + ?type: :"video.transformation.error" + ) -> void + + def to_hash: -> { + created_at: Time, + data: Imagekit::VideoTransformationErrorEvent::Data, + request: Imagekit::VideoTransformationErrorEvent::Request, + type: :"video.transformation.error" + } + + type data = + { + asset: Imagekit::VideoTransformationErrorEvent::Data::Asset, + transformation: Imagekit::VideoTransformationErrorEvent::Data::Transformation + } + + class Data < Imagekit::Internal::Type::BaseModel + attr_accessor asset: Imagekit::VideoTransformationErrorEvent::Data::Asset + + attr_accessor transformation: Imagekit::VideoTransformationErrorEvent::Data::Transformation + + def initialize: ( + asset: Imagekit::VideoTransformationErrorEvent::Data::Asset, + transformation: Imagekit::VideoTransformationErrorEvent::Data::Transformation + ) -> void + + def to_hash: -> { + asset: Imagekit::VideoTransformationErrorEvent::Data::Asset, + transformation: Imagekit::VideoTransformationErrorEvent::Data::Transformation + } + + type asset = { url: String } + + class Asset < Imagekit::Internal::Type::BaseModel + attr_accessor url: String + + def initialize: (url: String) -> void + + def to_hash: -> { url: String } + end + + type transformation = + { + type: Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::type_, + error: Imagekit::VideoTransformationErrorEvent::Data::Transformation::Error, + options: Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options + } + + class Transformation < Imagekit::Internal::Type::BaseModel + attr_accessor type: Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::type_ + + attr_reader error: Imagekit::VideoTransformationErrorEvent::Data::Transformation::Error? + + def error=: ( + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Error + ) -> Imagekit::VideoTransformationErrorEvent::Data::Transformation::Error + + attr_reader options: Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options? + + def options=: ( + Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options + ) -> Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options + + def initialize: ( + type: Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::type_, + ?error: Imagekit::VideoTransformationErrorEvent::Data::Transformation::Error, + ?options: Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options + ) -> void + + def to_hash: -> { + type: Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::type_, + error: Imagekit::VideoTransformationErrorEvent::Data::Transformation::Error, + options: Imagekit::VideoTransformationErrorEvent::Data::Transformation::Options + } + + type type_ = + :"video-transformation" | :"gif-to-video" | :"video-thumbnail" + + module Type + extend Imagekit::Internal::Type::Enum + + VIDEO_TRANSFORMATION: :"video-transformation" + GIF_TO_VIDEO: :"gif-to-video" + VIDEO_THUMBNAIL: :"video-thumbnail" + + def self?.values: -> ::Array[Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::type_] + end + + type error = + { + reason: Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Error::reason + } + + class Error < Imagekit::Internal::Type::BaseModel + attr_accessor reason: Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Error::reason + + def initialize: ( + reason: Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Error::reason + ) -> void + + def to_hash: -> { + reason: Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Error::reason + } + + type reason = + :encoding_failed | :download_failed | :internal_server_error + + module Reason + extend Imagekit::Internal::Type::Enum + + ENCODING_FAILED: :encoding_failed + DOWNLOAD_FAILED: :download_failed + INTERNAL_SERVER_ERROR: :internal_server_error + + def self?.values: -> ::Array[Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Error::reason] + end + end + + type options = + { + audio_codec: Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Options::audio_codec, + auto_rotate: bool, + format_: Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Options::format_, + quality: Integer, + stream_protocol: Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Options::stream_protocol, + variants: ::Array[String], + video_codec: Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Options::video_codec + } + + class Options < Imagekit::Internal::Type::BaseModel + attr_reader audio_codec: Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Options::audio_codec? + + def audio_codec=: ( + Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Options::audio_codec + ) -> Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Options::audio_codec + + attr_reader auto_rotate: bool? + + def auto_rotate=: (bool) -> bool + + attr_reader format_: Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Options::format_? + + def format_=: ( + Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Options::format_ + ) -> Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Options::format_ + + attr_reader quality: Integer? + + def quality=: (Integer) -> Integer + + attr_reader stream_protocol: Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Options::stream_protocol? + + def stream_protocol=: ( + Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Options::stream_protocol + ) -> Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Options::stream_protocol + + attr_reader variants: ::Array[String]? + + def variants=: (::Array[String]) -> ::Array[String] + + attr_reader video_codec: Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Options::video_codec? + + def video_codec=: ( + Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Options::video_codec + ) -> Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Options::video_codec + + def initialize: ( + ?audio_codec: Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Options::audio_codec, + ?auto_rotate: bool, + ?format_: Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Options::format_, + ?quality: Integer, + ?stream_protocol: Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Options::stream_protocol, + ?variants: ::Array[String], + ?video_codec: Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Options::video_codec + ) -> void + + def to_hash: -> { + audio_codec: Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Options::audio_codec, + auto_rotate: bool, + format_: Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Options::format_, + quality: Integer, + stream_protocol: Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Options::stream_protocol, + variants: ::Array[String], + video_codec: Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Options::video_codec + } + + type audio_codec = :aac | :opus + + module AudioCodec + extend Imagekit::Internal::Type::Enum + + AAC: :aac + OPUS: :opus + + def self?.values: -> ::Array[Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Options::audio_codec] + end + + type format_ = :mp4 | :webm | :jpg | :png | :webp + + module Format + extend Imagekit::Internal::Type::Enum + + MP4: :mp4 + WEBM: :webm + JPG: :jpg + PNG: :png + WEBP: :webp + + def self?.values: -> ::Array[Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Options::format_] + end + + type stream_protocol = :HLS | :DASH + + module StreamProtocol + extend Imagekit::Internal::Type::Enum + + HLS: :HLS + DASH: :DASH + + def self?.values: -> ::Array[Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Options::stream_protocol] + end + + type video_codec = :h264 | :vp9 | :av1 + + module VideoCodec + extend Imagekit::Internal::Type::Enum + + H264: :h264 + VP9: :vp9 + AV1: :av1 + + def self?.values: -> ::Array[Imagekit::Models::VideoTransformationErrorEvent::Data::Transformation::Options::video_codec] + end + end + end + end + + type request = { url: String, x_request_id: String, user_agent: String } + + class Request < Imagekit::Internal::Type::BaseModel + attr_accessor url: String + + attr_accessor x_request_id: String + + attr_reader user_agent: String? + + def user_agent=: (String) -> String + + def initialize: ( + url: String, + x_request_id: String, + ?user_agent: String + ) -> void + + def to_hash: -> { + url: String, + x_request_id: String, + user_agent: String + } + end + end + end +end diff --git a/sig/imagekit/models/video_transformation_ready_event.rbs b/sig/imagekit/models/video_transformation_ready_event.rbs new file mode 100644 index 00000000..0b4478a6 --- /dev/null +++ b/sig/imagekit/models/video_transformation_ready_event.rbs @@ -0,0 +1,359 @@ +module Imagekit + module Models + type video_transformation_ready_event = + { + created_at: Time, + data: Imagekit::VideoTransformationReadyEvent::Data, + request: Imagekit::VideoTransformationReadyEvent::Request, + type: :"video.transformation.ready", + timings: Imagekit::VideoTransformationReadyEvent::Timings + } + + class VideoTransformationReadyEvent < Imagekit::Models::BaseWebhookEvent + def created_at: -> Time + + def created_at=: (Time _) -> Time + + def data: -> Imagekit::VideoTransformationReadyEvent::Data + + def data=: ( + Imagekit::VideoTransformationReadyEvent::Data _ + ) -> Imagekit::VideoTransformationReadyEvent::Data + + def request: -> Imagekit::VideoTransformationReadyEvent::Request + + def request=: ( + Imagekit::VideoTransformationReadyEvent::Request _ + ) -> Imagekit::VideoTransformationReadyEvent::Request + + def `type`: -> :"video.transformation.ready" + + def type=: ( + :"video.transformation.ready" _ + ) -> :"video.transformation.ready" + + def timings: -> Imagekit::VideoTransformationReadyEvent::Timings? + + def timings=: ( + Imagekit::VideoTransformationReadyEvent::Timings _ + ) -> Imagekit::VideoTransformationReadyEvent::Timings + + def initialize: ( + created_at: Time, + data: Imagekit::VideoTransformationReadyEvent::Data, + request: Imagekit::VideoTransformationReadyEvent::Request, + ?timings: Imagekit::VideoTransformationReadyEvent::Timings, + ?type: :"video.transformation.ready" + ) -> void + + def to_hash: -> { + created_at: Time, + data: Imagekit::VideoTransformationReadyEvent::Data, + request: Imagekit::VideoTransformationReadyEvent::Request, + type: :"video.transformation.ready", + timings: Imagekit::VideoTransformationReadyEvent::Timings + } + + type data = + { + asset: Imagekit::VideoTransformationReadyEvent::Data::Asset, + transformation: Imagekit::VideoTransformationReadyEvent::Data::Transformation + } + + class Data < Imagekit::Internal::Type::BaseModel + attr_accessor asset: Imagekit::VideoTransformationReadyEvent::Data::Asset + + attr_accessor transformation: Imagekit::VideoTransformationReadyEvent::Data::Transformation + + def initialize: ( + asset: Imagekit::VideoTransformationReadyEvent::Data::Asset, + transformation: Imagekit::VideoTransformationReadyEvent::Data::Transformation + ) -> void + + def to_hash: -> { + asset: Imagekit::VideoTransformationReadyEvent::Data::Asset, + transformation: Imagekit::VideoTransformationReadyEvent::Data::Transformation + } + + type asset = { url: String } + + class Asset < Imagekit::Internal::Type::BaseModel + attr_accessor url: String + + def initialize: (url: String) -> void + + def to_hash: -> { url: String } + end + + type transformation = + { + type: Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::type_, + options: Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options, + output: Imagekit::VideoTransformationReadyEvent::Data::Transformation::Output + } + + class Transformation < Imagekit::Internal::Type::BaseModel + attr_accessor type: Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::type_ + + attr_reader options: Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options? + + def options=: ( + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options + ) -> Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options + + attr_reader output: Imagekit::VideoTransformationReadyEvent::Data::Transformation::Output? + + def output=: ( + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Output + ) -> Imagekit::VideoTransformationReadyEvent::Data::Transformation::Output + + def initialize: ( + type: Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::type_, + ?options: Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options, + ?output: Imagekit::VideoTransformationReadyEvent::Data::Transformation::Output + ) -> void + + def to_hash: -> { + type: Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::type_, + options: Imagekit::VideoTransformationReadyEvent::Data::Transformation::Options, + output: Imagekit::VideoTransformationReadyEvent::Data::Transformation::Output + } + + type type_ = + :"video-transformation" | :"gif-to-video" | :"video-thumbnail" + + module Type + extend Imagekit::Internal::Type::Enum + + VIDEO_TRANSFORMATION: :"video-transformation" + GIF_TO_VIDEO: :"gif-to-video" + VIDEO_THUMBNAIL: :"video-thumbnail" + + def self?.values: -> ::Array[Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::type_] + end + + type options = + { + audio_codec: Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Options::audio_codec, + auto_rotate: bool, + format_: Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Options::format_, + quality: Integer, + stream_protocol: Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Options::stream_protocol, + variants: ::Array[String], + video_codec: Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Options::video_codec + } + + class Options < Imagekit::Internal::Type::BaseModel + attr_reader audio_codec: Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Options::audio_codec? + + def audio_codec=: ( + Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Options::audio_codec + ) -> Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Options::audio_codec + + attr_reader auto_rotate: bool? + + def auto_rotate=: (bool) -> bool + + attr_reader format_: Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Options::format_? + + def format_=: ( + Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Options::format_ + ) -> Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Options::format_ + + attr_reader quality: Integer? + + def quality=: (Integer) -> Integer + + attr_reader stream_protocol: Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Options::stream_protocol? + + def stream_protocol=: ( + Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Options::stream_protocol + ) -> Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Options::stream_protocol + + attr_reader variants: ::Array[String]? + + def variants=: (::Array[String]) -> ::Array[String] + + attr_reader video_codec: Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Options::video_codec? + + def video_codec=: ( + Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Options::video_codec + ) -> Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Options::video_codec + + def initialize: ( + ?audio_codec: Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Options::audio_codec, + ?auto_rotate: bool, + ?format_: Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Options::format_, + ?quality: Integer, + ?stream_protocol: Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Options::stream_protocol, + ?variants: ::Array[String], + ?video_codec: Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Options::video_codec + ) -> void + + def to_hash: -> { + audio_codec: Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Options::audio_codec, + auto_rotate: bool, + format_: Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Options::format_, + quality: Integer, + stream_protocol: Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Options::stream_protocol, + variants: ::Array[String], + video_codec: Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Options::video_codec + } + + type audio_codec = :aac | :opus + + module AudioCodec + extend Imagekit::Internal::Type::Enum + + AAC: :aac + OPUS: :opus + + def self?.values: -> ::Array[Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Options::audio_codec] + end + + type format_ = :mp4 | :webm | :jpg | :png | :webp + + module Format + extend Imagekit::Internal::Type::Enum + + MP4: :mp4 + WEBM: :webm + JPG: :jpg + PNG: :png + WEBP: :webp + + def self?.values: -> ::Array[Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Options::format_] + end + + type stream_protocol = :HLS | :DASH + + module StreamProtocol + extend Imagekit::Internal::Type::Enum + + HLS: :HLS + DASH: :DASH + + def self?.values: -> ::Array[Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Options::stream_protocol] + end + + type video_codec = :h264 | :vp9 | :av1 + + module VideoCodec + extend Imagekit::Internal::Type::Enum + + H264: :h264 + VP9: :vp9 + AV1: :av1 + + def self?.values: -> ::Array[Imagekit::Models::VideoTransformationReadyEvent::Data::Transformation::Options::video_codec] + end + end + + type output = + { + url: String, + video_metadata: Imagekit::VideoTransformationReadyEvent::Data::Transformation::Output::VideoMetadata + } + + class Output < Imagekit::Internal::Type::BaseModel + attr_accessor url: String + + attr_reader video_metadata: Imagekit::VideoTransformationReadyEvent::Data::Transformation::Output::VideoMetadata? + + def video_metadata=: ( + Imagekit::VideoTransformationReadyEvent::Data::Transformation::Output::VideoMetadata + ) -> Imagekit::VideoTransformationReadyEvent::Data::Transformation::Output::VideoMetadata + + def initialize: ( + url: String, + ?video_metadata: Imagekit::VideoTransformationReadyEvent::Data::Transformation::Output::VideoMetadata + ) -> void + + def to_hash: -> { + url: String, + video_metadata: Imagekit::VideoTransformationReadyEvent::Data::Transformation::Output::VideoMetadata + } + + type video_metadata = + { + bitrate: Integer, + duration: Float, + height: Integer, + width: Integer + } + + class VideoMetadata < Imagekit::Internal::Type::BaseModel + attr_accessor bitrate: Integer + + attr_accessor duration: Float + + attr_accessor height: Integer + + attr_accessor width: Integer + + def initialize: ( + bitrate: Integer, + duration: Float, + height: Integer, + width: Integer + ) -> void + + def to_hash: -> { + bitrate: Integer, + duration: Float, + height: Integer, + width: Integer + } + end + end + end + end + + type request = { url: String, x_request_id: String, user_agent: String } + + class Request < Imagekit::Internal::Type::BaseModel + attr_accessor url: String + + attr_accessor x_request_id: String + + attr_reader user_agent: String? + + def user_agent=: (String) -> String + + def initialize: ( + url: String, + x_request_id: String, + ?user_agent: String + ) -> void + + def to_hash: -> { + url: String, + x_request_id: String, + user_agent: String + } + end + + type timings = { download_duration: Integer, encoding_duration: Integer } + + class Timings < Imagekit::Internal::Type::BaseModel + attr_reader download_duration: Integer? + + def download_duration=: (Integer) -> Integer + + attr_reader encoding_duration: Integer? + + def encoding_duration=: (Integer) -> Integer + + def initialize: ( + ?download_duration: Integer, + ?encoding_duration: Integer + ) -> void + + def to_hash: -> { + download_duration: Integer, + encoding_duration: Integer + } + end + end + end +end diff --git a/sig/imagekit/models/webhook_unsafe_unwrap_params.rbs b/sig/imagekit/models/webhook_unsafe_unwrap_params.rbs new file mode 100644 index 00000000..6b7b0859 --- /dev/null +++ b/sig/imagekit/models/webhook_unsafe_unwrap_params.rbs @@ -0,0 +1,15 @@ +module Imagekit + module Models + type webhook_unsafe_unwrap_params = + { } & Imagekit::Internal::Type::request_parameters + + class WebhookUnsafeUnwrapParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + def initialize: (?request_options: Imagekit::request_opts) -> void + + def to_hash: -> { request_options: Imagekit::RequestOptions } + end + end +end diff --git a/sig/imagekit/models/webhook_unwrap_params.rbs b/sig/imagekit/models/webhook_unwrap_params.rbs new file mode 100644 index 00000000..e321d3b5 --- /dev/null +++ b/sig/imagekit/models/webhook_unwrap_params.rbs @@ -0,0 +1,15 @@ +module Imagekit + module Models + type webhook_unwrap_params = + { } & Imagekit::Internal::Type::request_parameters + + class WebhookUnwrapParams < Imagekit::Internal::Type::BaseModel + extend Imagekit::Internal::Type::RequestParameters::Converter + include Imagekit::Internal::Type::RequestParameters + + def initialize: (?request_options: Imagekit::request_opts) -> void + + def to_hash: -> { request_options: Imagekit::RequestOptions } + end + end +end diff --git a/sig/imagekit/request_options.rbs b/sig/imagekit/request_options.rbs new file mode 100644 index 00000000..44de316d --- /dev/null +++ b/sig/imagekit/request_options.rbs @@ -0,0 +1,34 @@ +module Imagekit + type request_opts = + Imagekit::RequestOptions | Imagekit::request_options | ::Hash[Symbol, top] + + type request_options = + { + idempotency_key: String?, + extra_query: ::Hash[String, (::Array[String] | String)?]?, + extra_headers: ::Hash[String, String?]?, + extra_body: top?, + max_retries: Integer?, + timeout: Float? + } + + class RequestOptions < Imagekit::Internal::Type::BaseModel + def self.validate!: (Imagekit::request_opts opts) -> void + + attr_accessor idempotency_key: String? + + attr_accessor extra_query: ::Hash[String, (::Array[String] | String)?]? + + attr_accessor extra_headers: ::Hash[String, String?]? + + attr_accessor extra_body: top? + + attr_accessor max_retries: Integer? + + attr_accessor timeout: Float? + + def initialize: ( + ?Imagekit::request_options | ::Hash[Symbol, top] values + ) -> void + end +end diff --git a/sig/imagekit/resources/accounts.rbs b/sig/imagekit/resources/accounts.rbs new file mode 100644 index 00000000..dfc6188c --- /dev/null +++ b/sig/imagekit/resources/accounts.rbs @@ -0,0 +1,13 @@ +module Imagekit + module Resources + class Accounts + attr_reader usage: Imagekit::Resources::Accounts::Usage + + attr_reader origins: Imagekit::Resources::Accounts::Origins + + attr_reader url_endpoints: Imagekit::Resources::Accounts::URLEndpoints + + def initialize: (client: Imagekit::Client) -> void + end + end +end diff --git a/sig/imagekit/resources/accounts/origins.rbs b/sig/imagekit/resources/accounts/origins.rbs new file mode 100644 index 00000000..6fe76931 --- /dev/null +++ b/sig/imagekit/resources/accounts/origins.rbs @@ -0,0 +1,31 @@ +module Imagekit + module Resources + class Accounts + class Origins + def create: ( + origin_request: Imagekit::Models::Accounts::OriginRequest, + ?request_options: Imagekit::request_opts + ) -> Imagekit::Models::Accounts::origin_response + + def update: ( + String id, + origin_request: Imagekit::Models::Accounts::OriginRequest, + ?request_options: Imagekit::request_opts + ) -> Imagekit::Models::Accounts::origin_response + + def list: ( + ?request_options: Imagekit::request_opts + ) -> Imagekit::Models::Accounts::origin_list_response + + def delete: (String id, ?request_options: Imagekit::request_opts) -> nil + + def get: ( + String id, + ?request_options: Imagekit::request_opts + ) -> Imagekit::Models::Accounts::origin_response + + def initialize: (client: Imagekit::Client) -> void + end + end + end +end diff --git a/sig/imagekit/resources/accounts/url_endpoints.rbs b/sig/imagekit/resources/accounts/url_endpoints.rbs new file mode 100644 index 00000000..b87de7ed --- /dev/null +++ b/sig/imagekit/resources/accounts/url_endpoints.rbs @@ -0,0 +1,37 @@ +module Imagekit + module Resources + class Accounts + class URLEndpoints + def create: ( + description: String, + ?origins: ::Array[String], + ?url_prefix: String, + ?url_rewriter: Imagekit::Models::Accounts::URLEndpointRequest::url_rewriter, + ?request_options: Imagekit::request_opts + ) -> Imagekit::Accounts::URLEndpointResponse + + def update: ( + String id, + description: String, + ?origins: ::Array[String], + ?url_prefix: String, + ?url_rewriter: Imagekit::Models::Accounts::URLEndpointRequest::url_rewriter, + ?request_options: Imagekit::request_opts + ) -> Imagekit::Accounts::URLEndpointResponse + + def list: ( + ?request_options: Imagekit::request_opts + ) -> Imagekit::Models::Accounts::url_endpoint_list_response + + def delete: (String id, ?request_options: Imagekit::request_opts) -> nil + + def get: ( + String id, + ?request_options: Imagekit::request_opts + ) -> Imagekit::Accounts::URLEndpointResponse + + def initialize: (client: Imagekit::Client) -> void + end + end + end +end diff --git a/sig/imagekit/resources/accounts/usage.rbs b/sig/imagekit/resources/accounts/usage.rbs new file mode 100644 index 00000000..b4c781db --- /dev/null +++ b/sig/imagekit/resources/accounts/usage.rbs @@ -0,0 +1,15 @@ +module Imagekit + module Resources + class Accounts + class Usage + def get: ( + end_date: Date, + start_date: Date, + ?request_options: Imagekit::request_opts + ) -> Imagekit::Models::Accounts::UsageGetResponse + + def initialize: (client: Imagekit::Client) -> void + end + end + end +end diff --git a/sig/imagekit/resources/assets.rbs b/sig/imagekit/resources/assets.rbs new file mode 100644 index 00000000..65ba95d1 --- /dev/null +++ b/sig/imagekit/resources/assets.rbs @@ -0,0 +1,18 @@ +module Imagekit + module Resources + class Assets + def list: ( + ?file_type: Imagekit::Models::AssetListParams::file_type, + ?limit: Integer, + ?path: String, + ?search_query: String, + ?skip: Integer, + ?sort: Imagekit::Models::AssetListParams::sort, + ?type: Imagekit::Models::AssetListParams::type_, + ?request_options: Imagekit::request_opts + ) -> Imagekit::Models::asset_list_response + + def initialize: (client: Imagekit::Client) -> void + end + end +end diff --git a/sig/imagekit/resources/beta.rbs b/sig/imagekit/resources/beta.rbs new file mode 100644 index 00000000..750d302a --- /dev/null +++ b/sig/imagekit/resources/beta.rbs @@ -0,0 +1,9 @@ +module Imagekit + module Resources + class Beta + attr_reader v2: Imagekit::Resources::Beta::V2 + + def initialize: (client: Imagekit::Client) -> void + end + end +end diff --git a/sig/imagekit/resources/beta/v2.rbs b/sig/imagekit/resources/beta/v2.rbs new file mode 100644 index 00000000..3b91ef06 --- /dev/null +++ b/sig/imagekit/resources/beta/v2.rbs @@ -0,0 +1,11 @@ +module Imagekit + module Resources + class Beta + class V2 + attr_reader files: Imagekit::Resources::Beta::V2::Files + + def initialize: (client: Imagekit::Client) -> void + end + end + end +end diff --git a/sig/imagekit/resources/beta/v2/files.rbs b/sig/imagekit/resources/beta/v2/files.rbs new file mode 100644 index 00000000..a2d266ae --- /dev/null +++ b/sig/imagekit/resources/beta/v2/files.rbs @@ -0,0 +1,35 @@ +module Imagekit + module Resources + class Beta + class V2 + class Files + def upload: ( + file: Imagekit::Internal::file_input, + file_name: String, + ?token: String, + ?checks: String, + ?custom_coordinates: String, + ?custom_metadata: ::Hash[Symbol, top], + ?description: String, + ?extensions: Imagekit::Models::extensions, + ?folder: String, + ?is_private_file: bool, + ?is_published: bool, + ?overwrite_ai_tags: bool, + ?overwrite_custom_metadata: bool, + ?overwrite_file: bool, + ?overwrite_tags: bool, + ?response_fields: ::Array[Imagekit::Models::Beta::V2::FileUploadParams::response_field], + ?tags: ::Array[String], + ?transformation: Imagekit::Beta::V2::FileUploadParams::Transformation, + ?use_unique_file_name: bool, + ?webhook_url: String, + ?request_options: Imagekit::request_opts + ) -> Imagekit::Models::Beta::V2::FileUploadResponse + + def initialize: (client: Imagekit::Client) -> void + end + end + end + end +end diff --git a/sig/imagekit/resources/cache.rbs b/sig/imagekit/resources/cache.rbs new file mode 100644 index 00000000..e8051527 --- /dev/null +++ b/sig/imagekit/resources/cache.rbs @@ -0,0 +1,9 @@ +module Imagekit + module Resources + class Cache + attr_reader invalidation: Imagekit::Resources::Cache::Invalidation + + def initialize: (client: Imagekit::Client) -> void + end + end +end diff --git a/sig/imagekit/resources/cache/invalidation.rbs b/sig/imagekit/resources/cache/invalidation.rbs new file mode 100644 index 00000000..66bcbae0 --- /dev/null +++ b/sig/imagekit/resources/cache/invalidation.rbs @@ -0,0 +1,19 @@ +module Imagekit + module Resources + class Cache + class Invalidation + def create: ( + url: String, + ?request_options: Imagekit::request_opts + ) -> Imagekit::Models::Cache::InvalidationCreateResponse + + def get: ( + String request_id, + ?request_options: Imagekit::request_opts + ) -> Imagekit::Models::Cache::InvalidationGetResponse + + def initialize: (client: Imagekit::Client) -> void + end + end + end +end diff --git a/sig/imagekit/resources/custom_metadata_fields.rbs b/sig/imagekit/resources/custom_metadata_fields.rbs new file mode 100644 index 00000000..f14f6f73 --- /dev/null +++ b/sig/imagekit/resources/custom_metadata_fields.rbs @@ -0,0 +1,31 @@ +module Imagekit + module Resources + class CustomMetadataFields + def create: ( + label: String, + name: String, + schema: Imagekit::CustomMetadataFieldCreateParams::Schema, + ?request_options: Imagekit::request_opts + ) -> Imagekit::CustomMetadataField + + def update: ( + String id, + ?label: String, + ?schema: Imagekit::CustomMetadataFieldUpdateParams::Schema, + ?request_options: Imagekit::request_opts + ) -> Imagekit::CustomMetadataField + + def list: ( + ?include_deleted: bool, + ?request_options: Imagekit::request_opts + ) -> Imagekit::Models::custom_metadata_field_list_response + + def delete: ( + String id, + ?request_options: Imagekit::request_opts + ) -> Imagekit::Models::CustomMetadataFieldDeleteResponse + + def initialize: (client: Imagekit::Client) -> void + end + end +end diff --git a/sig/imagekit/resources/files.rbs b/sig/imagekit/resources/files.rbs new file mode 100644 index 00000000..e2c281c0 --- /dev/null +++ b/sig/imagekit/resources/files.rbs @@ -0,0 +1,76 @@ +module Imagekit + module Resources + class Files + attr_reader bulk: Imagekit::Resources::Files::Bulk + + attr_reader versions: Imagekit::Resources::Files::Versions + + attr_reader metadata: Imagekit::Resources::Files::Metadata + + def update: ( + String file_id, + update_file_request: Imagekit::Models::UpdateFileRequest, + ?request_options: Imagekit::request_opts + ) -> Imagekit::Models::FileUpdateResponse + + def delete: ( + String file_id, + ?request_options: Imagekit::request_opts + ) -> nil + + def copy: ( + destination_path: String, + source_file_path: String, + ?include_file_versions: bool, + ?request_options: Imagekit::request_opts + ) -> Imagekit::Models::FileCopyResponse + + def get: ( + String file_id, + ?request_options: Imagekit::request_opts + ) -> Imagekit::File + + def move: ( + destination_path: String, + source_file_path: String, + ?request_options: Imagekit::request_opts + ) -> Imagekit::Models::FileMoveResponse + + def rename: ( + file_path: String, + new_file_name: String, + ?purge_cache: bool, + ?request_options: Imagekit::request_opts + ) -> Imagekit::Models::FileRenameResponse + + def upload: ( + file: Imagekit::Internal::file_input, + file_name: String, + ?token: String, + ?checks: String, + ?custom_coordinates: String, + ?custom_metadata: ::Hash[Symbol, top], + ?description: String, + ?expire: Integer, + ?extensions: Imagekit::Models::extensions, + ?folder: String, + ?is_private_file: bool, + ?is_published: bool, + ?overwrite_ai_tags: bool, + ?overwrite_custom_metadata: bool, + ?overwrite_file: bool, + ?overwrite_tags: bool, + ?public_key: String, + ?response_fields: ::Array[Imagekit::Models::FileUploadParams::response_field], + ?signature: String, + ?tags: ::Array[String], + ?transformation: Imagekit::FileUploadParams::Transformation, + ?use_unique_file_name: bool, + ?webhook_url: String, + ?request_options: Imagekit::request_opts + ) -> Imagekit::Models::FileUploadResponse + + def initialize: (client: Imagekit::Client) -> void + end + end +end diff --git a/sig/imagekit/resources/files/bulk.rbs b/sig/imagekit/resources/files/bulk.rbs new file mode 100644 index 00000000..a8df17a8 --- /dev/null +++ b/sig/imagekit/resources/files/bulk.rbs @@ -0,0 +1,32 @@ +module Imagekit + module Resources + class Files + class Bulk + def delete: ( + file_ids: ::Array[String], + ?request_options: Imagekit::request_opts + ) -> Imagekit::Models::Files::BulkDeleteResponse + + def add_tags: ( + file_ids: ::Array[String], + tags: ::Array[String], + ?request_options: Imagekit::request_opts + ) -> Imagekit::Models::Files::BulkAddTagsResponse + + def remove_ai_tags: ( + ai_tags: ::Array[String], + file_ids: ::Array[String], + ?request_options: Imagekit::request_opts + ) -> Imagekit::Models::Files::BulkRemoveAITagsResponse + + def remove_tags: ( + file_ids: ::Array[String], + tags: ::Array[String], + ?request_options: Imagekit::request_opts + ) -> Imagekit::Models::Files::BulkRemoveTagsResponse + + def initialize: (client: Imagekit::Client) -> void + end + end + end +end diff --git a/sig/imagekit/resources/files/metadata.rbs b/sig/imagekit/resources/files/metadata.rbs new file mode 100644 index 00000000..4ddd61e6 --- /dev/null +++ b/sig/imagekit/resources/files/metadata.rbs @@ -0,0 +1,19 @@ +module Imagekit + module Resources + class Files + class Metadata + def get: ( + String file_id, + ?request_options: Imagekit::request_opts + ) -> Imagekit::Metadata + + def get_from_url: ( + url: String, + ?request_options: Imagekit::request_opts + ) -> Imagekit::Metadata + + def initialize: (client: Imagekit::Client) -> void + end + end + end +end diff --git a/sig/imagekit/resources/files/versions.rbs b/sig/imagekit/resources/files/versions.rbs new file mode 100644 index 00000000..881e2c57 --- /dev/null +++ b/sig/imagekit/resources/files/versions.rbs @@ -0,0 +1,32 @@ +module Imagekit + module Resources + class Files + class Versions + def list: ( + String file_id, + ?request_options: Imagekit::request_opts + ) -> Imagekit::Models::Files::version_list_response + + def delete: ( + String version_id, + file_id: String, + ?request_options: Imagekit::request_opts + ) -> Imagekit::Models::Files::VersionDeleteResponse + + def get: ( + String version_id, + file_id: String, + ?request_options: Imagekit::request_opts + ) -> Imagekit::File + + def restore: ( + String version_id, + file_id: String, + ?request_options: Imagekit::request_opts + ) -> Imagekit::File + + def initialize: (client: Imagekit::Client) -> void + end + end + end +end diff --git a/sig/imagekit/resources/folders.rbs b/sig/imagekit/resources/folders.rbs new file mode 100644 index 00000000..f5990d9b --- /dev/null +++ b/sig/imagekit/resources/folders.rbs @@ -0,0 +1,40 @@ +module Imagekit + module Resources + class Folders + attr_reader job: Imagekit::Resources::Folders::Job + + def create: ( + folder_name: String, + parent_folder_path: String, + ?request_options: Imagekit::request_opts + ) -> Imagekit::Models::FolderCreateResponse + + def delete: ( + folder_path: String, + ?request_options: Imagekit::request_opts + ) -> Imagekit::Models::FolderDeleteResponse + + def copy: ( + destination_path: String, + source_folder_path: String, + ?include_versions: bool, + ?request_options: Imagekit::request_opts + ) -> Imagekit::Models::FolderCopyResponse + + def move: ( + destination_path: String, + source_folder_path: String, + ?request_options: Imagekit::request_opts + ) -> Imagekit::Models::FolderMoveResponse + + def rename: ( + folder_path: String, + new_folder_name: String, + ?purge_cache: bool, + ?request_options: Imagekit::request_opts + ) -> Imagekit::Models::FolderRenameResponse + + def initialize: (client: Imagekit::Client) -> void + end + end +end diff --git a/sig/imagekit/resources/folders/job.rbs b/sig/imagekit/resources/folders/job.rbs new file mode 100644 index 00000000..81561a88 --- /dev/null +++ b/sig/imagekit/resources/folders/job.rbs @@ -0,0 +1,14 @@ +module Imagekit + module Resources + class Folders + class Job + def get: ( + String job_id, + ?request_options: Imagekit::request_opts + ) -> Imagekit::Models::Folders::JobGetResponse + + def initialize: (client: Imagekit::Client) -> void + end + end + end +end diff --git a/sig/imagekit/resources/webhooks.rbs b/sig/imagekit/resources/webhooks.rbs new file mode 100644 index 00000000..ea4242dd --- /dev/null +++ b/sig/imagekit/resources/webhooks.rbs @@ -0,0 +1,27 @@ +module Imagekit + module Resources + class Webhooks + def unsafe_unwrap: ( + String payload + ) -> (Imagekit::VideoTransformationAcceptedEvent + | Imagekit::VideoTransformationReadyEvent + | Imagekit::VideoTransformationErrorEvent + | Imagekit::UploadPreTransformSuccessEvent + | Imagekit::UploadPreTransformErrorEvent + | Imagekit::UploadPostTransformSuccessEvent + | Imagekit::UploadPostTransformErrorEvent) + + def unwrap: ( + String payload + ) -> (Imagekit::VideoTransformationAcceptedEvent + | Imagekit::VideoTransformationReadyEvent + | Imagekit::VideoTransformationErrorEvent + | Imagekit::UploadPreTransformSuccessEvent + | Imagekit::UploadPreTransformErrorEvent + | Imagekit::UploadPostTransformSuccessEvent + | Imagekit::UploadPostTransformErrorEvent) + + def initialize: (client: Imagekit::Client) -> void + end + end +end diff --git a/sig/imagekit/version.rbs b/sig/imagekit/version.rbs new file mode 100644 index 00000000..56afb0ab --- /dev/null +++ b/sig/imagekit/version.rbs @@ -0,0 +1,3 @@ +module Imagekit + VERSION: String +end diff --git a/sorbet/config b/sorbet/config new file mode 100644 index 00000000..6fe84ed8 --- /dev/null +++ b/sorbet/config @@ -0,0 +1,2 @@ +--dir=rbi/ +--ignore=test/ diff --git a/sorbet/rbi/.gitignore b/sorbet/rbi/.gitignore new file mode 100644 index 00000000..d6b7ef32 --- /dev/null +++ b/sorbet/rbi/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/test/imagekit/api_service/bulk_test.rb b/test/imagekit/api_service/bulk_test.rb deleted file mode 100644 index a1a234fb..00000000 --- a/test/imagekit/api_service/bulk_test.rb +++ /dev/null @@ -1,185 +0,0 @@ -require_relative '../spec_helper' - -RSpec.describe ImageKitIo::ApiService::Bulk do - let(:bulk_api_service) { described_class } - let(:config) { ImageKitIo.config } - let(:constants) { ImageKitIo.constants } - let!(:private_key) { config.private_key } - let!(:public_key) { config.public_key } - let!(:url_endpoint) { config.url_endpoint } - - describe 'TestBatchDelete' do - it "test_remove_files_fails_on_unauthenticated_request" do - file_ids = %w[file_id_1 file_id_2] - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({code: 401, body: {}}) - - SUT = bulk_api_service.new(request_obj) - resp = SUT.remove_files(file_ids: file_ids) - - expect(@ac[:payload]).to eq({"fileIds": file_ids}.to_json) - expect(resp[:code]).to eq(401) - end - - it "test_remove_files_fails_on_item_not_found" do - file_ids = %w[file_id_1 file_id_2] - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({code: 404, body: {message: "The requested file(s) does not exist.", - help: "For support kindly contact us at support@imagekit.io .", - missingFileIds: file_ids,},},) - - SUT = bulk_api_service.new(request_obj) - resp = SUT.remove_files(file_ids: file_ids) - - expect(@ac[:payload]).to eq({"fileIds": file_ids}.to_json) - expect(resp[:code]).to eq(404) - expect(resp[:body][:missingFileIds]).to eq(file_ids) - end - - it "test_remove_files_succeeds" do - request_obj = double - file_ids = %w[file_id_1 file_id_2] - - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({code: 200, body: {successfullyDeletedFileIds: file_ids}}) - - SUT = bulk_api_service.new(request_obj) - resp = SUT.remove_files(file_ids: file_ids) - - expect(@ac[:payload]).to eq({"fileIds": file_ids}.to_json) - expect(resp[:code]).to eq(200) - expect(resp[:body][:successfullyDeletedFileIds]).to eq(file_ids) - end - end - - context 'batch tags' do - let!(:req_obj) { double } - let(:file_ids) { %[file_id_1 file_id_2] } - - before do - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(req_obj) - allow(req_obj) - .to receive(:create_headers) - .and_return({}) - allow(req_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload: payload}} - .and_return({code: 200, body: { successfullyUpdatedFileIds: file_ids }}) - @sut = bulk_api_service.new(req_obj) - end - - context 'add_tags' do - it 'raises error on empty parameters' do - expect { - @sut.add_tags - }.to raise_error(ArgumentError) - end - - it 'test_add_tags' do - resp = @sut.add_tags(file_ids: file_ids, tags: ['custom_tag']) - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/files/addTags") - expect(@ac[:payload]).to eq("{\"fileIds\":\"file_id_1 file_id_2\",\"tags\":[\"custom_tag\"]}") - expect(resp[:code]).to eq(200) - end - end - - context 'remove_tags' do - it 'raises error on empty parameters' do - expect { - @sut.remove_tags - }.to raise_error(ArgumentError) - end - - it 'test_remove_tags' do - resp = @sut.remove_tags(file_ids: file_ids, tags: ['custom_tag_remove']) - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/files/removeTags") - expect(@ac[:payload]).to eq("{\"fileIds\":\"file_id_1 file_id_2\",\"tags\":[\"custom_tag_remove\"]}") - expect(resp[:code]).to eq(200) - end - end - - context 'remove_ai_tags' do - it 'raises error on empty parameters' do - expect { - @sut.remove_ai_tags - }.to raise_error(ArgumentError) - end - - it 'test_remove_ai_tags' do - resp = @sut.remove_ai_tags(file_ids: file_ids, ai_tags: ['custom_ai_tag']) - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/files/removeAITags") - expect(@ac[:payload]).to eq("{\"fileIds\":\"file_id_1 file_id_2\",\"AITags\":[\"custom_ai_tag\"]}") - expect(resp[:code]).to eq(200) - end - end - end - - context 'job status' do - let(:req_obj) { double } - let(:job_id) { '619e038e20b7ef03efc4eeb9' } - - before do - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(req_obj) - allow(req_obj) - .to receive(:create_headers) - .and_return({}) - response_body = {"jobId"=> job_id, "type"=>"MOVE_FOLDER", "status"=>"Completed"} - allow(req_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload: payload}} - .and_return({code: 200, body: response_body }) - @sut = bulk_api_service.new(req_obj) - end - - it 'raises error when parameter id not given' do - expect { - @sut.job_status - }.to raise_error(ArgumentError) - end - - it 'test_job_status' do - resp = @sut.job_status(job_id: job_id) - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/bulkJobs/#{job_id}") - expect(@ac[:method]).to eq('get') - expect(@ac[:payload]).to eq({ :jobId => job_id}) - expect(resp[:body]['jobId']).to eq(job_id) - expect(resp[:body]['status']).to eq('Completed') - end - end -end diff --git a/test/imagekit/api_service/custom_metadata_field_test.rb b/test/imagekit/api_service/custom_metadata_field_test.rb deleted file mode 100644 index 5555bb9b..00000000 --- a/test/imagekit/api_service/custom_metadata_field_test.rb +++ /dev/null @@ -1,101 +0,0 @@ -require_relative '../spec_helper' - -RSpec.describe ImageKitIo::ApiService::CustomMetadataField do - let(:custom_metadata_service) { described_class } - let(:config) { ImageKitIo.config } - let(:constants) { ImageKitIo.constants } - let!(:private_key) { config.private_key } - let!(:public_key) { config.public_key } - let!(:url_endpoint) { config.url_endpoint } - - context 'custom metadata' do - let(:req_obj) { double } - let(:success_response) { - {"id"=>"619e667520b7ef03efc5d870", "name"=>"price1", "label"=>"price", "schema"=>{"type"=>"Number", "minValue"=>100, "maxValue"=>300}} - } - before do - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(req_obj) - allow(req_obj) - .to receive(:create_headers) - .and_return({}) - - end - - it 'raises error when not providing parameter for create' do - @sut = custom_metadata_service.new(req_obj) - expect { - @sut.create(name: nil, label: 'test_label', schema: '') - }.to raise_error(ArgumentError) - end - - it 'test_create_custom_metadata' do - allow(req_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload: payload}} - .and_return({code: 200, body: success_response }) - @sut = custom_metadata_service.new(req_obj) - resp = @sut.create( - name: 'price1', - label: 'price', - schema: { - type: 'Number', - minValue: 100, - maxValue: 300 - } - ) - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/customMetadataFields") - expect(@ac[:method]).to eq('post') - expect(resp[:body]['id']).to eq(success_response["id"]) - end - - it 'test_get_custom_metadata' do - allow(req_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload: payload}} - .and_return({code: 200, body: [success_response] }) - @sut = custom_metadata_service.new(req_obj) - resp = @sut.list - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/customMetadataFields") - expect(@ac[:method]).to eq('get') - expect(resp[:body]).to eq([success_response]) - end - - it 'raises error when parameter not provided on update_custom_metadata' do - @sut = custom_metadata_service.new(req_obj) - expect { - @sut.update(id: nil, label: 'test_label', schema: '') - }.to raise_error(ArgumentError) - end - - it 'test_update_custom_metadata' do - metadata_id = "619e667320b7ef03efc5d850" - allow(req_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload: payload}} - .and_return({code: 200, body: {"id"=>metadata_id, "name"=>"price1", "label"=>"price1", "schema"=>{"type"=>"Number", "minValue"=>100, "maxValue"=>300}} }) - @sut = custom_metadata_service.new(req_obj) - resp = @sut.update(id: metadata_id, label: 'price1', schema: nil) - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/customMetadataFields/#{metadata_id}") - expect(@ac[:method]).to eq('patch') - expect(resp[:body]).to eq({"id"=>metadata_id, "name"=>"price1", "label"=>"price1", "schema"=>{"type"=>"Number", "minValue"=>100, "maxValue"=>300}} ) - end - - it 'raises error when parameter not provided on update_custom_metadata' do - @sut = custom_metadata_service.new(req_obj) - expect { - @sut.delete - }.to raise_error(ArgumentError) - end - - it 'test_delete_custom_metadata' do - metadata_id = "619e667320b7ef03efc5d850" - allow(req_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload: payload}} - .and_return({code: 204, body: { success: true} }) - @sut = custom_metadata_service.new(req_obj) - @sut.delete(id: metadata_id) - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/customMetadataFields/#{metadata_id}") - expect(@ac[:method]).to eq('delete') - end - end -end diff --git a/test/imagekit/api_service/file_test.rb b/test/imagekit/api_service/file_test.rb deleted file mode 100644 index 8707faf3..00000000 --- a/test/imagekit/api_service/file_test.rb +++ /dev/null @@ -1,1196 +0,0 @@ -require_relative '../spec_helper' - -RSpec.describe ImageKitIo::ApiService::File do - let(:file_api_service) { described_class } - let(:config) { ImageKitIo.config } - let(:constants) { ImageKitIo.constants } - let!(:private_key) { config.private_key } - let!(:public_key) { config.public_key } - let!(:url_endpoint) { config.url_endpoint } - - describe 'FileUploadTest' do - it "test_upload_with_valid_expected_success_without_tags_and_remote_url" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - @ac={} - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200}) - - SUT = file_api_service.new(request_obj) - - upload = SUT.upload(file: "http://remotefiles.com/fake_file.jpg", file_name: "my_file_name") - expect(@ac[:payload].to_json).to eq("{\"multipart\":true,\"file\":\"http://remotefiles.com/fake_file.jpg\",\"fileName\":\"my_file_name\"}") - - expect(upload[:status_code]).to eq(200) - - end - - it "test_upload_with_valid_expected_success_without_tags_and_base64" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - @ac={} - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200}) - - SUT = file_api_service.new(request_obj) - base64="f06830ca9f1e3e90" - upload = SUT.upload(file: base64, file_name: "my_file_name") - expect(@ac[:payload].to_json).to eq("{\"multipart\":true,\"file\":\"#{base64}\",\"fileName\":\"my_file_name\"}") - expect(ImageKitIo::Utils::Calculation.is_valid_hex(base64)).to eq(true) - expect(upload[:status_code]).to eq(200) - - end - - it "test_upload_with_valid_expected_success_without_tags_and_file" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - @ac={} - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200}) - - SUT = file_api_service.new(request_obj) - file = open("test/imagekit/dummy_data/sample.jpg", "rb") - upload = SUT.upload(file: file, file_name: "my_file_name") - expect(@ac[:payload].keys).to eq([:multipart, :file, :fileName]) - expect(@ac[:payload][:file].io).to eq(file) - expect(@ac[:payload][:fileName]).to eq('my_file_name') - expect(upload[:status_code]).to eq(200) - - end - - it "test_upload_with_valid_expected_success_with_custom_coordinates" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - @ac={} - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200}) - - SUT = file_api_service.new(request_obj) - - upload = SUT.upload(file: "./fake_file.jpg", file_name: "my_file_name", custom_coordinates: "10, 10, 100, 100") - - expect(@ac[:payload].to_json).to eq("{\"multipart\":true,\"file\":\"./fake_file.jpg\",\"fileName\":\"my_file_name\",\"customCoordinates\":\"10, 10, 100, 100\"}") - - expect(upload[:status_code]).to eq(200) - - end - - it "test_upload_with_valid_expected_success_with_extensions" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - @ac={} - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200}) - SUT = file_api_service.new(request_obj) - upload = SUT.upload(file: "./fake_file.jpg", file_name: "my_file_name", extensions: [ - { - name: 'remove-bg', - options: { - add_shadow: true - } - } - ]) - expect(@ac[:payload]['extensions']).to eq("[{\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true}}]") - expect(upload[:status_code]).to eq(200) - end - - it "test_upload_with_valid_expected_success_with_customMetadata" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - @ac={} - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200}) - SUT = file_api_service.new(request_obj) - upload = SUT.upload( - file: "./fake_file.jpg", - file_name: "my_file_name", - custom_metadata: { - brand: 'Nike', - color: 'red' - } - ) - expect(@ac[:payload]['customMetadata']).to eq("{\"brand\":\"Nike\",\"color\":\"red\"}") - expect(upload[:status_code]).to eq(200) - end - - it "test_upload_with_valid_expected_success" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200}) - - SUT = file_api_service.new(request_obj) - - upload = SUT.upload(file: "./fake_file.jpg", file_name: "my_file_name", response_fields: %w[is_private_file tags], tags: %w[abc def], use_unique_file_name: false) - - expect(@ac[:payload].to_json).to eq("{\"multipart\":true,\"file\":\"./fake_file.jpg\",\"fileName\":\"my_file_name\",\"responseFields\":\"is_private_file,tags\",\"tags\":\"abc,def\",\"useUniqueFileName\":\"false\"}") - - expect(upload[:status_code]).to eq(200) - - end - - it "test_upload_fails_on_invalid_options" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 401, message: nil}) - - SUT = file_api_service.new(request_obj) - expect{ - SUT.upload(file: "fake_file.jpg", file_name: "fake_name", invalid_option: "invalid_option" ) - }.to raise_error(ArgumentError) - end - - it "test_upload_fails_on_unauthenticated_request" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 401, message: nil}) - - SUT = file_api_service.new(request_obj) - upload = SUT.upload(file: "fake_file.jpg", file_name: "fake_name") - expect(@ac[:payload][:file]).to eq("fake_file.jpg") - expect(@ac[:payload][:fileName]).to eq("fake_name") - expect(upload[:status_code]).to eq(401) - end - - it "test_upload_with_valid_expected_success_with_transformation" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - @ac={} - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200}) - - SUT = file_api_service.new(request_obj) - - upload = SUT.upload(file: "./fake_file.jpg", file_name: "my_file_name", transformation: { pre: 'l-text,i-Imagekit,fs-50,l-end', post: [{type: 'transformation', value: 'w-100'}]}) - - expect(@ac[:payload]['transformation']).to eq("{\"pre\":\"l-text,i-Imagekit,fs-50,l-end\",\"post\":[{\"type\":\"transformation\",\"value\":\"w-100\"}]}") - - expect(upload[:status_code]).to eq(200) - - end - - it "test_upload_with_checks" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - @ac={} - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200}) - - SUT = file_api_service.new(request_obj) - - upload = SUT.upload(file: "./fake_file.jpg", file_name: "my_file_name", checks: '"file.size" < "1mb"') - - expect(@ac[:payload]['checks']).to eq('"file.size" < "1mb"') - - expect(upload[:status_code]).to eq(200) - - end - - it "test_upload_with_is_published" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - @ac={} - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200}) - - SUT = file_api_service.new(request_obj) - - upload = SUT.upload(file: "./fake_file.jpg", file_name: "my_file_name", is_published: true ) - - expect(@ac[:payload]['isPublished']).to eq("true") - - expect(upload[:status_code]).to eq(200) - - end - - end - - describe 'FileListTest' do - it "test_list_files_fails_on_unauthenticated_request" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 401}) - - SUT = file_api_service.new(request_obj) - resp = SUT.list("skip": 0, "limit": 10) - - expect(@ac[:payload].to_json).to eq("{\"skip\":0,\"limit\":10}") - expect(resp[:status_code]).to eq(401) - end - - it "test_list_files_succeeds_with_basic_request" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200, body:[]}) - - SUT = file_api_service.new(request_obj) - resp = SUT.list("skip": 0, "limit": 10) - expect(@ac[:payload].to_json).to eq("{\"skip\":0,\"limit\":10}") - expect(resp[:status_code]).to eq(200) - end - end - - describe 'FileVersionDetailTest' do - let(:success_response) { - "{\"fileId\":\"my_file_id\",\"name\":\"cat1.jpg\",\"size\":102117,\"versionInfo\":{\"id\":\"my_file_id\",\"name\":\"Version 2\"},\"filePath\":\"/cat1.jpg\",\"url\":\"https://ik.imagekit.io/app_id/cat1.jpg\",\"fileType\":\"image\",\"height\":700,\"width\":1050,\"thumbnailUrl\":\"https://ik.imagekit.io/app_id/tr:n-ik_ml_thumbnail/cat1.jpg\",\"tags\":[\"abc\",\"def\"],\"AITags\":null,\"isPrivateFile\":true,\"customCoordinates\":null,\"metadata\":{\"height\":700,\"width\":1050,\"size\":70842,\"format\":\"jpg\",\"hasColorProfile\":false,\"quality\":0,\"density\":72,\"hasTransparency\":false,\"exif\":{},\"pHash\":\"90249d9b1fc74367\"}}" - } - it 'test_get_file_version_detail_succeeds_with_id' do - request_client = double - allow_any_instance_of(ImageKitIo::Request) - .to receive(:create_headers) - .and_return({}) - allow(RestClient::Request) - .to receive(:new) - .and_return(request_client) - allow(request_client) - .to receive(:execute) - .and_return(OpenStruct.new(code: 200, - body: success_response, - content_type: "application/json" - )) - - imagekit_request = ImageKitIo::Request.new(private_key, public_key, url_endpoint) - SUT = file_api_service.new(imagekit_request) - resp = SUT.get_file_version_detail(file_id: "my_file_id", version_id: 'my_file_id') - expect(resp).to_not have_key(:error) - expect(resp[:response]).to have_key('versionInfo') - expect(resp[:response]['versionInfo']['id']).to eq('my_file_id') - end - - it 'test_get_file_version_detail_failed_without_file_id' do - imagekit_request = ImageKitIo::Request.new(private_key, public_key, url_endpoint) - SUT = file_api_service.new(imagekit_request) - expect{SUT.get_file_version_detail(version_id: 'file_version_id')}.to raise_error(ArgumentError, 'file_id is required') - end - - it 'test_get_file_version_detail_failed_without_version_id' do - imagekit_request = ImageKitIo::Request.new(private_key, public_key, url_endpoint) - SUT = file_api_service.new(imagekit_request) - expect{SUT.get_file_version_detail(file_id: 'my_file_id')}.to raise_error(ArgumentError, 'version_id is required') - end - end - - describe 'FileVersionsTest' do - let(:success_response) { - "[{\"type\":\"file\",\"name\":\"cat1.jpg\",\"createdAt\":\"2022-06-02T11:50:44.402Z\",\"updatedAt\":\"2022-06-14T15:44:12.300Z\",\"fileId\":\"my_file_id\",\"tags\":[\"abc\",\"def\"],\"AITags\":null,\"versionInfo\":{\"id\":\"my_file_id\",\"name\":\"Version 2\"},\"embeddedMetadata\":{\"DateCreated\":\"2022-06-14T15:44:12.299Z\",\"DateTimeCreated\":\"2022-06-14T15:44:12.299Z\"},\"customCoordinates\":null,\"customMetadata\":{},\"isPrivateFile\":true,\"url\":\"https://ik.imagekit.io/app_id/cat1.jpg\",\"thumbnail\":\"https://ik.imagekit.io/app_id/tr:n-ik_ml_thumbnail/cat1.jpg\",\"fileType\":\"image\",\"filePath\":\"/cat1.jpg\",\"height\":700,\"width\":1050,\"size\":102117,\"hasAlpha\":false,\"mime\":\"image/jpeg\"},{\"type\":\"file-version\",\"name\":\"cat1.jpg\",\"createdAt\":\"2022-06-14T15:44:10.910Z\",\"updatedAt\":\"2022-06-14T15:44:11.372Z\",\"fileId\":\"my_file_id\",\"tags\":[\"abc\",\"def\"],\"AITags\":null,\"versionInfo\":{\"id\":\"my_file_second_version_id\",\"name\":\"Version 1\"},\"embeddedMetadata\":{\"DateCreated\":\"2022-06-02T11:50:45.537Z\",\"DateTimeCreated\":\"2022-06-02T11:50:45.540Z\"},\"customCoordinates\":null,\"customMetadata\":{},\"isPrivateFile\":true,\"url\":\"https://ik.imagekit.io/app_id/cat1.jpg?ik-obj-version=ik_version_id\",\"thumbnail\":\"https://ik.imagekit.io/app_id/tr:n-ik_ml_thumbnail/cat1.jpg?ik-obj-version=ik_version_id\",\"fileType\":\"image\",\"filePath\":\"/cat1.jpg\",\"height\":700,\"width\":1050,\"size\":102117,\"hasAlpha\":false,\"mime\":\"image/jpeg\"}]" - } - it 'test_get_file_versions_succeeds_with_id' do - request_client = double - allow_any_instance_of(ImageKitIo::Request) - .to receive(:create_headers) - .and_return({}) - allow(RestClient::Request) - .to receive(:new) - .and_return(request_client) - allow(request_client) - .to receive(:execute) - .and_return(OpenStruct.new(code: 200, - body: success_response, - content_type: "application/json" - )) - - imagekit_request = ImageKitIo::Request.new(private_key, public_key, url_endpoint) - SUT = file_api_service.new(imagekit_request) - resp = SUT.get_file_versions(file_id: "my_file_id") - expect(resp).to_not have_key(:error) - expect(resp[:response]).to be_an_instance_of(Array) - expect(resp[:response].length).to eq(2) - expect(resp[:response][0]['versionInfo']['id']).to eq('my_file_id') - expect(resp[:response][0]['versionInfo']['name']).to eq('Version 2') - expect(resp[:response][1]['versionInfo']['id']).to eq('my_file_second_version_id') - expect(resp[:response][1]['versionInfo']['name']).to eq('Version 1') - end - - it 'test_get_file_version_failed_without_file_id' do - imagekit_request = ImageKitIo::Request.new(private_key, public_key, url_endpoint) - SUT = file_api_service.new(imagekit_request) - expect{SUT.get_file_versions}.to raise_error(ArgumentError) - end - end - - describe 'RestoreFileVersionTest' do - let(:success_response) { - "{\"type\":\"file\",\"name\":\"cat1.jpg\",\"createdAt\":\"2022-06-02T11:50:44.402Z\",\"updatedAt\":\"2022-06-14T16:20:06.258Z\",\"fileId\":\"my_file_id\",\"tags\":[\"abc\",\"def\"],\"AITags\":null,\"versionInfo\":{\"id\":\"my_second_version\",\"name\":\"Version 2\"},\"embeddedMetadata\":{\"DateCreated\":\"2022-06-02T11:50:45.537Z\",\"DateTimeCreated\":\"2022-06-02T11:50:45.540Z\"},\"customCoordinates\":null,\"customMetadata\":{},\"isPrivateFile\":true,\"url\":\"https://ik.imagekit.io/app_id/cat1.jpg\",\"thumbnail\":\"https://ik.imagekit.io/app_id/tr:n-ik_ml_thumbnail/cat1.jpg\",\"fileType\":\"image\",\"filePath\":\"/cat1.jpg\",\"height\":700,\"width\":1050,\"size\":102117,\"hasAlpha\":false,\"mime\":\"image/jpeg\"}" - } - it 'test_restore_file_version_succeeds_with_id' do - request_client = double - allow_any_instance_of(ImageKitIo::Request) - .to receive(:create_headers) - .and_return({}) - allow(RestClient::Request) - .to receive(:new) - .and_return(request_client) - allow(request_client) - .to receive(:execute) - .and_return(OpenStruct.new(code: 200, - body: success_response, - content_type: "application/json" - )) - - imagekit_request = ImageKitIo::Request.new(private_key, public_key, url_endpoint) - SUT = file_api_service.new(imagekit_request) - resp = SUT.restore_file_version(file_id: "my_file_id", version_id: 'my_second_version') - expect(resp).to_not have_key(:error) - expect(resp[:response]['versionInfo']['id']).to eq('my_second_version') - expect(resp[:response]['versionInfo']['name']).to eq('Version 2') - end - - it 'test_restore_file_version_failed_without_file_id' do - imagekit_request = ImageKitIo::Request.new(private_key, public_key, url_endpoint) - SUT = file_api_service.new(imagekit_request) - expect{SUT.restore_file_version(version_id: 'my_file_version_id')}.to raise_error(ArgumentError, 'file_id is required') - end - - it 'test_restore_file_version_failed_without_version_id' do - imagekit_request = ImageKitIo::Request.new(private_key, public_key, url_endpoint) - SUT = file_api_service.new(imagekit_request) - expect{SUT.restore_file_version(file_id: 'my_file_id')}.to raise_error(ArgumentError, 'version_id is required') - end - end - - describe 'DeleteFileVersionTest' do - let(:success_response) { - "{\"success\":true}" - } - it 'test_restore_file_version_succeeds_with_id' do - request_client = double - allow_any_instance_of(ImageKitIo::Request) - .to receive(:create_headers) - .and_return({}) - allow(RestClient::Request) - .to receive(:new) - .and_return(request_client) - allow(request_client) - .to receive(:execute) - .and_return(OpenStruct.new(code: 200, - body: success_response, - content_type: "application/json" - )) - - imagekit_request = ImageKitIo::Request.new(private_key, public_key, url_endpoint) - SUT = file_api_service.new(imagekit_request) - resp = SUT.delete_file_version(file_id: "my_file_id", version_id: 'my_second_version') - expect(resp).to_not have_key(:error) - expect(resp[:response]['success']).to eq(true) - end - - it 'test_delete_file_version_without_file_id' do - imagekit_request = ImageKitIo::Request.new(private_key, public_key, url_endpoint) - SUT = file_api_service.new(imagekit_request) - expect{SUT.delete_file_version(version_id: 'my_file_version_id')}.to raise_error(ArgumentError, 'file_id is required') - end - - it 'test_delete_file_version_failed_without_version_id' do - imagekit_request = ImageKitIo::Request.new(private_key, public_key, url_endpoint) - SUT = file_api_service.new(imagekit_request) - expect{SUT.delete_file_version(file_id: 'my_file_id')}.to raise_error(ArgumentError, 'version_id is required') - end - end - - describe 'FileDetailTest' do - it "test_get_file_details_fails_on_unauthenticated_request" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 401, body:{message: "Unauthorized request!"}}) - - SUT = file_api_service.new(request_obj) - resp = SUT.details(file_identifier: "demo-file-id") - - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/files/demo-file-id/details/") - expect(resp[:status_code]).to eq(401) - expect(resp[:body][:message]).to eq("Unauthorized request!") - end - - it "test_file_details_succeeds_with_id" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200, body: {fileId: "demo-file-id"}}) - - SUT = file_api_service.new(request_obj) - resp = SUT.details(file_identifier: "demo-file-id") - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/files/demo-file-id/details/") - expect(resp[:status_code]).to eq(200) - end - end - - describe 'TestDeleteFile' do - it "test_file_delete_fails_on_unauthenticated_request" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 401, body: {fileId: "demo-file-id"}}) - - SUT = file_api_service.new(request_obj) - resp = SUT.delete(file_id: "demo-file-id") - - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/files/demo-file-id") - expect(@ac[:method]).to eq("delete") - expect(resp[:status_code]).to eq(401) - end - - it "test_file_delete_fails_on_item_not_found" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 204, body: {fileId: "demo-file-id"}}) - - SUT = file_api_service.new(request_obj) - resp = SUT.delete(file_id: "demo-file-id") - - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/files/demo-file-id") - expect(@ac[:method]).to eq("delete") - expect(resp[:status_code]).to eq(204) - end - - it "test_file_delete_succeeds" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200, body: {fileId: "demo-file-id"}}) - - SUT = file_api_service.new(request_obj) - resp = SUT.delete(file_id: "demo-file-id") - - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/files/demo-file-id") - expect(@ac[:method]).to eq("delete") - expect(resp[:status_code]).to eq(200) - - end - end - - describe 'TestPurgeCache' do - it "test_purge_cache_fails_on_unauthenticated_request" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 401, body: {}}) - - SUT = file_api_service.new(request_obj) - resp = SUT.purge_cache(file_url: "file_url") - - expect(@ac[:payload].to_json).to eq("{\"url\":\"file_url\"}") - expect(resp[:status_code]).to eq(401) - end - - it "test_purge_cache_succeeds" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200, body: {requestId:"requestId"}}) - - SUT = file_api_service.new(request_obj) - resp = SUT.purge_cache(file_url: "file_url") - - expect(@ac[:payload].to_json).to eq("{\"url\":\"file_url\"}") - expect(resp[:status_code]).to eq(200) - expect(resp[:body][:requestId]).to eq("requestId") - end - end - - describe 'TestPurgeCacheStatus' do - it "test_get_purge_cache_status_fails_on_unauthenticated_request" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 401, body: {}}) - - SUT = file_api_service.new(request_obj) - resp = SUT.purge_cache_status(request_id: "request-id") - - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/files/purge/request-id") - expect(resp[:status_code]).to eq(401) - - end - - it "test_purge_cache_status_succeeds" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200, body: {status: "Complete"}}) - - SUT = file_api_service.new(request_obj) - resp = SUT.purge_cache_status(request_id: "request-id") - - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/files/purge/request-id") - expect(resp[:status_code]).to eq(200) - expect(resp[:body][:status]).to eq("Complete") - end - end - - describe 'TestGetMetaData' do - it "test_get_metadata_fails_on_unauthenticated_request" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 401, body: {}}) - - SUT = file_api_service.new(request_obj) - resp = SUT.get_metadata(file_id: "file_id") - - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/files/file_id/metadata") - expect(resp[:status_code]).to eq(401) - - end - - it 'raises error when parameter not provided' do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200, body: {}}) - - SUT = file_api_service.new(request_obj) - expect { - SUT.get_metadata - }.to raise_error(ArgumentError) - end - - it "test_get_metadata_succeeds" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200, body: {}}) - - SUT = file_api_service.new(request_obj) - resp = SUT.get_metadata(file_id: "file_id") - - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/files/file_id/metadata") - expect(resp[:status_code]).to eq(200) - end - end - - describe 'TestUpdateFileDetails' do - it "test_details_fails_on_unauthenticated_request" do - - options = {"tags": %w[tag1 tag2], "custom_coordinates": "10,10,100,100"} - - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 401, body: {}}) - - SUT = file_api_service.new(request_obj) - resp = SUT.update_details(file_id: "file_id", **options) - expect(@ac[:payload]).to eq("{\"tags\":[\"tag1\",\"tag2\"],\"customCoordinates\":\"10,10,100,100\"}") - expect(resp[:status_code]).to eq(401) - - end - - it "test_update_file_details_succeeds_with_id" do - options = {tags: %w[tag1 tag2], "custom_coordinates": "10,10,100,100"} - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200, body: options}) - - SUT = file_api_service.new(request_obj) - resp = SUT.update_details(file_id: "file_id", **options) - - expect(JSON.parse(@ac[:payload])['tags']).to eq(options[:tags]) - expect(JSON.parse(@ac[:payload])['customCoordinates']).to eq(options[:custom_coordinates]) - expect(resp[:status_code]).to eq(200) - expect(resp[:body]).to eq(options) - end - - it "test_update_file_publication_status" do - options = { publish: { isPublished: true, includeFileVersions: true }} - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200, body: options}) - - SUT = file_api_service.new(request_obj) - resp = SUT.update_details(file_id: "file_id", **options) - - expect(JSON.parse(@ac[:payload])['publish']['isPublished']).to eq(options[:publish][:isPublished]) - expect(JSON.parse(@ac[:payload])['publish']['isPublished']).to eq(options[:publish][:includeFileVersions]) - expect(resp[:status_code]).to eq(200) - expect(resp[:body]).to eq(options) - end - - it "test_update_file_details_fails_missing_arguments" do - options = { tags: 'custom tag' } - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200, body: options}) - - SUT = file_api_service.new(request_obj) - expect { - SUT.update_details(file_id: "file_id", **options) - }.to raise_error(ArgumentError) - end - - it "test_update_file_details_fails_tags_not_an_array" do - options = {tags: "RANDOM_TEXT", "custom_coordinates": "10,10,100,100"} - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200, body: options}) - - SUT = file_api_service.new(request_obj) - expect { - SUT.update_details(file_id: "file_id", **options) - }.to raise_error(ArgumentError) - end - - it "test_update_file_details_fails_custom_coordinates_not_a_string" do - options = {"custom_coordinates": %w[random]} - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200, body: options}) - - SUT = file_api_service.new(request_obj) - expect { - SUT.update_details(file_id: "file_id", **options) - }.to raise_error(ArgumentError) - end - - it "test_update_file_details_expected_success_with_extensions" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - @ac={} - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200}) - SUT = file_api_service.new(request_obj) - upload = SUT.update_details(file_id: "file_id_xyz", extensions: [ - { - 'name': 'google-auto-tagging', - 'maxTags': 5, - 'minConfidence': 95 - } - ]) - expect(@ac[:payload]).to eq("{\"extensions\":[{\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}]}") - expect(upload[:status_code]).to eq(200) - end - - it "test_update_with_valid_expected_success_with_customMetadata" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - @ac={} - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200}) - SUT = file_api_service.new(request_obj) - upload = SUT.update_details( - file_id: "file_id_xyz", - custom_metadata: { - brand: 'Nike', - color: 'red' - } - ) - expect(@ac[:payload]).to eq("{\"customMetadata\":{\"brand\":\"Nike\",\"color\":\"red\"}}") - expect(upload[:status_code]).to eq(200) - end - end - - describe 'TestGetRemoteFileURLMetaData' do - it "test_get_metadata_from_remote_url_fails_on_unauthenticated_request" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 401, body: {}}) - - SUT = file_api_service.new(request_obj) - resp = SUT.get_metadata_from_remote_url(remote_file_url: "http://example.com/fakefileurl") - - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/metadata?url=http://example.com/fakefileurl") - expect(resp[:status_code]).to eq(401) - end - - it "test_get_metadata_from_remote_url_fails_on_blank_url" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 401, body: {}}) - - SUT = file_api_service.new(request_obj) - expect { - SUT.get_metadata_from_remote_url(remote_file_url: "") - }.to raise_error(ArgumentError) - end - - it "test_get_metadata_from_remote_url_succeeds" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200, body: {}}) - - SUT = file_api_service.new(request_obj) - resp = SUT.get_metadata_from_remote_url(remote_file_url: "http://example.com/fakefileurl") - - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/metadata?url=http://example.com/fakefileurl") - expect(resp[:status_code]).to eq(200) - end - end - - context 'copy' do - let!(:req_obj) { double } - before do - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(req_obj) - allow(req_obj) - .to receive(:create_headers) - .and_return({}) - allow(req_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload: payload}} - .and_return({status_code: 200, body: { success: true }}) - @sut = file_api_service.new(req_obj) - end - - it 'raises error when parameter not provided' do - expect { - @sut.copy(source_file_path: '', destination_path: nil) - }.to raise_error(ArgumentError) - - end - - it 'test_copy' do - source_file = 'test/dummy.png' - destination_path = '/my_image' - resp = @sut.copy(source_file_path: source_file, destination_path: destination_path) - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/files/copy") - expect(@ac[:payload]).to eq("{\"sourceFilePath\":\"test/dummy.png\",\"destinationPath\":\"/my_image\",\"includeFileVersions\":false}") - expect(resp[:status_code]).to eq(200) - resp = @sut.copy(source_file_path: source_file, destination_path: destination_path, include_file_versions: true) - expect(@ac[:payload]).to eq("{\"sourceFilePath\":\"test/dummy.png\",\"destinationPath\":\"/my_image\",\"includeFileVersions\":true}") - expect(resp[:status_code]).to eq(200) - end - end - - context 'move' do - let!(:req_obj) { double } - before do - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(req_obj) - allow(req_obj) - .to receive(:create_headers) - .and_return({}) - allow(req_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload: payload}} - .and_return({status_code: 200, body: { success: true }}) - @sut = file_api_service.new(req_obj) - end - - it 'raises error when parameter not provided' do - expect { - @sut.move(source_file_path: '', destination_path: nil) - }.to raise_error(ArgumentError) - - end - - it 'test_move' do - source_file = 'test/dummy.png' - destination_path = '/my_image' - resp = @sut.move(source_file_path: source_file, destination_path: destination_path) - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/files/move") - expect(@ac[:payload]).to eq({:sourceFilePath=>"test/dummy.png", :destinationPath=>"/my_image"}) - expect(resp[:status_code]).to eq(200) - end - end - - context 'rename' do - let!(:req_obj) { double } - before do - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(req_obj) - allow(req_obj) - .to receive(:create_headers) - .and_return({}) - allow(req_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload: payload}} - .and_return({status_code: 200, body: { success: true }}) - @sut = file_api_service.new(req_obj) - end - - it 'raises error when parameter not provided' do - expect { - @sut.rename(file_path: '', new_file_name: nil) - }.to raise_error(ArgumentError) - - end - - it 'test_rename' do - source_file = 'test/dummy.png' - new_name = 'my_image.png' - resp = @sut.rename(file_path: source_file, new_file_name: new_name) - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/files/rename") - expect(@ac[:payload]).to eq("{\"filePath\":\"test/dummy.png\",\"newFileName\":\"my_image.png\"}") - expect(@ac[:method]).to eq('put') - expect(resp[:status_code]).to eq(200) - end - - it 'test_rename with the option purge_cache' do - source_file = 'test/dummy.png' - new_name = 'my_image.png' - resp = @sut.rename(file_path: source_file, new_file_name: new_name, purge_cache: true) - expect(@ac[:payload]).to eq("{\"filePath\":\"test/dummy.png\",\"newFileName\":\"my_image.png\",\"purgeCache\":true}") - end - end - - context 'stream file' do - let!(:req_obj) { double } - - before do - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(req_obj) - allow(req_obj) - .to receive(:create_headers) - .and_return({}) - allow(req_obj) - .to receive(:request_stream){|method,url,headers, &block| @ac={method: method, url: url, headers: headers, block: block}} - .and_return({status_code: 200, body: { success: true }}) - @sut = file_api_service.new(req_obj) - end - - it 'raises error when parameter not provided' do - expect { - @sut.stream_file - }.to raise_error(ArgumentError) - end - - it 'test_stream_file' do - remote_file_url = 'https://ik.imagekit.io/kcdfvxhgfkn/testing_Hx_I_Ys_c.jpg' - block = proc { - puts 'block given' - } - @sut.stream_file(remote_file_url: remote_file_url, &block) - - expect(@ac[:block].is_a?(Proc)).to be(true) - expect(@ac[:url]).to eq(remote_file_url) - end - end -end diff --git a/test/imagekit/api_service/folder_test.rb b/test/imagekit/api_service/folder_test.rb deleted file mode 100644 index ba42c4d2..00000000 --- a/test/imagekit/api_service/folder_test.rb +++ /dev/null @@ -1,127 +0,0 @@ -require_relative '../spec_helper' - -RSpec.describe ImageKitIo::ApiService::Folder do - let(:folder_api_service) { described_class } - let(:config) { ImageKitIo.config } - let(:constants) { ImageKitIo.constants } - let!(:private_key) { config.private_key } - let!(:public_key) { config.public_key } - let!(:url_endpoint) { config.url_endpoint } - - context 'folder' do - let!(:req_obj) { double } - before do - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(req_obj) - allow(req_obj) - .to receive(:create_headers) - .and_return({}) - end - - context 'create' do - it 'raises error when parameter not provided' do - @sut = folder_api_service.new(req_obj) - expect { - @sut.create('', nil) - }.to raise_error(ArgumentError) - end - - it 'test_create_folder' do - allow(req_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload: payload}} - .and_return({status_code: 201, body: { success: true }}) - @sut = folder_api_service.new(req_obj) - folder_name = 'test_folder' - parent_folder = '' - resp = @sut.create(folder_name: folder_name, parent_folder_path: parent_folder) - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/folder") - expect(@ac[:payload]).to eq("{\"folderName\":\"test_folder\",\"parentFolderPath\":\"\"}") - expect(@ac[:method]).to eq('post') - expect(resp[:status_code]).to eq(201) - end - end - - context 'delete' do - it 'raises error when parameter not provided' do - @sut = folder_api_service.new(req_obj) - expect { - @sut.delete - }.to raise_error(ArgumentError) - end - - it 'test_delete_folder' do - allow(req_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload: payload}} - .and_return({status_code: 204, body: { success: true }}) - @sut = folder_api_service.new(req_obj) - folder_path = 'test_folder' - resp = @sut.delete(folder_path: folder_path) - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/folder") - expect(@ac[:method]).to eq('delete') - expect(resp[:body][:success]).to be(true) - end - end - - context 'copy' do - it 'raises error when parameter not provided' do - @sut = folder_api_service.new(req_obj) - expect { - @sut.copy - }.to raise_error(ArgumentError) - end - - it 'test_copy_folder' do - allow(req_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload: payload}} - .and_return({status_code: 200, body: { jobId: '123456' }}) - @sut = folder_api_service.new(req_obj) - source_folder = 'my_folder' - destination_path = 'copied' - resp = @sut.copy(source_folder_path: source_folder, destination_path: destination_path) - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/bulkJobs/copyFolder") - expect(@ac[:method]).to eq('post') - expect(@ac[:payload]).to eq("{\"sourceFolderPath\":\"my_folder\",\"destinationPath\":\"copied\",\"includeFileVersions\":false}") - expect(resp[:body][:jobId]).to eq('123456') - end - - it 'test_copy_folder_with_include_versions_parameter' do - allow(req_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload: payload}} - .and_return({status_code: 200, body: { jobId: '123456' }}) - @sut = folder_api_service.new(req_obj) - source_folder = 'my_folder' - destination_path = 'copied' - resp = @sut.copy(source_folder_path: source_folder, destination_path: destination_path, include_file_versions: true) - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/bulkJobs/copyFolder") - expect(@ac[:method]).to eq('post') - expect(@ac[:payload]).to eq("{\"sourceFolderPath\":\"my_folder\",\"destinationPath\":\"copied\",\"includeFileVersions\":true}") - expect(resp[:body][:jobId]).to eq('123456') - end - end - - context 'move' do - it 'raises error when parameter not provided' do - @sut = folder_api_service.new(req_obj) - expect { - @sut.copy - }.to raise_error(ArgumentError) - end - - it 'test_move_folder' do - allow(req_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload: payload}} - .and_return({status_code: 200, body: { jobId: '123456' }}) - @sut = folder_api_service.new(req_obj) - source_folder = 'my_folder/inside_folder' - destination_path = 'moved/inside_another_folder' - resp = @sut.move(source_folder_path: source_folder, destination_path: destination_path) - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/bulkJobs/moveFolder") - expect(@ac[:method]).to eq('post') - expect(@ac[:payload]).to eq({:sourceFolderPath=>"my_folder/inside_folder", :destinationPath=>"moved/inside_another_folder"}) - expect(resp[:body][:jobId]).to eq('123456') - end - end - end -end diff --git a/test/imagekit/client_test.rb b/test/imagekit/client_test.rb index 33c13832..5280fad1 100644 --- a/test/imagekit/client_test.rb +++ b/test/imagekit/client_test.rb @@ -1,409 +1,405 @@ -require_relative './spec_helper' -require 'rspec/autorun' - -RSpec.describe ImageKitIo::Client do - let(:subject) { described_class } - let!(:public_key) { 'public_xyz' } - let!(:private_key) { 'private_xyz' } - let!(:url_endpoint) { 'https://imagekit.io/your-imgekit-id' } - let(:constants) { ImageKitIo.constants } - - it "test_initialization_with_private_key_missing" do - request_obj = double - expect { - subject.new(" ", public_key, url_endpoint) - }.to raise_error(ArgumentError, constants.MISSING_PRIVATE_KEY) - end +# frozen_string_literal: true - it "test_initialization_with_non_string_private_key" do - request_obj = double - expect { - subject.new({ RANDOM: "RANDOM"}, public_key, url_endpoint) - }.to raise_error(ArgumentError, constants.MISSING_PRIVATE_KEY) - end +require_relative "test_helper" - it "test_initialization_with_public_key_missing" do - request_obj = double - expect { - subject.new(private_key, " ", url_endpoint) - }.to raise_error(ArgumentError, constants.MISSING_PUBLIC_KEY) - end +class ImagekitTest < Minitest::Test + extend Minitest::Serial + include WebMock::API - it "test_initialization_with_non_string_public_key" do - request_obj = double - expect { - subject.new(private_key, { RANDOM: "RANDOM"}, url_endpoint) - }.to raise_error(ArgumentError, constants.MISSING_PUBLIC_KEY) + def before_all + super + WebMock.enable! end - it "test_initialization_with_url_endpoint_missing" do - request_obj = double - expect { - subject.new(private_key, public_key, " ") - }.to raise_error(ArgumentError, constants.MISSING_URL_ENDPOINT) + def setup + super + Thread.current.thread_variable_set(:mock_sleep, []) end - it "test_initialization_with_non_string_url_endpoint" do - request_obj = double - expect { - subject.new(private_key, public_key, { RANDOM: "RANDOM"}) - }.to raise_error(ArgumentError, constants.MISSING_URL_ENDPOINT) + def teardown + Thread.current.thread_variable_set(:mock_sleep, nil) + WebMock.reset! + super end - context 'FileUploadTest' do - it "test_upload_with_valid_expected_success" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request) - .and_return({code: 200}) - - SUT = ImageKitIo::Client.new(private_key, public_key, url_endpoint) - SUT.set_ik_request(request_obj) - - upload = SUT.upload_file(file: "fakefile.jpg", file_name: "fake", content_type: 'image/jpeg') + def after_all + WebMock.disable! + super + end - expect(upload[:code]).to eq(200) + def test_raises_on_missing_non_nullable_opts + e = assert_raises(ArgumentError) do + Imagekit::Client.new end + assert_match(/is required/, e.message) + end + def test_client_default_request_default_retry_attempts + stub_request(:post, "http://localhost/api/v1/files/upload").to_return_json(status: 500, body: {}) - it "test_list_files_with_valid_expected_success" do - # test list_files method - - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request) - .and_return({code: 200}) - - SUT = ImageKitIo::Client.new(private_key, public_key, url_endpoint) - SUT.set_ik_request(request_obj) - - file_list = SUT.list_files + image_kit = + Imagekit::Client.new( + base_url: "http://localhost", + private_key: "My Private Key", + password: "My Password" + ) - expect(file_list[:code]).to eq(200) + assert_raises(Imagekit::Errors::InternalServerError) do + image_kit.files.upload(file: Pathname(__FILE__), file_name: "fileName") end - it "test_file_versions_with_valid_expected_success" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) + assert_requested(:any, /./, times: 3) + end - allow(request_obj) - .to receive(:request) - .and_return({code: 200}) + def test_client_given_request_default_retry_attempts + stub_request(:post, "http://localhost/api/v1/files/upload").to_return_json(status: 500, body: {}) - SUT = ImageKitIo::Client.new(private_key, public_key, url_endpoint) - resp = SUT.file_versions(file_id: 'my_new_file_id') + image_kit = + Imagekit::Client.new( + base_url: "http://localhost", + private_key: "My Private Key", + password: "My Password", + max_retries: 3 + ) - expect(resp[:code]).to eq(200) + assert_raises(Imagekit::Errors::InternalServerError) do + image_kit.files.upload(file: Pathname(__FILE__), file_name: "fileName") end - it "test_file_version_detail_with_valid_expected_success" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request) - .and_return({code: 200}) - - SUT = ImageKitIo::Client.new(private_key, public_key, url_endpoint) - resp = SUT.file_version_detail(file_id: 'my_new_file_id', version_id: 'my_file_version_id') + assert_requested(:any, /./, times: 4) + end - expect(resp[:code]).to eq(200) + def test_client_default_request_given_retry_attempts + stub_request(:post, "http://localhost/api/v1/files/upload").to_return_json(status: 500, body: {}) + + image_kit = + Imagekit::Client.new( + base_url: "http://localhost", + private_key: "My Private Key", + password: "My Password" + ) + + assert_raises(Imagekit::Errors::InternalServerError) do + image_kit.files.upload( + file: Pathname(__FILE__), + file_name: "fileName", + request_options: {max_retries: 3} + ) end - it "test_delete_file_version_with_valid_expected_success" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request) - .and_return({code: 200}) - - SUT = ImageKitIo::Client.new(private_key, public_key, url_endpoint) - resp = SUT.delete_file_version(file_id: 'my_new_file_id', version_id: 'my_file_version_id') + assert_requested(:any, /./, times: 4) + end - expect(resp[:code]).to eq(200) + def test_client_given_request_given_retry_attempts + stub_request(:post, "http://localhost/api/v1/files/upload").to_return_json(status: 500, body: {}) + + image_kit = + Imagekit::Client.new( + base_url: "http://localhost", + private_key: "My Private Key", + password: "My Password", + max_retries: 3 + ) + + assert_raises(Imagekit::Errors::InternalServerError) do + image_kit.files.upload( + file: Pathname(__FILE__), + file_name: "fileName", + request_options: {max_retries: 4} + ) end - it "test_restore_file_version_with_valid_expected_success" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request) - .and_return({code: 200}) - - SUT = ImageKitIo::Client.new(private_key, public_key, url_endpoint) - resp = SUT.restore_file_version(file_id: 'my_new_file_id', version_id: 'my_file_version_id') + assert_requested(:any, /./, times: 5) + end - expect(resp[:code]).to eq(200) + def test_client_retry_after_seconds + stub_request(:post, "http://localhost/api/v1/files/upload").to_return_json( + status: 500, + headers: {"retry-after" => "1.3"}, + body: {} + ) + + image_kit = + Imagekit::Client.new( + base_url: "http://localhost", + private_key: "My Private Key", + password: "My Password", + max_retries: 1 + ) + + assert_raises(Imagekit::Errors::InternalServerError) do + image_kit.files.upload(file: Pathname(__FILE__), file_name: "fileName") end - it "test_get_file_details_with_valid_expected_success" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request) - .and_return({code: 200}) - - SUT = ImageKitIo::Client.new(private_key, public_key, url_endpoint) - SUT.set_ik_request(request_obj) - - file_detail = SUT.get_file_details(file_id: "http://example.com/fake.jpg") + assert_requested(:any, /./, times: 2) + assert_equal(1.3, Thread.current.thread_variable_get(:mock_sleep).last) + end - expect(file_detail[:code]).to eq(200) + def test_client_retry_after_date + stub_request(:post, "http://localhost/api/v1/files/upload").to_return_json( + status: 500, + headers: {"retry-after" => (Time.now + 10).httpdate}, + body: {} + ) + + image_kit = + Imagekit::Client.new( + base_url: "http://localhost", + private_key: "My Private Key", + password: "My Password", + max_retries: 1 + ) + + assert_raises(Imagekit::Errors::InternalServerError) do + Thread.current.thread_variable_set(:time_now, Time.now) + image_kit.files.upload(file: Pathname(__FILE__), file_name: "fileName") + Thread.current.thread_variable_set(:time_now, nil) end - it "test_update_file_details_with_valid_expected_success" do - - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request) - .and_return({code: 200}) - - SUT = ImageKitIo::Client.new(private_key, public_key, url_endpoint) - SUT.set_ik_request(request_obj) - - upload = SUT.update_file_details(file_id: "fake_id", tags: ["image_tag"], - custom_coordinates: "10,10,100, 100") + assert_requested(:any, /./, times: 2) + assert_in_delta(10, Thread.current.thread_variable_get(:mock_sleep).last, 1.0) + end - expect(upload[:code]).to eq(200) + def test_client_retry_after_ms + stub_request(:post, "http://localhost/api/v1/files/upload").to_return_json( + status: 500, + headers: {"retry-after-ms" => "1300"}, + body: {} + ) + + image_kit = + Imagekit::Client.new( + base_url: "http://localhost", + private_key: "My Private Key", + password: "My Password", + max_retries: 1 + ) + + assert_raises(Imagekit::Errors::InternalServerError) do + image_kit.files.upload(file: Pathname(__FILE__), file_name: "fileName") end - it "test_delete_file_with_valid_expected_success" do - # test for delete_file - - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request) - .and_return({code: 200}) + assert_requested(:any, /./, times: 2) + assert_equal(1.3, Thread.current.thread_variable_get(:mock_sleep).last) + end - SUT = ImageKitIo::Client.new(private_key, public_key, url_endpoint) - SUT.set_ik_request(request_obj) + def test_retry_count_header + stub_request(:post, "http://localhost/api/v1/files/upload").to_return_json(status: 500, body: {}) - delete_resp = SUT.delete_file(file_id: "fake_id") + image_kit = + Imagekit::Client.new( + base_url: "http://localhost", + private_key: "My Private Key", + password: "My Password" + ) - expect(delete_resp[:code]).to eq(200) + assert_raises(Imagekit::Errors::InternalServerError) do + image_kit.files.upload(file: Pathname(__FILE__), file_name: "fileName") end - it "test_get_file_metadata_valid_expected_success" do - # test for get_file_metadata - - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request) - .and_return({code: 200}) - - SUT = ImageKitIo::Client.new(private_key, public_key, url_endpoint) - SUT.set_ik_request(request_obj) - - resp = SUT.get_file_metadata(file_id: "fake_id") - - expect(resp[:code]).to eq(200) + 3.times do + assert_requested(:any, /./, headers: {"x-stainless-retry-count" => _1}) end + end - it "test_get_metadata_from_remote_url_succeeds" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({code: 200, body: {}}) - - SUT = ImageKitIo::Client.new(private_key, public_key, url_endpoint) - SUT.set_ik_request(request_obj) - - resp = SUT.get_remote_file_url_metadata(remote_file_url: "http://example.com/fakefileurl") - - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/metadata?url=http://example.com/fakefileurl") - expect(resp[:code]).to eq(200) + def test_omit_retry_count_header + stub_request(:post, "http://localhost/api/v1/files/upload").to_return_json(status: 500, body: {}) + + image_kit = + Imagekit::Client.new( + base_url: "http://localhost", + private_key: "My Private Key", + password: "My Password" + ) + + assert_raises(Imagekit::Errors::InternalServerError) do + image_kit.files.upload( + file: Pathname(__FILE__), + file_name: "fileName", + request_options: {extra_headers: {"x-stainless-retry-count" => nil}} + ) end - it "test_purge_file_cache_valid_expected_success" do - # test for get_purge_file_cache - - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request) - .and_return({code: 200}) - - SUT = ImageKitIo::Client.new(private_key, public_key, url_endpoint) - SUT.set_ik_request(request_obj) - - resp = SUT.purge_file_cache(file_url: "http://example.com/fake.jpg") - - expect(resp[:code]).to eq(200) + assert_requested(:any, /./, times: 3) do + refute_includes(_1.headers.keys.map(&:downcase), "x-stainless-retry-count") end + end - it "test_purge_file_cache_status_valid_expected_success" do - # test for get_purge_file_cache - - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request) - .and_return({code: 200}) - - SUT = ImageKitIo::Client.new(private_key, public_key, url_endpoint) - SUT.set_ik_request(request_obj) + def test_overwrite_retry_count_header + stub_request(:post, "http://localhost/api/v1/files/upload").to_return_json(status: 500, body: {}) + + image_kit = + Imagekit::Client.new( + base_url: "http://localhost", + private_key: "My Private Key", + password: "My Password" + ) + + assert_raises(Imagekit::Errors::InternalServerError) do + image_kit.files.upload( + file: Pathname(__FILE__), + file_name: "fileName", + request_options: {extra_headers: {"x-stainless-retry-count" => "42"}} + ) + end - resp = SUT.purge_file_cache_status(request_id: "fake_id") + assert_requested(:any, /./, headers: {"x-stainless-retry-count" => "42"}, times: 3) + end - expect(resp[:code]).to eq(200) + def test_client_redirect_307 + stub_request(:post, "http://localhost/api/v1/files/upload").to_return_json( + status: 307, + headers: {"location" => "/redirected"}, + body: {} + ) + stub_request(:any, "http://localhost/redirected").to_return( + status: 307, + headers: {"location" => "/redirected"} + ) + + image_kit = + Imagekit::Client.new( + base_url: "http://localhost", + private_key: "My Private Key", + password: "My Password" + ) + + assert_raises(Imagekit::Errors::APIConnectionError) do + image_kit.files.upload( + file: Pathname(__FILE__), + file_name: "fileName", + request_options: {extra_headers: {}} + ) end - it "test_phash_distance_fails_if_not_hexa" do - # test for get_purge_file_cache + recorded, = WebMock::RequestRegistry.instance.requested_signatures.hash.first - request_obj = double - - SUT = ImageKitIo::Client.new(private_key, public_key, url_endpoint) - SUT.set_ik_request(request_obj) + assert_requested(:any, "http://localhost/redirected", times: Imagekit::Client::MAX_REDIRECTS) do + assert_equal(recorded.method, _1.method) + assert_equal(recorded.body, _1.body) + assert_equal( + recorded.headers.transform_keys(&:downcase).fetch("content-type"), + _1.headers.transform_keys(&:downcase).fetch("content-type") + ) + end + end - expect { - SUT.phash_distance("f06830ca9f1e3e90", "RANDOM") - }.to raise_error(ArgumentError) + def test_client_redirect_303 + stub_request(:post, "http://localhost/api/v1/files/upload").to_return_json( + status: 303, + headers: {"location" => "/redirected"}, + body: {} + ) + stub_request(:get, "http://localhost/redirected").to_return( + status: 303, + headers: {"location" => "/redirected"} + ) + + image_kit = + Imagekit::Client.new( + base_url: "http://localhost", + private_key: "My Private Key", + password: "My Password" + ) + + assert_raises(Imagekit::Errors::APIConnectionError) do + image_kit.files.upload( + file: Pathname(__FILE__), + file_name: "fileName", + request_options: {extra_headers: {}} + ) end - it "test_phash_distance_fails_if_argument_missing" do + assert_requested(:get, "http://localhost/redirected", times: Imagekit::Client::MAX_REDIRECTS) do + headers = _1.headers.keys.map(&:downcase) + refute_includes(headers, "content-type") + assert_nil(_1.body) + end + end - request_obj = double + def test_client_redirect_auth_keep_same_origin + stub_request(:post, "http://localhost/api/v1/files/upload").to_return_json( + status: 307, + headers: {"location" => "/redirected"}, + body: {} + ) + stub_request(:any, "http://localhost/redirected").to_return( + status: 307, + headers: {"location" => "/redirected"} + ) + + image_kit = + Imagekit::Client.new( + base_url: "http://localhost", + private_key: "My Private Key", + password: "My Password" + ) + + assert_raises(Imagekit::Errors::APIConnectionError) do + image_kit.files.upload( + file: Pathname(__FILE__), + file_name: "fileName", + request_options: {extra_headers: {"authorization" => "Bearer xyz"}} + ) + end - SUT = ImageKitIo::Client.new(private_key, public_key, url_endpoint) - SUT.set_ik_request(request_obj) + recorded, = WebMock::RequestRegistry.instance.requested_signatures.hash.first + auth_header = recorded.headers.transform_keys(&:downcase).fetch("authorization") - expect { - SUT.phash_distance("f06830ca9f1e3e90", " ") - }.to raise_error(ArgumentError) + assert_equal("Bearer xyz", auth_header) + assert_requested(:any, "http://localhost/redirected", times: Imagekit::Client::MAX_REDIRECTS) do + auth_header = _1.headers.transform_keys(&:downcase).fetch("authorization") + assert_equal("Bearer xyz", auth_header) end + end - it "test_generate_url_with_path" do - # request_obj=ImageKitIo::Request.new(@private_key,@public_key,@url_endpoint) - # url_obj = Url.new(request_obj) + def test_client_redirect_auth_strip_cross_origin + stub_request(:post, "http://localhost/api/v1/files/upload").to_return_json( + status: 307, + headers: {"location" => "https://example.com/redirected"}, + body: {} + ) + stub_request(:any, "https://example.com/redirected").to_return( + status: 307, + headers: {"location" => "https://example.com/redirected"} + ) + + image_kit = + Imagekit::Client.new( + base_url: "http://localhost", + private_key: "My Private Key", + password: "My Password" + ) + + assert_raises(Imagekit::Errors::APIConnectionError) do + image_kit.files.upload( + file: Pathname(__FILE__), + file_name: "fileName", + request_options: {extra_headers: {"authorization" => "Bearer xyz"}} + ) + end - SUT = ImageKitIo::Client.new(private_key, public_key, url_endpoint) + assert_requested(:any, "https://example.com/redirected", times: Imagekit::Client::MAX_REDIRECTS) do + headers = _1.headers.keys.map(&:downcase) + refute_includes(headers, "authorization") + end + end - options = {path: "/default-image.jpg", - url_endpoint: url_endpoint, - transformation: [{height: 300, width: 400}], - } - url = SUT.url(options) + def test_default_headers + stub_request(:post, "http://localhost/api/v1/files/upload").to_return_json(status: 200, body: {}) - expect(url).to eq("https://imagekit.io/your-imgekit-id/tr:h-300,w-400/default-image.jpg") - end + image_kit = + Imagekit::Client.new( + base_url: "http://localhost", + private_key: "My Private Key", + password: "My Password" + ) - it "get_authentication_params_test_with_hard_coded_params" do - SUT = ImageKitIo::Client.new('private_key_test', public_key, url_endpoint) - # SUT.set_ik_request(request_obj) + image_kit.files.upload(file: Pathname(__FILE__), file_name: "fileName") - result=SUT.get_authentication_parameters('your_token',1582269249) - expect('your_token').to eq(result[:token]) - expect(nil).not_to eq(result[:expire]) - expect('e71bcd6031016b060d349d212e23e85c791decdd').to eq(result[:signature]) + assert_requested(:any, /./) do |req| + headers = req.headers.transform_keys(&:downcase).fetch_values("accept", "content-type") + headers.each { refute_empty(_1) } end end end diff --git a/test/imagekit/configuration_test.rb b/test/imagekit/configuration_test.rb deleted file mode 100644 index 74db598b..00000000 --- a/test/imagekit/configuration_test.rb +++ /dev/null @@ -1,64 +0,0 @@ -require_relative './spec_helper' -require 'rspec/autorun' - -RSpec.describe ImageKitIo::Configurable do - let(:configurable_obj) { Class.new.send :include, ImageKitIo::Configurable} - - describe 'Configuration' do - it 'configure with the keys' do - configurable_obj.configure do |config| - config.public_key = 'public_key_123' - end - expect(configurable_obj.config.public_key).to eq('public_key_123') - # test the default service - expect(configurable_obj.config.service).to eq(:carrierwave) - end - - it 'configure without keys' do - expect(configurable_obj.config.service).to eq(:carrierwave) - expect(configurable_obj.config.private_key).to eq(nil) - end - - context 'constants' do - let(:constants) { configurable_obj.constants} - - it 'returns constant class' do - expect(constants).to eq(ImageKitIo::Constant) - end - - it "returns default key's value" do - expect(constants.BASE_URL).to eq("https://api.imagekit.io/v1/files") - end - - it "supports customization" do - constants.TIMESTAMP = '88888' - expect(constants.TIMESTAMP).to eq('88888') - configurable_obj.configure do |config| - config.constants.TIMESTAMP = '5555' - end - expect(configurable_obj.constants.TIMESTAMP).to eq('5555') - end - end - - context 'services' do - it 'configures carrierwave by default' do - expect(configurable_obj.config.service).to eq(:carrierwave) - expect(configurable_obj).to receive(:require_relative).with('../carrierwave/carrierwave') - expect(configurable_obj).to_not receive(:require_relative).with('../active_storage/active_storage') - configurable_obj.configure do |config| - config.private_key = 'private_key_123' - end - end - - it 'supports active_storage configuration' do - expect(configurable_obj).to_not receive(:require_relative).with('../carrierwave/carrierwave') - expect(configurable_obj).to receive(:require_relative).with('../active_storage/active_storage') - configurable_obj.configure do |config| - config.private_key = 'private_key_123' - config.service = :active_storage - end - expect(configurable_obj.config.service).to eq(:active_storage) - end - end - end -end diff --git a/test/imagekit/constant_test.rb b/test/imagekit/constant_test.rb deleted file mode 100644 index dbb0bcc4..00000000 --- a/test/imagekit/constant_test.rb +++ /dev/null @@ -1,17 +0,0 @@ -require_relative './spec_helper' -require 'rspec/autorun' - -RSpec.describe ImageKitIo::Constantable do - let(:constantable_class) { ImageKitIo::Constant } - - it 'defines the constants method in included class' do - constantable_obj = Class.new.send(:include, ImageKitIo::Constantable) - expect(constantable_obj).to receive(:constants).and_return(true) - constantable_obj.constants - end - - it "returns the defined constant's value" do - expect(constantable_class).to receive(:method_missing).and_call_original - expect(constantable_class.BASE_URL).to eq("https://api.imagekit.io/v1/files") - end -end diff --git a/test/imagekit/dummy_data/data.rb b/test/imagekit/dummy_data/data.rb deleted file mode 100644 index cf655e2c..00000000 --- a/test/imagekit/dummy_data/data.rb +++ /dev/null @@ -1,5 +0,0 @@ -# frozen_string_literal: true - -PRIVATE_KEY = "private_xyz" -PUBLIC_KEY = "public_xyz" -URL_ENDPOINT = "imagekit.io/your-imgekit-id/" diff --git a/test/imagekit/dummy_data/file.rb b/test/imagekit/dummy_data/file.rb deleted file mode 100644 index 67be48ed..00000000 --- a/test/imagekit/dummy_data/file.rb +++ /dev/null @@ -1,60 +0,0 @@ -FAILED_GENERIC_RESP = {"message": "Hi There is an error"} -SUCCESS_GENERIC_RESP = {"response": "Success"} -AUTHENTICATION_ERR_MSG = { - "message": "Your account cannot be authenticated.", - "help": "For support kindly contact us at support@imagekit.io .", -} -FAILED_DELETE_RESP = {"message": "Item Not Found"} - -SUCCESS_PURGE_CACHE_MSG = {"request_id": "fake_abc_xyz"} - -SUCCESS_PURGE_CACHE_STATUS_MSG = {"status": "pending"} - -SERVER_ERR_MSG = { - "message": "We have experienced an internal error while processing your request.", - "help": "For support kindly contact us at support@imagekit.io .", -} - -SUCCESS_LIST_RESP_MESSAGE = { - "response": [ - { - "type": "file", - "name": "default-image.jpg", - "fileId": "53dgd6023f28ft7fse488992c", - "tags": None, - "customCoordinates": None, - "isPrivateFile": None, - "url": "https://ik.imagekit.io/fakeid/default-image.jpg", - "thumbnail": "https://ik.imagekit.io/fakeid/tr:n-media_library_thumbnail/default-image.jpg", - "fileType": "image", - "filePath": "/default-image.jpg", - }, - { - "type": "file", - "name": "default-image.jpg", - "fileId": "53dgd6023f28ft7fse488992c", - "tags": None, - "customCoordinates": None, - "isPrivateFile": None, - "url": "https://ik.imagekit.io/fakeid/default-image.jpg", - "thumbnail": "https://ik.imagekit.io/fakeid/tr:n-media_library_thumbnail/default-image.jpg", - "fileType": "image", - "filePath": "/default-image.jpg", - }, - ], -} - -SUCCESS_DETAIL_MSG = { - "response": { - "type": "file", - "name": "default-image.jpg", - "fileId": "53dgd6023f28ft7fse488992c", - "tags": None, - "customCoordinates": None, - "isPrivateFile": None, - "url": "https://ik.imagekit.io/fakeid/default-image.jpg", - "thumbnail": "https://ik.imagekit.io/fakeid/tr:n-media_library_thumbnail/default-image.jpg", - "fileType": "image", - "filePath": "/default-image.jpg", - } -} diff --git a/test/imagekit/dummy_data/sample.jpg b/test/imagekit/dummy_data/sample.jpg deleted file mode 100644 index 1db39e04..00000000 Binary files a/test/imagekit/dummy_data/sample.jpg and /dev/null differ diff --git a/test/imagekit/file_part_test.rb b/test/imagekit/file_part_test.rb new file mode 100644 index 00000000..15b7078c --- /dev/null +++ b/test/imagekit/file_part_test.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require_relative "test_helper" + +class Imagekit::Test::FilePartTest < Minitest::Test + def test_to_json + text = "gray" + filepart = Imagekit::FilePart.new(StringIO.new(text)) + + assert_equal(text.to_json, filepart.to_json) + assert_equal(text.to_yaml, filepart.to_yaml) + end +end diff --git a/test/imagekit/internal/sorbet_runtime_support_test.rb b/test/imagekit/internal/sorbet_runtime_support_test.rb new file mode 100644 index 00000000..4075f247 --- /dev/null +++ b/test/imagekit/internal/sorbet_runtime_support_test.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true + +require_relative "../test_helper" + +class Imagekit::Test::SorbetRuntimeSupportTest < Minitest::Test + extend Minitest::Serial + + i_suck_and_my_tests_are_order_dependent! + + module E + extend Imagekit::Internal::Type::Enum + + define_sorbet_constant!(:TaggedSymbol) { 1 } + end + + module U + extend Imagekit::Internal::Type::Union + + define_sorbet_constant!(:Variants) { 2 } + end + + class M < Imagekit::Internal::Type::BaseModel + define_sorbet_constant!(:OrHash) { 3 } + end + + def test_nil_aliases + err = Imagekit::Internal::Util::SorbetRuntimeSupport::MissingSorbetRuntimeError + + assert_raises(err) { Imagekit::Internal::AnyHash } + assert_raises(err) { Imagekit::Internal::FileInput } + assert_raises(err) { Imagekit::Internal::Type::Converter::Input } + assert_raises(err) { Imagekit::Internal::Type::Converter::CoerceState } + assert_raises(err) { Imagekit::Internal::Type::Converter::DumpState } + assert_raises(err) { Imagekit::Internal::Type::BaseModel::KnownField } + assert_raises(err) { Imagekit::Internal::Util::ParsedUri } + assert_raises(err) { Imagekit::Internal::Util::ServerSentEvent } + assert_raises(err) { Imagekit::Internal::Transport::BaseClient::RequestComponents } + assert_raises(err) { Imagekit::Internal::Transport::BaseClient::RequestInput } + assert_raises(err) { Imagekit::Internal::Transport::PooledNetRequester::Request } + assert_raises(err) { E::TaggedSymbol } + assert_raises(err) { U::Variants } + assert_raises(err) { M::OrHash } + end + + def test_stubbed_aliases + Kernel.instance_eval { const_set(:T, nil) } + + assert_equal(1, E::TaggedSymbol) + assert_equal(2, U::Variants) + assert_equal(3, M::OrHash) + end +end diff --git a/test/imagekit/internal/type/base_model_test.rb b/test/imagekit/internal/type/base_model_test.rb new file mode 100644 index 00000000..4373043c --- /dev/null +++ b/test/imagekit/internal/type/base_model_test.rb @@ -0,0 +1,727 @@ +# frozen_string_literal: true + +require_relative "../../test_helper" + +class Imagekit::Test::PrimitiveModelTest < Minitest::Test + A = Imagekit::Internal::Type::ArrayOf[-> { Integer }] + H = Imagekit::Internal::Type::HashOf[-> { Integer }, nil?: true] + + module E + extend Imagekit::Internal::Type::Enum + end + + module U + extend Imagekit::Internal::Type::Union + end + + class B < Imagekit::Internal::Type::BaseModel + optional :a, Integer + optional :b, B + end + + def test_typing + converters = [ + Imagekit::Internal::Type::Unknown, + Imagekit::Internal::Type::Boolean, + A, + H, + E, + U, + B + ] + + converters.each do |conv| + assert_pattern do + conv => Imagekit::Internal::Type::Converter + end + end + end + + def test_coerce + cases = { + [Imagekit::Internal::Type::Unknown, :a] => [{yes: 1}, :a], + [NilClass, :a] => [{maybe: 1}, nil], + [NilClass, nil] => [{yes: 1}, nil], + [Imagekit::Internal::Type::Boolean, true] => [{yes: 1}, true], + [Imagekit::Internal::Type::Boolean, "true"] => [{no: 1}, "true"], + [Integer, 1] => [{yes: 1}, 1], + [Integer, 1.0] => [{maybe: 1}, 1], + [Integer, "1"] => [{maybe: 1}, 1], + [Integer, "one"] => [{no: 1}, "one"], + [Float, 1] => [{yes: 1}, 1.0], + [Float, "1"] => [{maybe: 1}, 1.0], + [Float, :one] => [{no: 1}, :one], + [String, :str] => [{yes: 1}, "str"], + [String, "str"] => [{yes: 1}, "str"], + [String, 1] => [{maybe: 1}, "1"], + [:a, "a"] => [{yes: 1}, :a], + [Date, "1990-09-19"] => [{yes: 1}, Date.new(1990, 9, 19)], + [Date, Date.new(1990, 9, 19)] => [{yes: 1}, Date.new(1990, 9, 19)], + [Date, "one"] => [{no: 1}, "one"], + [Time, "1990-09-19"] => [{yes: 1}, Time.new(1990, 9, 19)], + [Time, Time.new(1990, 9, 19)] => [{yes: 1}, Time.new(1990, 9, 19)], + [Time, "one"] => [{no: 1}, "one"] + } + + cases.each do |lhs, rhs| + target, input = lhs + exactness, expect = rhs + state = Imagekit::Internal::Type::Converter.new_coerce_state + assert_pattern do + Imagekit::Internal::Type::Converter.coerce(target, input, state: state) => ^expect + state.fetch(:exactness).filter { _2.nonzero? }.to_h => ^exactness + end + end + end + + def test_dump + cases = { + [Imagekit::Internal::Type::Unknown, B.new(a: "one", b: B.new(a: 1.0))] => {a: "one", b: {a: 1}}, + [A, B.new(a: "one", b: B.new(a: 1.0))] => {a: "one", b: {a: 1}}, + [H, B.new(a: "one", b: B.new(a: 1.0))] => {a: "one", b: {a: 1}}, + [E, B.new(a: "one", b: B.new(a: 1.0))] => {a: "one", b: {a: 1}}, + [U, B.new(a: "one", b: B.new(a: 1.0))] => {a: "one", b: {a: 1}}, + [B, B.new(a: "one", b: B.new(a: 1.0))] => {a: "one", b: {a: 1}}, + [String, B.new(a: "one", b: B.new(a: 1.0))] => {a: "one", b: {a: 1}}, + [:b, B.new(a: "one", b: B.new(a: 1.0))] => {a: "one", b: {a: 1}}, + [nil, B.new(a: "one", b: B.new(a: 1.0))] => {a: "one", b: {a: 1}}, + [Imagekit::Internal::Type::Boolean, true] => true, + [Imagekit::Internal::Type::Boolean, "true"] => "true", + [Integer, "1"] => "1", + [Float, 1] => 1, + [String, "one"] => "one", + [String, :one] => :one, + [:a, :b] => :b, + [:a, "a"] => "a", + [String, StringIO.new("one")] => "one", + [String, Pathname(__FILE__)] => Imagekit::FilePart + } + + cases.each do + target, input = _1 + expect = _2 + assert_pattern do + Imagekit::Internal::Type::Converter.dump(target, input) => ^expect + end + end + end + + def test_coerce_errors + cases = { + [Integer, "one"] => ArgumentError, + [Float, "one"] => ArgumentError, + [String, Time] => TypeError, + [Date, "one"] => ArgumentError, + [Time, "one"] => ArgumentError + } + + cases.each do |testcase, expect| + target, input = testcase + state = Imagekit::Internal::Type::Converter.new_coerce_state + Imagekit::Internal::Type::Converter.coerce(target, input, state: state) + assert_pattern do + state => {error: ^expect} + end + end + end + + def test_dump_retry + types = [ + Imagekit::Internal::Type::Unknown, + Imagekit::Internal::Type::Boolean, + A, + H, + E, + U, + B + ] + Pathname(__FILE__).open do |fd| + cases = [ + fd, + [fd], + {a: fd}, + {a: {b: fd}} + ] + types.product(cases).each do |target, input| + state = {can_retry: true} + Imagekit::Internal::Type::Converter.dump(target, input, state: state) + + assert_pattern do + state => {can_retry: false} + end + end + end + end +end + +class Imagekit::Test::EnumModelTest < Minitest::Test + class E0 + include Imagekit::Internal::Type::Enum + + attr_reader :values + + def initialize(*values) = (@values = values) + end + + module E1 + extend Imagekit::Internal::Type::Enum + + TRUE = true + end + + module E2 + extend Imagekit::Internal::Type::Enum + + ONE = 1 + TWO = 2 + end + + module E3 + extend Imagekit::Internal::Type::Enum + + ONE = 1.0 + TWO = 2.0 + end + + module E4 + extend Imagekit::Internal::Type::Enum + + ONE = :one + TWO = :two + end + + def test_coerce + cases = { + [E0.new, "one"] => [{no: 1}, "one"], + [E0.new(:one), "one"] => [{yes: 1}, :one], + [E0.new(:two), "one"] => [{maybe: 1}, "one"], + + [E1, true] => [{yes: 1}, true], + [E1, false] => [{no: 1}, false], + [E1, :true] => [{no: 1}, :true], + + [E2, 1] => [{yes: 1}, 1], + [E2, 1.0] => [{yes: 1}, 1], + [E2, 1.2] => [{no: 1}, 1.2], + [E2, "1"] => [{no: 1}, "1"], + + [E3, 1.0] => [{yes: 1}, 1.0], + [E3, 1] => [{yes: 1}, 1.0], + [E3, "one"] => [{no: 1}, "one"], + + [E4, :one] => [{yes: 1}, :one], + [E4, "one"] => [{yes: 1}, :one], + [E4, "1"] => [{maybe: 1}, "1"], + [E4, :"1"] => [{maybe: 1}, :"1"], + [E4, 1] => [{no: 1}, 1] + } + + cases.each do |lhs, rhs| + target, input = lhs + exactness, expect = rhs + state = Imagekit::Internal::Type::Converter.new_coerce_state + assert_pattern do + Imagekit::Internal::Type::Converter.coerce(target, input, state: state) => ^expect + state.fetch(:exactness).filter { _2.nonzero? }.to_h => ^exactness + end + end + end + + def test_dump + cases = { + [E1, true] => true, + [E1, "true"] => "true", + + [E2, 1.0] => 1.0, + [E2, 3] => 3, + [E2, "1.0"] => "1.0", + + [E3, 1.0] => 1.0, + [E3, 3] => 3, + [E3, "1.0"] => "1.0", + + [E4, :one] => :one, + [E4, "one"] => "one", + [E4, "1.0"] => "1.0" + } + + cases.each do + target, input = _1 + expect = _2 + assert_pattern do + Imagekit::Internal::Type::Converter.dump(target, input) => ^expect + end + end + end +end + +class Imagekit::Test::CollectionModelTest < Minitest::Test + A1 = Imagekit::Internal::Type::ArrayOf[-> { Integer }] + H1 = Imagekit::Internal::Type::HashOf[Integer] + + A2 = Imagekit::Internal::Type::ArrayOf[H1] + H2 = Imagekit::Internal::Type::HashOf[-> { A1 }] + + A3 = Imagekit::Internal::Type::ArrayOf[Integer, nil?: true] + H3 = Imagekit::Internal::Type::HashOf[Integer, nil?: true] + + def test_coerce + cases = { + [A1, []] => [{yes: 1}, []], + [A1, {}] => [{no: 1}, {}], + [A1, [1, 2.0]] => [{yes: 2, maybe: 1}, [1, 2]], + [A1, ["1", 2.0]] => [{yes: 1, maybe: 2}, [1, 2]], + [H1, {}] => [{yes: 1}, {}], + [H1, []] => [{no: 1}, []], + [H1, {a: 1, b: 2}] => [{yes: 3}, {a: 1, b: 2}], + [H1, {"a" => 1, "b" => 2}] => [{yes: 3}, {a: 1, b: 2}], + [H1, {[] => 1}] => [{yes: 2, no: 1}, {[] => 1}], + [H1, {a: 1.5}] => [{yes: 1, maybe: 1}, {a: 1}], + + [A2, [{}, {"a" => 1}]] => [{yes: 4}, [{}, {a: 1}]], + [A2, [{"a" => "1"}]] => [{yes: 2, maybe: 1}, [{a: 1}]], + [H2, {a: [1, 2]}] => [{yes: 4}, {a: [1, 2]}], + [H2, {"a" => ["1", 2]}] => [{yes: 3, maybe: 1}, {a: [1, 2]}], + [H2, {"a" => ["one", 2]}] => [{yes: 3, no: 1}, {a: ["one", 2]}], + + [A3, [nil, 1]] => [{yes: 3}, [nil, 1]], + [A3, [nil, "1"]] => [{yes: 2, maybe: 1}, [nil, 1]], + [H3, {a: nil, b: "1"}] => [{yes: 2, maybe: 1}, {a: nil, b: 1}], + [H3, {a: nil}] => [{yes: 2}, {a: nil}] + } + + cases.each do |lhs, rhs| + target, input = lhs + exactness, expect = rhs + state = Imagekit::Internal::Type::Converter.new_coerce_state + assert_pattern do + Imagekit::Internal::Type::Converter.coerce(target, input, state: state) => ^expect + state.fetch(:exactness).filter { _2.nonzero? }.to_h => ^exactness + end + end + end +end + +class Imagekit::Test::BaseModelTest < Minitest::Test + class M1 < Imagekit::Internal::Type::BaseModel + required :a, Integer + end + + class M2 < M1 + required :a, Time + required :b, Integer, nil?: true + optional :c, String + end + + class M3 < Imagekit::Internal::Type::BaseModel + optional :c, const: :c + required :d, const: :d + end + + class M4 < M1 + request_only do + required :a, Integer + optional :b, String + end + + response_only do + required :c, Integer + optional :d, String + end + end + + class M5 < Imagekit::Internal::Type::BaseModel + request_only do + required :c, const: :c + end + + response_only do + required :d, const: :d + end + end + + class M6 < M1 + required :a, Imagekit::Internal::Type::ArrayOf[M6] + optional :b, M6 + end + + def test_coerce + cases = { + [M1, {}] => [{yes: 1, no: 1}, {}], + [M1, :m1] => [{no: 1}, :m1], + + [M2, {}] => [{yes: 2, no: 1, maybe: 1}, {}], + [M2, {a: "1990-09-19", b: nil}] => [{yes: 4}, {a: "1990-09-19", b: nil}], + [M2, {a: "1990-09-19", b: "1"}] => [{yes: 3, maybe: 1}, {a: "1990-09-19", b: "1"}], + [M2, {a: "1990-09-19"}] => [{yes: 3, maybe: 1}, {a: "1990-09-19"}], + [M2, {a: "1990-09-19", c: nil}] => [{yes: 2, maybe: 2}, {a: "1990-09-19", c: nil}], + + [M3, {c: "c", d: "d"}] => [{yes: 3}, {c: :c, d: :d}], + [M3, {c: "d", d: "c"}] => [{yes: 1, maybe: 2}, {c: "d", d: "c"}], + + [M4, {c: 2}] => [{yes: 5}, {c: 2}], + [M4, {a: "1", c: 2}] => [{yes: 4, maybe: 1}, {a: "1", c: 2}], + [M4, {b: nil, c: 2}] => [{yes: 4, maybe: 1}, {b: nil, c: 2}], + + [M5, {}] => [{yes: 3}, {}], + [M5, {c: "c"}] => [{yes: 3}, {c: :c}], + [M5, {d: "d"}] => [{yes: 3}, {d: :d}], + [M5, {d: nil}] => [{yes: 2, no: 1}, {d: nil}], + + [M6, {a: [{a: []}]}] => [{yes: 6}, -> { _1 in {a: [M6]} }], + [M6, {b: {a: []}}] => [{yes: 4, no: 1}, -> { _1 in {b: M6} }] + } + + cases.each do |lhs, rhs| + target, input = lhs + exactness, expect = rhs + state = Imagekit::Internal::Type::Converter.new_coerce_state + assert_pattern do + coerced = Imagekit::Internal::Type::Converter.coerce(target, input, state: state) + assert_equal(coerced, coerced) + if coerced.is_a?(Imagekit::Internal::Type::BaseModel) + coerced.to_h => ^expect + else + coerced => ^expect + end + state.fetch(:exactness).filter { _2.nonzero? }.to_h => ^exactness + end + end + end + + def test_dump + cases = { + [M3, M3.new] => {d: :d}, + [M3, {}] => {d: :d}, + [M3, {d: 1}] => {d: 1}, + + [M4, M4.new(a: 1, b: "b", c: 2, d: "d")] => {a: 1, b: "b"}, + [M4, {a: 1, b: "b", c: 2, d: "d"}] => {a: 1, b: "b"}, + + [M5, M5.new] => {c: :c}, + [M5, {}] => {c: :c}, + [M5, {c: 1}] => {c: 1} + } + + cases.each do + target, input = _1 + expect = _2 + assert_pattern do + Imagekit::Internal::Type::Converter.dump(target, input) => ^expect + end + end + end + + def test_accessors + cases = { + M2.new({a: "1990-09-19", b: "1"}) => [{a: "1990-09-19", b: "1"}, {a: Time.new(1990, 9, 19), b: 1}], + M2.new(a: "one", b: "one") => [{a: "one", b: "one"}, {a: ArgumentError, b: ArgumentError}], + M2.new(a: nil, b: 2.0) => [{a: nil, b: 2.0}, {a: TypeError}], + M2.new(a: nil, b: 2.2) => [{a: nil, b: 2.2}, {a: TypeError, b: 2}], + + M3.new => [{}, {d: :d}], + M3.new(d: 1) => [{d: 1}, {d: ArgumentError}], + + M5.new => [{}, {c: :c, d: :d}] + } + + cases.each do + target = _1 + data, attributes = _2 + + assert_pattern do + target.to_h => ^data + end + + attributes.each do |accessor, expect| + case expect + in Class if expect <= StandardError + tap do + target.public_send(accessor) + flunk + rescue Imagekit::Errors::ConversionError => e + assert_kind_of(expect, e.cause) + end + else + assert_pattern { target.public_send(accessor) => ^expect } + end + end + end + end + + def test_inplace_modification + m1 = M6.new(a: []) + m1.a << M6.new(a: []) + + m2 = M6.new(b: M6.new(a: [])) + m2.b.a << M6.new(a: []) + + m3 = M6.new(a: []) + m4 = M6.new(b: m3) + m3.a << M6.new(a: []) + + assert_pattern do + m1 => {a: [{a: []}]} + m2 => {b: {a: [{a: []}]}} + m4 => {b: {a: [{a: []}]}} + end + end +end + +class Imagekit::Test::UnionTest < Minitest::Test + class U0 + include Imagekit::Internal::Type::Union + + def initialize(*variants) = variants.each { variant(_1) } + end + + module U1 + extend Imagekit::Internal::Type::Union + + variant const: :a + variant const: 2 + end + + class M1 < Imagekit::Internal::Type::BaseModel + required :t, const: :a, api_name: :type + optional :c, String + end + + class M2 < Imagekit::Internal::Type::BaseModel + required :type, const: :b + optional :c, String + end + + module U2 + extend Imagekit::Internal::Type::Union + + discriminator :type + + variant :a, M1 + variant :b, M2 + end + + module U3 + extend Imagekit::Internal::Type::Union + + discriminator :type + + variant :a, M1 + variant String + end + + module U4 + extend Imagekit::Internal::Type::Union + + discriminator :type + + variant String + variant :a, M1 + end + + class M3 < Imagekit::Internal::Type::BaseModel + optional :recur, -> { U5 } + required :a, Integer + end + + class M4 < Imagekit::Internal::Type::BaseModel + optional :recur, -> { U5 } + required :a, Imagekit::Internal::Type::ArrayOf[-> { U5 }] + end + + class M5 < Imagekit::Internal::Type::BaseModel + optional :recur, -> { U5 } + required :b, Imagekit::Internal::Type::ArrayOf[-> { U5 }] + end + + module U5 + extend Imagekit::Internal::Type::Union + + variant -> { M3 } + variant -> { M4 } + end + + module U6 + extend Imagekit::Internal::Type::Union + + variant -> { M3 } + variant -> { M5 } + end + + def test_accessors + model = M3.new(recur: []) + tap do + model.recur + flunk + rescue Imagekit::Errors::ConversionError => e + assert_kind_of(ArgumentError, e.cause) + end + end + + def test_coerce + cases = { + [U0, :""] => [{no: 1}, 0, :""], + + [U0.new(Integer, Float), "one"] => [{no: 1}, 2, "one"], + [U0.new(Integer, Float), 1.0] => [{yes: 1}, 2, 1.0], + [U0.new({const: :a}), "a"] => [{yes: 1}, 1, :a], + [U0.new({const: :a}), "2"] => [{maybe: 1}, 1, "2"], + + [U1, "a"] => [{yes: 1}, 1, :a], + [U1, "2"] => [{maybe: 1}, 2, "2"], + [U1, :b] => [{maybe: 1}, 2, :b], + + [U2, {type: :a}] => [{yes: 3}, 0, {t: :a}], + [U2, {type: "b"}] => [{yes: 3}, 0, {type: :b}], + + [U3, "one"] => [{yes: 1}, 2, "one"], + [U4, "one"] => [{yes: 1}, 1, "one"], + + [U5, {a: []}] => [{yes: 3}, 2, {a: []}], + [U6, {b: []}] => [{yes: 3}, 2, {b: []}], + + [U5, {a: [{a: []}]}] => [{yes: 6}, 4, {a: [M4.new(a: [])]}], + [U5, {a: [{a: [{a: []}]}]}] => [{yes: 9}, 6, {a: [M4.new(a: [M4.new(a: [])])]}] + } + + cases.each do |lhs, rhs| + target, input = lhs + exactness, branched, expect = rhs + state = Imagekit::Internal::Type::Converter.new_coerce_state + assert_pattern do + coerced = Imagekit::Internal::Type::Converter.coerce(target, input, state: state) + assert_equal(coerced, coerced) + if coerced.is_a?(Imagekit::Internal::Type::BaseModel) + coerced.to_h => ^expect + else + coerced => ^expect + end + state.fetch(:exactness).filter { _2.nonzero? }.to_h => ^exactness + state => {branched: ^branched} + end + end + end +end + +class Imagekit::Test::BaseModelQoLTest < Minitest::Test + class E0 + include Imagekit::Internal::Type::Enum + + attr_reader :values + + def initialize(*values) = (@values = values) + end + + module E1 + extend Imagekit::Internal::Type::Enum + + A = 1 + end + + module E2 + extend Imagekit::Internal::Type::Enum + + A = 1 + end + + module E3 + extend Imagekit::Internal::Type::Enum + + A = 2 + B = 3 + end + + class U0 + include Imagekit::Internal::Type::Union + + def initialize(*variants) = variants.each { variant(_1) } + end + + module U1 + extend Imagekit::Internal::Type::Union + + variant String + variant Integer + end + + module U2 + extend Imagekit::Internal::Type::Union + + variant String + variant Integer + end + + class M1 < Imagekit::Internal::Type::BaseModel + required :a, Integer + end + + class M2 < Imagekit::Internal::Type::BaseModel + required :a, Integer, nil?: true + end + + class M3 < M2 + required :a, Integer + end + + def test_equality + cases = { + [Imagekit::Internal::Type::Unknown, Imagekit::Internal::Type::Unknown] => true, + [Imagekit::Internal::Type::Boolean, Imagekit::Internal::Type::Boolean] => true, + [Imagekit::Internal::Type::Unknown, Imagekit::Internal::Type::Boolean] => false, + [E0.new(:a, :b), E0.new(:a, :b)] => true, + [E0.new(:a, :b), E0.new(:b, :a)] => true, + [E0.new(:a, :b), E0.new(:b, :c)] => false, + [E1, E2] => true, + [E1, E3] => false, + [U0.new(String, Integer), U0.new(String, Integer)] => true, + [U0.new(String, Integer), U0.new(Integer, String)] => false, + [U0.new(String, Float), U0.new(String, Integer)] => false, + [U1, U2] => true, + [M1, M2] => false, + [M1, M3] => true, + [M1.new(a: 1), M1.new(a: 1)] => true + } + + cases.each do + if _2 + assert_equal(*_1) + assert_equal(*_1.map(&:hash)) + else + refute_equal(*_1) + refute_equal(*_1.map(&:hash)) + end + end + end +end + +class Imagekit::Test::MetaInfoTest < Minitest::Test + A1 = Imagekit::Internal::Type::ArrayOf[Integer, nil?: true, doc: "dog"] + H1 = Imagekit::Internal::Type::HashOf[-> { String }, nil?: true, doc: "dawg"] + + class M1 < Imagekit::Internal::Type::BaseModel + required :a, Integer, doc: "dog" + optional :b, -> { String }, nil?: true, doc: "dawg" + end + + module U1 + extend Imagekit::Internal::Type::Union + + variant -> { Integer }, const: 2, doc: "dog" + variant -> { String }, doc: "dawg" + end + + def test_meta_retrieval + m1 = A1.instance_variable_get(:@meta) + m2 = H1.instance_variable_get(:@meta) + assert_equal({doc: "dog"}, m1) + assert_equal({doc: "dawg"}, m2) + + ma, mb = M1.fields.fetch_values(:a, :b) + assert_equal({doc: "dog"}, ma.fetch(:meta)) + assert_equal({doc: "dawg"}, mb.fetch(:meta)) + + ua, ub = U1.send(:known_variants).map(&:last) + assert_equal({doc: "dog"}, ua) + assert_equal({doc: "dawg"}, ub) + end +end diff --git a/test/imagekit/internal/util_test.rb b/test/imagekit/internal/util_test.rb new file mode 100644 index 00000000..48616831 --- /dev/null +++ b/test/imagekit/internal/util_test.rb @@ -0,0 +1,594 @@ +# frozen_string_literal: true + +require_relative "../test_helper" + +class Imagekit::Test::UtilDataHandlingTest < Minitest::Test + def test_left_map + assert_pattern do + Imagekit::Internal::Util.deep_merge({a: 1}, nil) => nil + end + end + + def test_right_map + assert_pattern do + Imagekit::Internal::Util.deep_merge(nil, {a: 1}) => {a: 1} + end + end + + def test_disjoint_maps + assert_pattern do + Imagekit::Internal::Util.deep_merge({b: 2}, {a: 1}) => {a: 1, b: 2} + end + end + + def test_overlapping_maps + assert_pattern do + Imagekit::Internal::Util.deep_merge({b: 2, c: 3}, {a: 1, c: 4}) => {a: 1, b: 2, c: 4} + end + end + + def test_nested + assert_pattern do + Imagekit::Internal::Util.deep_merge({b: {b2: 1}}, {b: {b2: 2}}) => {b: {b2: 2}} + end + end + + def test_nested_left_map + assert_pattern do + Imagekit::Internal::Util.deep_merge({b: {b2: 1}}, {b: 6}) => {b: 6} + end + end + + def test_omission + merged = Imagekit::Internal::Util.deep_merge( + {b: {b2: 1, b3: {c: 4, d: 5}}}, + {b: {b2: 1, b3: {c: Imagekit::Internal::OMIT, d: 5}}} + ) + + assert_pattern do + merged => {b: {b2: 1, b3: {d: 5}}} + end + end + + def test_concat + merged = Imagekit::Internal::Util.deep_merge( + {a: {b: [1, 2]}}, + {a: {b: [3, 4]}}, + concat: true + ) + + assert_pattern do + merged => {a: {b: [1, 2, 3, 4]}} + end + end + + def test_concat_false + merged = Imagekit::Internal::Util.deep_merge( + {a: {b: [1, 2]}}, + {a: {b: [3, 4]}}, + concat: false + ) + + assert_pattern do + merged => {a: {b: [3, 4]}} + end + end + + def test_dig + assert_pattern do + Imagekit::Internal::Util.dig(1, nil) => 1 + Imagekit::Internal::Util.dig({a: 1}, :b) => nil + Imagekit::Internal::Util.dig({a: 1}, :a) => 1 + Imagekit::Internal::Util.dig({a: {b: 1}}, [:a, :b]) => 1 + + Imagekit::Internal::Util.dig([], 1) => nil + Imagekit::Internal::Util.dig([nil, [nil, 1]], [1, 1]) => 1 + Imagekit::Internal::Util.dig({a: [nil, 1]}, [:a, 1]) => 1 + Imagekit::Internal::Util.dig([], 1.0) => nil + + Imagekit::Internal::Util.dig(Object, 1) => nil + Imagekit::Internal::Util.dig([], 1.0) { 2 } => 2 + Imagekit::Internal::Util.dig([], ->(_) { 2 }) => 2 + Imagekit::Internal::Util.dig([1], -> { _1 in [1] }) => true + end + end +end + +class Imagekit::Test::UtilUriHandlingTest < Minitest::Test + def test_parsing + %w[ + http://example.com + https://example.com/ + https://example.com:443/example?e1=e1&e2=e2&e= + ].each do |url| + parsed = Imagekit::Internal::Util.parse_uri(url) + unparsed = Imagekit::Internal::Util.unparse_uri(parsed).to_s + + assert_equal(url, unparsed) + assert_equal(parsed, Imagekit::Internal::Util.parse_uri(unparsed)) + end + end + + def test_joining + cases = [ + [ + "h://a.b/c?d=e", + "h://nope/ignored", + Imagekit::Internal::Util.parse_uri("h://a.b/c?d=e") + ], + [ + "h://a.b/c?d=e", + "h://nope", + { + host: "a.b", + path: "/c", + query: {"d" => ["e"]} + } + ] + ] + + cases.each do |expect, lhs, rhs| + assert_equal( + URI.parse(expect), + Imagekit::Internal::Util.join_parsed_uri( + Imagekit::Internal::Util.parse_uri(lhs), + rhs + ) + ) + end + end + + def test_joining_queries + base_url = "h://a.b/c?d=e" + cases = { + "c2" => "h://a.b/c/c2", + "/c2?f=g" => "h://a.b/c2?f=g", + "/c?f=g" => "h://a.b/c?d=e&f=g" + } + + cases.each do |path, expected| + assert_equal( + URI.parse(expected), + Imagekit::Internal::Util.join_parsed_uri( + Imagekit::Internal::Util.parse_uri(base_url), + {path: path} + ) + ) + end + end +end + +class Imagekit::Test::RegexMatchTest < Minitest::Test + def test_json_content + cases = { + "application/json" => true, + "application/jsonl" => false, + "application/vnd.github.v3+json" => true, + "application/vnd.api+json" => true + } + cases.each do |header, verdict| + assert_pattern do + Imagekit::Internal::Util::JSON_CONTENT.match?(header) => ^verdict + end + end + end + + def test_jsonl_content + cases = { + "application/x-ndjson" => true, + "application/x-ldjson" => true, + "application/jsonl" => true, + "application/x-jsonl" => true, + "application/json" => false, + "application/vnd.api+json" => false + } + cases.each do |header, verdict| + assert_pattern do + Imagekit::Internal::Util::JSONL_CONTENT.match?(header) => ^verdict + end + end + end +end + +class Imagekit::Test::UtilFormDataEncodingTest < Minitest::Test + class FakeCGI < CGI + def initialize(headers, io) + encoded = io.to_a + @ctype = headers["content-type"] + # rubocop:disable Lint/EmptyBlock + @io = Imagekit::Internal::Util::ReadIOAdapter.new(encoded.to_enum) {} + # rubocop:enable Lint/EmptyBlock + @c_len = encoded.join.bytesize.to_s + super() + end + + def stdinput = @io + + def env_table + { + "REQUEST_METHOD" => "POST", + "CONTENT_TYPE" => @ctype, + "CONTENT_LENGTH" => @c_len + } + end + end + + def test_file_encode + file = Pathname(__FILE__) + headers = {"content-type" => "multipart/form-data"} + cases = { + "abc" => "abc", + StringIO.new("abc") => "abc", + Imagekit::FilePart.new("abc") => "abc", + Imagekit::FilePart.new(StringIO.new("abc")) => "abc", + file => /^class Imagekit/, + Imagekit::FilePart.new(file) => /^class Imagekit/ + } + cases.each do |body, val| + encoded = Imagekit::Internal::Util.encode_content(headers, body) + cgi = FakeCGI.new(*encoded) + assert_pattern do + cgi[""].read => ^val + end + end + end + + def test_hash_encode + headers = {"content-type" => "multipart/form-data"} + cases = { + {a: 2, b: 3} => {"a" => "2", "b" => "3"}, + {a: 2, b: nil} => {"a" => "2", "b" => "null"}, + {a: 2, b: [1, 2, 3]} => {"a" => "2", "b" => "1"}, + {strio: StringIO.new("a")} => {"strio" => "a"}, + {strio: Imagekit::FilePart.new("a")} => {"strio" => "a"}, + {pathname: Pathname(__FILE__)} => {"pathname" => -> { _1.read in /^class Imagekit/ }}, + {pathname: Imagekit::FilePart.new(Pathname(__FILE__))} => {"pathname" => -> { _1.read in /^class Imagekit/ }} + } + cases.each do |body, testcase| + encoded = Imagekit::Internal::Util.encode_content(headers, body) + cgi = FakeCGI.new(*encoded) + testcase.each do |key, val| + assert_pattern do + cgi[key] => ^val + end + end + end + end +end + +class Imagekit::Test::UtilIOAdapterTest < Minitest::Test + def test_copy_read + cases = { + StringIO.new("abc") => "abc", + Enumerator.new { _1 << "abc" } => "abc" + } + cases.each do |input, expected| + io = StringIO.new + # rubocop:disable Lint/EmptyBlock + adapter = Imagekit::Internal::Util::ReadIOAdapter.new(input) {} + # rubocop:enable Lint/EmptyBlock + IO.copy_stream(adapter, io) + assert_equal(expected, io.string) + end + end + + def test_copy_write + cases = { + StringIO.new => "", + StringIO.new("abc") => "abc" + } + cases.each do |input, expected| + enum = Imagekit::Internal::Util.writable_enum do |y| + IO.copy_stream(input, y) + end + assert_equal(expected, enum.to_a.join) + end + end +end + +class Imagekit::Test::UtilFusedEnumTest < Minitest::Test + def test_closing + arr = [1, 2, 3] + once = 0 + fused = Imagekit::Internal::Util.fused_enum(arr.to_enum) do + once = once.succ + end + + enumerated_1 = fused.to_a + assert_equal(arr, enumerated_1) + assert_equal(1, once) + + enumerated_2 = fused.to_a + assert_equal([], enumerated_2) + assert_equal(1, once) + end + + def test_rewind_chain + once = 0 + fused = Imagekit::Internal::Util.fused_enum([1, 2, 3].to_enum) do + once = once.succ + end + .lazy + .map(&:succ) + .filter(&:odd?) + first = fused.next + + assert_equal(3, first) + assert_equal(0, once) + assert_raises(StopIteration) { fused.rewind.next } + assert_equal(1, once) + end + + def test_external_iteration + iter = [1, 2, 3].to_enum + first = iter.next + fused = Imagekit::Internal::Util.fused_enum(iter, external: true) + + assert_equal(1, first) + assert_equal([2, 3], fused.to_a) + end + + def test_close_fused + once = 0 + fused = Imagekit::Internal::Util.fused_enum([1, 2, 3].to_enum) do + once = once.succ + end + + Imagekit::Internal::Util.close_fused!(fused) + + assert_equal(1, once) + assert_equal([], fused.to_a) + assert_equal(1, once) + end + + def test_closed_fused_extern_iteration + taken = 0 + enum = [1, 2, 3].to_enum.lazy.map do + taken = taken.succ + _1 + end + fused = Imagekit::Internal::Util.fused_enum(enum) + first = fused.next + + assert_equal(1, first) + Imagekit::Internal::Util.close_fused!(fused) + assert_equal(1, taken) + end + + def test_closed_fused_taken_count + taken = 0 + enum = [1, 2, 3].to_enum.lazy.map do + taken = taken.succ + _1 + end + .map(&:succ) + .filter(&:odd?) + fused = Imagekit::Internal::Util.fused_enum(enum) + + assert_equal(0, taken) + Imagekit::Internal::Util.close_fused!(fused) + assert_equal(0, taken) + end + + def test_closed_fused_extern_iter_taken_count + taken = 0 + enum = [1, 2, 3].to_enum.lazy.map do + taken = taken.succ + _1 + end + .map(&:succ) + .filter(&:itself) + first = enum.next + assert_equal(2, first) + assert_equal(1, taken) + + fused = Imagekit::Internal::Util.fused_enum(enum) + Imagekit::Internal::Util.close_fused!(fused) + assert_equal(1, taken) + end + + def test_close_fused_sse_chain + taken = 0 + enum = [1, 2, 3].to_enum.lazy.map do + taken = taken.succ + _1 + end + .map(&:succ) + .filter(&:odd?) + .map(&:to_s) + + fused_1 = Imagekit::Internal::Util.fused_enum(enum) + fused_2 = Imagekit::Internal::Util.decode_lines(fused_1) + fused_3 = Imagekit::Internal::Util.decode_sse(fused_2) + + assert_equal(0, taken) + Imagekit::Internal::Util.close_fused!(fused_3) + assert_equal(0, taken) + end +end + +class Imagekit::Test::UtilContentDecodingTest < Minitest::Test + def test_charset + cases = { + "application/json" => Encoding::BINARY, + "application/json; charset=utf-8" => Encoding::UTF_8, + "charset=uTf-8 application/json; " => Encoding::UTF_8, + "charset=UTF-8; application/json; " => Encoding::UTF_8, + "charset=ISO-8859-1 ;application/json; " => Encoding::ISO_8859_1, + "charset=EUC-KR ;application/json; " => Encoding::EUC_KR + } + text = String.new.force_encoding(Encoding::BINARY) + cases.each do |content_type, encoding| + Imagekit::Internal::Util.force_charset!(content_type, text: text) + assert_equal(encoding, text.encoding) + end + end +end + +class Imagekit::Test::UtilSseTest < Minitest::Test + def test_decode_lines + cases = { + %w[] => %w[], + %W[\n\n] => %W[\n \n], + %W[\n \n] => %W[\n \n], + %w[a] => %w[a], + %W[a\nb] => %W[a\n b], + %W[a\nb\n] => %W[a\n b\n], + %W[\na b\n] => %W[\n ab\n], + %W[\na b\n\n] => %W[\n ab\n \n], + %W[\na b] => %W[\n ab], + %W[\u1F62E\u200D\u1F4A8] => %W[\u1F62E\u200D\u1F4A8], + %W[\u1F62E \u200D \u1F4A8] => %W[\u1F62E\u200D\u1F4A8], + ["\xf0\x9f".b, "\xa5\xba".b] => ["\xf0\x9f\xa5\xba".b], + ["\xf0".b, "\x9f".b, "\xa5".b, "\xba".b] => ["\xf0\x9f\xa5\xba".b] + } + eols = %W[\n \r \r\n] + cases.each do |enum, expected| + eols.each do |eol| + lines = Imagekit::Internal::Util.decode_lines(enum.map { _1.gsub("\n", eol) }) + assert_equal(expected.map { _1.gsub("\n", eol) }, lines.to_a, "eol=#{JSON.generate(eol)}") + end + end + end + + def test_mixed_decode_lines + cases = { + %w[] => %w[], + %W[\r\r] => %W[\r \r], + %W[\r \r] => %W[\r \r], + %W[\r\r\r] => %W[\r \r \r], + %W[\r\r \r] => %W[\r \r \r], + %W[\r \n] => %W[\r\n], + %W[\r\r\n] => %W[\r \r\n], + %W[\n\r] => %W[\n \r] + } + cases.each do |enum, expected| + lines = Imagekit::Internal::Util.decode_lines(enum) + assert_equal(expected, lines.to_a) + end + end + + def test_decode_sse + cases = { + "empty input" => { + [] => [] + }, + "single data event" => { + [ + "data: hello world\n", + "\n" + ] => [ + {data: "hello world\n"} + ] + }, + "multiple data lines" => { + [ + "data: line 1\n", + "data: line 2\n", + "\n" + ] => [ + {data: "line 1\nline 2\n"} + ] + }, + "complete event" => { + [ + "id: 123\n", + "event: update\n", + "data: hello world\n", + "retry: 5000\n", + "\n" + ] => [ + { + event: "update", + id: "123", + data: "hello world\n", + retry: 5000 + } + ] + }, + "multiple events" => { + [ + "event: update\n", + "data: first\n", + "\n", + "event: message\n", + "data: second\n", + "\n" + ] => [ + {event: "update", data: "first\n"}, + {event: "message", data: "second\n"} + ] + }, + "comments" => { + [ + ": this is a comment\n", + "data: actual data\n", + "\n" + ] => [ + {data: "actual data\n"} + ] + }, + "invalid retry" => { + [ + "retry: not a number\n", + "data: hello\n", + "\n" + ] => [ + {data: "hello\n"} + ] + }, + "invalid id with null" => { + [ + "id: bad\0id\n", + "data: hello\n", + "\n" + ] => [ + {data: "hello\n"} + ] + }, + "leading space in value" => { + [ + "data: hello world\n", + "data: leading space\n", + "\n" + ] => [ + {data: "hello world\n leading space\n"} + ] + }, + "no final newline" => { + [ + "data: hello\n", + "id: 1" + ] => [ + {data: "hello\n", id: "1"} + ] + }, + "multiple empty lines" => { + [ + "data: first\n", + "\n", + "\n", + "data: second\n", + "\n" + ] => [ + {data: "first\n"}, + {data: "second\n"} + ] + }, + "multibyte unicode" => { + [ + "data: \u1F62E\u200D\u1F4A8\n" + ] => [ + {data: "\u1F62E\u200D\u1F4A8\n"} + ] + } + } + + cases.each do |name, test_cases| + test_cases.each do |input, expected| + actual = Imagekit::Internal::Util.decode_sse(input).map(&:compact) + assert_equal(expected, actual, name) + end + end + end +end diff --git a/test/imagekit/request_test.rb b/test/imagekit/request_test.rb deleted file mode 100644 index 1fe06a04..00000000 --- a/test/imagekit/request_test.rb +++ /dev/null @@ -1,110 +0,0 @@ -require_relative "./spec_helper" -require "rspec/autorun" - -RSpec.describe ImageKitIo::Request do - let(:subject) { described_class } - - before(:each) do - @private_key = 'private_key_xyz' - @public_key = 'public_key_xyz' - @url_endpoint = 'https://imagekit.io/your-imgekit-id' - @request_obj = subject.new(@private_key, @public_key, @url_endpoint) - stub_request(:get, "https://www.examplenonjson.com").to_return(status: 200, body: "", headers: {content_type: "text/html"}) - stub_request(:get, "https://www.examplejson.com").to_return(body: '{"example_key": "example_value"}', headers: {content_type: "application/json"}) - stub_request(:get, "https://www.examplenotfound.com").to_return(status: 404) - stub_request(:get, "https://www.example204.com").to_return(status: 204) - end - describe 'TestRequest' do - it "test_request_init" do - request_obj = ImageKitIo::Request.new(@private_key, @public_key, @url_endpoint) - - expect(request_obj.private_key).to eq(@private_key) - end - - it "test_create_headers" do - headers = @request_obj.create_headers - expect(headers[:'Accept-Encoding']).to include("application/json") - end - - it "test_auth_headers" do - # test Auth headers working properly - auth_headers = @request_obj.auth_headers - expect(auth_headers[:Authorization]).to include("Basic") - end - - it "test_request_method_non_JSON_fail" do - response = @request_obj.request(:get, "https://www.examplenonjson.com") - expect(response).to have_key(:error) - end - - it "test_request_method_JSON_success" do - response = @request_obj.request(:get, "https://www.examplejson.com") - expect(response).to have_key(:response) - end - - it "test_request_method_404" do - response = @request_obj.request(:get, "https://www.examplenotfound.com") - expect(response).to have_key(:error) - end - - it "test_request_method_204" do - response = @request_obj.request(:get, "https://www.example204.com") - expect(response[:response]).to have_key(:success) - expect(response).to_not have_key(:error) - end - - it 'test_request_method_non_JSON_fail_with_post' do - stub_request(:post, 'https://www.exampleservererror/upload').to_return(status: 400, body: '{"message": "Server failed"}', headers: {content_type: 'application/json'}) - response = @request_obj.request(:post, 'https://www.exampleservererror/upload', nil, []) - expect(response).to have_key(:error) - end - - it 'test_request_method_JSON_success_with_post' do - stub_request(:post, 'https://www.exampleservererror/upload').to_return(status: 200, body: '{"id": "1"}', headers: {content_type: 'application/json'}) - response = @request_obj.request(:post, 'https://www.exampleservererror/upload', nil, []) - expect(response).to_not have_key(:error) - expect(response).to have_key(:response) - end - - it 'test_request_method_JSON_success_with_multipart_post' do - stub_request(:post, 'https://www.exampleservererror/upload').to_return(status: 200, body: '{"id": "1"}', headers: {content_type: 'application/json'}) - response = @request_obj.request(:post, 'https://www.exampleservererror/upload', nil, { multipart: true }) - expect(response).to_not have_key(:error) - expect(response).to have_key(:response) - end - - it 'test_request_method_non_JSON_fail_with_multipart_post' do - stub_request(:post, 'https://www.exampleservererror/upload').to_return(status: 400, body: '{"message": "Server failed"}', headers: {content_type: 'application/json'}) - response = @request_obj.request(:post, 'https://www.exampleservererror/upload', nil, { multipart: true }) - expect(response).to have_key(:error) - end - - it 'test_request_method_403' do - stub_request(:post, 'https://www.exampleservererror/upload').to_return(status: 403, body: "{\"message\":\"Your account cannot be authenticated.\",\"help\":\"For support kindly contact us at support@imagekit.io .\"}", headers: {content_type: 'application/json'}) - response = @request_obj.request(:post, 'https://www.exampleservererror/upload', nil, { multipart: true }) - expect(response).to have_key(:error) - expect(response[:error]).to eq({"message"=>"Your account cannot be authenticated.", "help"=>"For support kindly contact us at support@imagekit.io ."}) - expect(response[:headers]).to eq({"content-type"=>["application/json"]}) - expect(response[:raw_body]).to eq("{\"message\":\"Your account cannot be authenticated.\",\"help\":\"For support kindly contact us at support@imagekit.io .\"}") - expect(response[:status_code]).to eq("403") - end - - it 'test_response_headers' do - stub_request(:post, 'https://www.exampleservererror/upload').to_return(status: 200, body: "{\"message\":\"Success.\"}", headers: {"strict-transport-security"=>["max-age=15552000"], - "x-ik-requestid"=>["39e19bd4-c9c3-4025-453e-a13e6a412aa0"], - "content-type"=>["application/json; charset=utf-8"], - "x-request-id"=>["39e19bd4-c9c3-4025-a043-a13e6a412aa0"]}) - response = @request_obj.request(:post, 'https://www.exampleservererror/upload', nil, { multipart: true }) - expect(response[:headers]).to eq({"strict-transport-security"=>["max-age=15552000"], - "x-ik-requestid"=>["39e19bd4-c9c3-4025-453e-a13e6a412aa0"], - "content-type"=>["application/json; charset=utf-8"], - "x-request-id"=>["39e19bd4-c9c3-4025-a043-a13e6a412aa0"]}) - end - - it 'test_response_raw_body' do - stub_request(:post, 'https://www.exampleservererror/upload').to_return(status: 200, body: "{\"message\":\"Success.\"}", headers: {"strict-transport-security"=>["max-age=15552000"], "content-type"=>["application/json; charset=utf-8"]}) - response = @request_obj.request(:post, 'https://www.exampleservererror/upload', nil, { multipart: false }) - expect(response[:raw_body]).to eq("{\"message\":\"Success.\"}") - end - end -end diff --git a/test/imagekit/resource_namespaces.rb b/test/imagekit/resource_namespaces.rb new file mode 100644 index 00000000..52347d84 --- /dev/null +++ b/test/imagekit/resource_namespaces.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +module Imagekit + module Test + module Resources + module Accounts + end + + module Beta + module V2 + end + end + + module Cache + end + + module Files + end + + module Folders + end + + module V2 + end + end + end +end diff --git a/test/imagekit/resources/accounts/origins_test.rb b/test/imagekit/resources/accounts/origins_test.rb new file mode 100644 index 00000000..87930425 --- /dev/null +++ b/test/imagekit/resources/accounts/origins_test.rb @@ -0,0 +1,347 @@ +# frozen_string_literal: true + +require_relative "../../test_helper" + +class Imagekit::Test::Resources::Accounts::OriginsTest < Imagekit::Test::ResourceTest + def test_create_required_params + skip("Prism tests are disabled") + + response = + @image_kit.accounts.origins.create( + base_url: "https://akeneo.company.com", + client_id: "akeneo-client-id", + client_secret: "akeneo-client-secret", + name: "US S3 Storage", + password: "strongpassword123", + type: :AKENEO_PIM, + username: "integration-user" + ) + + assert_pattern do + response => Imagekit::Accounts::OriginResponse + end + + assert_pattern do + case response + in Imagekit::Accounts::OriginResponse::S3 + in Imagekit::Accounts::OriginResponse::S3Compatible + in Imagekit::Accounts::OriginResponse::CloudinaryBackup + in Imagekit::Accounts::OriginResponse::WebFolder + in Imagekit::Accounts::OriginResponse::WebProxy + in Imagekit::Accounts::OriginResponse::Gcs + in Imagekit::Accounts::OriginResponse::AzureBlob + in Imagekit::Accounts::OriginResponse::AkeneoPim + end + end + + assert_pattern do + case response + in { + type: :S3, + id: String, + bucket: String, + include_canonical_header: Imagekit::Internal::Type::Boolean, + name: String, + prefix: String, + base_url_for_canonical_header: String | nil + } + in { + type: :S3_COMPATIBLE, + id: String, + bucket: String, + endpoint: String, + include_canonical_header: Imagekit::Internal::Type::Boolean, + name: String, + prefix: String, + s3_force_path_style: Imagekit::Internal::Type::Boolean, + base_url_for_canonical_header: String | nil + } + in { + type: :CLOUDINARY_BACKUP, + id: String, + bucket: String, + include_canonical_header: Imagekit::Internal::Type::Boolean, + name: String, + prefix: String, + base_url_for_canonical_header: String | nil + } + in { + type: :WEB_FOLDER, + id: String, + base_url: String, + forward_host_header_to_origin: Imagekit::Internal::Type::Boolean, + include_canonical_header: Imagekit::Internal::Type::Boolean, + name: String, + base_url_for_canonical_header: String | nil + } + in { + type: :WEB_PROXY, + id: String, + include_canonical_header: Imagekit::Internal::Type::Boolean, + name: String, + base_url_for_canonical_header: String | nil + } + in { + type: :GCS, + id: String, + bucket: String, + client_email: String, + include_canonical_header: Imagekit::Internal::Type::Boolean, + name: String, + prefix: String, + base_url_for_canonical_header: String | nil + } + in { + type: :AZURE_BLOB, + id: String, + account_name: String, + container: String, + include_canonical_header: Imagekit::Internal::Type::Boolean, + name: String, + prefix: String, + base_url_for_canonical_header: String | nil + } + in { + type: :AKENEO_PIM, + id: String, + base_url: String, + include_canonical_header: Imagekit::Internal::Type::Boolean, + name: String, + base_url_for_canonical_header: String | nil + } + end + end + end + + def test_update_required_params + skip("Prism tests are disabled") + + response = + @image_kit.accounts.origins.update( + "id", + base_url: "https://akeneo.company.com", + client_id: "akeneo-client-id", + client_secret: "akeneo-client-secret", + name: "US S3 Storage", + password: "strongpassword123", + type: :AKENEO_PIM, + username: "integration-user" + ) + + assert_pattern do + response => Imagekit::Accounts::OriginResponse + end + + assert_pattern do + case response + in Imagekit::Accounts::OriginResponse::S3 + in Imagekit::Accounts::OriginResponse::S3Compatible + in Imagekit::Accounts::OriginResponse::CloudinaryBackup + in Imagekit::Accounts::OriginResponse::WebFolder + in Imagekit::Accounts::OriginResponse::WebProxy + in Imagekit::Accounts::OriginResponse::Gcs + in Imagekit::Accounts::OriginResponse::AzureBlob + in Imagekit::Accounts::OriginResponse::AkeneoPim + end + end + + assert_pattern do + case response + in { + type: :S3, + id: String, + bucket: String, + include_canonical_header: Imagekit::Internal::Type::Boolean, + name: String, + prefix: String, + base_url_for_canonical_header: String | nil + } + in { + type: :S3_COMPATIBLE, + id: String, + bucket: String, + endpoint: String, + include_canonical_header: Imagekit::Internal::Type::Boolean, + name: String, + prefix: String, + s3_force_path_style: Imagekit::Internal::Type::Boolean, + base_url_for_canonical_header: String | nil + } + in { + type: :CLOUDINARY_BACKUP, + id: String, + bucket: String, + include_canonical_header: Imagekit::Internal::Type::Boolean, + name: String, + prefix: String, + base_url_for_canonical_header: String | nil + } + in { + type: :WEB_FOLDER, + id: String, + base_url: String, + forward_host_header_to_origin: Imagekit::Internal::Type::Boolean, + include_canonical_header: Imagekit::Internal::Type::Boolean, + name: String, + base_url_for_canonical_header: String | nil + } + in { + type: :WEB_PROXY, + id: String, + include_canonical_header: Imagekit::Internal::Type::Boolean, + name: String, + base_url_for_canonical_header: String | nil + } + in { + type: :GCS, + id: String, + bucket: String, + client_email: String, + include_canonical_header: Imagekit::Internal::Type::Boolean, + name: String, + prefix: String, + base_url_for_canonical_header: String | nil + } + in { + type: :AZURE_BLOB, + id: String, + account_name: String, + container: String, + include_canonical_header: Imagekit::Internal::Type::Boolean, + name: String, + prefix: String, + base_url_for_canonical_header: String | nil + } + in { + type: :AKENEO_PIM, + id: String, + base_url: String, + include_canonical_header: Imagekit::Internal::Type::Boolean, + name: String, + base_url_for_canonical_header: String | nil + } + end + end + end + + def test_list + skip("Prism tests are disabled") + + response = @image_kit.accounts.origins.list + + assert_pattern do + response => ^(Imagekit::Internal::Type::ArrayOf[union: Imagekit::Accounts::OriginResponse]) + end + end + + def test_delete + skip("Prism tests are disabled") + + response = @image_kit.accounts.origins.delete("id") + + assert_pattern do + response => nil + end + end + + def test_get + skip("Prism tests are disabled") + + response = @image_kit.accounts.origins.get("id") + + assert_pattern do + response => Imagekit::Accounts::OriginResponse + end + + assert_pattern do + case response + in Imagekit::Accounts::OriginResponse::S3 + in Imagekit::Accounts::OriginResponse::S3Compatible + in Imagekit::Accounts::OriginResponse::CloudinaryBackup + in Imagekit::Accounts::OriginResponse::WebFolder + in Imagekit::Accounts::OriginResponse::WebProxy + in Imagekit::Accounts::OriginResponse::Gcs + in Imagekit::Accounts::OriginResponse::AzureBlob + in Imagekit::Accounts::OriginResponse::AkeneoPim + end + end + + assert_pattern do + case response + in { + type: :S3, + id: String, + bucket: String, + include_canonical_header: Imagekit::Internal::Type::Boolean, + name: String, + prefix: String, + base_url_for_canonical_header: String | nil + } + in { + type: :S3_COMPATIBLE, + id: String, + bucket: String, + endpoint: String, + include_canonical_header: Imagekit::Internal::Type::Boolean, + name: String, + prefix: String, + s3_force_path_style: Imagekit::Internal::Type::Boolean, + base_url_for_canonical_header: String | nil + } + in { + type: :CLOUDINARY_BACKUP, + id: String, + bucket: String, + include_canonical_header: Imagekit::Internal::Type::Boolean, + name: String, + prefix: String, + base_url_for_canonical_header: String | nil + } + in { + type: :WEB_FOLDER, + id: String, + base_url: String, + forward_host_header_to_origin: Imagekit::Internal::Type::Boolean, + include_canonical_header: Imagekit::Internal::Type::Boolean, + name: String, + base_url_for_canonical_header: String | nil + } + in { + type: :WEB_PROXY, + id: String, + include_canonical_header: Imagekit::Internal::Type::Boolean, + name: String, + base_url_for_canonical_header: String | nil + } + in { + type: :GCS, + id: String, + bucket: String, + client_email: String, + include_canonical_header: Imagekit::Internal::Type::Boolean, + name: String, + prefix: String, + base_url_for_canonical_header: String | nil + } + in { + type: :AZURE_BLOB, + id: String, + account_name: String, + container: String, + include_canonical_header: Imagekit::Internal::Type::Boolean, + name: String, + prefix: String, + base_url_for_canonical_header: String | nil + } + in { + type: :AKENEO_PIM, + id: String, + base_url: String, + include_canonical_header: Imagekit::Internal::Type::Boolean, + name: String, + base_url_for_canonical_header: String | nil + } + end + end + end +end diff --git a/test/imagekit/resources/accounts/url_endpoints_test.rb b/test/imagekit/resources/accounts/url_endpoints_test.rb new file mode 100644 index 00000000..88895a66 --- /dev/null +++ b/test/imagekit/resources/accounts/url_endpoints_test.rb @@ -0,0 +1,85 @@ +# frozen_string_literal: true + +require_relative "../../test_helper" + +class Imagekit::Test::Resources::Accounts::URLEndpointsTest < Imagekit::Test::ResourceTest + def test_create_required_params + skip("Prism tests are disabled") + + response = @image_kit.accounts.url_endpoints.create(description: "My custom URL endpoint") + + assert_pattern do + response => Imagekit::Accounts::URLEndpointResponse + end + + assert_pattern do + response => { + id: String, + description: String, + origins: ^(Imagekit::Internal::Type::ArrayOf[String]), + url_prefix: String, + url_rewriter: Imagekit::Accounts::URLEndpointResponse::URLRewriter | nil + } + end + end + + def test_update_required_params + skip("Prism tests are disabled") + + response = @image_kit.accounts.url_endpoints.update("id", description: "My custom URL endpoint") + + assert_pattern do + response => Imagekit::Accounts::URLEndpointResponse + end + + assert_pattern do + response => { + id: String, + description: String, + origins: ^(Imagekit::Internal::Type::ArrayOf[String]), + url_prefix: String, + url_rewriter: Imagekit::Accounts::URLEndpointResponse::URLRewriter | nil + } + end + end + + def test_list + skip("Prism tests are disabled") + + response = @image_kit.accounts.url_endpoints.list + + assert_pattern do + response => ^(Imagekit::Internal::Type::ArrayOf[Imagekit::Accounts::URLEndpointResponse]) + end + end + + def test_delete + skip("Prism tests are disabled") + + response = @image_kit.accounts.url_endpoints.delete("id") + + assert_pattern do + response => nil + end + end + + def test_get + skip("Prism tests are disabled") + + response = @image_kit.accounts.url_endpoints.get("id") + + assert_pattern do + response => Imagekit::Accounts::URLEndpointResponse + end + + assert_pattern do + response => { + id: String, + description: String, + origins: ^(Imagekit::Internal::Type::ArrayOf[String]), + url_prefix: String, + url_rewriter: Imagekit::Accounts::URLEndpointResponse::URLRewriter | nil + } + end + end +end diff --git a/test/imagekit/resources/accounts/usage_test.rb b/test/imagekit/resources/accounts/usage_test.rb new file mode 100644 index 00000000..30337d45 --- /dev/null +++ b/test/imagekit/resources/accounts/usage_test.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +require_relative "../../test_helper" + +class Imagekit::Test::Resources::Accounts::UsageTest < Imagekit::Test::ResourceTest + def test_get_required_params + skip("Prism tests are disabled") + + response = @image_kit.accounts.usage.get(end_date: "2019-12-27", start_date: "2019-12-27") + + assert_pattern do + response => Imagekit::Models::Accounts::UsageGetResponse + end + + assert_pattern do + response => { + bandwidth_bytes: Integer | nil, + extension_units_count: Integer | nil, + media_library_storage_bytes: Integer | nil, + original_cache_storage_bytes: Integer | nil, + video_processing_units_count: Integer | nil + } + end + end +end diff --git a/test/imagekit/resources/accounts_test.rb b/test/imagekit/resources/accounts_test.rb new file mode 100644 index 00000000..73ea1f30 --- /dev/null +++ b/test/imagekit/resources/accounts_test.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +require_relative "../test_helper" + +class Imagekit::Test::Resources::AccountsTest < Imagekit::Test::ResourceTest +end diff --git a/test/imagekit/resources/assets_test.rb b/test/imagekit/resources/assets_test.rb new file mode 100644 index 00000000..31121c1c --- /dev/null +++ b/test/imagekit/resources/assets_test.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require_relative "../test_helper" + +class Imagekit::Test::Resources::AssetsTest < Imagekit::Test::ResourceTest + def test_list + skip("Prism tests are disabled") + + response = @image_kit.assets.list + + assert_pattern do + response => ^(Imagekit::Internal::Type::ArrayOf[union: Imagekit::Models::AssetListResponseItem]) + end + end +end diff --git a/test/imagekit/resources/beta/v2/files_test.rb b/test/imagekit/resources/beta/v2/files_test.rb new file mode 100644 index 00000000..c664cb10 --- /dev/null +++ b/test/imagekit/resources/beta/v2/files_test.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true + +require_relative "../../../test_helper" + +class Imagekit::Test::Resources::Beta::V2::FilesTest < Imagekit::Test::ResourceTest + def test_upload_required_params + skip("Prism tests are disabled") + + response = @image_kit.beta.v2.files.upload(file: Pathname(__FILE__), file_name: "fileName") + + assert_pattern do + response => Imagekit::Models::Beta::V2::FileUploadResponse + end + + assert_pattern do + response => { + ai_tags: ^(Imagekit::Internal::Type::ArrayOf[Imagekit::Models::Beta::V2::FileUploadResponse::AITag]) | nil, + audio_codec: String | nil, + bit_rate: Integer | nil, + custom_coordinates: String | nil, + custom_metadata: ^(Imagekit::Internal::Type::HashOf[Imagekit::Internal::Type::Unknown]) | nil, + description: String | nil, + duration: Integer | nil, + embedded_metadata: ^(Imagekit::Internal::Type::HashOf[Imagekit::Internal::Type::Unknown]) | nil, + extension_status: Imagekit::Models::Beta::V2::FileUploadResponse::ExtensionStatus | nil, + file_id: String | nil, + file_path: String | nil, + file_type: String | nil, + height: Float | nil, + is_private_file: Imagekit::Internal::Type::Boolean | nil, + is_published: Imagekit::Internal::Type::Boolean | nil, + metadata: Imagekit::Metadata | nil, + name: String | nil, + size: Float | nil, + tags: ^(Imagekit::Internal::Type::ArrayOf[String]) | nil, + thumbnail_url: String | nil, + url: String | nil, + version_info: Imagekit::Models::Beta::V2::FileUploadResponse::VersionInfo | nil, + video_codec: String | nil, + width: Float | nil + } + end + end +end diff --git a/test/imagekit/resources/beta/v2_test.rb b/test/imagekit/resources/beta/v2_test.rb new file mode 100644 index 00000000..e35e2d0d --- /dev/null +++ b/test/imagekit/resources/beta/v2_test.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +require_relative "../../test_helper" + +class Imagekit::Test::Resources::Beta::V2Test < Imagekit::Test::ResourceTest +end diff --git a/test/imagekit/resources/beta_test.rb b/test/imagekit/resources/beta_test.rb new file mode 100644 index 00000000..9118a6f1 --- /dev/null +++ b/test/imagekit/resources/beta_test.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +require_relative "../test_helper" + +class Imagekit::Test::Resources::BetaTest < Imagekit::Test::ResourceTest +end diff --git a/test/imagekit/resources/cache/invalidation_test.rb b/test/imagekit/resources/cache/invalidation_test.rb new file mode 100644 index 00000000..e732093a --- /dev/null +++ b/test/imagekit/resources/cache/invalidation_test.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +require_relative "../../test_helper" + +class Imagekit::Test::Resources::Cache::InvalidationTest < Imagekit::Test::ResourceTest + def test_create_required_params + skip("Prism tests are disabled") + + response = + @image_kit.cache.invalidation.create(url: "https://ik.imagekit.io/your_imagekit_id/default-image.jpg") + + assert_pattern do + response => Imagekit::Models::Cache::InvalidationCreateResponse + end + + assert_pattern do + response => { + request_id: String | nil + } + end + end + + def test_get + skip("Prism tests are disabled") + + response = @image_kit.cache.invalidation.get("requestId") + + assert_pattern do + response => Imagekit::Models::Cache::InvalidationGetResponse + end + + assert_pattern do + response => { + status: Imagekit::Models::Cache::InvalidationGetResponse::Status | nil + } + end + end +end diff --git a/test/imagekit/resources/cache_test.rb b/test/imagekit/resources/cache_test.rb new file mode 100644 index 00000000..5844ad3c --- /dev/null +++ b/test/imagekit/resources/cache_test.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +require_relative "../test_helper" + +class Imagekit::Test::Resources::CacheTest < Imagekit::Test::ResourceTest +end diff --git a/test/imagekit/resources/custom_metadata_fields_test.rb b/test/imagekit/resources/custom_metadata_fields_test.rb new file mode 100644 index 00000000..c87be2e5 --- /dev/null +++ b/test/imagekit/resources/custom_metadata_fields_test.rb @@ -0,0 +1,70 @@ +# frozen_string_literal: true + +require_relative "../test_helper" + +class Imagekit::Test::Resources::CustomMetadataFieldsTest < Imagekit::Test::ResourceTest + def test_create_required_params + skip("Prism tests are disabled") + + response = + @image_kit.custom_metadata_fields.create(label: "price", name: "price", schema: {type: :Number}) + + assert_pattern do + response => Imagekit::CustomMetadataField + end + + assert_pattern do + response => { + id: String, + label: String, + name: String, + schema: Imagekit::CustomMetadataField::Schema + } + end + end + + def test_update + skip("Prism tests are disabled") + + response = @image_kit.custom_metadata_fields.update("id") + + assert_pattern do + response => Imagekit::CustomMetadataField + end + + assert_pattern do + response => { + id: String, + label: String, + name: String, + schema: Imagekit::CustomMetadataField::Schema + } + end + end + + def test_list + skip("Prism tests are disabled") + + response = @image_kit.custom_metadata_fields.list + + assert_pattern do + response => ^(Imagekit::Internal::Type::ArrayOf[Imagekit::CustomMetadataField]) + end + end + + def test_delete + skip("Prism tests are disabled") + + response = @image_kit.custom_metadata_fields.delete("id") + + assert_pattern do + response => Imagekit::Models::CustomMetadataFieldDeleteResponse + end + + assert_pattern do + response => { + **_ + } + end + end +end diff --git a/test/imagekit/resources/files/bulk_test.rb b/test/imagekit/resources/files/bulk_test.rb new file mode 100644 index 00000000..dc86a12b --- /dev/null +++ b/test/imagekit/resources/files/bulk_test.rb @@ -0,0 +1,82 @@ +# frozen_string_literal: true + +require_relative "../../test_helper" + +class Imagekit::Test::Resources::Files::BulkTest < Imagekit::Test::ResourceTest + def test_delete_required_params + skip("Prism tests are disabled") + + response = + @image_kit.files.bulk.delete(file_ids: %w[598821f949c0a938d57563bd 598821f949c0a938d57563be]) + + assert_pattern do + response => Imagekit::Models::Files::BulkDeleteResponse + end + + assert_pattern do + response => { + successfully_deleted_file_ids: ^(Imagekit::Internal::Type::ArrayOf[String]) | nil + } + end + end + + def test_add_tags_required_params + skip("Prism tests are disabled") + + response = + @image_kit.files.bulk.add_tags( + file_ids: %w[598821f949c0a938d57563bd 598821f949c0a938d57563be], + tags: %w[t-shirt round-neck sale2019] + ) + + assert_pattern do + response => Imagekit::Models::Files::BulkAddTagsResponse + end + + assert_pattern do + response => { + successfully_updated_file_ids: ^(Imagekit::Internal::Type::ArrayOf[String]) | nil + } + end + end + + def test_remove_ai_tags_required_params + skip("Prism tests are disabled") + + response = + @image_kit.files.bulk.remove_ai_tags( + ai_tags: %w[t-shirt round-neck sale2019], + file_ids: %w[598821f949c0a938d57563bd 598821f949c0a938d57563be] + ) + + assert_pattern do + response => Imagekit::Models::Files::BulkRemoveAITagsResponse + end + + assert_pattern do + response => { + successfully_updated_file_ids: ^(Imagekit::Internal::Type::ArrayOf[String]) | nil + } + end + end + + def test_remove_tags_required_params + skip("Prism tests are disabled") + + response = + @image_kit.files.bulk.remove_tags( + file_ids: %w[598821f949c0a938d57563bd 598821f949c0a938d57563be], + tags: %w[t-shirt round-neck sale2019] + ) + + assert_pattern do + response => Imagekit::Models::Files::BulkRemoveTagsResponse + end + + assert_pattern do + response => { + successfully_updated_file_ids: ^(Imagekit::Internal::Type::ArrayOf[String]) | nil + } + end + end +end diff --git a/test/imagekit/resources/files/metadata_test.rb b/test/imagekit/resources/files/metadata_test.rb new file mode 100644 index 00000000..9a60e643 --- /dev/null +++ b/test/imagekit/resources/files/metadata_test.rb @@ -0,0 +1,63 @@ +# frozen_string_literal: true + +require_relative "../../test_helper" + +class Imagekit::Test::Resources::Files::MetadataTest < Imagekit::Test::ResourceTest + def test_get + skip("Prism tests are disabled") + + response = @image_kit.files.metadata.get("fileId") + + assert_pattern do + response => Imagekit::Metadata + end + + assert_pattern do + response => { + audio_codec: String | nil, + bit_rate: Integer | nil, + density: Integer | nil, + duration: Integer | nil, + exif: Imagekit::Metadata::Exif | nil, + format_: String | nil, + has_color_profile: Imagekit::Internal::Type::Boolean | nil, + has_transparency: Imagekit::Internal::Type::Boolean | nil, + height: Integer | nil, + p_hash: String | nil, + quality: Integer | nil, + size: Integer | nil, + video_codec: String | nil, + width: Integer | nil + } + end + end + + def test_get_from_url_required_params + skip("Prism tests are disabled") + + response = @image_kit.files.metadata.get_from_url(url: "https://example.com") + + assert_pattern do + response => Imagekit::Metadata + end + + assert_pattern do + response => { + audio_codec: String | nil, + bit_rate: Integer | nil, + density: Integer | nil, + duration: Integer | nil, + exif: Imagekit::Metadata::Exif | nil, + format_: String | nil, + has_color_profile: Imagekit::Internal::Type::Boolean | nil, + has_transparency: Imagekit::Internal::Type::Boolean | nil, + height: Integer | nil, + p_hash: String | nil, + quality: Integer | nil, + size: Integer | nil, + video_codec: String | nil, + width: Integer | nil + } + end + end +end diff --git a/test/imagekit/resources/files/versions_test.rb b/test/imagekit/resources/files/versions_test.rb new file mode 100644 index 00000000..cb25fb21 --- /dev/null +++ b/test/imagekit/resources/files/versions_test.rb @@ -0,0 +1,105 @@ +# frozen_string_literal: true + +require_relative "../../test_helper" + +class Imagekit::Test::Resources::Files::VersionsTest < Imagekit::Test::ResourceTest + def test_list + skip("Prism tests are disabled") + + response = @image_kit.files.versions.list("fileId") + + assert_pattern do + response => ^(Imagekit::Internal::Type::ArrayOf[Imagekit::File]) + end + end + + def test_delete_required_params + skip("Prism tests are disabled") + + response = @image_kit.files.versions.delete("versionId", file_id: "fileId") + + assert_pattern do + response => Imagekit::Models::Files::VersionDeleteResponse + end + + assert_pattern do + response => { + **_ + } + end + end + + def test_get_required_params + skip("Prism tests are disabled") + + response = @image_kit.files.versions.get("versionId", file_id: "fileId") + + assert_pattern do + response => Imagekit::File + end + + assert_pattern do + response => { + ai_tags: ^(Imagekit::Internal::Type::ArrayOf[Imagekit::File::AITag]) | nil, + created_at: Time | nil, + custom_coordinates: String | nil, + custom_metadata: ^(Imagekit::Internal::Type::HashOf[Imagekit::Internal::Type::Unknown]) | nil, + description: String | nil, + file_id: String | nil, + file_path: String | nil, + file_type: String | nil, + has_alpha: Imagekit::Internal::Type::Boolean | nil, + height: Float | nil, + is_private_file: Imagekit::Internal::Type::Boolean | nil, + is_published: Imagekit::Internal::Type::Boolean | nil, + mime: String | nil, + name: String | nil, + size: Float | nil, + tags: ^(Imagekit::Internal::Type::ArrayOf[String]) | nil, + thumbnail: String | nil, + type: Imagekit::File::Type | nil, + updated_at: Time | nil, + url: String | nil, + version_info: Imagekit::File::VersionInfo | nil, + width: Float | nil + } + end + end + + def test_restore_required_params + skip("Prism tests are disabled") + + response = @image_kit.files.versions.restore("versionId", file_id: "fileId") + + assert_pattern do + response => Imagekit::File + end + + assert_pattern do + response => { + ai_tags: ^(Imagekit::Internal::Type::ArrayOf[Imagekit::File::AITag]) | nil, + created_at: Time | nil, + custom_coordinates: String | nil, + custom_metadata: ^(Imagekit::Internal::Type::HashOf[Imagekit::Internal::Type::Unknown]) | nil, + description: String | nil, + file_id: String | nil, + file_path: String | nil, + file_type: String | nil, + has_alpha: Imagekit::Internal::Type::Boolean | nil, + height: Float | nil, + is_private_file: Imagekit::Internal::Type::Boolean | nil, + is_published: Imagekit::Internal::Type::Boolean | nil, + mime: String | nil, + name: String | nil, + size: Float | nil, + tags: ^(Imagekit::Internal::Type::ArrayOf[String]) | nil, + thumbnail: String | nil, + type: Imagekit::File::Type | nil, + updated_at: Time | nil, + url: String | nil, + version_info: Imagekit::File::VersionInfo | nil, + width: Float | nil + } + end + end +end diff --git a/test/imagekit/resources/files_test.rb b/test/imagekit/resources/files_test.rb new file mode 100644 index 00000000..c09eb4bb --- /dev/null +++ b/test/imagekit/resources/files_test.rb @@ -0,0 +1,151 @@ +# frozen_string_literal: true + +require_relative "../test_helper" + +class Imagekit::Test::Resources::FilesTest < Imagekit::Test::ResourceTest + def test_update + skip("Prism tests are disabled") + + response = @image_kit.files.update("fileId") + + assert_pattern do + response => Imagekit::Models::FileUpdateResponse + end + end + + def test_delete + skip("Prism tests are disabled") + + response = @image_kit.files.delete("fileId") + + assert_pattern do + response => nil + end + end + + def test_copy_required_params + skip("Prism tests are disabled") + + response = + @image_kit.files.copy(destination_path: "/folder/to/copy/into/", source_file_path: "/path/to/file.jpg") + + assert_pattern do + response => Imagekit::Models::FileCopyResponse + end + + assert_pattern do + response => { + **_ + } + end + end + + def test_get + skip("Prism tests are disabled") + + response = @image_kit.files.get("fileId") + + assert_pattern do + response => Imagekit::File + end + + assert_pattern do + response => { + ai_tags: ^(Imagekit::Internal::Type::ArrayOf[Imagekit::File::AITag]) | nil, + created_at: Time | nil, + custom_coordinates: String | nil, + custom_metadata: ^(Imagekit::Internal::Type::HashOf[Imagekit::Internal::Type::Unknown]) | nil, + description: String | nil, + file_id: String | nil, + file_path: String | nil, + file_type: String | nil, + has_alpha: Imagekit::Internal::Type::Boolean | nil, + height: Float | nil, + is_private_file: Imagekit::Internal::Type::Boolean | nil, + is_published: Imagekit::Internal::Type::Boolean | nil, + mime: String | nil, + name: String | nil, + size: Float | nil, + tags: ^(Imagekit::Internal::Type::ArrayOf[String]) | nil, + thumbnail: String | nil, + type: Imagekit::File::Type | nil, + updated_at: Time | nil, + url: String | nil, + version_info: Imagekit::File::VersionInfo | nil, + width: Float | nil + } + end + end + + def test_move_required_params + skip("Prism tests are disabled") + + response = + @image_kit.files.move(destination_path: "/folder/to/move/into/", source_file_path: "/path/to/file.jpg") + + assert_pattern do + response => Imagekit::Models::FileMoveResponse + end + + assert_pattern do + response => { + **_ + } + end + end + + def test_rename_required_params + skip("Prism tests are disabled") + + response = @image_kit.files.rename(file_path: "/path/to/file.jpg", new_file_name: "newFileName.jpg") + + assert_pattern do + response => Imagekit::Models::FileRenameResponse + end + + assert_pattern do + response => { + purge_request_id: String | nil + } + end + end + + def test_upload_required_params + skip("Prism tests are disabled") + + response = @image_kit.files.upload(file: Pathname(__FILE__), file_name: "fileName") + + assert_pattern do + response => Imagekit::Models::FileUploadResponse + end + + assert_pattern do + response => { + ai_tags: ^(Imagekit::Internal::Type::ArrayOf[Imagekit::Models::FileUploadResponse::AITag]) | nil, + audio_codec: String | nil, + bit_rate: Integer | nil, + custom_coordinates: String | nil, + custom_metadata: ^(Imagekit::Internal::Type::HashOf[Imagekit::Internal::Type::Unknown]) | nil, + description: String | nil, + duration: Integer | nil, + embedded_metadata: ^(Imagekit::Internal::Type::HashOf[Imagekit::Internal::Type::Unknown]) | nil, + extension_status: Imagekit::Models::FileUploadResponse::ExtensionStatus | nil, + file_id: String | nil, + file_path: String | nil, + file_type: String | nil, + height: Float | nil, + is_private_file: Imagekit::Internal::Type::Boolean | nil, + is_published: Imagekit::Internal::Type::Boolean | nil, + metadata: Imagekit::Metadata | nil, + name: String | nil, + size: Float | nil, + tags: ^(Imagekit::Internal::Type::ArrayOf[String]) | nil, + thumbnail_url: String | nil, + url: String | nil, + version_info: Imagekit::Models::FileUploadResponse::VersionInfo | nil, + video_codec: String | nil, + width: Float | nil + } + end + end +end diff --git a/test/imagekit/resources/folders/job_test.rb b/test/imagekit/resources/folders/job_test.rb new file mode 100644 index 00000000..6521e30e --- /dev/null +++ b/test/imagekit/resources/folders/job_test.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +require_relative "../../test_helper" + +class Imagekit::Test::Resources::Folders::JobTest < Imagekit::Test::ResourceTest + def test_get + skip("Prism tests are disabled") + + response = @image_kit.folders.job.get("jobId") + + assert_pattern do + response => Imagekit::Models::Folders::JobGetResponse + end + + assert_pattern do + response => { + job_id: String | nil, + purge_request_id: String | nil, + status: Imagekit::Models::Folders::JobGetResponse::Status | nil, + type: Imagekit::Models::Folders::JobGetResponse::Type | nil + } + end + end +end diff --git a/test/imagekit/resources/folders_test.rb b/test/imagekit/resources/folders_test.rb new file mode 100644 index 00000000..4e5e4e43 --- /dev/null +++ b/test/imagekit/resources/folders_test.rb @@ -0,0 +1,93 @@ +# frozen_string_literal: true + +require_relative "../test_helper" + +class Imagekit::Test::Resources::FoldersTest < Imagekit::Test::ResourceTest + def test_create_required_params + skip("Prism tests are disabled") + + response = @image_kit.folders.create(folder_name: "summer", parent_folder_path: "/product/images/") + + assert_pattern do + response => Imagekit::Models::FolderCreateResponse + end + + assert_pattern do + response => { + **_ + } + end + end + + def test_delete_required_params + skip("Prism tests are disabled") + + response = @image_kit.folders.delete(folder_path: "/folder/to/delete/") + + assert_pattern do + response => Imagekit::Models::FolderDeleteResponse + end + + assert_pattern do + response => { + **_ + } + end + end + + def test_copy_required_params + skip("Prism tests are disabled") + + response = + @image_kit.folders.copy( + destination_path: "/path/of/destination/folder", + source_folder_path: "/path/of/source/folder" + ) + + assert_pattern do + response => Imagekit::Models::FolderCopyResponse + end + + assert_pattern do + response => { + job_id: String + } + end + end + + def test_move_required_params + skip("Prism tests are disabled") + + response = + @image_kit.folders.move( + destination_path: "/path/of/destination/folder", + source_folder_path: "/path/of/source/folder" + ) + + assert_pattern do + response => Imagekit::Models::FolderMoveResponse + end + + assert_pattern do + response => { + job_id: String + } + end + end + + def test_rename_required_params + skip("Prism tests are disabled") + + response = @image_kit.folders.rename(folder_path: "/path/of/folder", new_folder_name: "new-folder-name") + + assert_pattern do + response => Imagekit::Models::FolderRenameResponse + end + + assert_pattern do + response => { + job_id: String + } + end + end +end diff --git a/test/imagekit/resources/shared_test.rb b/test/imagekit/resources/shared_test.rb new file mode 100644 index 00000000..be22f0e4 --- /dev/null +++ b/test/imagekit/resources/shared_test.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +require_relative "../test_helper" + +class Imagekit::Test::Resources::SharedTest < Imagekit::Test::ResourceTest +end diff --git a/test/imagekit/resources/webhooks_test.rb b/test/imagekit/resources/webhooks_test.rb new file mode 100644 index 00000000..2b78db80 --- /dev/null +++ b/test/imagekit/resources/webhooks_test.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +require_relative "../test_helper" + +class Imagekit::Test::Resources::WebhooksTest < Imagekit::Test::ResourceTest +end diff --git a/test/imagekit/spec_helper.rb b/test/imagekit/spec_helper.rb deleted file mode 100644 index 433b4162..00000000 --- a/test/imagekit/spec_helper.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'simplecov' -SimpleCov.start 'rails' - -# require 'codecov' -# SimpleCov.formatter = SimpleCov::Formatter::Codecov - -require 'base64' -require 'rspec' -require 'webmock/rspec' -require 'carrierwave' -require 'byebug' -require 'active_storage' -require "rspec/autorun" - -require_relative '../../lib/imagekitio' diff --git a/test/imagekit/test_helper.rb b/test/imagekit/test_helper.rb new file mode 100644 index 00000000..56fd104f --- /dev/null +++ b/test/imagekit/test_helper.rb @@ -0,0 +1,91 @@ +# frozen_string_literal: true + +# Requiring this file from each test file ensures we always do the following, even +# when running a single-file test: +# - Load the whole gem (as one would in production) +# - Define shared testing namespace so that we don't need to indent test files as much +# - Setting up testing dependencies + +require "digest" +require "singleton" + +require "async" +require "minitest/autorun" +require "minitest/focus" +require "minitest/hooks/test" +require "minitest/proveit" +require "minitest/rg" +require "webmock" + +require_relative "../../lib/imagekit" +require_relative "resource_namespaces" + +module Kernel + alias_method :_sleep, :sleep + + def sleep(secs) + case Thread.current.thread_variable_get(:mock_sleep) + in Array => counter + counter << secs + secs + else + _sleep(secs) + end + end +end + +class Time + class << self + alias_method :_now, :now + end + + def self.now = Thread.current.thread_variable_get(:time_now) || _now +end + +class Imagekit::Test::SingletonClient < Imagekit::Client + include Singleton + + TEST_API_BASE_URL = ENV.fetch("TEST_API_BASE_URL", "http://localhost:4010") + + def initialize + super( + base_url: Imagekit::Test::SingletonClient::TEST_API_BASE_URL, + private_key: "My Private Key", + password: "My Password" + ) + end +end + +module Minitest::Serial + def test_order = :random + + def run_one_method(...) = Minitest::Runnable.run_one_method(...) +end + +class Minitest::Test + include Minitest::Hooks + + make_my_diffs_pretty! + parallelize_me! + prove_it! +end + +class Imagekit::Test::ResourceTest < Minitest::Test + def async? + return @async unless @async.nil? + @async = Digest::SHA256.hexdigest(self.class.name).to_i(16).odd? + end + + def before_all + super + @image_kit = Imagekit::Test::SingletonClient.instance + end + + def around_all = async? ? Sync { super } : super + + def around = async? ? Async { super }.wait : super +end + +module WebMock + AssertionFailure.error_class = Minitest::Assertion +end diff --git a/test/imagekit/url_test.rb b/test/imagekit/url_test.rb deleted file mode 100644 index 88b6051c..00000000 --- a/test/imagekit/url_test.rb +++ /dev/null @@ -1,444 +0,0 @@ -require_relative "./spec_helper" -require "rspec/autorun" - -RSpec.describe ImageKitIo::Url do - let(:request_obj) { ImageKitIo::Request.new(@private_key, @public_key, @url_endpoint) } - let(:url_obj) { ImageKitIo::Url.new(request_obj) } - - before(:each) do - @private_key = 'private_key_xyz' - @public_key = 'public_key_xyz' - @url_endpoint = 'https://imagekit.io/your-imgekit-id' - end - describe "TestGenerateUrl" do - it "test_request_init" do - expect(request_obj.private_key).to eq(@private_key) - end - - it "test_generate_url_without_transformations" do - - options = { path: "/default-image.jpg", - url_endpoint: @url_endpoint, - } - url = url_obj.generate_url(options) - - expect(url).to eq("https://imagekit.io/your-imgekit-id/default-image.jpg") - end - - it "test_generate_url_with_path" do - - options = { path: "/default-image.jpg", - url_endpoint: @url_endpoint, - transformation: [{ height: 300, width: 400 }], - } - url = url_obj.generate_url(options) - - expect(url).to eq("https://imagekit.io/your-imgekit-id/tr:h-300,w-400/default-image.jpg") - end - - it "test_generate_url_with_path_with_special_characters" do - - options = { path: "/γειασας/Fjällräven_KnSJwp87u6q.png", - url_endpoint: @url_endpoint, - transformation: [{ height: 300, width: 400 }], - } - url = url_obj.generate_url(options) - - expect(url).to eq("https://imagekit.io/your-imgekit-id/tr:h-300,w-400/γειασας/Fjällräven_KnSJwp87u6q.png") - end - - it "test_generate_url_without_slash" do - options = { path: "default-image.jpg", - url_endpoint: @url_endpoint, - transformation: [{ height: 300, width: 400 }], - } - url = url_obj.generate_url(options) - - expect(url).to eq("https://imagekit.io/your-imgekit-id/tr:h-300,w-400/default-image.jpg") - end - - it "test_generate_url_with_path_without_slash_with_special_characters" do - - options = { path: "γειασας/Fjällräven_KnSJwp87u6q.png", - url_endpoint: @url_endpoint, - transformation: [{ height: 300, width: 400 }], - } - url = url_obj.generate_url(options) - - expect(url).to eq("https://imagekit.io/your-imgekit-id/tr:h-300,w-400/γειασας/Fjällräven_KnSJwp87u6q.png") - end - - it "test_generate_url_with_override_url_endpoint_without_slash" do - options = { path: "/default-image.jpg", - url_endpoint: "https://ik.imagekit.io/your_override_imagekit_id", - transformation: [{ height: 300, width: 400 }], - } - url = url_obj.generate_url(options) - - expect(url).to eq("https://ik.imagekit.io/your_override_imagekit_id/tr:h-300,w-400/default-image.jpg") - end - - it "test_generate_url_with_override_url_endpoint_without_slash_with_special_characters" do - options = { path: "/γειασας/Fjällräven_KnSJwp87u6q.png", - url_endpoint: "https://ik.imagekit.io/your_override_imagekit_id", - transformation: [{ height: 300, width: 400 }], - } - url = url_obj.generate_url(options) - - expect(url).to eq("https://ik.imagekit.io/your_override_imagekit_id/tr:h-300,w-400/γειασας/Fjällräven_KnSJwp87u6q.png") - end - - it "test_generate_url_with_override_url_endpoint_with_slash" do - - options = { path: "/default-image.jpg", - url_endpoint: "https://ik.imagekit.io/your_override_imagekit_id/", - transformation: [{ height: 300, width: 400 }], - } - url = url_obj.generate_url(options) - - expect(url).to eq("https://ik.imagekit.io/your_override_imagekit_id/tr:h-300,w-400/default-image.jpg") - end - - it "test_generate_url_with_override_url_endpoint_with_slash_with_special_characters" do - options = { path: "/γειασας/Fjällräven_KnSJwp87u6q.png", - url_endpoint: "https://ik.imagekit.io/your_override_imagekit_id/", - transformation: [{ height: 300, width: 400 }], - } - url = url_obj.generate_url(options) - - expect(url).to eq("https://ik.imagekit.io/your_override_imagekit_id/tr:h-300,w-400/γειασας/Fjällräven_KnSJwp87u6q.png") - end - - it "test_generate_url_with_override_url_endpoint_with_special_characters" do - options = { path: "/γειασας/Fjällräven_KnSJwp87u6q.png", - url_endpoint: "https://www.Fjällräven.com/your_override_imagekit_id/", - transformation: [{ height: 300, width: 400 }], - } - url = url_obj.generate_url(options) - - expect(url).to eq("https://www.Fjällräven.com/your_override_imagekit_id/tr:h-300,w-400/γειασας/Fjällräven_KnSJwp87u6q.png") - end - - it "test_generate_url_with_new_transformation_parameters" do - - options = { path: "default-image.jpg", - url_endpoint: @url_endpoint, - transformation: [{ height: 300, width: 400 }, { new_params: 100 }], - } - url = url_obj.generate_url(options) - expect(url).to eq("https://imagekit.io/your-imgekit-id/tr:h-300,w-400:new_params-100/default-image.jpg") - end - - it "test_generate_url_should_have_ik_sdk_version" do - - options = { path: "default-image.jpg", - url_endpoint: @url_endpoint, - transformation: [{ height: 300, width: 400 },] - } - url = url_obj.generate_url(options) - expect(url).to eq("https://imagekit.io/your-imgekit-id/tr:h-300,w-400/default-image.jpg") - end - - it "test_generate_url_should_have_transformation_parameters" do - - options = { path: "default-image.jpg", - url_endpoint: @url_endpoint, - transformation: [{ - height: 300, - width: 400, - aspect_ratio: '4-3', - quality: 40, - crop: 'force', - crop_mode: 'extract', - focus: 'left', - format: 'jpeg', - radius: 50, - bg: "A94D34", - border: "5-A94D34", - rotation: 90, - blur: 10, - named: "some_name", - progressive: true, - lossless: true, - trim: 5, - metadata: true, - color_profile: true, - default_image: "/folder/file.jpg", - dpr: 3, - effect_sharpen: 10, - effect_usm: "2-2-0.8-0.024", - effect_contrast: true, - effect_gray: true, - effect_shadow: 'bl-15_st-40_x-10_y-N5', - effect_gradient: 'from-red_to-white', - original: true, - raw: 'w-200,h-200' - },] - } - url = url_obj.generate_url(options) - expect(url).to eq("https://imagekit.io/your-imgekit-id/tr:h-300,w-400,ar-4-3,q-40,c-force,cm-extract,fo-left,f-jpeg,r-50,bg-A94D34,b-5-A94D34,rt-90,bl-10,n-some_name,pr-true,lo-true,t-5,md-true,cp-true,di-folder@@file.jpg,dpr-3,e-sharpen-10,e-usm-2-2-0.8-0.024,e-contrast-true,e-grayscale-true,e-shadow-bl-15_st-40_x-10_y-N5,e-gradient-from-red_to-white,orig-true,w-200,h-200/default-image.jpg") - end - - it "test_generate_url_with_chained_transformation" do - - options = { path: "default-image.jpg", - url_endpoint: @url_endpoint, - transformation: [{ height: 300, width: 400 }, { rotation: 90 }], - } - url = url_obj.generate_url(options) - expect(url).to eq("https://imagekit.io/your-imgekit-id/tr:h-300,w-400:rt-90/default-image.jpg") - end - - it "test_generate_url_transformation_parameters_setted_to_query" do - - options = { path: "default-image.jpg", - url_endpoint: @url_endpoint, - transformation: [{ height: 300, width: 400 }], - transformation_position: "query", - } - url = url_obj.generate_url(options) - - expect(url).to eq("https://imagekit.io/your-imgekit-id/default-image.jpg?tr=h-300,w-400") - end - - it "test_generate_url_with_special_characters_transformation_parameters_setted_to_query" do - - options = { path: "/γειασας/Fjällräven_KnSJwp87u6q.png", - url_endpoint: @url_endpoint, - transformation: [{ height: 300, width: 400 }], - transformation_position: "query", - } - url = url_obj.generate_url(options) - - expect(url).to eq("https://imagekit.io/your-imgekit-id/γειασας/Fjällräven_KnSJwp87u6q.png?tr=h-300,w-400") - end - - it "test_generate_url_with_query_parameters" do - - options = { path: "/default-image.jpg", - query_parameters: { "v": "123", "blank_parameter": "" }, - transformation: [{ height: 300, width: 400 }] - } - url = url_obj.generate_url(options) - - expect(url).to eq("https://imagekit.io/your-imgekit-id/tr:h-300,w-400/default-image.jpg?v=123&blank_parameter") - end - - it "test_generate_url_with_query_parameters_with_special_characters" do - - options = { path: "/default-image.jpg", - query_parameters: { "γειασας": "γειασας" }, - transformation: [{ height: 300, width: 400 }] - } - url = url_obj.generate_url(options) - - expect(url).to eq("https://imagekit.io/your-imgekit-id/tr:h-300,w-400/default-image.jpg?γειασας=γειασας") - end - - it 'test_generate_url_with_absolute_path' do - options = { path: "https://example.com/external-image.jpg", - query_parameters: { "γειασας": "γειασας" }, - transformation: [{ height: 300, width: 400 }] - } - url = url_obj.generate_url(options) - - expect(url).to eq("https://imagekit.io/your-imgekit-id/tr:h-300,w-400/https%3A%2F%2Fexample.com%2Fexternal-image.jpg?γειασας=γειασας") - end - - it "test_generate_url_with_src_checking_query_param_added" do - - options = { src: "https://ik.imagekit.io/ldt7znpgpjs/test_YhNhoRxWt.jpg?another=abc&xyz=888", - transformation: [{ height: "300", width: "400", }], - query_parameters: { "v": "123" }, - } - - url = url_obj.generate_url(options) - expect(url).to eq("https://ik.imagekit.io/ldt7znpgpjs/test_YhNhoRxWt.jpg?another=abc&xyz=888&v=123&tr=h-300,w-400") - end - - it "test_generate_url_with_path_checking_query_param_added" do - - options = { path: "/test_YhNhoRxWt.jpg?another=abc&xyz=888", - transformation: [{ height: "300", width: "400", }], - query_parameters: { "v": "123" }, - } - - url = url_obj.generate_url(options) - expect(url).to eq("https://imagekit.io/your-imgekit-id/tr:h-300,w-400/test_YhNhoRxWt.jpg?another=abc&xyz=888&v=123") - end - - it "test_generate_url_with_src" do - # Test url generation with src param - - options = { src: "https://ik.imagekit.io/ldt7znpgpjs/test_YhNhoRxWt.jpg", - transformation: [{ height: "300", - width: "400", - format: "jpg", - progressive: "true", - effect_sharpen: "-", - effect_contrast: "1", }, - { rotation: 90 },], - transformation_position: "query" } - - url = url_obj.generate_url(options) - - expect(url).to eq("https://ik.imagekit.io/ldt7znpgpjs/test_YhNhoRxWt.jpg?tr=h-300,w-400,f-jpg,pr-true,e-sharpen,e-contrast-1:rt-90") - - end - - it "test_generate_url_with_src_with_special_characters" do - # Test url generation with src param - - options = { src: "https://www.Fjällräve.com/γειασας/Fjällräven_KnSJwp87u6q.png", - transformation: [{ height: "300", - width: "400", - format: "jpg", - progressive: "true", - effect_sharpen: "-", - effect_contrast: "1", }, - { rotation: 90 },], - transformation_position: "query" } - - url = url_obj.generate_url(options) - - expect(url).to eq("https://www.Fjällräve.com/γειασας/Fjällräven_KnSJwp87u6q.png?tr=h-300,w-400,f-jpg,pr-true,e-sharpen,e-contrast-1:rt-90") - - end - - it "test_generate_url_with_src_and_query_parameters_is_path" do - - options = { src: "https://ik.imagekit.io/ldt7znpgpjs/test_YhNhoRxWt.jpg", - transformation: [{ height: "300", - width: "400", - format: "jpg", - progressive: "true", - effect_sharpen: "-", - effect_contrast: "1", }, - { rotation: 90 },], - transformation_position: "path" } - - url = url_obj.generate_url(options) - - expect(url).to eq("https://ik.imagekit.io/ldt7znpgpjs/test_YhNhoRxWt.jpg?tr=h-300,w-400,f-jpg,pr-true,e-sharpen,e-contrast-1:rt-90") - end - - it "test_generate_url_with_path_and_signed" do - - options = { path: "/default-image.jpg", - url_endpoint: "https://ik.imagekit.io/your_imagekit_id/endpoint/", - transformation: [{ height: "300", width: "400" }], - signed: true, } - - url = url_obj.generate_url(options) - - expect(url).to include("https://ik.imagekit.io/your_imagekit_id/endpoint/tr:h-300,w-400/default-image.jpg?ik-s=") - end - - it "test_generate_url_with_path_and_signed_with_special_characters" do - - options = { path: "/Fjällräven_KnSJwp87u6q.png", - url_endpoint: "https://ik.imagekit.io/your_imagekit_id/endpoint/", - transformation: [{ height: "300", width: "400" }], - signed: true, } - - url = url_obj.generate_url(options) - - expect(url).to include("https://ik.imagekit.io/your_imagekit_id/endpoint/tr:h-300,w-400/Fjällräven_KnSJwp87u6q.png?ik-s=") - end - - it 'test_generate_url_with_absolute_path_and_signed' do - allow(url_obj).to receive(:get_signature_timestamp).with(5) { 100 } - options = { path: "https://example.com/external-image.jpg", - query_parameters: { "γειασας": "γειασας" }, - transformation: [{ height: 300, width: 400 }], - signed: true, - expire_seconds: 5 - } - url = url_obj.generate_url(options) - - expect(url).to eq("https://imagekit.io/your-imgekit-id/tr:h-300,w-400/https%3A%2F%2Fexample.com%2Fexternal-image.jpg?γειασας=γειασας&ik-s=44c1295edb1dbc1d59216fba8994b4d3a36c61e2&ik-t=100") - end - - it "test_url_with_invalid_args_returns_as_it_is" do - - options = { path: "/default-image.jpg", - url_endpoint: @url_endpoint, - transformation: [{ height: "300", fake_field: "400" }], - } - url = url_obj.generate_url(options) - - expect(url).to eq("https://imagekit.io/your-imgekit-id/tr:h-300,fake_field-400/default-image.jpg") - end - - it "test_url_without_path_and_src_should_return_empty" do - - options = { url_endpoint: @url_endpoint, - transformation: { height: "300", width: 400 }, - signed: true, - } - url = url_obj.generate_url(options) - expect(url.to_s).to eq("") - end - - it "test_url_with_invalid_trans_pos" do - - options = { path: "/default-image.jpg", - url_endpoint: @url_endpoint, - transformation: [{ height: "300", fake: "400" }], - transformation_position: "fake", - signed: true, } - - expect { url_obj.generate_url(options) }.to raise_error(ArgumentError) - - end - - it "test_url_with_signed_without_seconds" do - request_obj = ImageKitIo::Request.new('private_key_test', 'public_key_test', 'https://test-domain.com/test-endpoint') - url_obj = ImageKitIo::Url.new(request_obj) - - options = { path: "/test-signed-url.png", - transformation: [{ width: 100 }], - signed: true, } - url = url_obj.generate_url(options) - - expect(url).to include("https://test-domain.com/test-endpoint/tr:w-100/test-signed-url.png?ik-s=") - end - - it "test_url_with_signed_with_seconds" do - request_obj = ImageKitIo::Request.new('private_key_test', 'public_key_test', 'https://test-domain.com/test-endpoint') - url_obj = ImageKitIo::Url.new(request_obj) - - options = { path: "/test-signed-url.png", - transformation: [{ width: 100 }], - expire_seconds: 100, - signed: true } - url = url_obj.generate_url(options) - - expect(url).to include("ik-t") - end - - it "test_get_signature_with_100_expire_seconds" do - - url = "https://test-domain.com/test-endpoint/tr:w-100/test-signed-url.png" - signature = url_obj.get_signature("private_key_test", url, "https://test-domain.com/test-endpoint/", 100) - expect(signature).to eq("5e5037a31a7121cbe2964e220b4338cc6e1ba66d") - end - - it "test_get_signature_expect_without_expire_seconds" do - - url = "https://test-domain.com/test-endpoint/tr:w-100/test-signed-url.png" - signature = url_obj.get_signature("private_key_test", url, "https://test-domain.com/test-endpoint/", 0) - - expect(signature).to eq("41b3075c40bc84147eb71b8b49ae7fbf349d0f00") - end - - it "test_get_signature_expect_without_expire_seconds_without_slash" do - - url = "https://test-domain.com/test-endpoint/tr:w-100/test-signed-url.png" - signature = url_obj.get_signature("private_key_test", url, "https://test-domain.com/test-endpoint", 0) - - expect(signature).to eq("41b3075c40bc84147eb71b8b49ae7fbf349d0f00") - end - - end -end diff --git a/test/imagekit/utils/calculation_test.rb b/test/imagekit/utils/calculation_test.rb deleted file mode 100644 index 239a53a9..00000000 --- a/test/imagekit/utils/calculation_test.rb +++ /dev/null @@ -1,68 +0,0 @@ -require_relative '../spec_helper' -require "rspec/autorun" - -RSpec.describe ImageKitIo::Utils::Calculation do - let(:subject) { described_class } - - it "is_valid_hex_with_valid_hex" do - result = subject.is_valid_hex('f06830ca9f1e3e90') - expect(true).to eq(result) - end - - it "is_valid_hex_with_invalid_hex" do - result = subject.is_valid_hex('f06830ca9f1e3e90$') - expect(false).to eq(result) - end - - it "hamming_distance_test_expect_0" do - result = subject.hamming_distance('f06830ca9f1e3e90', 'f06830ca9f1e3e90') - expect(0).to eq(result) - end - - it "hamming_distance_test_expect_17" do - result = subject.hamming_distance('2d5ad3936d2e015b', '2d6ed293db36a4fb') - expect(17).to eq(result) - end - - it "hamming_distance_test_expect_37" do - result = subject.hamming_distance('a4a65595ac94518b', '7838873e791f8400') - expect(37).to eq(result) - end - - it "get_authenticated_params_test_with_nil_expire_nill_token" do - allow(OpenSSL::HMAC).to receive(:hexdigest).and_return('my_signature') - result = subject.get_authenticated_params(nil, nil, 'private_key') - expect(nil).not_to eq(result[:token]) - expect(nil).not_to eq(result[:expire]) - expect('my_signature').to eq(result[:signature]) - end - - it "get_authenticated_params_test_with_nil_expire" do - allow(OpenSSL::HMAC).to receive(:hexdigest).and_return('my_signature') - result = subject.get_authenticated_params('my_token', nil, 'private_key') - expect('my_token').to eq(result[:token]) - expect(nil).not_to eq(result[:expire]) - expect('my_signature').to eq(result[:signature]) - end - - it "get_authenticated_params_test_with_hard_coded_params" do - result = subject.get_authenticated_params('your_token', 1582269249, 'private_key_test') - expect('your_token').to eq(result[:token]) - expect(nil).not_to eq(result[:expire]) - expect('e71bcd6031016b060d349d212e23e85c791decdd').to eq(result[:signature]) - end - - it "get_authenticated_params_test_with_nil_token" do - allow(OpenSSL::HMAC).to receive(:hexdigest).and_return('my_signature') - result = subject.get_authenticated_params(nil, nil, 'private_key') - expect(nil).not_to eq(result[:token]) - expect(nil).not_to eq(result[:expire]) - expect('my_signature').to eq(result[:signature]) - end - - it "get_authenticated_params_test_with_nil_private_key" do - allow(OpenSSL::HMAC).to receive(:hexdigest).and_return('my_signature') - result = subject.get_authenticated_params('your_token', 1582269249, nil) - expect(result).to eq(nil) - end -end diff --git a/test/imagekit/utils/formatter_test.rb b/test/imagekit/utils/formatter_test.rb deleted file mode 100644 index 13a470c5..00000000 --- a/test/imagekit/utils/formatter_test.rb +++ /dev/null @@ -1,21 +0,0 @@ -require_relative '../spec_helper' -require "rspec/autorun" - -RSpec.describe ImageKitIo::Utils::Formatter do - let(:subject) { described_class } - - it "snake_to_camel_test" do - result=subject.snake_to_camel('my_snake_to_camel') - expect('mySnakeToCamel').to eq(result) - end - - it "camel_to_snake_test" do - result=subject.camel_to_snake('mySnakeToCamel') - expect('my_snake_to_camel').to eq(result) - end - - it "request_formatter_test" do - result =subject.request_formatter({'my_snake' => 'test'}) - expect('mySnake').to eq(result.keys.first) - end -end diff --git a/test/test_helper.rb b/test/test_helper.rb deleted file mode 100644 index 0ea9cca7..00000000 --- a/test/test_helper.rb +++ /dev/null @@ -1,20 +0,0 @@ -# Configure Rails Environment -ENV["RAILS_ENV"] = "test" - -require_relative "../test/dummy/config/environment" -ActiveRecord::Migrator.migrations_paths = [File.expand_path("../test/dummy/db/migrate", __dir__)] -require "rails/test_help" - -# Filter out the backtrace from minitest while preserving the one from other libraries. -Minitest.backtrace_filter = Minitest::BacktraceFilter.new - -require "rails/test_unit/reporter" -Rails::TestUnitReporter.executable = 'bin/test' - -# Load fixtures from the engine -if ActiveSupport::TestCase.respond_to?(:fixture_path=) - ActiveSupport::TestCase.fixture_path = File.expand_path("fixtures", __dir__) - ActionDispatch::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path - ActiveSupport::TestCase.file_fixture_path = ActiveSupport::TestCase.fixture_path + "/files" - ActiveSupport::TestCase.fixtures :all -end