コード例 #1
0
    def _create(self, **kwargs):
        """Create operation - private method"""

        config = misc_utils.resolve_config(kwargs.pop('config', None),
                                           kwargs.pop('config_file', None))

        return self._make_request(method='POST', config=config)
コード例 #2
0
    def create(self, **kwargs):
        """Creates (or updates) extension component service

        Parameters
        ----------
        **kwargs :
            optional keyword arguments

        Keyword Arguments
        -----------------
        config : dict
            a dictionary containing configuration
        config_file : str
            a local file containing configuration to load

        Returns
        -------
        dict
            the response to a service create
        """

        config = kwargs.pop('config', None)
        config_file = kwargs.pop('config_file', None)

        response, status_code = self._client.make_request(
            self._get_configure_endpoint()['uri'],
            method='POST',
            body=misc_utils.resolve_config(config, config_file),
            advanced_return=True)

        # check for async task pattern response
        if status_code == constants.HTTP_STATUS_CODE['ACCEPTED']:
            return self._wait_for_task(response['selfLink'])
        # return response data
        return response
コード例 #3
0
    def _update(self, **kwargs):
        """Update operation - private method"""

        resource_name = self._get_resource_name(**kwargs)
        config = misc_utils.resolve_config(kwargs.pop('config', None),
                                           kwargs.pop('config_file', None))

        return self._make_request(uri='%s/%s' %
                                  (self._metadata['uri'], resource_name),
                                  method='PUT',
                                  config=config)
コード例 #4
0
    def _reset(self, **kwargs):
        """Performs a POST against the component reset endpoint

        Parameters
        ----------
        **kwargs :
            optional keyword arguments

        Keyword Arguments
        -----------------
        config : dict
            a dictionary containing configuration
        config_file : str
            a local file containing configuration to load

        Returns
        -------
        dict
            the API response
        """

        config = kwargs.pop('config', None)
        config_file = kwargs.pop('config_file', None)

        # set default if no declaration is provided
        if config is None and config_file is None:
            config = self._get_reset_endpoint()["defaultPostBody"]
        else:
            config = misc_utils.resolve_config(config, config_file)

        response, status_code = self._client.make_request(
            self._get_reset_endpoint()['uri'],
            method='POST',
            body=config,
            advanced_return=True)

        # check for async task pattern response
        if status_code == constants.HTTP_STATUS_CODE['ACCEPTED']:
            return self._wait_for_task(response['selfLink'])
        # return response data
        return response