Class: Imagekitio::Resources::Files::Versions

Inherits:
Object
  • Object
show all
Defined in:
lib/imagekitio/resources/files/versions.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Versions

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 Versions.

Parameters:



126
127
128
# File 'lib/imagekitio/resources/files/versions.rb', line 126

def initialize(client:)
  @client = client
end

Instance Method Details

#delete(version_id, file_id: , request_options: {}) ⇒ Imagekitio::Models::Files::VersionDeleteResponse

Some parameter documentations has been truncated, see 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.

Parameters:

  • version_id (String)

    The unique ‘versionId` of the uploaded file. `versionId` is returned in list and

  • file_id (String)

    The unique ‘fileId` of the uploaded file. `fileId` is returned in list and searc

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

Returns:

See Also:



49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/imagekitio/resources/files/versions.rb', line 49

def delete(version_id, params)
  parsed, options = Imagekitio::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: Imagekitio::Models::Files::VersionDeleteResponse,
    options: options
  )
end

#get(version_id, file_id: , request_options: {}) ⇒ Imagekitio::Models::File

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

This API returns an object with details or attributes of a file version.

Parameters:

  • version_id (String)

    The unique ‘versionId` of the uploaded file. `versionId` is returned in list and

  • file_id (String)

    The unique ‘fileId` of the uploaded file. `fileId` is returned in list and searc

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

Returns:

See Also:



79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/imagekitio/resources/files/versions.rb', line 79

def get(version_id, params)
  parsed, options = Imagekitio::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: Imagekitio::File,
    options: options
  )
end

#list(file_id, request_options: {}) ⇒ Array<Imagekitio::Models::File>

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

This API returns details of all versions of a file.

Parameters:

  • file_id (String)

    The unique ‘fileId` of the uploaded file. `fileId` is returned in list and searc

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

Returns:

See Also:



21
22
23
24
25
26
27
28
# File 'lib/imagekitio/resources/files/versions.rb', line 21

def list(file_id, params = {})
  @client.request(
    method: :get,
    path: ["v1/files/%1$s/versions", file_id],
    model: Imagekitio::Internal::Type::ArrayOf[Imagekitio::File],
    options: params[:request_options]
  )
end

#restore(version_id, file_id: , request_options: {}) ⇒ Imagekitio::Models::File

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

This API restores a file version as the current file version.

Parameters:

  • version_id (String)

    The unique ‘versionId` of the uploaded file. `versionId` is returned in list and

  • file_id (String)

    The unique ‘fileId` of the uploaded file. `fileId` is returned in list and searc

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

Returns:

See Also:



109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/imagekitio/resources/files/versions.rb', line 109

def restore(version_id, params)
  parsed, options = Imagekitio::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: Imagekitio::File,
    options: options
  )
end