コード例 #1
0
    def update_srs(self,
                   project: ResourceId,
                   *,
                   horizontal_srs_wkt: str = None,
                   vertical_srs_wkt: str = None,
                   **kwargs) -> Project:
        """Update the SRS of a project. Horizontal or Vertical or both.

        Args:
            project: Identifier of the project to update.

            horizontal_srs_wkt: Optional WKT of horizontal SRS.

            vertical_srs_wkt: Optional WKT of vertical SRS.

            **kwargs: Optional keyword arguments. Those arguments are
                passed as is to the API provider.

        Returns:
            Project: Updated project resource.
        """

        data = kwargs
        data.update({'project': project})
        if horizontal_srs_wkt is not None:
            data['horizontal_srs_wkt'] = horizontal_srs_wkt
        if vertical_srs_wkt is not None:
            data['vertical_srs_wkt'] = vertical_srs_wkt

        desc = self._provider.post(path='update-project-srs', data=data)
        return Project(**desc)
コード例 #2
0
    def update_bbox(self, project: ResourceId, *, real_bbox: dict,
                    **kwargs) -> Project:
        """Update the project real bbox.

        Args:
            project: Identifier of the project to update.

            real_bbox: GeoJSON Geometry, needs ``type`` and ``coordinates``, and an
                optional ``bbox`` with 4-numbers's list (``[minX, minY, maxX, maxY]``).

            **kwargs: Optional keyword arguments. Those arguments are
                passed as is to the API provider.

        Returns:
            Project: Updated project resource.

        Examples:
            >>> sdk.projects.update_bbox('5d6e0dcc965a0f56891f3860', real_bbox={
            ...     'type': 'Polygon',
            ...     'coordinates': [[[112.5, 43.2], [112.6, 43.3], [112.7, 43.1], [112.5, 43.2]]],
            ... })
            Project(_id='5d6e0dcc965a0f56891f3860')

        """
        if not real_bbox.get('type'):
            raise QueryError('"real_bbox.type" must exists')
        if not real_bbox.get('coordinates'):
            raise QueryError('"real_bbox.coordinates" must exists')

        data = kwargs
        data.update({'project': project, 'real_bbox': real_bbox})
        desc = self._provider.post(path='update-project-bbox', data=data)
        return Project(**desc)
コード例 #3
0
    def update_units(self, project: ResourceId, *, units: dict,
                     **kwargs) -> Project:
        """Update the units of a project.

        Args:
            project: Identifier of the project to update.

            units: Dictionary of different types of units ("distances", "surfaces", "volumes",
                "altitude", "gsd", "weight", "slope").

            **kwargs: Optional keyword arguments. Those arguments are
                passed as is to the API provider.

        Returns:
            Project: Updated project resource.

        Examples:
            >>> sdk.projects.update_units('3037636c9a416900074ac253', units={
            ...     'distances': 'feet',
            ...     'surfaces': 'square-feet',
            ...     'volumes': 'cubic-feet',
            ...     'altitude': 'feet',
            ...     'gsd': 'inch/pixel',
            ...     'weight': 'metric-tons',
            ...     'slope': 'percent',
            ... })
            Project(_id='3037636c9a416900074ac253')
        """

        data = kwargs
        data.update({'project': project, 'units': units})
        desc = self._provider.post(path='update-project-units', data=data)
        return Project(**desc)
コード例 #4
0
    def update_status(self, project: ResourceId, status: str) -> Project:
        """Update the project status.

        Args:
            project: Identifier of the project to update.

            status: Project status (``pending``, ``available``, ``failed``, ``maintenance``).

        Raises:
            ResponseError : When the project has not been found.

            RuntimeError: The passed status is not allowed.

        Returns:
            Project: Updated project resource.

        """
        available_status = ['pending', 'available', 'failed', 'maintenance']
        if status not in available_status:
            raise RuntimeError(f'Status not in {available_status}')

        data = {'project': project, 'status': status}
        content = self._provider.post(path=f'projects/update/{project}',
                                      data=data)

        if project not in str(content):
            raise ResponseError(f'Project {project!r} has not been found')
        else:
            d = content.get('project')
            project_resource = Project(**d)
        return project_resource
コード例 #5
0
    def compute_bbox(self, project: ResourceId, **kwargs) -> Project:
        """Perform an automatic computation of the project's bbox.

        Args:
            project: Identifier of the project to update.

            **kwargs: Optional keyword arguments. Those arguments are
                passed as is to the API provider.

        Returns:
            Project: Updated project resource.
        """
        data = kwargs
        data.update({'project': project})
        desc = self._provider.post(path='compute-project-bbox', data=data)
        return Project(**desc)
コード例 #6
0
    def update_location(self,
                        project: ResourceId,
                        *,
                        location: List[float] = None,
                        fixed: bool = None,
                        **kwargs) -> Project:
        """Update the project's location, set if the project's location is fixed. Or both updates.

        Args:
            project: Identifier of the project to update.

            location: Optional Location in WGS84: (format: ``[Longitude, Latitude]``).
                ``None`` to not change this parameter.

            fixed: Optional Flag to indicate if the location value will be fixed or not.
                ``True`` if you want to fix the position. ``False`` to let the location
                automatically updated in the future. ``None`` to not change this parameter.
                Default: None.

            **kwargs: Optional keyword arguments. Those arguments are
                passed as is to the API provider.

        Returns:
            Project: Updated project resource.

        Examples:
            >>> # fix a location of a project. It will not change automatically.
            >>> sdk.projects.update_location('5d6e0dcc965a0f56891f3861',
            ...                              location=[-118.254, 46.95],
            ...                              fixed=True)
            Project(_id='5d6e0dcc965a0f56891f3861')
            >>> # Remove fixed location of a project. It will change automatically.
            >>> sdk.projects.update_location('3037636c9a416900074ac253',
            ...                              fixed=None)
            Project(_id='3037636c9a416900074ac253')

        """

        data = kwargs
        data.update({'project': project})
        if location is not None:
            data['location'] = location
        if fixed is not None:
            data['fixed'] = bool(fixed)

        desc = self._provider.post(path='update-project-location', data=data)
        return Project(**desc)
コード例 #7
0
    def update_name(self, project: ResourceId, *, name: str,
                    **kwargs) -> Project:
        """Update the project name.

        Args:
            project: Identifier of the project to update.

            name: New project name.

            **kwargs: Optional keyword arguments. Those arguments are
                passed as is to the API provider.

        Returns:
            Project: Updated project resource.
        """
        data = kwargs
        data.update({'project': project, 'name': name})
        desc = self._provider.post(path='update-project-name', data=data)
        return Project(**desc)
コード例 #8
0
    def test_create_mission(self):
        responses.add('POST', '/project-manager/missions',
                      body=self.__create_mission_post_response(), status=200,
                      content_type='application/json')

        project = Project(id='project_id')
        self.sdk.missions.create_mission(
          project=project.id,
          survey_date='2019-06-01T00:00:00.000Z',
          name='mission_name'
        )

        calls = responses.calls

        # test responses
        self.assertEqual(len(calls), 1)

        self.assertEqual(calls[0].request.url, '/project-manager/missions')
        self.assertEqual(json.loads(calls[0].request.body),
                         json.loads(MISSION_CREATION_RESP_BODY))
コード例 #9
0
    def update_local_coordinates_dataset(self, project: ResourceId, *,
                                         dataset: ResourceId,
                                         **kwargs) -> Project:
        """Update the local coordinates dataset of a project.

        Args:
            project: Identifier of the project to update.

            dataset: Dataset identifier of the local coordinates file.

            **kwargs: Optional keyword arguments. Those arguments are
                passed as is to the API provider.

        Returns:
            Project: Updated project resource.
        """

        data = kwargs
        data.update({'project': project, 'local_coords_dataset': dataset})
        desc = self._provider.post(path='update-project-local-coords',
                                   data=data)
        return Project(**desc)
コード例 #10
0
    def create(self,
               name: str,
               company: ResourceId,
               geometry: dict = None,
               **kwargs) -> Project:
        """Create a project.

        Args:
            name: Project name.

            company: Company identifier.

            geometry: Optional project geometry.

            **kwargs: Optional keyword arguments. Those arguments are
                passed as is to the API provider.

        Raises:
            QueryError: The project creation response is incorrect.

        Returns:
            Project: A resource encapsulating the created project.

        """
        data = kwargs

        data.update({'name': name, 'company': company})

        if geometry is not None:
            data['geometry'] = geometry

        if 'addProjectToUsers' not in data:
            data['addProjectToUsers'] = True

        content = self._provider.post(path='projects', data=data)
        if 'project' not in content:
            raise QueryError('"project" should be in the response content')
        project_desc = content['project']
        return Project(**project_desc)
コード例 #11
0
    def update_geometry(self, project: ResourceId, *, geometry: dict,
                        **kwargs) -> Project:
        """Update the project geometry.

        Args:
            project: Identifier of the project to update.

            geometry: GeoJSON Geometry format, needs ``type`` and ``coordinates``.

            **kwargs: Optional keyword arguments. Those arguments are
                passed as is to the API provider.

        Returns:
            Project: Updated project resource.
        """
        if not geometry.get('type'):
            raise QueryError('"geometry.type" must exists')
        if not geometry.get('coordinates'):
            raise QueryError('"geometry.coordinates" must exists')
        data = kwargs
        data.update({'project': project, 'geometry': geometry})
        desc = self._provider.post(path='update-project-geometry', data=data)
        return Project(**desc)