Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AWS Rekognition Moderation add-on and update docs for rest of the Add-Ons #164

Merged
merged 4 commits into from
Apr 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

### Added
* Added `AWS Rekognition Moderation` Add-On.

### Changed
* File attribute `datetime_stored` is deprecated and will warn on usage from `File` object properties.

Expand Down
23 changes: 18 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -556,37 +556,50 @@ An `Add-On` is an application implemented by Uploadcare that accepts uploaded fi
##### AWS Rekognition

```ruby
# Execute AWS Rekognition Add-On for a given target to detect labels in an image. Note: Detected labels are stored in the file's appdata.
# Execute AWS Rekognition Add-On for a given target to detect labels in an image.
# Note: Detected labels are stored in the file's appdata.
Uploadcare::Addons.ws_rekognition_detect_labels('FILE_UUID')

# Check the status of AWS Rekognition.
Uploadcare::Addons.ws_rekognition_detect_labels_status('RETURNED_ID_FROM_WS_REKOGNITION_DETECT_LABELS')
```

##### AWS Rekognition Moderation

```ruby
# Execute AWS Rekognition Moderation Add-On for a given target to detect moderation labels in an image.
# Note: Detected moderation labels are stored in the file's appdata.

Uploadcare::Addons.ws_rekognition_detect_moderation_labels('FILE_UUID')

# Check the status of an Add-On execution request that had been started using the Execute Add-On operation.
Uploadcare::Addons.ws_rekognition_detect_moderation_labels_status('RETURNED_ID_FROM_WS_REKOGNITION_DETECT_MODERATION_LABELS')
```

##### ClamAV

```ruby
# ClamAV virus checking Add-On for a given target.
Uploadcare::Addons.uc_clamav_virus_scan('FILE_UUID')

# Checking and purge infected file.
# Check and purge infected file.
Uploadcare::Addons.uc_clamav_virus_scan('FILE_UUID', purge_infected: true )

# Check the status ClamAV virus scan.
# Check the status of an Add-On execution request that had been started using the Execute Add-On operation.
Uploadcare::Addons.uc_clamav_virus_scan_status('RETURNED_ID_FROM_UC_CLAMAV_VIRUS_SCAN')
```

##### Remove.bg

```ruby
# Remove background image removal Add-On for a given target.
# Execute remove.bg background image removal Add-On for a given target.
Uploadcare::Addons.remove_bg('FILE_UUID')

# You can pass optional parameters.
# See the full list of parameters here: https://uploadcare.com/api-refs/rest-api/v0.7.0/#operation/removeBgExecute
Uploadcare::Addons.remove_bg('FILE_UUID', crop: true, type_level: '2')

# Check the status of background image removal.
# Check the status of an Add-On execution request that had been started using the Execute Add-On operation.
Uploadcare::Addons.remove_bg_status('RETURNED_ID_FROM_REMOVE_BG')
```

Expand Down
13 changes: 13 additions & 0 deletions lib/uploadcare/client/addons_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,19 @@ def remove_bg_status(uuid)
get(uri: "/addons/remove_bg/execute/status/#{query_params(uuid)}")
end

# Execute AWS Rekognition Moderation Add-On for a given target to detect labels in an image.
# @see https://uploadcare.com/api-refs/rest-api/v0.7.0/#tag/Add-Ons/operation/awsRekognitionDetectModerationLabelsExecute
def ws_rekognition_detect_moderation_labels(uuid)
content = { target: uuid }.to_json
post(uri: '/addons/aws_rekognition_detect_moderation_labels/execute/', content: content)
end

# Check the status of an Add-On execution request that had been started using the Execute Add-On operation.
# @see https://uploadcare.com/api-refs/rest-api/v0.7.0/#tag/Add-Ons/operation/awsRekognitionDetectModerationLabelsExecutionStatus
def ws_rekognition_detect_moderation_labels_status(uuid)
get(uri: "/addons/aws_rekognition_detect_moderation_labels/execute/status/#{query_params(uuid)}")
end

private

def query_params(uuid)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions spec/uploadcare/client/addons_client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,26 @@ module Client
end
end
end

describe 'ws_rekognition_detect_moderation_labels' do
it 'executes aws rekognition' do
VCR.use_cassette('ws_rekognition_detect_moderation_labels') do
uuid = 'ff4d3d37-4de0-4f6d-a7db-8cdabe7fc768'
response = subject.ws_rekognition_detect_moderation_labels(uuid)
expect(response.success).to eq({ request_id: '0f4598dd-d168-4272-b49e-e7f9d2543542' })
end
end
end

describe 'ws_rekognition_detect_moderation_labels_status' do
it 'checking the status of a recognized file' do
VCR.use_cassette('ws_rekognition_detect_moderation_labels_status') do
uuid = '0f4598dd-d168-4272-b49e-e7f9d2543542'
response = subject.ws_rekognition_detect_moderation_labels_status(uuid)
expect(response.success).to eq({ status: 'done' })
end
end
end
end
end
end
Loading
Loading