Skip to content

Commit 234be19

Browse files
use items instead of "features"
1 parent bf6bc0b commit 234be19

File tree

5 files changed

+32
-33
lines changed

5 files changed

+32
-33
lines changed

planet/cli/features.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ async def collections_list(ctx, pretty, compact):
9494
@click.argument("collection_id", required=True)
9595
@pretty
9696
async def collection_get(ctx, collection_id, pretty):
97-
"""List Features API collections
97+
"""Get a collection by ID
9898
9999
Example:
100100
@@ -119,7 +119,7 @@ async def items_list(ctx, collection_id, pretty):
119119
planet features items-list my-collection-123
120120
"""
121121
async with features_client(ctx) as cl:
122-
results = cl.list_features(collection_id)
122+
results = cl.list_items(collection_id)
123123
echo_json([f async for f in results], pretty)
124124

125125

@@ -154,7 +154,7 @@ async def item_get(ctx, collection_id, feature_id, pretty):
154154
collection_id, feature_id = split_ref(collection_id)
155155

156156
async with features_client(ctx) as cl:
157-
feature = await cl.get_feature(collection_id, feature_id)
157+
feature = await cl.get_item(collection_id, feature_id)
158158
echo_json(feature, pretty)
159159

160160

@@ -175,7 +175,7 @@ async def item_add(ctx, collection_id, filename, pretty):
175175
async with features_client(ctx) as cl:
176176
with open(filename) as data:
177177
try:
178-
res = await cl.add_features(collection_id, json.load(data))
178+
res = await cl.add_items(collection_id, json.load(data))
179179
except json.decoder.JSONDecodeError:
180180
raise ClickException(
181181
"Only JSON (.json, .geojson) files are supported in the CLI. Please use https://planet.com/features to upload other files."

planet/clients/features.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ async def get_collection(self, collection_id: str) -> dict:
114114
response = await self._session.request(method='GET', url=url)
115115
return response.json()
116116

117-
async def list_features(
117+
async def list_items(
118118
self,
119119
collection_id: str,
120120
limit: int = 10,
@@ -131,7 +131,7 @@ async def list_features(
131131
example:
132132
133133
```
134-
results = await client.list_features(collection_id)
134+
results = await client.list_items(collection_id)
135135
async for feature in results:
136136
print(feature.ref)
137137
print(feature["id"])
@@ -164,8 +164,7 @@ def _next_link(self, page):
164164
limit=limit):
165165
yield Feature(**feat)
166166

167-
async def get_feature(self, collection_id: str,
168-
feature_id: str) -> Feature:
167+
async def get_item(self, collection_id: str, feature_id: str) -> Feature:
169168
"""
170169
Return metadata for a single feature in a collection
171170
"""
@@ -198,10 +197,10 @@ async def create_collection(self,
198197

199198
return resp.json()["id"]
200199

201-
async def add_features(self,
202-
collection_id: str,
203-
feature: Union[dict, GeoInterface],
204-
property_id: Optional[str] = None) -> list[str]:
200+
async def add_items(self,
201+
collection_id: str,
202+
feature: Union[dict, GeoInterface],
203+
property_id: Optional[str] = None) -> list[str]:
205204
"""
206205
Add a Feature or FeatureCollection to the collection given by `collection_id`.
207206
Returns a list of feature references.

planet/sync/features.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def create_collection(self,
8383
collection = self._client.create_collection(title, description)
8484
return self._client._call_sync(collection)
8585

86-
def list_features(self, collection_id: str) -> Iterator[Feature]:
86+
def list_items(self, collection_id: str) -> Iterator[Feature]:
8787
"""
8888
List features in `collection_id`.
8989
@@ -97,7 +97,7 @@ def list_features(self, collection_id: str) -> Iterator[Feature]:
9797
9898
```
9999
pl = Planet()
100-
features = pl.features.list_features(collection_id)
100+
features = pl.features.list_items(collection_id)
101101
for feature in features:
102102
print(feature.ref)
103103
print(feature["id"])
@@ -107,25 +107,25 @@ def list_features(self, collection_id: str) -> Iterator[Feature]:
107107
results = pl.data.search(["PSScene"], geometry=feature])
108108
```
109109
"""
110-
results = self._client.list_features(collection_id)
110+
results = self._client.list_items(collection_id)
111111

112112
try:
113113
while True:
114114
yield self._client._call_sync(results.__anext__())
115115
except StopAsyncIteration:
116116
pass
117117

118-
def get_feature(self, collection_id: str, feature_id: str) -> Feature:
118+
def get_item(self, collection_id: str, feature_id: str) -> Feature:
119119
"""
120120
Return metadata for a single feature in a collection
121121
"""
122122
return self._client._call_sync(
123-
self._client.get_feature(collection_id, feature_id))
123+
self._client.get_item(collection_id, feature_id))
124124

125-
def add_features(self,
126-
collection_id: str,
127-
feature: Union[dict, GeoInterface],
128-
property_id: Optional[str] = None) -> list[str]:
125+
def add_items(self,
126+
collection_id: str,
127+
feature: Union[dict, GeoInterface],
128+
property_id: Optional[str] = None) -> list[str]:
129129
"""
130130
Add a Feature or FeatureCollection to the collection given by `collection_id`.
131131
Returns a list of feature references.
@@ -180,7 +180,7 @@ def add_features(self,
180180
"description": "Test feature"
181181
}
182182
}
183-
new_features = pl.features.add_features(
183+
new_features = pl.features.add_items(
184184
collection_id="my-collection",
185185
feature=feature,
186186
)
@@ -193,8 +193,8 @@ def add_features(self,
193193
The return value is always a list of references, even if you only upload one
194194
feature.
195195
"""
196-
uploaded_features = self._client.add_features(collection_id,
197-
feature,
198-
property_id)
196+
uploaded_features = self._client.add_items(collection_id,
197+
feature,
198+
property_id)
199199

200200
return self._client._call_sync(uploaded_features)

tests/integration/test_features_api.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ def assertf(resp):
220220

221221

222222
@respx.mock
223-
async def test_list_features(session: Session):
223+
async def test_list_items(session: Session):
224224
collection_id = "test"
225225
items_url = f'{TEST_URL}/collections/{collection_id}/items'
226226

@@ -234,8 +234,8 @@ def assertf(resp):
234234
cl_async = FeaturesClient(session, base_url=TEST_URL)
235235
cl_sync = FeaturesAPI(session, base_url=TEST_URL)
236236

237-
assertf([feat async for feat in cl_async.list_features(collection_id)])
238-
assertf(list(cl_sync.list_features(collection_id)))
237+
assertf([feat async for feat in cl_async.list_items(collection_id)])
238+
assertf(list(cl_sync.list_items(collection_id)))
239239

240240

241241
@respx.mock
@@ -245,7 +245,7 @@ def assertf(resp):
245245
(TEST_GEOM, TEST_GEOM),
246246
(ExampleGeoInterface(), TEST_GEOM),
247247
])
248-
async def test_add_features(feature, expected_body, session):
248+
async def test_add_items(feature, expected_body, session):
249249
"""test adding a feature with the SDK
250250
cases:
251251
* a geojson Feature
@@ -266,8 +266,8 @@ def assertf(resp):
266266
cl_async = FeaturesClient(session, base_url=TEST_URL)
267267
cl_sync = FeaturesAPI(session, base_url=TEST_URL)
268268

269-
assertf(await cl_async.add_features(collection_id, feature))
270-
assertf(cl_sync.add_features(collection_id, feature))
269+
assertf(await cl_async.add_items(collection_id, feature))
270+
assertf(cl_sync.add_items(collection_id, feature))
271271

272272
# check request body. In all test cases, the request body
273273
# should be a geojson Feature.

tests/integration/test_features_cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def assertf(resp):
7474

7575

7676
@respx.mock
77-
def test_list_features():
77+
def test_list_items():
7878
collection_id = "test"
7979
items_url = f'{TEST_URL}/collections/{collection_id}/items'
8080

@@ -93,7 +93,7 @@ def assertf(resp):
9393
(TEST_FEAT, TEST_GEOM),
9494
(TEST_GEOM, TEST_GEOM),
9595
])
96-
def test_add_features(feature, expected_body):
96+
def test_add_items(feature, expected_body):
9797
"""test adding a feature with the CLI
9898
cases:
9999
* a geojson Feature

0 commit comments

Comments
 (0)