github.com/treeverse/lakefs@v1.24.1-0.20240520134607-95648127bfb0/clients/python/lakefs_sdk/api/commits_api.py (about)

     1  # coding: utf-8
     2  
     3  """
     4      lakeFS API
     5  
     6      lakeFS HTTP API
     7  
     8      The version of the OpenAPI document: 1.0.0
     9      Contact: services@treeverse.io
    10      Generated by OpenAPI Generator (https://openapi-generator.tech)
    11  
    12      Do not edit the class manually.
    13  """  # noqa: E501
    14  
    15  
    16  import re  # noqa: F401
    17  import io
    18  import warnings
    19  
    20  try:
    21      from pydantic.v1 import validate_arguments, ValidationError
    22  except ImportError:
    23      from pydantic import validate_arguments, ValidationError
    24  from typing_extensions import Annotated
    25  
    26  try:
    27      from pydantic.v1 import Field, StrictStr
    28  except ImportError:
    29      from pydantic import Field, StrictStr
    30  
    31  from typing import Optional
    32  
    33  from lakefs_sdk.models.commit import Commit
    34  from lakefs_sdk.models.commit_creation import CommitCreation
    35  
    36  from lakefs_sdk.api_client import ApiClient
    37  from lakefs_sdk.api_response import ApiResponse
    38  from lakefs_sdk.exceptions import (  # noqa: F401
    39      ApiTypeError,
    40      ApiValueError
    41  )
    42  
    43  
    44  class CommitsApi(object):
    45      """NOTE: This class is auto generated by OpenAPI Generator
    46      Ref: https://openapi-generator.tech
    47  
    48      Do not edit the class manually.
    49      """
    50  
    51      def __init__(self, api_client=None):
    52          if api_client is None:
    53              api_client = ApiClient.get_default()
    54          self.api_client = api_client
    55  
    56      @validate_arguments
    57      def commit(self, repository : StrictStr, branch : StrictStr, commit_creation : CommitCreation, source_metarange : Annotated[Optional[StrictStr], Field(description="The source metarange to commit. Branch must not have uncommitted changes.")] = None, **kwargs) -> Commit:  # noqa: E501
    58          """create commit  # noqa: E501
    59  
    60          This method makes a synchronous HTTP request by default. To make an
    61          asynchronous HTTP request, please pass async_req=True
    62  
    63          >>> thread = api.commit(repository, branch, commit_creation, source_metarange, async_req=True)
    64          >>> result = thread.get()
    65  
    66          :param repository: (required)
    67          :type repository: str
    68          :param branch: (required)
    69          :type branch: str
    70          :param commit_creation: (required)
    71          :type commit_creation: CommitCreation
    72          :param source_metarange: The source metarange to commit. Branch must not have uncommitted changes.
    73          :type source_metarange: str
    74          :param async_req: Whether to execute the request asynchronously.
    75          :type async_req: bool, optional
    76          :param _request_timeout: timeout setting for this request. If one
    77                                   number provided, it will be total request
    78                                   timeout. It can also be a pair (tuple) of
    79                                   (connection, read) timeouts.
    80          :return: Returns the result object.
    81                   If the method is called asynchronously,
    82                   returns the request thread.
    83          :rtype: Commit
    84          """
    85          kwargs['_return_http_data_only'] = True
    86          if '_preload_content' in kwargs:
    87              raise ValueError("Error! Please call the commit_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data")
    88          return self.commit_with_http_info(repository, branch, commit_creation, source_metarange, **kwargs)  # noqa: E501
    89  
    90      @validate_arguments
    91      def commit_with_http_info(self, repository : StrictStr, branch : StrictStr, commit_creation : CommitCreation, source_metarange : Annotated[Optional[StrictStr], Field(description="The source metarange to commit. Branch must not have uncommitted changes.")] = None, **kwargs) -> ApiResponse:  # noqa: E501
    92          """create commit  # noqa: E501
    93  
    94          This method makes a synchronous HTTP request by default. To make an
    95          asynchronous HTTP request, please pass async_req=True
    96  
    97          >>> thread = api.commit_with_http_info(repository, branch, commit_creation, source_metarange, async_req=True)
    98          >>> result = thread.get()
    99  
   100          :param repository: (required)
   101          :type repository: str
   102          :param branch: (required)
   103          :type branch: str
   104          :param commit_creation: (required)
   105          :type commit_creation: CommitCreation
   106          :param source_metarange: The source metarange to commit. Branch must not have uncommitted changes.
   107          :type source_metarange: str
   108          :param async_req: Whether to execute the request asynchronously.
   109          :type async_req: bool, optional
   110          :param _preload_content: if False, the ApiResponse.data will
   111                                   be set to none and raw_data will store the 
   112                                   HTTP response body without reading/decoding.
   113                                   Default is True.
   114          :type _preload_content: bool, optional
   115          :param _return_http_data_only: response data instead of ApiResponse
   116                                         object with status code, headers, etc
   117          :type _return_http_data_only: bool, optional
   118          :param _request_timeout: timeout setting for this request. If one
   119                                   number provided, it will be total request
   120                                   timeout. It can also be a pair (tuple) of
   121                                   (connection, read) timeouts.
   122          :param _request_auth: set to override the auth_settings for an a single
   123                                request; this effectively ignores the authentication
   124                                in the spec for a single request.
   125          :type _request_auth: dict, optional
   126          :type _content_type: string, optional: force content-type for the request
   127          :return: Returns the result object.
   128                   If the method is called asynchronously,
   129                   returns the request thread.
   130          :rtype: tuple(Commit, status_code(int), headers(HTTPHeaderDict))
   131          """
   132  
   133          _params = locals()
   134  
   135          _all_params = [
   136              'repository',
   137              'branch',
   138              'commit_creation',
   139              'source_metarange'
   140          ]
   141          _all_params.extend(
   142              [
   143                  'async_req',
   144                  '_return_http_data_only',
   145                  '_preload_content',
   146                  '_request_timeout',
   147                  '_request_auth',
   148                  '_content_type',
   149                  '_headers'
   150              ]
   151          )
   152  
   153          # validate the arguments
   154          for _key, _val in _params['kwargs'].items():
   155              if _key not in _all_params:
   156                  raise ApiTypeError(
   157                      "Got an unexpected keyword argument '%s'"
   158                      " to method commit" % _key
   159                  )
   160              _params[_key] = _val
   161          del _params['kwargs']
   162  
   163          _collection_formats = {}
   164  
   165          # process the path parameters
   166          _path_params = {}
   167          if _params['repository']:
   168              _path_params['repository'] = _params['repository']
   169  
   170          if _params['branch']:
   171              _path_params['branch'] = _params['branch']
   172  
   173  
   174          # process the query parameters
   175          _query_params = []
   176          if _params.get('source_metarange') is not None:  # noqa: E501
   177              _query_params.append(('source_metarange', _params['source_metarange']))
   178  
   179          # process the header parameters
   180          _header_params = dict(_params.get('_headers', {}))
   181          # process the form parameters
   182          _form_params = []
   183          _files = {}
   184          # process the body parameter
   185          _body_params = None
   186          if _params['commit_creation'] is not None:
   187              _body_params = _params['commit_creation']
   188  
   189          # set the HTTP header `Accept`
   190          _header_params['Accept'] = self.api_client.select_header_accept(
   191              ['application/json'])  # noqa: E501
   192  
   193          # set the HTTP header `Content-Type`
   194          _content_types_list = _params.get('_content_type',
   195              self.api_client.select_header_content_type(
   196                  ['application/json']))
   197          if _content_types_list:
   198                  _header_params['Content-Type'] = _content_types_list
   199  
   200          # authentication setting
   201          _auth_settings = ['basic_auth', 'cookie_auth', 'oidc_auth', 'saml_auth', 'jwt_token']  # noqa: E501
   202  
   203          _response_types_map = {
   204              '201': "Commit",
   205              '400': "Error",
   206              '401': "Error",
   207              '403': "Error",
   208              '404': "Error",
   209              '409': "Error",
   210              '412': "Error",
   211              '420': None,
   212          }
   213  
   214          return self.api_client.call_api(
   215              '/repositories/{repository}/branches/{branch}/commits', 'POST',
   216              _path_params,
   217              _query_params,
   218              _header_params,
   219              body=_body_params,
   220              post_params=_form_params,
   221              files=_files,
   222              response_types_map=_response_types_map,
   223              auth_settings=_auth_settings,
   224              async_req=_params.get('async_req'),
   225              _return_http_data_only=_params.get('_return_http_data_only'),  # noqa: E501
   226              _preload_content=_params.get('_preload_content', True),
   227              _request_timeout=_params.get('_request_timeout'),
   228              collection_formats=_collection_formats,
   229              _request_auth=_params.get('_request_auth'))
   230  
   231      @validate_arguments
   232      def get_commit(self, repository : StrictStr, commit_id : StrictStr, **kwargs) -> Commit:  # noqa: E501
   233          """get commit  # noqa: E501
   234  
   235          This method makes a synchronous HTTP request by default. To make an
   236          asynchronous HTTP request, please pass async_req=True
   237  
   238          >>> thread = api.get_commit(repository, commit_id, async_req=True)
   239          >>> result = thread.get()
   240  
   241          :param repository: (required)
   242          :type repository: str
   243          :param commit_id: (required)
   244          :type commit_id: str
   245          :param async_req: Whether to execute the request asynchronously.
   246          :type async_req: bool, optional
   247          :param _request_timeout: timeout setting for this request. If one
   248                                   number provided, it will be total request
   249                                   timeout. It can also be a pair (tuple) of
   250                                   (connection, read) timeouts.
   251          :return: Returns the result object.
   252                   If the method is called asynchronously,
   253                   returns the request thread.
   254          :rtype: Commit
   255          """
   256          kwargs['_return_http_data_only'] = True
   257          if '_preload_content' in kwargs:
   258              raise ValueError("Error! Please call the get_commit_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data")
   259          return self.get_commit_with_http_info(repository, commit_id, **kwargs)  # noqa: E501
   260  
   261      @validate_arguments
   262      def get_commit_with_http_info(self, repository : StrictStr, commit_id : StrictStr, **kwargs) -> ApiResponse:  # noqa: E501
   263          """get commit  # noqa: E501
   264  
   265          This method makes a synchronous HTTP request by default. To make an
   266          asynchronous HTTP request, please pass async_req=True
   267  
   268          >>> thread = api.get_commit_with_http_info(repository, commit_id, async_req=True)
   269          >>> result = thread.get()
   270  
   271          :param repository: (required)
   272          :type repository: str
   273          :param commit_id: (required)
   274          :type commit_id: str
   275          :param async_req: Whether to execute the request asynchronously.
   276          :type async_req: bool, optional
   277          :param _preload_content: if False, the ApiResponse.data will
   278                                   be set to none and raw_data will store the 
   279                                   HTTP response body without reading/decoding.
   280                                   Default is True.
   281          :type _preload_content: bool, optional
   282          :param _return_http_data_only: response data instead of ApiResponse
   283                                         object with status code, headers, etc
   284          :type _return_http_data_only: bool, optional
   285          :param _request_timeout: timeout setting for this request. If one
   286                                   number provided, it will be total request
   287                                   timeout. It can also be a pair (tuple) of
   288                                   (connection, read) timeouts.
   289          :param _request_auth: set to override the auth_settings for an a single
   290                                request; this effectively ignores the authentication
   291                                in the spec for a single request.
   292          :type _request_auth: dict, optional
   293          :type _content_type: string, optional: force content-type for the request
   294          :return: Returns the result object.
   295                   If the method is called asynchronously,
   296                   returns the request thread.
   297          :rtype: tuple(Commit, status_code(int), headers(HTTPHeaderDict))
   298          """
   299  
   300          _params = locals()
   301  
   302          _all_params = [
   303              'repository',
   304              'commit_id'
   305          ]
   306          _all_params.extend(
   307              [
   308                  'async_req',
   309                  '_return_http_data_only',
   310                  '_preload_content',
   311                  '_request_timeout',
   312                  '_request_auth',
   313                  '_content_type',
   314                  '_headers'
   315              ]
   316          )
   317  
   318          # validate the arguments
   319          for _key, _val in _params['kwargs'].items():
   320              if _key not in _all_params:
   321                  raise ApiTypeError(
   322                      "Got an unexpected keyword argument '%s'"
   323                      " to method get_commit" % _key
   324                  )
   325              _params[_key] = _val
   326          del _params['kwargs']
   327  
   328          _collection_formats = {}
   329  
   330          # process the path parameters
   331          _path_params = {}
   332          if _params['repository']:
   333              _path_params['repository'] = _params['repository']
   334  
   335          if _params['commit_id']:
   336              _path_params['commitId'] = _params['commit_id']
   337  
   338  
   339          # process the query parameters
   340          _query_params = []
   341          # process the header parameters
   342          _header_params = dict(_params.get('_headers', {}))
   343          # process the form parameters
   344          _form_params = []
   345          _files = {}
   346          # process the body parameter
   347          _body_params = None
   348          # set the HTTP header `Accept`
   349          _header_params['Accept'] = self.api_client.select_header_accept(
   350              ['application/json'])  # noqa: E501
   351  
   352          # authentication setting
   353          _auth_settings = ['basic_auth', 'cookie_auth', 'oidc_auth', 'saml_auth', 'jwt_token']  # noqa: E501
   354  
   355          _response_types_map = {
   356              '200': "Commit",
   357              '401': "Error",
   358              '404': "Error",
   359              '420': None,
   360          }
   361  
   362          return self.api_client.call_api(
   363              '/repositories/{repository}/commits/{commitId}', 'GET',
   364              _path_params,
   365              _query_params,
   366              _header_params,
   367              body=_body_params,
   368              post_params=_form_params,
   369              files=_files,
   370              response_types_map=_response_types_map,
   371              auth_settings=_auth_settings,
   372              async_req=_params.get('async_req'),
   373              _return_http_data_only=_params.get('_return_http_data_only'),  # noqa: E501
   374              _preload_content=_params.get('_preload_content', True),
   375              _request_timeout=_params.get('_request_timeout'),
   376              collection_formats=_collection_formats,
   377              _request_auth=_params.get('_request_auth'))