コード例 #1
0
    def update_driver_duty_status(self, driver_id, body):
        """Does a PATCH request to /v1.0/drivers/{driverId}/duty_status.

        Clients can send custom-integrated duty status changes to the TSP to
        trigger duty status changes for a given driver by pushing data to this
        endpoint.
        **Access Controls**
        |Role:  |Vehicle Query|Vehicle Follow|Driver Query|Driver
        Follow|Driver Dispatch|Driver Duty |HR          |Admin       |
        |-------|-------------|--------------|------------|-------------|------
        ---------|------------|------------|------------|
        |Access:| **DENY**    | **DENY**     | **DENY**   | **DENY**    |
        **DENY**      | ALLOW      | **DENY**   | ALLOW      |

        Args:
            driver_id (string): The id of the driver who created this status
                change.
            body (ExternallyTriggeredDutyStatusChange): TODO: type description
                here. Example: 

        Returns:
            void: 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.

        """
        try:
            self.logger.info('update_driver_duty_status called.')

            # Prepare query URL
            self.logger.info(
                'Preparing query URL for update_driver_duty_status.')
            _url_path = '/v1.0/drivers/{driverId}/duty_status'
            _url_path = APIHelper.append_url_with_template_parameters(
                _url_path, {'driverId': driver_id})
            _query_builder = Configuration.get_base_uri()
            _query_builder += _url_path
            _query_url = APIHelper.clean_url(_query_builder)

            # Prepare headers
            self.logger.info(
                'Preparing headers for update_driver_duty_status.')
            _headers = {'content-type': 'application/json; charset=utf-8'}

            # Prepare and execute request
            self.logger.info(
                'Preparing and executing request for update_driver_duty_status.'
            )
            _request = self.http_client.patch(
                _query_url,
                headers=_headers,
                parameters=APIHelper.json_serialize(body))
            BasicAuth.apply(_request)
            _context = self.execute_request(_request,
                                            name='update_driver_duty_status')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info(
                'Validating response for update_driver_duty_status.')
            if _context.response.status_code == 401:
                raise APIException('', _context)
            elif _context.response.status_code == 404:
                raise APIException('Error: driverId Not Found', _context)
            elif _context.response.status_code == 429:
                raise APIException('', _context)
            self.validate_response(_context)

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise
コード例 #2
0
    def create_a_vehicle_route(self, vehicle_id, body):
        """Does a POST request to /v1.0/vehicles/{vehicleId}/routes.

        Clients can request the creation of a new route for a given vehicle,
        providing start & stop location along with
        additional instructions in a *Externally Sourced Route Start Stop
        Details* object.
        **Access Controls**
        |Role:  |Vehicle Query|Vehicle Follow|Driver Query|Driver
        Follow|Driver Dispatch|Driver Duty |HR          |Admin       |
        |-------|-------------|--------------|------------|-------------|------
        ---------|------------|------------|------------|
        |Access:| **DENY**    | **DENY**     | **DENY**   | **DENY**    |
        ALLOW         | **DENY**   | **DENY**   | ALLOW      |

        Args:
            vehicle_id (string): The vehicle id to associate this route to
            body (ExternallySourcedRouteStartStopDetails): TODO: type
                description here. Example: 

        Returns:
            CreateAVehicleRouteResponse: 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.

        """
        try:
            self.logger.info('create_a_vehicle_route called.')

            # Prepare query URL
            self.logger.info('Preparing query URL for create_a_vehicle_route.')
            _url_path = '/v1.0/vehicles/{vehicleId}/routes'
            _url_path = APIHelper.append_url_with_template_parameters(
                _url_path, {'vehicleId': vehicle_id})
            _query_builder = Configuration.get_base_uri()
            _query_builder += _url_path
            _query_url = APIHelper.clean_url(_query_builder)

            # Prepare headers
            self.logger.info('Preparing headers for create_a_vehicle_route.')
            _headers = {
                'accept': 'application/json',
                'content-type': 'application/json; charset=utf-8'
            }

            # Prepare and execute request
            self.logger.info(
                'Preparing and executing request for create_a_vehicle_route.')
            _request = self.http_client.post(
                _query_url,
                headers=_headers,
                parameters=APIHelper.json_serialize(body))
            BasicAuth.apply(_request)
            _context = self.execute_request(_request,
                                            name='create_a_vehicle_route')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info('Validating response for create_a_vehicle_route.')
            if _context.response.status_code == 401:
                raise APIException('', _context)
            elif _context.response.status_code == 404:
                raise APIException('Error: vehicleId Not Found', _context)
            elif _context.response.status_code == 429:
                raise APIException('', _context)
            self.validate_response(_context)

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

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise
コード例 #3
0
    def update_stop_geographic_details(self, stop_id, body):
        """Does a PATCH request to /v1.0/stops/{stopId}.

        Clients can update the _geographic details_ of a stop; the *Stop
        Geographic Details* are the specific location for the
        truck and trailer to park and a polygon of geographic points
        indicating the entryway onto a facility (i.e. where the
        truck should drive on approach).
        Sending data to this endpoint, using a previously returned `stopId`
        will update the geograhic details of the stop and
        any other routes using this stop will also be updated.
        **Access Controls**
        |Role:  |Vehicle Query|Vehicle Follow|Driver Query|Driver
        Follow|Driver Dispatch|Driver Duty |HR          |Admin       |
        |-------|-------------|--------------|------------|-------------|------
        ---------|------------|------------|------------|
        |Access:| **DENY**    | **DENY**     | **DENY**   | **DENY**    |
        ALLOW         | **DENY**   | **DENY**   | ALLOW      |

        Args:
            stop_id (string): The stop id to update
            body (ExternallySourcedStopGeographicDetails): TODO: type
                description here. Example: 

        Returns:
            UpdateStopGeographicDetailsResponse: 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.

        """
        try:
            self.logger.info('update_stop_geographic_details called.')

            # Prepare query URL
            self.logger.info(
                'Preparing query URL for update_stop_geographic_details.')
            _url_path = '/v1.0/stops/{stopId}'
            _url_path = APIHelper.append_url_with_template_parameters(
                _url_path, {'stopId': stop_id})
            _query_builder = Configuration.get_base_uri()
            _query_builder += _url_path
            _query_url = APIHelper.clean_url(_query_builder)

            # Prepare headers
            self.logger.info(
                'Preparing headers for update_stop_geographic_details.')
            _headers = {
                'accept': 'application/json',
                'content-type': 'application/json; charset=utf-8'
            }

            # Prepare and execute request
            self.logger.info(
                'Preparing and executing request for update_stop_geographic_details.'
            )
            _request = self.http_client.patch(
                _query_url,
                headers=_headers,
                parameters=APIHelper.json_serialize(body))
            BasicAuth.apply(_request)
            _context = self.execute_request(
                _request, name='update_stop_geographic_details')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info(
                'Validating response for update_stop_geographic_details.')
            if _context.response.status_code == 401:
                raise APIException('', _context)
            elif _context.response.status_code == 404:
                raise APIException('Error: stopId Not Found', _context)
            elif _context.response.status_code == 429:
                raise APIException('', _context)
            self.validate_response(_context)

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

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise
コード例 #4
0
    def update_driver_route_stop(self, vehicle_id, route_id, body):
        """Does a PUT request to /v1.0/vehicles/{vehicleId}/routes/{routeId}.

        Clients can update a Driver's destination; sending data to this
        endpoint, using a previously obtained `routeId` will
        change the destination of the route, hence also changing the stopId
        associated with the route.
        **Access Controls**
        |Role:  |Vehicle Query|Vehicle Follow|Driver Query|Driver
        Follow|Driver Dispatch|Driver Duty |HR          |Admin       |
        |-------|-------------|--------------|------------|-------------|------
        ---------|------------|------------|------------|
        |Access:| **DENY**    | **DENY**     | **DENY**   | **DENY**    |
        ALLOW         | **DENY**   | **DENY**   | ALLOW      |

        Args:
            vehicle_id (string): The vehicle id to associate this route to
            route_id (string): the id of the route created, to be used for
                later updates to the route
            body (ExternallySourcedRouteStopDetails): TODO: type description
                here. Example: 

        Returns:
            UpdateDriverRouteStopResponse: 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.

        """
        try:
            self.logger.info('update_driver_route_stop called.')

            # Prepare query URL
            self.logger.info(
                'Preparing query URL for update_driver_route_stop.')
            _url_path = '/v1.0/vehicles/{vehicleId}/routes/{routeId}'
            _url_path = APIHelper.append_url_with_template_parameters(
                _url_path, {
                    'vehicleId': vehicle_id,
                    'routeId': route_id
                })
            _query_builder = Configuration.get_base_uri()
            _query_builder += _url_path
            _query_url = APIHelper.clean_url(_query_builder)

            # Prepare headers
            self.logger.info('Preparing headers for update_driver_route_stop.')
            _headers = {
                'accept': 'application/json',
                'content-type': 'application/json; charset=utf-8'
            }

            # Prepare and execute request
            self.logger.info(
                'Preparing and executing request for update_driver_route_stop.'
            )
            _request = self.http_client.put(
                _query_url,
                headers=_headers,
                parameters=APIHelper.json_serialize(body))
            BasicAuth.apply(_request)
            _context = self.execute_request(_request,
                                            name='update_driver_route_stop')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info(
                'Validating response for update_driver_route_stop.')
            if _context.response.status_code == 401:
                raise APIException('', _context)
            elif _context.response.status_code == 404:
                raise APIException('Error: vehicleId or routeId Not Found',
                                   _context)
            elif _context.response.status_code == 429:
                raise APIException('', _context)
            self.validate_response(_context)

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

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise
コード例 #5
0
    def send_message_to_a_vehicle(self, vehicle_id, body):
        """Does a POST request to /v1.0/vehicles/{vehicleId}/message.

        **Access Controls**
        |Role:  |Vehicle Query|Vehicle Follow|Driver Query|Driver
        Follow|Driver Dispatch|Driver Duty |HR          |Admin       |
        |-------|-------------|--------------|------------|-------------|------
        ---------|------------|------------|------------|
        |Access:| **DENY**    | **DENY**     | **DENY**   | **DENY**    |
        ALLOW         | **DENY**   | **DENY**   | ALLOW      |

        Args:
            vehicle_id (string): The vehicle id to send the message to
            body (ExternallySourcedVehicleDisplayMessages): TODO: type
                description here. Example: 

        Returns:
            void: 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.

        """
        try:
            self.logger.info('send_message_to_a_vehicle called.')

            # Prepare query URL
            self.logger.info(
                'Preparing query URL for send_message_to_a_vehicle.')
            _url_path = '/v1.0/vehicles/{vehicleId}/message'
            _url_path = APIHelper.append_url_with_template_parameters(
                _url_path, {'vehicleId': vehicle_id})
            _query_builder = Configuration.get_base_uri()
            _query_builder += _url_path
            _query_url = APIHelper.clean_url(_query_builder)

            # Prepare headers
            self.logger.info(
                'Preparing headers for send_message_to_a_vehicle.')
            _headers = {'content-type': 'application/json; charset=utf-8'}

            # Prepare and execute request
            self.logger.info(
                'Preparing and executing request for send_message_to_a_vehicle.'
            )
            _request = self.http_client.post(
                _query_url,
                headers=_headers,
                parameters=APIHelper.json_serialize(body))
            BasicAuth.apply(_request)
            _context = self.execute_request(_request,
                                            name='send_message_to_a_vehicle')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info(
                'Validating response for send_message_to_a_vehicle.')
            if _context.response.status_code == 401:
                raise APIException('', _context)
            elif _context.response.status_code == 404:
                raise APIException('Error: vehicleId not found', _context)
            elif _context.response.status_code == 429:
                raise APIException('', _context)
            self.validate_response(_context)

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise