text: # coding: utf-8
  
  """
      Portainer API
  
      Portainer API is an HTTP API served by Portainer. It is used by the Portainer UI and everything you can do with the UI can be done using the HTTP API. Examples are available at https://gist.github.com/deviantony/77026d402366b4b43fa5918d41bc42f8 You can find out more about Portainer at [http://portainer.io](http://portainer.io) and get some support on [Slack](http://portainer.io/slack/).  # Authentication  Most of the API endpoints require to be authenticated as well as some level of authorization to be used. Portainer API uses JSON Web Token to manage authentication and thus requires you to provide a token in the **Authorization** header of each request with the **Bearer** authentication mechanism.  Example: ``` Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwidXNlcm5hbWUiOiJhZG1pbiIsInJvbGUiOjEsImV4cCI6MTQ5OTM3NjE1NH0.NJ6vE8FY1WG6jsRQzfMqeatJ4vh2TWAeeYfDhP71YEE ```  # Security  Each API endpoint has an associated access policy, it is documented in the description of each endpoint.  Different access policies are available: * Public access * Authenticated access * Restricted access * Administrator access  ### Public access  No authentication is required to access the endpoints with this access policy.  ### Authenticated access  Authentication is required to access the endpoints with this access policy.  ### Restricted access  Authentication is required to access the endpoints with this access policy. Extra-checks might be added to ensure access to the resource is granted. Returned data might also be filtered.  ### Administrator access  Authentication as well as an administrator role are required to access the endpoints with this access policy.  # Execute Docker requests  Portainer **DO NOT** expose specific endpoints to manage your Docker resources (create a container, remove a volume, etc...).  Instead, it acts as a reverse-proxy to the Docker HTTP API. This means that you can execute Docker requests **via** the Portainer HTTP API.  To do so, you can use the `/endpoints/{id}/docker` Portainer API endpoint (which is not documented below due to Swagger limitations). This endpoint has a restricted access policy so you still need to be authenticated to be able to query this endpoint. Any query on this endpoint will be proxied to the Docker API of the associated endpoint (requests and responses objects are the same as documented in the Docker API).  **NOTE**: You can find more information on how to query the Docker API in the [Docker official documentation](https://docs.docker.com/engine/api/v1.30/) as well as in [this Portainer example](https://gist.github.com/deviantony/77026d402366b4b43fa5918d41bc42f8).   # noqa: E501
  
      OpenAPI spec version: 1.24.1
      Contact: info@portainer.io
      Generated by: https://github.com/swagger-api/swagger-codegen.git
  """
  
  
  from __future__ import absolute_import
  
  import re  # noqa: F401
  
  # python 2 and python 3 compatibility library
  import six
  
  from swagger_client.api_client import ApiClient
  
  
  class TemplatesApi(object):
      """NOTE: This class is auto generated by the swagger code generator program.
  
      Do not edit the class manually.
      Ref: https://github.com/swagger-api/swagger-codegen
      """
  
      def __init__(self, api_client=None):
          if api_client is None:
              api_client = ApiClient()
          self.api_client = api_client
  
      def template_create(self, body, **kwargs):  # noqa: E501
          """Create a new template  # noqa: E501
  
          Create a new template. **Access policy**: administrator   # noqa: E501
          This method makes a synchronous HTTP request by default. To make an
          asynchronous HTTP request, please pass async_req=True
          >>> thread = api.template_create(body, async_req=True)
          >>> result = thread.get()
  
          :param async_req bool
          :param TemplateCreateRequest body: Template details (required)
          :return: Template
                   If the method is called asynchronously,
                   returns the request thread.
          """
          kwargs['_return_http_data_only'] = True
          if kwargs.get('async_req'):
              return self.template_create_with_http_info(body, **kwargs)  # noqa: E501
          else:
              (data) = self.template_create_with_http_info(body, **kwargs)  # noqa: E501
              return data
  
      def template_create_with_http_info(self, body, **kwargs):  # noqa: E501
          """Create a new template  # noqa: E501
  
          Create a new template. **Access policy**: administrator   # noqa: E501
          This method makes a synchronous HTTP request by default. To make an
          asynchronous HTTP request, please pass async_req=True
          >>> thread = api.template_create_with_http_info(body, async_req=True)
          >>> result = thread.get()
  
          :param async_req bool
          :param TemplateCreateRequest body: Template details (required)
          :return: Template
                   If the method is called asynchronously,
                   returns the request thread.
          """
  
          all_params = ['body']  # noqa: E501
          all_params.append('async_req')
          all_params.append('_return_http_data_only')
          all_params.append('_preload_content')
          all_params.append('_request_timeout')
  
          params = locals()
          for key, val in six.iteritems(params['kwargs']):
              if key not in all_params:
                  raise TypeError(
                      "Got an unexpected keyword argument '%s'"
                      " to method template_create" % key
                  )
              params[key] = val
          del params['kwargs']
          # verify the required parameter 'body' is set
          if ('body' not in params or
                  params['body'] is None):
              raise ValueError("Missing the required parameter `body` when calling `template_create`")  # noqa: E501
  
          collection_formats = {}
  
          path_params = {}
  
          query_params = []
  
          header_params = {}
  
          form_params = []
          local_var_files = {}
  
          body_params = None
          if 'body' in params:
              body_params = params['body']
          # HTTP header `Accept`
          header_params['Accept'] = self.api_client.select_header_accept(
              ['application/json'])  # noqa: E501
  
          # HTTP header `Content-Type`
          header_params['Content-Type'] = self.api_client.select_header_content_type(  # noqa: E501
              ['application/json'])  # noqa: E501
  
          # Authentication setting
          auth_settings = ['jwt']  # noqa: E501
  
          return self.api_client.call_api(
              '/templates', 'POST',
              path_params,
              query_params,
              header_params,
              body=body_params,
              post_params=form_params,
              files=local_var_files,
              response_type='Template',  # noqa: E501
              auth_settings=auth_settings,
              async_req=params.get('async_req'),
              _return_http_data_only=params.get('_return_http_data_only'),
              _preload_content=params.get('_preload_content', True),
              _request_timeout=params.get('_request_timeout'),
              collection_formats=collection_formats)
  
      def template_delete(self, id, **kwargs):  # noqa: E501
          """Remove a template  # noqa: E501
  
          Remove a template. **Access policy**: administrator   # noqa: E501
          This method makes a synchronous HTTP request by default. To make an
          asynchronous HTTP request, please pass async_req=True
          >>> thread = api.template_delete(id, async_req=True)
          >>> result = thread.get()
  
          :param async_req bool
          :param int id: Template identifier (required)
          :return: None
                   If the method is called asynchronously,
                   returns the request thread.
          """
          kwargs['_return_http_data_only'] = True
          if kwargs.get('async_req'):
              return self.template_delete_with_http_info(id, **kwargs)  # noqa: E501
          else:
              (data) = self.template_delete_with_http_info(id, **kwargs)  # noqa: E501
              return data
  
      def template_delete_with_http_info(self, id, **kwargs):  # noqa: E501
          """Remove a template  # noqa: E501
  
          Remove a template. **Access policy**: administrator   # noqa: E501
          This method makes a synchronous HTTP request by default. To make an
          asynchronous HTTP request, please pass async_req=True
          >>> thread = api.template_delete_with_http_info(id, async_req=True)
          >>> result = thread.get()
  
          :param async_req bool
          :param int id: Template identifier (required)
          :return: None
                   If the method is called asynchronously,
                   returns the request thread.
          """
  
          all_params = ['id']  # noqa: E501
          all_params.append('async_req')
          all_params.append('_return_http_data_only')
          all_params.append('_preload_content')
          all_params.append('_request_timeout')
  
          params = locals()
          for key, val in six.iteritems(params['kwargs']):
              if key not in all_params:
                  raise TypeError(
                      "Got an unexpected keyword argument '%s'"
                      " to method template_delete" % key
                  )
              params[key] = val
          del params['kwargs']
          # verify the required parameter 'id' is set
          if ('id' not in params or
                  params['id'] is None):
              raise ValueError("Missing the required parameter `id` when calling `template_delete`")  # noqa: E501
  
          collection_formats = {}
  
          path_params = {}
          if 'id' in params:
              path_params['id'] = params['id']  # noqa: E501
  
          query_params = []
  
          header_params = {}
  
          form_params = []
          local_var_files = {}
  
          body_params = None
          # Authentication setting
          auth_settings = ['jwt']  # noqa: E501
  
          return self.api_client.call_api(
              '/templates/{id}', 'DELETE',
              path_params,
              query_params,
              header_params,
              body=body_params,
              post_params=form_params,
              files=local_var_files,
              response_type=None,  # noqa: E501
              auth_settings=auth_settings,
              async_req=params.get('async_req'),
              _return_http_data_only=params.get('_return_http_data_only'),
              _preload_content=params.get('_preload_content', True),
              _request_timeout=params.get('_request_timeout'),
              collection_formats=collection_formats)
  
      def template_inspect(self, id, **kwargs):  # noqa: E501
          """Inspect a template  # noqa: E501
  
          Retrieve details about a template. **Access policy**: administrator   # noqa: E501
          This method makes a synchronous HTTP request by default. To make an
          asynchronous HTTP request, please pass async_req=True
          >>> thread = api.template_inspect(id, async_req=True)
          >>> result = thread.get()
  
          :param async_req bool
          :param int id: Template identifier (required)
          :return: Template
                   If the method is called asynchronously,
                   returns the request thread.
          """
          kwargs['_return_http_data_only'] = True
          if kwargs.get('async_req'):
              return self.template_inspect_with_http_info(id, **kwargs)  # noqa: E501
          else:
              (data) = self.template_inspect_with_http_info(id, **kwargs)  # noqa: E501
              return data
  
      def template_inspect_with_http_info(self, id, **kwargs):  # noqa: E501
          """Inspect a template  # noqa: E501
  
          Retrieve details about a template. **Access policy**: administrator   # noqa: E501
          This method makes a synchronous HTTP request by default. To make an
          asynchronous HTTP request, please pass async_req=True
          >>> thread = api.template_inspect_with_http_info(id, async_req=True)
          >>> result = thread.get()
  
          :param async_req bool
          :param int id: Template identifier (required)
          :return: Template
                   If the method is called asynchronously,
                   returns the request thread.
          """
  
          all_params = ['id']  # noqa: E501
          all_params.append('async_req')
          all_params.append('_return_http_data_only')
          all_params.append('_preload_content')
          all_params.append('_request_timeout')
  
          params = locals()
          for key, val in six.iteritems(params['kwargs']):
              if key not in all_params:
                  raise TypeError(
                      "Got an unexpected keyword argument '%s'"
                      " to method template_inspect" % key
                  )
              params[key] = val
          del params['kwargs']
          # verify the required parameter 'id' is set
          if ('id' not in params or
                  params['id'] is None):
              raise ValueError("Missing the required parameter `id` when calling `template_inspect`")  # noqa: E501
  
          collection_formats = {}
  
          path_params = {}
          if 'id' in params:
              path_params['id'] = params['id']  # noqa: E501
  
          query_params = []
  
          header_params = {}
  
          form_params = []
          local_var_files = {}
  
          body_params = None
          # HTTP header `Accept`
          header_params['Accept'] = self.api_client.select_header_accept(
              ['application/json'])  # noqa: E501
  
          # Authentication setting
          auth_settings = ['jwt']  # noqa: E501
  
          return self.api_client.call_api(
              '/templates/{id}', 'GET',
              path_params,
              query_params,
              header_params,
              body=body_params,
              post_params=form_params,
              files=local_var_files,
              response_type='Template',  # noqa: E501
              auth_settings=auth_settings,
              async_req=params.get('async_req'),
              _return_http_data_only=params.get('_return_http_data_only'),
              _preload_content=params.get('_preload_content', True),
              _request_timeout=params.get('_request_timeout'),
              collection_formats=collection_formats)
  
      def template_list(self, **kwargs):  # noqa: E501
          """List available templates  # noqa: E501
  
          List available templates. Administrator templates will not be listed for non-administrator users. **Access policy**: restricted   # noqa: E501
          This method makes a synchronous HTTP request by default. To make an
          asynchronous HTTP request, please pass async_req=True
          >>> thread = api.template_list(async_req=True)
          >>> result = thread.get()
  
          :param async_req bool
          :return: TemplateListResponse
                   If the method is called asynchronously,
                   returns the request thread.
          """
          kwargs['_return_http_data_only'] = True
          if kwargs.get('async_req'):
              return self.template_list_with_http_info(**kwargs)  # noqa: E501
          else:
              (data) = self.template_list_with_http_info(**kwargs)  # noqa: E501
              return data
  
      def template_list_with_http_info(self, **kwargs):  # noqa: E501
          """List available templates  # noqa: E501
  
          List available templates. Administrator templates will not be listed for non-administrator users. **Access policy**: restricted   # noqa: E501
          This method makes a synchronous HTTP request by default. To make an
          asynchronous HTTP request, please pass async_req=True
          >>> thread = api.template_list_with_http_info(async_req=True)
          >>> result = thread.get()
  
          :param async_req bool
          :return: TemplateListResponse
                   If the method is called asynchronously,
                   returns the request thread.
          """
  
          all_params = []  # noqa: E501
          all_params.append('async_req')
          all_params.append('_return_http_data_only')
          all_params.append('_preload_content')
          all_params.append('_request_timeout')
  
          params = locals()
          for key, val in six.iteritems(params['kwargs']):
              if key not in all_params:
                  raise TypeError(
                      "Got an unexpected keyword argument '%s'"
                      " to method template_list" % key
                  )
              params[key] = val
          del params['kwargs']
  
          collection_formats = {}
  
          path_params = {}
  
          query_params = []
  
          header_params = {}
  
          form_params = []
          local_var_files = {}
  
          body_params = None
          # HTTP header `Accept`
          header_params['Accept'] = self.api_client.select_header_accept(
              ['application/json'])  # noqa: E501
  
          # Authentication setting
          auth_settings = ['jwt']  # noqa: E501
  
          return self.api_client.call_api(
              '/templates', 'GET',
              path_params,
              query_params,
              header_params,
              body=body_params,
              post_params=form_params,
              files=local_var_files,
              response_type='TemplateListResponse',  # noqa: E501
              auth_settings=auth_settings,
              async_req=params.get('async_req'),
              _return_http_data_only=params.get('_return_http_data_only'),
              _preload_content=params.get('_preload_content', True),
              _request_timeout=params.get('_request_timeout'),
              collection_formats=collection_formats)
  
      def template_update(self, id, body, **kwargs):  # noqa: E501
          """Update a template  # noqa: E501
  
          Update a template. **Access policy**: administrator   # noqa: E501
          This method makes a synchronous HTTP request by default. To make an
          asynchronous HTTP request, please pass async_req=True
          >>> thread = api.template_update(id, body, async_req=True)
          >>> result = thread.get()
  
          :param async_req bool
          :param int id: Template identifier (required)
          :param TemplateUpdateRequest body: Template details (required)
          :return: None
                   If the method is called asynchronously,
                   returns the request thread.
          """
          kwargs['_return_http_data_only'] = True
          if kwargs.get('async_req'):
              return self.template_update_with_http_info(id, body, **kwargs)  # noqa: E501
          else:
              (data) = self.template_update_with_http_info(id, body, **kwargs)  # noqa: E501
              return data
  
      def template_update_with_http_info(self, id, body, **kwargs):  # noqa: E501
          """Update a template  # noqa: E501
  
          Update a template. **Access policy**: administrator   # noqa: E501
          This method makes a synchronous HTTP request by default. To make an
          asynchronous HTTP request, please pass async_req=True
          >>> thread = api.template_update_with_http_info(id, body, async_req=True)
          >>> result = thread.get()
  
          :param async_req bool
          :param int id: Template identifier (required)
          :param TemplateUpdateRequest body: Template details (required)
          :return: None
                   If the method is called asynchronously,
                   returns the request thread.
          """
  
          all_params = ['id', 'body']  # noqa: E501
          all_params.append('async_req')
          all_params.append('_return_http_data_only')
          all_params.append('_preload_content')
          all_params.append('_request_timeout')
  
          params = locals()
          for key, val in six.iteritems(params['kwargs']):
              if key not in all_params:
                  raise TypeError(
                      "Got an unexpected keyword argument '%s'"
                      " to method template_update" % key
                  )
              params[key] = val
          del params['kwargs']
          # verify the required parameter 'id' is set
          if ('id' not in params or
                  params['id'] is None):
              raise ValueError("Missing the required parameter `id` when calling `template_update`")  # noqa: E501
          # verify the required parameter 'body' is set
          if ('body' not in params or
                  params['body'] is None):
              raise ValueError("Missing the required parameter `body` when calling `template_update`")  # noqa: E501
  
          collection_formats = {}
  
          path_params = {}
          if 'id' in params:
              path_params['id'] = params['id']  # noqa: E501
  
          query_params = []
  
          header_params = {}
  
          form_params = []
          local_var_files = {}
  
          body_params = None
          if 'body' in params:
              body_params = params['body']
          # HTTP header `Accept`
          header_params['Accept'] = self.api_client.select_header_accept(
              ['application/json'])  # noqa: E501
  
          # HTTP header `Content-Type`
          header_params['Content-Type'] = self.api_client.select_header_content_type(  # noqa: E501
              ['application/json'])  # noqa: E501
  
          # Authentication setting
          auth_settings = ['jwt']  # noqa: E501
  
          return self.api_client.call_api(
              '/templates/{id}', 'PUT',
              path_params,
              query_params,
              header_params,
              body=body_params,
              post_params=form_params,
              files=local_var_files,
              response_type=None,  # noqa: E501
              auth_settings=auth_settings,
              async_req=params.get('async_req'),
              _return_http_data_only=params.get('_return_http_data_only'),
              _preload_content=params.get('_preload_content', True),
              _request_timeout=params.get('_request_timeout'),
              collection_formats=collection_formats)
  