Class: PulpPythonClient::PypiLegacyApi

Inherits:
Object
  • Object
show all
Defined in:
lib/pulp_python_client/api/pypi_legacy_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ PypiLegacyApi

Returns a new instance of PypiLegacyApi.



19
20
21
# File 'lib/pulp_python_client/api/pypi_legacy_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/pulp_python_client/api/pypi_legacy_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#create(path, content, sha256_digest, opts = {}) ⇒ PackageUploadTaskResponse

Upload a package Upload package to the index. This is the endpoint that tools like Twine and Poetry use for their upload commands.

Parameters:

  • path (String)
  • content (File)

    A Python package release file to upload to the index.

  • sha256_digest (String)

    SHA256 of package to validate upload integrity.

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

    the optional parameters

Options Hash (opts):

  • :action (String)

    Defaults to `file_upload`, don't change it or request will fail! (default to ‘file_upload’)

Returns:



30
31
32
33
# File 'lib/pulp_python_client/api/pypi_legacy_api.rb', line 30

def create(path, content, sha256_digest, opts = {})
  data, _status_code, _headers = create_with_http_info(path, content, sha256_digest, opts)
  data
end

#create_with_http_info(path, content, sha256_digest, opts = {}) ⇒ Array<(PackageUploadTaskResponse, Integer, Hash)>

Upload a package Upload package to the index. This is the endpoint that tools like Twine and Poetry use for their upload commands.

Parameters:

  • path (String)
  • content (File)

    A Python package release file to upload to the index.

  • sha256_digest (String)

    SHA256 of package to validate upload integrity.

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

    the optional parameters

Options Hash (opts):

  • :action (String)

    Defaults to &#x60;file_upload&#x60;, don&#39;t change it or request will fail!

Returns:

  • (Array<(PackageUploadTaskResponse, Integer, Hash)>)

    PackageUploadTaskResponse data, response status code and response headers



43
44
45
46
47
48
49
50
51
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/pulp_python_client/api/pypi_legacy_api.rb', line 43

def create_with_http_info(path, content, sha256_digest, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: PypiLegacyApi.create ...'
  end
  # verify the required parameter 'path' is set
  if @api_client.config.client_side_validation && path.nil?
    fail ArgumentError, "Missing the required parameter 'path' when calling PypiLegacyApi.create"
  end
  # verify the required parameter 'content' is set
  if @api_client.config.client_side_validation && content.nil?
    fail ArgumentError, "Missing the required parameter 'content' when calling PypiLegacyApi.create"
  end
  # verify the required parameter 'sha256_digest' is set
  if @api_client.config.client_side_validation && sha256_digest.nil?
    fail ArgumentError, "Missing the required parameter 'sha256_digest' when calling PypiLegacyApi.create"
  end
  if @api_client.config.client_side_validation && sha256_digest.to_s.length > 64
    fail ArgumentError, 'invalid value for "sha256_digest" when calling PypiLegacyApi.create, the character length must be smaller than or equal to 64.'
  end

  if @api_client.config.client_side_validation && sha256_digest.to_s.length < 64
    fail ArgumentError, 'invalid value for "sha256_digest" when calling PypiLegacyApi.create, the character length must be great than or equal to 64.'
  end

  if @api_client.config.client_side_validation && !opts[:'action'].nil? && opts[:'action'].to_s.length < 1
    fail ArgumentError, 'invalid value for "opts[:"action"]" when calling PypiLegacyApi.create, the character length must be great than or equal to 1.'
  end

  # resource path
  local_var_path = '/pypi/{path}/legacy/'.sub('{' + 'path' + '}', CGI.escape(path.to_s).gsub('%2F', '/'))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[: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(['multipart/form-data', 'application/x-www-form-urlencoded'])

  # form parameters
  form_params = opts[:form_params] || {}
  form_params['content'] = content
  form_params['sha256_digest'] = sha256_digest
  form_params['action'] = opts[:'action'] if !opts[:'action'].nil?

  # http body (model)
  post_body = opts[:body] 

  # return_type
  return_type = opts[:return_type] || 'PackageUploadTaskResponse' 

  # auth_names
  auth_names = opts[:auth_names] || ['basicAuth']

  new_options = opts.merge(
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: PypiLegacyApi#create\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end