#!/usr/bin/env python
# coding: utf-8

"""
FileManagementApi.py

  The Clear BSD License

  Copyright (c) – 2016, NetApp, Inc. All rights reserved.

  Redistribution and use in source and binary forms, with or without modification, are permitted (subject to the limitations in the disclaimer below) provided that the following conditions are met:

  * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  * Neither the name of NetApp, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

  NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""
from __future__ import absolute_import

import sys
import os

# python 2 and python 3 compatibility library
from six import iteritems

from ....santricity.configuration import Configuration
from ....santricity.api_client import ApiClient


class FileManagementApi(object):

    def __init__(self, api_client=None):
        config = Configuration()
        if api_client:
            self.api_client = api_client
        else:
            if not config.api_client:
                config.api_client = ApiClient(context_path='/devmgr/v2')
            self.api_client = config.api_client
    
    
    def get_all_support_artifacts(self, **kwargs):
            """
            Retrieve the list of support artifacts by type
            Mode: Both Embedded and Proxy. 

            This method makes a synchronous HTTP request by default. To make an
            asynchronous HTTP request, please define a `callback` function
            to be invoked when receiving the response.
            >>> def callback_function(response):
            >>>     pprint(response)
            >>>
    
            >>> thread = api.get_all_support_artifacts(callback=callback_function)
    
    

            :param callback function: The callback function
                for asynchronous request. (optional)
    
            :return: list[SupportArtifacts]
                     If the method is called asynchronously,
                     returns the request thread.
            :raises: ValueError
                       If the required params are not provided or if the response data format is unknown.
                     TypeError:
                        When the data type of response data is different from what we are expecting
                     ApiException:
                        Occurs when we get a HTTP error code (422 and above).

            """

            all_params = []
            all_params.append('callback')

            params = locals()
            for key, val in iteritems(params['kwargs']):
                if key not in all_params:
                    raise TypeError(
                        "Got an unexpected keyword argument '%s'"
                        " to method get_all_support_artifacts" % key
                    )
                params[key] = val
            del params['kwargs']

    

            resource_path = '/support-data/files'.replace('{format}', 'json')
            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'])
            if not header_params['Accept']:
                del header_params['Accept']

            # HTTP header `Content-Type`
            header_params['Content-Type'] = self.api_client.\
                select_header_content_type(['application/json'])

            # Authentication setting
            auth_settings = ['basicAuth']

            response = self.api_client.call_api(resource_path, 'GET',
                                                path_params,
                                                query_params,
                                                header_params,
                                                body=body_params,
                                                post_params=form_params,
                                                files=local_var_files,
                                                response_type='list[SupportArtifacts]',
                                                auth_settings=auth_settings,
                                                callback=params.get('callback'))
            return response
    
    def get_file_from_scratch_dir(self, filename, **kwargs):
            """
            Gets a file from the scratch directory 
            Mode: Both Embedded and Proxy. The response type of this method is a file stream.

            This method makes a synchronous HTTP request by default. To make an
            asynchronous HTTP request, please define a `callback` function
            to be invoked when receiving the response.
            >>> def callback_function(response):
            >>>     pprint(response)
            >>>
    
            >>> thread = api.get_file_from_scratch_dir(filename, callback=callback_function)
    
    

            :param callback function: The callback function
                for asynchronous request. (optional)
    
            :param str filename:  (required)
    
            :param bool auto_delete: Automatically remove the file after the retrieval completes
    
            :return: File
                     If the method is called asynchronously,
                     returns the request thread.
            :raises: ValueError
                       If the required params are not provided or if the response data format is unknown.
                     TypeError:
                        When the data type of response data is different from what we are expecting
                     ApiException:
                        Occurs when we get a HTTP error code (422 and above).

            """

            all_params = ['filename', 'auto_delete']
            all_params.append('callback')

            params = locals()
            for key, val in iteritems(params['kwargs']):
                if key not in all_params:
                    raise TypeError(
                        "Got an unexpected keyword argument '%s'"
                        " to method get_file_from_scratch_dir" % key
                    )
                params[key] = val
            del params['kwargs']

    
    
            # verify the required parameter 'filename' is set
            if ('filename' not in params) or (params['filename'] is None):
                raise ValueError("Missing the required parameter `filename` when calling `get_file_from_scratch_dir`")
    
    
    
    

            resource_path = '/files/{filename}'.replace('{format}', 'json')
            path_params = {}
    
            if 'filename' in params:
                path_params['filename'] = params['filename']
    

            query_params = {}
    
            if 'auto_delete' in params:
                query_params['auto-delete'] = params['auto_delete']
    

            header_params = {}
    

            form_params = []
            local_var_files = {}
    

            body_params = None
    

            # HTTP header `Accept`
            header_params['Accept'] = self.api_client.\
                select_header_accept(['application/octet-stream'])
            if not header_params['Accept']:
                del header_params['Accept']

            # HTTP header `Content-Type`
            header_params['Content-Type'] = self.api_client.\
                select_header_content_type(['application/json'])

            # Authentication setting
            auth_settings = ['basicAuth']

            response = self.api_client.call_api(resource_path, 'GET',
                                                path_params,
                                                query_params,
                                                header_params,
                                                body=body_params,
                                                post_params=form_params,
                                                files=local_var_files,
                                                response_type='File',
                                                auth_settings=auth_settings,
                                                callback=params.get('callback'))
            return response
    
    def get_scratch_file(self, **kwargs):
            """
            Retrieve a file from the scratch directory
            Mode: Both Embedded and Proxy. 

            This method makes a synchronous HTTP request by default. To make an
            asynchronous HTTP request, please define a `callback` function
            to be invoked when receiving the response.
            >>> def callback_function(response):
            >>>     pprint(response)
            >>>
    
            >>> thread = api.get_scratch_file(callback=callback_function)
    
    

            :param callback function: The callback function
                for asynchronous request. (optional)
    
            :return: list[FileInfo]
                     If the method is called asynchronously,
                     returns the request thread.
            :raises: ValueError
                       If the required params are not provided or if the response data format is unknown.
                     TypeError:
                        When the data type of response data is different from what we are expecting
                     ApiException:
                        Occurs when we get a HTTP error code (422 and above).

            """

            all_params = []
            all_params.append('callback')

            params = locals()
            for key, val in iteritems(params['kwargs']):
                if key not in all_params:
                    raise TypeError(
                        "Got an unexpected keyword argument '%s'"
                        " to method get_scratch_file" % key
                    )
                params[key] = val
            del params['kwargs']

    

            resource_path = '/files'.replace('{format}', 'json')
            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'])
            if not header_params['Accept']:
                del header_params['Accept']

            # HTTP header `Content-Type`
            header_params['Content-Type'] = self.api_client.\
                select_header_content_type(['application/json'])

            # Authentication setting
            auth_settings = ['basicAuth']

            response = self.api_client.call_api(resource_path, 'GET',
                                                path_params,
                                                query_params,
                                                header_params,
                                                body=body_params,
                                                post_params=form_params,
                                                files=local_var_files,
                                                response_type='list[FileInfo]',
                                                auth_settings=auth_settings,
                                                callback=params.get('callback'))
            return response
    
    def get_support_artifacts(self, identifier, **kwargs):
            """
            Retrieve a specific support artifact.
            Mode: Both Embedded and Proxy. 

            This method makes a synchronous HTTP request by default. To make an
            asynchronous HTTP request, please define a `callback` function
            to be invoked when receiving the response.
            >>> def callback_function(response):
            >>>     pprint(response)
            >>>
    
            >>> thread = api.get_support_artifacts(identifier, callback=callback_function)
    
    

            :param callback function: The callback function
                for asynchronous request. (optional)
    
            :param str identifier:  (required)
    
            :return: File
                     If the method is called asynchronously,
                     returns the request thread.
            :raises: ValueError
                       If the required params are not provided or if the response data format is unknown.
                     TypeError:
                        When the data type of response data is different from what we are expecting
                     ApiException:
                        Occurs when we get a HTTP error code (422 and above).

            """

            all_params = ['identifier']
            all_params.append('callback')

            params = locals()
            for key, val in iteritems(params['kwargs']):
                if key not in all_params:
                    raise TypeError(
                        "Got an unexpected keyword argument '%s'"
                        " to method get_support_artifacts" % key
                    )
                params[key] = val
            del params['kwargs']

    
    
            # verify the required parameter 'identifier' is set
            if ('identifier' not in params) or (params['identifier'] is None):
                raise ValueError("Missing the required parameter `identifier` when calling `get_support_artifacts`")
    
    

            resource_path = '/support-data/files/{identifier}'.replace('{format}', 'json')
            path_params = {}
    
            if 'identifier' in params:
                path_params['identifier'] = params['identifier']
    

            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/octet-stream'])
            if not header_params['Accept']:
                del header_params['Accept']

            # HTTP header `Content-Type`
            header_params['Content-Type'] = self.api_client.\
                select_header_content_type(['application/json'])

            # Authentication setting
            auth_settings = ['basicAuth']

            response = self.api_client.call_api(resource_path, 'GET',
                                                path_params,
                                                query_params,
                                                header_params,
                                                body=body_params,
                                                post_params=form_params,
                                                files=local_var_files,
                                                response_type='File',
                                                auth_settings=auth_settings,
                                                callback=params.get('callback'))
            return response
    
    def remove_scratch_file(self, filename, **kwargs):
            """
            Deletes a generic file 
            Mode: Both Embedded and Proxy. 

            This method makes a synchronous HTTP request by default. To make an
            asynchronous HTTP request, please define a `callback` function
            to be invoked when receiving the response.
            >>> def callback_function(response):
            >>>     pprint(response)
            >>>
    
            >>> thread = api.remove_scratch_file(filename, callback=callback_function)
    
    

            :param callback function: The callback function
                for asynchronous request. (optional)
    
            :param str filename: Name of file to delete (required)
    
            :return: None
                     If the method is called asynchronously,
                     returns the request thread.
            :raises: ValueError
                       If the required params are not provided or if the response data format is unknown.
                     TypeError:
                        When the data type of response data is different from what we are expecting
                     ApiException:
                        Occurs when we get a HTTP error code (422 and above).

            """

            all_params = ['filename']
            all_params.append('callback')

            params = locals()
            for key, val in iteritems(params['kwargs']):
                if key not in all_params:
                    raise TypeError(
                        "Got an unexpected keyword argument '%s'"
                        " to method remove_scratch_file" % key
                    )
                params[key] = val
            del params['kwargs']

    
    
            # verify the required parameter 'filename' is set
            if ('filename' not in params) or (params['filename'] is None):
                raise ValueError("Missing the required parameter `filename` when calling `remove_scratch_file`")
    
    

            resource_path = '/files/{filename}'.replace('{format}', 'json')
            path_params = {}
    
            if 'filename' in params:
                path_params['filename'] = params['filename']
    

            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'])
            if not header_params['Accept']:
                del header_params['Accept']

            # HTTP header `Content-Type`
            header_params['Content-Type'] = self.api_client.\
                select_header_content_type(['application/json'])

            # Authentication setting
            auth_settings = ['basicAuth']

            response = self.api_client.call_api(resource_path, 'DELETE',
                                                path_params,
                                                query_params,
                                                header_params,
                                                body=body_params,
                                                post_params=form_params,
                                                files=local_var_files,
                                                response_type=None,
                                                auth_settings=auth_settings,
                                                callback=params.get('callback'))
            return response
    
    def remove_support_artifact(self, identifier, **kwargs):
            """
            Deletes a specific support artifact.
            Mode: Both Embedded and Proxy. 

            This method makes a synchronous HTTP request by default. To make an
            asynchronous HTTP request, please define a `callback` function
            to be invoked when receiving the response.
            >>> def callback_function(response):
            >>>     pprint(response)
            >>>
    
            >>> thread = api.remove_support_artifact(identifier, callback=callback_function)
    
    

            :param callback function: The callback function
                for asynchronous request. (optional)
    
            :param str identifier:  (required)
    
            :return: None
                     If the method is called asynchronously,
                     returns the request thread.
            :raises: ValueError
                       If the required params are not provided or if the response data format is unknown.
                     TypeError:
                        When the data type of response data is different from what we are expecting
                     ApiException:
                        Occurs when we get a HTTP error code (422 and above).

            """

            all_params = ['identifier']
            all_params.append('callback')

            params = locals()
            for key, val in iteritems(params['kwargs']):
                if key not in all_params:
                    raise TypeError(
                        "Got an unexpected keyword argument '%s'"
                        " to method remove_support_artifact" % key
                    )
                params[key] = val
            del params['kwargs']

    
    
            # verify the required parameter 'identifier' is set
            if ('identifier' not in params) or (params['identifier'] is None):
                raise ValueError("Missing the required parameter `identifier` when calling `remove_support_artifact`")
    
    

            resource_path = '/support-data/files/{identifier}'.replace('{format}', 'json')
            path_params = {}
    
            if 'identifier' in params:
                path_params['identifier'] = params['identifier']
    

            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'])
            if not header_params['Accept']:
                del header_params['Accept']

            # HTTP header `Content-Type`
            header_params['Content-Type'] = self.api_client.\
                select_header_content_type(['application/json'])

            # Authentication setting
            auth_settings = ['basicAuth']

            response = self.api_client.call_api(resource_path, 'DELETE',
                                                path_params,
                                                query_params,
                                                header_params,
                                                body=body_params,
                                                post_params=form_params,
                                                files=local_var_files,
                                                response_type=None,
                                                auth_settings=auth_settings,
                                                callback=params.get('callback'))
            return response
    
    def upload_file(self, **kwargs):
            """
            Upload a generic file for later reference in an API call.
            Mode: Both Embedded and Proxy. If your multipart form has non-file data, it will be ignored and only the files handled.

            This method makes a synchronous HTTP request by default. To make an
            asynchronous HTTP request, please define a `callback` function
            to be invoked when receiving the response.
            >>> def callback_function(response):
            >>>     pprint(response)
            >>>
    
            >>> thread = api.upload_file(callback=callback_function)
    
    

            :param callback function: The callback function
                for asynchronous request. (optional)
    
            :param file file: file
    
            :return: list[FileInfo]
                     If the method is called asynchronously,
                     returns the request thread.
            :raises: ValueError
                       If the required params are not provided or if the response data format is unknown.
                     TypeError:
                        When the data type of response data is different from what we are expecting
                     ApiException:
                        Occurs when we get a HTTP error code (422 and above).

            """

            all_params = ['file']
            all_params.append('callback')

            params = locals()
            for key, val in iteritems(params['kwargs']):
                if key not in all_params:
                    raise TypeError(
                        "Got an unexpected keyword argument '%s'"
                        " to method upload_file" % key
                    )
                params[key] = val
            del params['kwargs']

    
    
    

            resource_path = '/files'.replace('{format}', 'json')
            path_params = {}
    

            query_params = {}
    

            header_params = {}
    

            form_params = []
            local_var_files = {}
    
            if 'file' in params:
                local_var_files['file'] = params['file']
    

            body_params = None
    

            # HTTP header `Accept`
            header_params['Accept'] = self.api_client.\
                select_header_accept(['application/json'])
            if not header_params['Accept']:
                del header_params['Accept']

            # HTTP header `Content-Type`
            header_params['Content-Type'] = self.api_client.\
                select_header_content_type(['multipart/form-data'])

            # Authentication setting
            auth_settings = ['basicAuth']

            response = self.api_client.call_api(resource_path, 'POST',
                                                path_params,
                                                query_params,
                                                header_params,
                                                body=body_params,
                                                post_params=form_params,
                                                files=local_var_files,
                                                response_type='list[FileInfo]',
                                                auth_settings=auth_settings,
                                                callback=params.get('callback'))
            return response
    









