Class: Imagekitio::Resources::NamedTransformations

Inherits:
Object
  • Object
show all
Defined in:
lib/imagekitio/resources/named_transformations.rb,
sig/imagekitio/resources/named_transformations.rbs

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ NamedTransformations

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of NamedTransformations.

Parameters:



146
147
148
# File 'lib/imagekitio/resources/named_transformations.rb', line 146

def initialize(client:)
  @client = client
end

Instance Method Details

#create(name:, transformation:, enabled: nil, request_options: {}) ⇒ Imagekitio::Models::NamedTransformation

Some parameter documentations has been truncated, see Models::NamedTransformationCreateParams for more details.

Creates a new named transformation and returns the created object.

A named transformation is a short, reusable name for a transformation string. Use it in image and video URLs as tr:n-<name>, and update the underlying transformation later without changing existing URLs. Learn more about named transformations.

You can create up to 250 named transformations per account.

Parameters:

  • name (String)

    Alias for the transformation string, used in URLs as tr:n-<name>. This is case

  • transformation (String)

    The transformation string this named transformation refers to. Learn more about

  • enabled (Boolean)

    Whether the named transformation is currently enabled. When set to false, requ

  • request_options (Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



31
32
33
34
35
36
37
38
39
40
# File 'lib/imagekitio/resources/named_transformations.rb', line 31

def create(params)
  parsed, options = Imagekitio::NamedTransformationCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "v1/named-transformations",
    body: parsed,
    model: Imagekitio::NamedTransformation,
    options: options
  )
end

#delete(id, request_options: {}) ⇒ nil

Permanently deletes the named transformation identified by id.

Deletion fails with a 409 error if the named transformation is still referenced (via the n-<name> token) by an upload pre-transformation or post-transformation setting. This check is best-effort and can't detect references in your own application code or in previously generated URLs.

Parameters:

  • id (String)

    Unique identifier for a named transformation.

  • request_options (Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil)
  • request_options: (Imagekitio::request_opts)

Returns:

  • (nil)

See Also:



114
115
116
117
118
119
120
121
# File 'lib/imagekitio/resources/named_transformations.rb', line 114

def delete(id, params = {})
  @client.request(
    method: :delete,
    path: ["v1/named-transformations/%1$s", id],
    model: NilClass,
    options: params[:request_options]
  )
end

#get(id, request_options: {}) ⇒ Imagekitio::Models::NamedTransformation

Retrieves the named transformation identified by id.

Parameters:

  • id (String)

    Unique identifier for a named transformation.

  • request_options (Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



134
135
136
137
138
139
140
141
# File 'lib/imagekitio/resources/named_transformations.rb', line 134

def get(id, params = {})
  @client.request(
    method: :get,
    path: ["v1/named-transformations/%1$s", id],
    model: Imagekitio::NamedTransformation,
    options: params[:request_options]
  )
end

#list(request_options: {}) ⇒ Array<Imagekitio::Models::NamedTransformation>

Returns an array of all named transformations configured for your account.

Parameters:

Returns:

See Also:



89
90
91
92
93
94
95
96
# File 'lib/imagekitio/resources/named_transformations.rb', line 89

def list(params = {})
  @client.request(
    method: :get,
    path: "v1/named-transformations",
    model: Imagekitio::Internal::Type::ArrayOf[Imagekitio::NamedTransformation],
    options: params[:request_options]
  )
end

#update(id, enabled: nil, name: nil, transformation: nil, request_options: {}) ⇒ Imagekitio::Models::NamedTransformation

Some parameter documentations has been truncated, see Models::NamedTransformationUpdateParams for more details.

Updates the named transformation identified by id and returns the updated object. Only the fields present in the request body are updated; other fields stay unchanged.

Renaming or disabling a named transformation fails with a 409 error if it is still referenced (via the n-<name> token) by an upload pre-transformation or post-transformation setting. This check is best-effort and can't detect references in your own application code or in previously generated URLs.

Parameters:

  • id (String)

    Unique identifier for a named transformation.

  • enabled (Boolean)

    Whether the named transformation is enabled. Omit to leave the current value unc

  • name (String)

    Alias for the transformation string, used in URLs as tr:n-<name>. This is case

  • transformation (String)

    The transformation string this named transformation refers to. Learn more about

  • request_options (Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



69
70
71
72
73
74
75
76
77
78
# File 'lib/imagekitio/resources/named_transformations.rb', line 69

def update(id, params = {})
  parsed, options = Imagekitio::NamedTransformationUpdateParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["v1/named-transformations/%1$s", id],
    body: parsed,
    model: Imagekitio::NamedTransformation,
    options: options
  )
end