Skip to content

cloudinary/account-provisioning-ruby

Repository files navigation

Cloudinary Account Provisioning Ruby SDK

Gem Version Gem Downloads License

Developer-friendly & type-safe Ruby SDK specifically catered to leverage the Cloudinary Account Provisioning API.

Summary

Cloudinary Account Provisioning API: Accounts with provisioning API access can create and manage their product environments, users and user groups using the RESTful Provisioning API.

Provisioning API access is available upon request for accounts on an Enterprise plan.

The API uses Basic Authentication over HTTPS. Your Account API Key and Account API Secret (previously referred to as Provisioning API keys) are used for the authentication. These credentials (as well as your ACCOUNT_ID) are located in the Cloudinary Console under Settings > Account API Keys.

The Provisioning API has dedicated SDKs for the following languages:

Useful links:

Accounts with Permissions API access can assign roles, made up of system policies, to control what principals (users, groups, and API keys) can do across the Cloudinary account and product environments. For more information about Cloudinary roles and permissions, see the Role-based permissions guide.

Permissions API access is available upon request for accounts on an Enterprise plan.

The API uses Basic Authentication over HTTPS. Your Account API Key and Account API Secret (previously referred to as Provisioning API keys) are used for the authentication. These credentials (as well as your ACCOUNT_ID) are located in the Cloudinary Console under Settings > Account API Keys.

Important:

Cloudinary's Roles and Permissions Management is now available as a Beta. This is an early stage release, and while it's functional and ready for real-world testing, it's subject to change as we continue refining the experience based on what we learn, including your feedback. During the Beta period, core functionality is considered stable, though some APIs, scopes, or response formats may evolve.

How you can help:

  • Use Roles and Permissions Management in real projects, prototypes, or tests.
  • Share feedback, issues, or ideas with our support team.

Thank you for exploring this early release and helping us shape these tools to best meet your needs.

Table of Contents

SDK Installation

The SDK can be installed using RubyGems:

gem install cloudinary-account-provisioning

SDK Example Usage

Example

require "cloudinary_account_provisioning"

Models = ::CldProvisioning::Models
s = ::CldProvisioning::CldProvisioning.new(
  account_id: "<id>",
  security: Models::Shared::Security.new(
    provisioning_api_key: "CLOUDINARY_PROVISIONING_API_KEY",
    provisioning_api_secret: "CLOUDINARY_PROVISIONING_API_SECRET"
  )
)

req = Models::Operations::GetProductEnvironmentsRequest.new(
  enabled: true,
  prefix: "product"
)
res = s.product_environments.list(request: req)

unless res.nil?
  # handle response
end

Authentication

Per-Client Security Schemes

This SDK supports the following security scheme globally:

Name Type Scheme Environment Variable
provisioning_api_key
provisioning_api_secret
http Custom HTTP CLOUDINARY_PROVISIONING_API_KEY
CLOUDINARY_PROVISIONING_API_SECRET

You can set the security parameters through the security optional parameter when initializing the SDK client instance. For example:

require "cloudinary_account_provisioning"

Models = ::CldProvisioning::Models
s = ::CldProvisioning::CldProvisioning.new(
  security: Models::Shared::Security.new(
    provisioning_api_key: "CLOUDINARY_PROVISIONING_API_KEY",
    provisioning_api_secret: "CLOUDINARY_PROVISIONING_API_SECRET"
  ),
  account_id: "<id>"
)

req = Models::Operations::GetProductEnvironmentsRequest.new(
  enabled: true,
  prefix: "product"
)
res = s.product_environments.list(request: req)

unless res.nil?
  # handle response
end

Available Resources and Operations

Available methods
  • get - Get billing usage information
  • list - Get custom policies
  • create - Create custom policy
  • get - Get custom policy
  • update - Update custom policy
  • delete - Delete custom policy
  • list - Get effective policies
  • list - Get product environments
  • create - Create product environment
  • get - Get product environment
  • update - Update product environment
  • delete - Delete product environment
  • list - Get system policies

Global Parameters

A parameter is configured globally. This parameter may be set on the SDK client instance itself during initialization. When configured as an option during SDK initialization, This global value will be used as the default on the operations that use it. When such operations are called, there is a place in each to override the global value, if needed.

For example, you can set account_id to '<id>' at SDK initialization and then you do not have to pass the same value on calls to operations like list. But if you want to do so you may, which will locally override the global setting. See the example code below for a demonstration.

Available Globals

The following global parameter is available. Global parameters can also be set via environment variable.

Name Type Description Environment
account_id ::String Account ID CLOUDINARY_ACCOUNT_ID

Example

require "cloudinary_account_provisioning"

Models = ::CldProvisioning::Models
s = ::CldProvisioning::CldProvisioning.new(
  account_id: "<id>",
  security: Models::Shared::Security.new(
    provisioning_api_key: "CLOUDINARY_PROVISIONING_API_KEY",
    provisioning_api_secret: "CLOUDINARY_PROVISIONING_API_SECRET"
  )
)

req = Models::Operations::GetProductEnvironmentsRequest.new(
  enabled: true,
  prefix: "product"
)
res = s.product_environments.list(request: req)

unless res.nil?
  # handle response
end

Error Handling

Handling errors in this SDK should largely match your expectations. All operations return a response object or raise an error.

By default an API error will raise a Errors::APIError, which has the following properties:

Property Type Description
message string The error message
status_code int The HTTP status code
raw_response Faraday::Response The raw HTTP response
body string The response content

When custom error responses are specified for an operation, the SDK may also throw their associated exception. You can refer to respective Errors tables in SDK docs for more details on possible exception types for each operation. For example, the list method throws the following exceptions:

Error Type Status Code Content Type
Models::Errors::ErrorResponse 400, 401, 403, 404, 409, 420, 429 application/json
Errors::APIError 4XX, 5XX */*

Example

require "cloudinary_account_provisioning"

Models = ::CldProvisioning::Models
s = ::CldProvisioning::CldProvisioning.new(
  account_id: "<id>",
  security: Models::Shared::Security.new(
    provisioning_api_key: "CLOUDINARY_PROVISIONING_API_KEY",
    provisioning_api_secret: "CLOUDINARY_PROVISIONING_API_SECRET"
  )
)

begin
  req = Models::Operations::GetProductEnvironmentsRequest.new(
    enabled: true,
    prefix: "product"
  )
  res = s.product_environments.list(request: req)

  unless res.nil?
    # handle response
  end

rescue Models::Errors::ErrorResponse => e
  # handle e.container data
  raise e
rescue Errors::APIError => e
  # handle default exception
  raise e
end

Server Selection

Select Server by Index

You can override the default server globally by passing a server index to the server_idx (Integer) optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the indexes associated with the available servers:

# Server Variables Description
0 https://{region}.cloudinary.com region Regional API endpoints for optimal performance.
1 https://{host} host Custom domains for enterprise deployments.

If the selected server has variables, you may override its default values through the additional parameters made available in the SDK constructor:

Variable Parameter Supported Values Default Description
region region (::CldProvisioning::Models::ServerVariables::ServerRegion) - "api"
- "api-eu"
- "api-ap"
"api" Regional endpoint selection
host host (::String) ::String "api.cloudinary.com" API host domain.

Example

require "cloudinary_account_provisioning"

Models = ::CldProvisioning::Models
s = ::CldProvisioning::CldProvisioning.new(
  server_idx: 0,
  region: "api-ap",
  account_id: "<id>",
  security: Models::Shared::Security.new(
    provisioning_api_key: "CLOUDINARY_PROVISIONING_API_KEY",
    provisioning_api_secret: "CLOUDINARY_PROVISIONING_API_SECRET"
  )
)

req = Models::Operations::GetProductEnvironmentsRequest.new(
  enabled: true,
  prefix: "product"
)
res = s.product_environments.list(request: req)

unless res.nil?
  # handle response
end

Override Server URL Per-Client

The default server can also be overridden globally by passing a URL to the server_url (String) optional parameter when initializing the SDK client instance. For example:

require "cloudinary_account_provisioning"

Models = ::CldProvisioning::Models
s = ::CldProvisioning::CldProvisioning.new(
  server_url: "https://api.cloudinary.com",
  account_id: "<id>",
  security: Models::Shared::Security.new(
    provisioning_api_key: "CLOUDINARY_PROVISIONING_API_KEY",
    provisioning_api_secret: "CLOUDINARY_PROVISIONING_API_SECRET"
  )
)

req = Models::Operations::GetProductEnvironmentsRequest.new(
  enabled: true,
  prefix: "product"
)
res = s.product_environments.list(request: req)

unless res.nil?
  # handle response
end

Development

Maturity

This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.

Contributions

While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation. We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.

SDK Created by Speakeasy

About

Cloudinary Account Provisioning Ruby SDK

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages