Class: DirectusSDK::FilesApi

Inherits:
Object
  • Object
show all
Defined in:
lib/directus_sdk/api/files_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ FilesApi

Returns a new instance of FilesApi.



19
20
21
# File 'lib/directus_sdk/api/files_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/directus_sdk/api/files_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#create_file(opts = {}) ⇒ nil

Creates file

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :data (String)

    The file's Base64 content

  • :active (Integer)

    The file's status, default options are: 1 (active), 2 (inactive), 0 (deleted)

  • :name (String)

    The name used in the filesystem, including the extension, eg: "my-file.jpg". This is generated by the system based on Global Settings

  • :title (String)

    The file's title

  • :location (String)

    Location of where the picture was taken, if any. Pulled from the IPTC location when available

  • :type (String)

    The file's mime type

  • :tags (String)

    A CSV of tags for this file. Pulled from the IPTC keywords when available

  • :caption (String)

    The file's caption or description. Pulled from the IPTC description when available

Returns:

  • (nil)


35
36
37
38
# File 'lib/directus_sdk/api/files_api.rb', line 35

def create_file(opts = {})
  create_file_with_http_info(opts)
  return nil
end

#create_file_with_http_info(opts = {}) ⇒ Array<(nil, Fixnum, Hash)>

Creates file

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :data (String)

    The file&#39;s Base64 content

  • :active (Integer)

    The file&#39;s status, default options are: 1 (active), 2 (inactive), 0 (deleted)

  • :name (String)

    The name used in the filesystem, including the extension, eg: &quot;my-file.jpg&quot;. This is generated by the system based on Global Settings

  • :title (String)

    The file&#39;s title

  • :location (String)

    Location of where the picture was taken, if any. Pulled from the IPTC location when available

  • :type (String)

    The file&#39;s mime type

  • :tags (String)

    A CSV of tags for this file. Pulled from the IPTC keywords when available

  • :caption (String)

    The file&#39;s caption or description. Pulled from the IPTC description when available

Returns:

  • (Array<(nil, Fixnum, Hash)>)

    nil, response status code and response headers



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/directus_sdk/api/files_api.rb', line 52

def create_file_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: FilesApi.create_file ..."
  end
  # resource path
  local_var_path = "/files"

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])

  # form parameters
  form_params = {}
  form_params["data"] = opts[:'data'] if !opts[:'data'].nil?
  form_params["active"] = opts[:'active'] if !opts[:'active'].nil?
  form_params["name"] = opts[:'name'] if !opts[:'name'].nil?
  form_params["title"] = opts[:'title'] if !opts[:'title'].nil?
  form_params["location"] = opts[:'location'] if !opts[:'location'].nil?
  form_params["type"] = opts[:'type'] if !opts[:'type'].nil?
  form_params["tags"] = opts[:'tags'] if !opts[:'tags'].nil?
  form_params["caption"] = opts[:'caption'] if !opts[:'caption'].nil?

  # http body (model)
  post_body = nil
  auth_names = ['api_key']
  data, status_code, headers = @api_client.call_api(:POST, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: FilesApi#create_file\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_file(file_id, opts = {}) ⇒ GetFile

Returns specific file by id

Parameters:

  • file_id

    ID of file to get

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



100
101
102
103
# File 'lib/directus_sdk/api/files_api.rb', line 100

def get_file(file_id, opts = {})
  data, _status_code, _headers = get_file_with_http_info(file_id, opts)
  return data
end

#get_file_with_http_info(file_id, opts = {}) ⇒ Array<(GetFile, Fixnum, Hash)>

Returns specific file by id

Parameters:

  • file_id

    ID of file to get

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(GetFile, Fixnum, Hash)>)

    GetFile data, response status code and response headers



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/directus_sdk/api/files_api.rb', line 110

def get_file_with_http_info(file_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: FilesApi.get_file ..."
  end
  # verify the required parameter 'file_id' is set
  if @api_client.config.client_side_validation && file_id.nil?
    fail ArgumentError, "Missing the required parameter 'file_id' when calling FilesApi.get_file"
  end
  # resource path
  local_var_path = "/files/{fileId}".sub('{' + 'fileId' + '}', file_id.to_s)

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['api_key']
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'GetFile')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: FilesApi#get_file\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_files(opts = {}) ⇒ GetFiles

Returns files

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



152
153
154
155
# File 'lib/directus_sdk/api/files_api.rb', line 152

def get_files(opts = {})
  data, _status_code, _headers = get_files_with_http_info(opts)
  return data
end

#get_files_with_http_info(opts = {}) ⇒ Array<(GetFiles, Fixnum, Hash)>

Returns files

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(GetFiles, Fixnum, Hash)>)

    GetFiles data, response status code and response headers



161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# File 'lib/directus_sdk/api/files_api.rb', line 161

def get_files_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: FilesApi.get_files ..."
  end
  # resource path
  local_var_path = "/files"

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['api_key']
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'GetFiles')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: FilesApi#get_files\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#update_file(file_id, opts = {}) ⇒ nil

Creates file

Parameters:

  • file_id

    ID of file to get

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :data (String)

    The file&#39;s Base64 content

  • :active (Integer)

    The file&#39;s status, default options are: 1 (active), 2 (inactive), 0 (deleted)

  • :name (String)

    The name used in the filesystem, including the extension, eg: &quot;my-file.jpg&quot;. This is generated by the system based on Global Settings

  • :title (String)

    The file&#39;s title

  • :location (String)

    Location of where the picture was taken, if any. Pulled from the IPTC location when available

  • :type (String)

    The file&#39;s mime type

  • :tags (String)

    A CSV of tags for this file. Pulled from the IPTC keywords when available

  • :caption (String)

    The file&#39;s caption or description. Pulled from the IPTC description when available

  • :url (String)

    File url relativity to Directus base url

  • :width (Integer)

    File width

  • :height (Integer)

    File height

  • :size (Integer)

    File size in bytes

  • :embed_id (String)

    ID of the embedded file. Ex Youtube ID

  • :user (Integer)

    File owner (who uploaded the file)

  • :date_uploaded (String)

    File uploaded date. TODO It should be an DateTime object

  • :storage_adapter (String)

    Storage adapter used to upload the file

Returns:

  • (nil)


216
217
218
219
# File 'lib/directus_sdk/api/files_api.rb', line 216

def update_file(file_id, opts = {})
  update_file_with_http_info(file_id, opts)
  return nil
end

#update_file_with_http_info(file_id, opts = {}) ⇒ Array<(nil, Fixnum, Hash)>

Creates file

Parameters:

  • file_id

    ID of file to get

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :data (String)

    The file&#39;s Base64 content

  • :active (Integer)

    The file&#39;s status, default options are: 1 (active), 2 (inactive), 0 (deleted)

  • :name (String)

    The name used in the filesystem, including the extension, eg: &quot;my-file.jpg&quot;. This is generated by the system based on Global Settings

  • :title (String)

    The file&#39;s title

  • :location (String)

    Location of where the picture was taken, if any. Pulled from the IPTC location when available

  • :type (String)

    The file&#39;s mime type

  • :tags (String)

    A CSV of tags for this file. Pulled from the IPTC keywords when available

  • :caption (String)

    The file&#39;s caption or description. Pulled from the IPTC description when available

  • :url (String)

    File url relativity to Directus base url

  • :width (Integer)

    File width

  • :height (Integer)

    File height

  • :size (Integer)

    File size in bytes

  • :embed_id (String)

    ID of the embedded file. Ex Youtube ID

  • :user (Integer)

    File owner (who uploaded the file)

  • :date_uploaded (String)

    File uploaded date. TODO It should be an DateTime object

  • :storage_adapter (String)

    Storage adapter used to upload the file

Returns:

  • (Array<(nil, Fixnum, Hash)>)

    nil, response status code and response headers



242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
# File 'lib/directus_sdk/api/files_api.rb', line 242

def update_file_with_http_info(file_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: FilesApi.update_file ..."
  end
  # verify the required parameter 'file_id' is set
  if @api_client.config.client_side_validation && file_id.nil?
    fail ArgumentError, "Missing the required parameter 'file_id' when calling FilesApi.update_file"
  end
  # resource path
  local_var_path = "/files/{fileId}".sub('{' + 'fileId' + '}', file_id.to_s)

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])

  # form parameters
  form_params = {}
  form_params["data"] = opts[:'data'] if !opts[:'data'].nil?
  form_params["active"] = opts[:'active'] if !opts[:'active'].nil?
  form_params["name"] = opts[:'name'] if !opts[:'name'].nil?
  form_params["title"] = opts[:'title'] if !opts[:'title'].nil?
  form_params["location"] = opts[:'location'] if !opts[:'location'].nil?
  form_params["type"] = opts[:'type'] if !opts[:'type'].nil?
  form_params["tags"] = opts[:'tags'] if !opts[:'tags'].nil?
  form_params["caption"] = opts[:'caption'] if !opts[:'caption'].nil?
  form_params["url"] = opts[:'url'] if !opts[:'url'].nil?
  form_params["width"] = opts[:'width'] if !opts[:'width'].nil?
  form_params["height"] = opts[:'height'] if !opts[:'height'].nil?
  form_params["size"] = opts[:'size'] if !opts[:'size'].nil?
  form_params["embed_id"] = opts[:'embed_id'] if !opts[:'embed_id'].nil?
  form_params["user"] = opts[:'user'] if !opts[:'user'].nil?
  form_params["date_uploaded"] = opts[:'date_uploaded'] if !opts[:'date_uploaded'].nil?
  form_params["storage_adapter"] = opts[:'storage_adapter'] if !opts[:'storage_adapter'].nil?

  # http body (model)
  post_body = nil
  auth_names = ['api_key']
  data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: FilesApi#update_file\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end