Exemple #1
0
    def update(self, entry_id, body):
        """Does a PUT request to /v1.1/whitelists/geolocations/{entry_id}/update.

        Update a Geo Location in the Whitelist

        Args:
            entry_id (string): a unique identifier for the Geo Location;
                opaque but likely a GUID
            body (GeoLocation): TODO: type description here. Example: 

        Returns:
            UpdateResponse1: Response from the API. 

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """

        # Prepare query URL
        _url_path = '/v1.1/whitelists/geolocations/{entry_id}/update'
        _url_path = APIHelper.append_url_with_template_parameters(
            _url_path, {'entry_id': entry_id})
        _query_builder = Configuration.get_base_uri()
        _query_builder += _url_path
        _query_url = APIHelper.clean_url(_query_builder)

        # Prepare headers
        _headers = {
            'accept': 'application/json',
            'content-type': 'application/json; charset=utf-8'
        }

        # Prepare and execute request
        _request = self.http_client.put(
            _query_url,
            headers=_headers,
            parameters=APIHelper.json_serialize(body))
        CustomAuth.apply(_request)
        _context = self.execute_request(_request)

        # Endpoint and global error handling using HTTP status codes.
        if _context.response.status_code == 400:
            raise ReturnException(
                'Unexpected error in API call. See HTTP response body for details.',
                _context)
        self.validate_response(_context)

        # Return appropriate type
        return APIHelper.json_deserialize(_context.response.raw_body,
                                          UpdateResponse1.from_dictionary)
Exemple #2
0
    def register_new_user(self, body):
        """Does a POST request to /v1.1/register.

        ONLY AVAILABLE when Bouncer is started with the `--testing`
        parameter.
        Register a new user with this instance of Bouncer.

        Args:
            body (RegisterNewUserRequest): TODO: type description here.
                Example: 

        Returns:
            RegisterNewUserResponse: Response from the API. 

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """

        # Prepare query URL
        _url_path = '/v1.1/register'
        _query_builder = Configuration.get_base_uri()
        _query_builder += _url_path
        _query_url = APIHelper.clean_url(_query_builder)

        # Prepare headers
        _headers = {
            'accept': 'application/json',
            'content-type': 'application/json; charset=utf-8'
        }

        # Prepare and execute request
        _request = self.http_client.post(
            _query_url,
            headers=_headers,
            parameters=APIHelper.json_serialize(body))
        CustomAuth.apply(_request)
        _context = self.execute_request(_request)

        # Endpoint and global error handling using HTTP status codes.
        if _context.response.status_code == 400:
            raise ReturnException(
                'Unexpected error in API call. See HTTP response body for details.',
                _context)
        self.validate_response(_context)

        # Return appropriate type
        return APIHelper.json_deserialize(
            _context.response.raw_body,
            RegisterNewUserResponse.from_dictionary)
Exemple #3
0
    def create(self, body):
        """Does a POST request to /v1.1/whitelists/geolocations/create.

        Create a Geo Location in the Whitelist. When POSTed-to this endpoint,
        Bouncer scans `geolist.txt` for any IPs matching the Country Code (CC)
        in the POSTed object and, for each: Bouncer will create a new
        ipaddress in this list (black- or white-list).

        Args:
            body (GeoLocation): TODO: type description here. Example: 

        Returns:
            CreateResponse1: Response from the API. 

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """

        # Prepare query URL
        _url_path = '/v1.1/whitelists/geolocations/create'
        _query_builder = Configuration.get_base_uri()
        _query_builder += _url_path
        _query_url = APIHelper.clean_url(_query_builder)

        # Prepare headers
        _headers = {
            'accept': 'application/json',
            'content-type': 'application/json; charset=utf-8'
        }

        # Prepare and execute request
        _request = self.http_client.post(
            _query_url,
            headers=_headers,
            parameters=APIHelper.json_serialize(body))
        CustomAuth.apply(_request)
        _context = self.execute_request(_request)

        # Endpoint and global error handling using HTTP status codes.
        if _context.response.status_code == 400:
            raise ReturnException(
                'Unexpected error in API call. See HTTP response body for details.',
                _context)
        self.validate_response(_context)

        # Return appropriate type
        return APIHelper.json_deserialize(_context.response.raw_body,
                                          CreateResponse1.from_dictionary)