def create(cls,
               name,
               title,
               description,
               owners=None,
               readers=None,
               writers=None,
               vector_client=None):
        """
        Create a vector product in your catalog.

        Example
        -------
        >>> from descarteslabs.vectors import FeatureCollection
        >>> FeatureCollection.create(name='foo',
        ...    title='My Foo Vector Collection',
        ...    description='Just a test')  # doctest: +SKIP
        """
        params = dict(
            name=name,
            title=title,
            description=description,
            owners=owners,
            readers=readers,
            writers=writers,
        )

        if vector_client is None:
            vector_client = Vector()

        return cls._from_jsonapi(
            vector_client.create_product(**params).data, vector_client)
Пример #2
0
    def create(cls,
               product_id,
               title,
               description,
               owners=None,
               readers=None,
               writers=None,
               vector_client=None):
        """
        Create a vector product in your catalog.

        Parameters
        ----------
        product_id : str
            A unique name for this product. In the created
            product a namespace consisting of your user id (e.g.
            "ae60fc891312ggadc94ade8062213b0063335a3c:") or your organization id (e.g.,
            "yourcompany:") will be prefixed to this, if it doesn't already have one, in
            order to make the id globally unique.
        title : str
            A more verbose and expressive name for display purposes.
        description : str
            Information about the `FeatureCollection`, why it exists,
            and what it provides.
        owners : list(str), optional
            User, group, or organization IDs that own
            the newly created FeatureCollection.  Defaults to
            [``current user``, ``current org``].
            The owner can edit and delete this `FeatureCollection`.
        readers : list(str), optional
            User, group, or organization IDs that can read
            the newly created `FeatureCollection`.
        writers : list(str), optional
            User, group, or organization IDs that can edit
            the newly created `FeatureCollection` (includes read permission).

        Example
        -------
        >>> from descarteslabs.vectors import FeatureCollection
        >>> FeatureCollection.create(product_id='foo',
        ...    title='My Foo Vector Collection',
        ...    description='Just a test')  # doctest: +SKIP
        """
        params = dict(
            product_id=product_id,
            title=title,
            description=description,
            owners=owners,
            readers=readers,
            writers=writers,
        )

        if vector_client is None:
            vector_client = Vector()

        return cls._from_jsonapi(
            vector_client.create_product(**params).data, vector_client)
    def create(cls,
               name,
               title,
               description,
               owners=None,
               readers=None,
               writers=None,
               vector_client=None):
        """
        Create a vector product in your catalog.

        Parameters
        ----------
        name : str
            A short name without spaces (like a handle).
        title : str
            A more verbose and expressive name for display purposes.
        description : str
            Information about the `FeatureCollection`, why it exists,
            and what it provides.
        owners : list(str), optional
            User, group, or organization IDs that own
            the newly created FeatureCollection.  Defaults to
            [``current user``, ``current org``].
            The owner can edit and delete this `FeatureCollection`.
        readers : list(str), optional
            User, group, or organization IDs that can read
            the newly created `FeatureCollection`.
        writers : list(str), optional
            User, group, or organization IDs that can edit
            the newly created `FeatureCollection` (includes read permission).

        Example
        -------
        >>> from descarteslabs.vectors import FeatureCollection
        >>> FeatureCollection.create(name='foo',
        ...    title='My Foo Vector Collection',
        ...    description='Just a test')  # doctest: +SKIP
        """
        params = dict(
            name=name,
            title=title,
            description=description,
            owners=owners,
            readers=readers,
            writers=writers,
        )

        if vector_client is None:
            vector_client = Vector()

        return cls._from_jsonapi(
            vector_client.create_product(**params).data, vector_client)
    def list(cls, vector_client=None):
        """
        List all ``FeatureCollection`` products that you have access to.

        Returns
        -------
        list(:class:`FeatureCollection`)
            A list of all products that you have access to.

        Raises
        ------
        ~descarteslabs.client.exceptions.NotFoundError
            Raised if subsequent pages cannot be found.
        ~descarteslabs.client.exceptions.RateLimitError
            Raised when too many requests have been made within a given time period.
        ~descarteslabs.client.exceptions.ServerError
            Raised when a unknown error occurred on the server.

        Example
        -------
        >>> from descarteslabs.vectors import FeatureCollection
        >>> FeatureCollection.list()  # doctest: +SKIP
        """

        if vector_client is None:
            vector_client = Vector()

        list = []

        page = 1
        # The first page will always succeed...
        response = vector_client.list_products(page=page)

        while len(response) > 0:
            partial_list = [
                cls._from_jsonapi(fc, vector_client) for fc in response.data
            ]
            list.extend(partial_list)
            page += 1

            # Subsequent pages may throw NotFoundError
            try:
                response = vector_client.list_products(page=page)
            except NotFoundError:
                response = []

        return list
Пример #5
0
    def __init__(self, guid, tuid=None, client=None, result_attrs=None, key=None):
        if client is None:
            from descarteslabs.client.services.vector import Vector  # circular import

            client = Vector()

        super(ExportTask, self).__init__(guid, tuid, client=client)
        self.export_id = tuid
        self._task_result = result_attrs
        self._set_key(key)
    def list(cls, vector_client=None):
        """
        List all `FeatureCollection` products that you have access to.

        Returns
        -------
        list(`FeatureCollection`)
            A list of all products that you have access to.

        Example
        -------
        >>> from descarteslabs.vectors import FeatureCollection
        >>> FeatureCollection.list()  # doctest: +SKIP
        """

        if vector_client is None:
            vector_client = Vector()

        list = []

        page = 1
        # The first page will always succeed...
        response = vector_client.list_products(page=page)

        while len(response) > 0:
            partial_list = [
                cls._from_jsonapi(fc, vector_client) for fc in response.data
            ]
            list.extend(partial_list)
            page += 1

            # Subsequent pages may throw NotFoundError
            try:
                response = vector_client.list_products(page=page)
            except NotFoundError:
                response = []

        return list
Пример #7
0
    def __init__(self,
                 guid,
                 tuid=None,
                 client=None,
                 upload_id=None,
                 result_attrs=None):
        if client is None:
            from descarteslabs.client.services.vector import Vector  # circular import
            client = Vector()

        super(UploadTask, self).__init__(guid, tuid, client=client)

        self._upload_id = upload_id
        self._task_result = result_attrs
Пример #8
0
    def setUp(self):
        self.url = "http://example.vector.com"
        self.gcs_url = "http://example.gcs.com"

        self.client = Vector(url=self.url,
                             auth=Auth(jwt_token=public_token,
                                       token_info_path=None))

        self.match_url = re.compile(self.url)
        self.match_gcs_url = re.compile(self.gcs_url)

        self.attrs = {
            'geometry': {
                'coordinates': [[[-113.40087890624999, 40.069664523297774],
                                 [-111.434326171875, 40.069664523297774],
                                 [-111.434326171875, 41.918628865183045],
                                 [-113.40087890624999, 41.918628865183045],
                                 [-113.40087890624999, 40.069664523297774]]],
                'type':
                'Polygon'
            },
            'properties': {
                'baz': 1.0,
                'foo': 'bar'
            }
        }

        self.product_response = {
            'data': {
                'attributes': {
                    'description':
                    'bar',
                    'name':
                    'new-test-product',
                    'owners': [
                        'org:descarteslabs',
                        'user:3d7bf4b0b1f4e6283e5cbeaadddbc6de6f16dea1'
                    ],
                    'readers': [],
                    'title':
                    'Test Product',
                    'writers': []
                },
                'id': '2b4552ff4b8a4bb5bb278c94005db50',
                'meta': {
                    'created': '2018-12-27T17:01:16.197369'
                },
                'type': 'product'
            }
        }

        self.status_response = {
            'data': {
                'attributes': {
                    'created': '2019-01-03T20:07:51.720000+00:00',
                    'started': '2019-01-03T20:07:51.903000+00:00',
                    'status': 'RUNNING'
                },
                'id': 'c589d688-3230-4caf-9f9d-18854f71e91d',
                'type': 'copy_query'
            }
        }
 def setUp(self):
     url = "http://example.com"
     self.client = Vector(
         url=url, auth=Auth(jwt_token=public_token, token_info_path=None)
     )
     self.match_url = re.compile(url)
Пример #10
0
    def vector_client(self):
        if self._vector_client is None:
            self._vector_client = Vector()

        return self._vector_client
    def create(
        cls,
        product_id,
        title,
        description,
        owners=None,
        readers=None,
        writers=None,
        vector_client=None,
    ):
        """
        Create a vector product in your catalog.

        Parameters
        ----------
        product_id : str
            A unique name for this product. In the created
            product a namespace consisting of your user id (e.g.
            "ae60fc891312ggadc94ade8062213b0063335a3c:") or your organization id (e.g.,
            "yourcompany:") will be prefixed to this, if it doesn't already have one, in
            order to make the id globally unique.
        title : str
            A more verbose and expressive name for display purposes.
        description : str
            Information about the ``FeatureCollection``, why it exists,
            and what it provides.
        owners : list(str), optional
            User, group, or organization IDs that own
            the newly created FeatureCollection.  Defaults to
            [``current user``, ``current org``].
            The owner can edit and delete this ``FeatureCollection``.
        readers : list(str), optional
            User, group, or organization IDs that can read
            the newly created ``FeatureCollection``.
        writers : list(str), optional
            User, group, or organization IDs that can edit
            the newly created ``FeatureCollection`` (includes read permission).

        Returns
        -------
        :class:`FeatureCollection`
            A new ``FeatureCollection``.

        Raises
        ------
        ~descarteslabs.client.exceptions.BadRequestError
            Raised when the request is malformed, e.g. the supplied product id is already in use.
        ~descarteslabs.client.exceptions.RateLimitError
            Raised when too many requests have been made within a given time period.
        ~descarteslabs.client.exceptions.ServerError
            Raised when a unknown error occurred on the server.

        Example
        -------
        >>> from descarteslabs.vectors import FeatureCollection
        >>> FeatureCollection.create(product_id='my-vector-product-id',
        ...    title='My Vector Collection',
        ...    description='Just a test')  # doctest: +SKIP
        """
        params = dict(
            product_id=product_id,
            title=title,
            description=description,
            owners=owners,
            readers=readers,
            writers=writers,
        )

        if vector_client is None:
            vector_client = Vector()

        return cls._from_jsonapi(
            vector_client.create_product(**params).data, vector_client)
Пример #12
0
    def setUp(self):
        self.url = "http://example.vector.com"
        self.gcs_url = "http://example.gcs.com"

        self.client = Vector(url=self.url,
                             auth=Auth(jwt_token=public_token,
                                       token_info_path=None))

        self.match_url = re.compile(self.url)
        self.match_gcs_url = re.compile(self.gcs_url)

        self.attrs = {
            "geometry": {
                "coordinates": [[
                    [-113.40087890624999, 40.069664523297774],
                    [-111.434326171875, 40.069664523297774],
                    [-111.434326171875, 41.918628865183045],
                    [-113.40087890624999, 41.918628865183045],
                    [-113.40087890624999, 40.069664523297774],
                ]],
                "type":
                "Polygon",
            },
            "properties": {
                "baz": 1.0,
                "foo": "bar"
            },
        }

        self.product_response = {
            "data": {
                "attributes": {
                    "description":
                    "bar",
                    "name":
                    "new-test-product",
                    "owners": [
                        "org:descarteslabs",
                        "user:3d7bf4b0b1f4e6283e5cbeaadddbc6de6f16dea1",
                    ],
                    "readers": [],
                    "title":
                    "Test Product",
                    "writers": [],
                },
                "id": "2b4552ff4b8a4bb5bb278c94005db50",
                "meta": {
                    "created": "2018-12-27T17:01:16.197369"
                },
                "type": "product",
            }
        }

        self.status_response = {
            "data": {
                "attributes": {
                    "created": "2019-01-03T20:07:51.720000+00:00",
                    "started": "2019-01-03T20:07:51.903000+00:00",
                    "status": "RUNNING",
                },
                "id": "c589d688-3230-4caf-9f9d-18854f71e91d",
                "type": "copy_query",
            }
        }

        self.feature_response = {
            "data": [{
                "attributes": {
                    "created": "2019-03-28T23:08:24.991729+00:00",
                    "geometry": {
                        "coordinates": [[[-95, 42], [-95, 41], [-93, 40],
                                         [-93, 42], [-95, 42]]],
                        "type":
                        "Polygon",
                    },
                    "properties": {},
                },
                "id": "7d724ae48d1fab595bc95b6091b005c920327",
                "type": "feature",
            }]
        }