Repository: planetlabs/planet-client-python

Issue:
Update `search-create` CLI and python API commands to match `search`
**Expected behavior**
UI of `planet data search-create` and `planet data search` should be similar.

**Actual behavior (describe the problem)**
`planet data search` has filter and name as options, `planet data search-create` has name and filter as arguments.

**Proposed Solution**

Update `search-create` CLI and python API commands to match `search`.

Discussion:

Patch:
diff --git a/planet/cli/data.py b/planet/cli/data.py
index cbca75e..46a9603 100644
--- a/planet/cli/data.py
+++ b/planet/cli/data.py
@@ -283,7 +283,8 @@ def filter(ctx,
                 callback=check_item_types)
 @click.option('--filter',
               type=types.JSON(),
-              help='Apply specified filter to search.')
+              help="""Apply specified filter to search. Can be a json string,
+              filename, or '-' for stdin.""")
 @limit
 @click.option('--name', type=str, help='Name of the saved search.')
 @click.option('--sort',
@@ -321,32 +322,35 @@ async def search(ctx, item_types, filter, limit, name, sort, pretty):
 @click.pass_context
 @translate_exceptions
 @coro
-@click.argument('name')
 @click.argument("item_types",
                 type=types.CommaSeparatedString(),
                 callback=check_item_types)
-@click.argument("filter", type=types.JSON())
+@click.option(
+    '--filter',
+    type=types.JSON(),
+    required=True,
+    help="""Filter to apply to search. Can be a json string, filename,
+         or '-' for stdin.""")
+@click.option('--name',
+              type=str,
+              required=True,
+              help='Name of the saved search.')
 @click.option('--daily-email',
               is_flag=True,
               help='Send a daily email when new results are added.')
 @pretty
-async def search_create(ctx, name, item_types, filter, daily_email, pretty):
+async def search_create(ctx, item_types, filter, name, daily_email, pretty):
     """Create a new saved structured item search.
 
     This function outputs a full JSON description of the created search,
     optionally pretty-printed.
 
-    NAME is the name to give the search.
-
     ITEM_TYPES is a comma-separated list of item-types to search.
-
-    FILTER must be JSON and can be specified a json string, filename, or '-'
-    for stdin.
     """
     async with data_client(ctx) as cl:
-        items = await cl.create_search(name=name,
-                                       item_types=item_types,
+        items = await cl.create_search(item_types=item_types,
                                        search_filter=filter,
+                                       name=name,
                                        enable_email=daily_email)
         echo_json(items, pretty)
 
diff --git a/planet/clients/data.py b/planet/clients/data.py
index 82c22c2..2e80dd0 100644
--- a/planet/clients/data.py
+++ b/planet/clients/data.py
@@ -167,9 +167,9 @@ class DataClient:
             yield i
 
     async def create_search(self,
-                            name: str,
                             item_types: List[str],
                             search_filter: dict,
+                            name: str,
                             enable_email: bool = False) -> dict:
         """Create a new saved structured item search.
 
@@ -190,9 +190,9 @@ class DataClient:
 
 
         Parameters:
-            name: The name of the saved search.
             item_types: The item types to include in the search.
             search_filter: Structured search criteria.
+            name: The name of the saved search.
             enable_email: Send a daily email when new results are added.
 
         Returns:
diff --git a/planet/clients/orders.py b/planet/clients/orders.py
index 584df8d..d0918c9 100644
--- a/planet/clients/orders.py
+++ b/planet/clients/orders.py
@@ -123,10 +123,10 @@ class OrdersClient:
         >>> from planet.order_request import build_request, product
         >>>
         >>> async def main():
-        ...     image_ids = ["20200925_161029_69_2223"]
+        ...     image_ids = ['3949357_1454705_2020-12-01_241c']
         ...     request = build_request(
         ...         'test_order',
-        ...         [product(image_ids, 'analytic_udm2', 'psscene')]
+        ...         [product(image_ids, 'analytic', 'psorthotile')]
         ...     )
         ...     async with Session() as sess:
         ...         cl = OrdersClient(sess)


Test patch:
diff --git a/tests/integration/test_data_api.py b/tests/integration/test_data_api.py
index 736d751..8a2c500 100644
--- a/tests/integration/test_data_api.py
+++ b/tests/integration/test_data_api.py
@@ -245,7 +245,9 @@ async def test_create_search_basic(search_filter, session):
     respx.post(TEST_SEARCHES_URL).return_value = mock_resp
 
     cl = DataClient(session, base_url=TEST_URL)
-    search = await cl.create_search('test', ['PSScene'], search_filter)
+    search = await cl.create_search(['PSScene'],
+                                    search_filter=search_filter,
+                                    name='test')
 
     # check that request is correct
     expected_request = {
@@ -281,8 +283,9 @@ async def test_create_search_email(search_filter, session):
     respx.post(TEST_SEARCHES_URL).return_value = mock_resp
 
     cl = DataClient(session, base_url=TEST_URL)
-    search = await cl.create_search('test', ['PSScene'],
-                                    search_filter,
+    search = await cl.create_search(['PSScene'],
+                                    search_filter=search_filter,
+                                    name='test',
                                     enable_email=True)
 
     # check that request is correct
diff --git a/tests/integration/test_data_cli.py b/tests/integration/test_data_cli.py
index 6150d25..47265bd 100644
--- a/tests/integration/test_data_cli.py
+++ b/tests/integration/test_data_cli.py
@@ -572,7 +572,13 @@ def test_data_search_create_filter_invalid_json(invoke, item_types, filter):
     name = "temp"
 
     runner = CliRunner()
-    result = invoke(["search-create", name, item_types, filter], runner=runner)
+    result = invoke([
+        "search-create",
+        item_types,
+        f'--name={name}',
+        f'--filter={json.dumps(filter)}'
+    ],
+                    runner=runner)
     assert result.exit_code == 2
 
 
@@ -599,7 +605,12 @@ def test_data_search_create_filter_success(invoke, item_types):
     respx.post(TEST_SEARCHES_URL).return_value = mock_resp
 
     runner = CliRunner()
-    result = invoke(["search-create", name, item_types, json.dumps(filter)],
+    result = invoke([
+        "search-create",
+        item_types,
+        f'--filter={json.dumps(filter)}',
+        f'--name={name}'
+    ],
                     runner=runner)
 
     assert result.exit_code == 0
@@ -621,9 +632,9 @@ def test_data_search_create_daily_email(invoke, search_result):
 
     result = invoke([
         'search-create',
-        'temp',
         'SkySatScene',
-        json.dumps(filter),
+        '--name=temp',
+        f'--filter={json.dumps(filter)}',
         '--daily-email'
     ])