mcm-cli 1.3.1__tar.gz → 1.4.0__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. {mcm_cli-1.3.1/mcm_cli.egg-info → mcm_cli-1.4.0}/PKG-INFO +1 -1
  2. {mcm_cli-1.3.1 → mcm_cli-1.4.0/mcm_cli.egg-info}/PKG-INFO +1 -1
  3. {mcm_cli-1.3.1 → mcm_cli-1.4.0}/mcm_cli.egg-info/SOURCES.txt +1 -0
  4. {mcm_cli-1.3.1 → mcm_cli-1.4.0}/mcmcli/__main__.py +1 -1
  5. {mcm_cli-1.3.1 → mcm_cli-1.4.0}/mcmcli/command/admin.py +64 -0
  6. mcm_cli-1.4.0/mcmcli/data/item_blocking_result.py +54 -0
  7. {mcm_cli-1.3.1 → mcm_cli-1.4.0}/setup.py +1 -1
  8. {mcm_cli-1.3.1 → mcm_cli-1.4.0}/LICENSE +0 -0
  9. {mcm_cli-1.3.1 → mcm_cli-1.4.0}/NOTICE +0 -0
  10. {mcm_cli-1.3.1 → mcm_cli-1.4.0}/README.md +0 -0
  11. {mcm_cli-1.3.1 → mcm_cli-1.4.0}/mcm_cli.egg-info/dependency_links.txt +0 -0
  12. {mcm_cli-1.3.1 → mcm_cli-1.4.0}/mcm_cli.egg-info/entry_points.txt +0 -0
  13. {mcm_cli-1.3.1 → mcm_cli-1.4.0}/mcm_cli.egg-info/requires.txt +0 -0
  14. {mcm_cli-1.3.1 → mcm_cli-1.4.0}/mcm_cli.egg-info/top_level.txt +0 -0
  15. {mcm_cli-1.3.1 → mcm_cli-1.4.0}/mcmcli/__init__.py +0 -0
  16. {mcm_cli-1.3.1 → mcm_cli-1.4.0}/mcmcli/command/account.py +0 -0
  17. {mcm_cli-1.3.1 → mcm_cli-1.4.0}/mcmcli/command/auth.py +0 -0
  18. {mcm_cli-1.3.1 → mcm_cli-1.4.0}/mcmcli/command/config.py +0 -0
  19. {mcm_cli-1.3.1 → mcm_cli-1.4.0}/mcmcli/command/decision.py +0 -0
  20. {mcm_cli-1.3.1 → mcm_cli-1.4.0}/mcmcli/command/wallet.py +0 -0
  21. {mcm_cli-1.3.1 → mcm_cli-1.4.0}/mcmcli/data/account.py +0 -0
  22. {mcm_cli-1.3.1 → mcm_cli-1.4.0}/mcmcli/data/account_user.py +0 -0
  23. {mcm_cli-1.3.1 → mcm_cli-1.4.0}/mcmcli/data/decision.py +0 -0
  24. {mcm_cli-1.3.1 → mcm_cli-1.4.0}/mcmcli/data/error.py +0 -0
  25. {mcm_cli-1.3.1 → mcm_cli-1.4.0}/mcmcli/data/item.py +0 -0
  26. {mcm_cli-1.3.1 → mcm_cli-1.4.0}/mcmcli/data/seller.py +0 -0
  27. {mcm_cli-1.3.1 → mcm_cli-1.4.0}/mcmcli/data/token.py +0 -0
  28. {mcm_cli-1.3.1 → mcm_cli-1.4.0}/mcmcli/data/wallet.py +0 -0
  29. {mcm_cli-1.3.1 → mcm_cli-1.4.0}/mcmcli/logging.py +0 -0
  30. {mcm_cli-1.3.1 → mcm_cli-1.4.0}/mcmcli/requests.py +0 -0
  31. {mcm_cli-1.3.1 → mcm_cli-1.4.0}/setup.cfg +0 -0
  32. {mcm_cli-1.3.1 → mcm_cli-1.4.0}/tests/test_config.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mcm-cli
3
- Version: 1.3.1
3
+ Version: 1.4.0
4
4
  Summary: A command-line interface for Moloco Commerde Media
5
5
  Home-page: https://github.com/moloco-mcm/mcm-cli
6
6
  Author: Moloco MCM Team
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mcm-cli
3
- Version: 1.3.1
3
+ Version: 1.4.0
4
4
  Summary: A command-line interface for Moloco Commerde Media
5
5
  Home-page: https://github.com/moloco-mcm/mcm-cli
6
6
  Author: Moloco MCM Team
@@ -23,6 +23,7 @@ mcmcli/data/account_user.py
23
23
  mcmcli/data/decision.py
24
24
  mcmcli/data/error.py
25
25
  mcmcli/data/item.py
26
+ mcmcli/data/item_blocking_result.py
26
27
  mcmcli/data/seller.py
27
28
  mcmcli/data/token.py
28
29
  mcmcli/data/wallet.py
@@ -35,7 +35,7 @@ def version():
35
35
  """
36
36
  Show the tool version
37
37
  """
38
- typer.echo(f"Version: mcm-cli v1.3.1")
38
+ typer.echo(f"Version: mcm-cli v1.4.0")
39
39
 
40
40
  app.add_typer(mcmcli.command.account.app, name="account", help="Ad account management")
41
41
  app.add_typer(mcmcli.command.admin.app, name="admin", help="Platform administration")
@@ -11,6 +11,11 @@
11
11
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
+ from datetime import datetime, timedelta, timezone
15
+ from mcmcli.data.error import Error
16
+ from mcmcli.data.item_blocking_result import ItemBlockingResult
17
+ from mcmcli.requests import CurlString, api_request
18
+ from typing import Optional
14
19
 
15
20
  import mcmcli.command.account
16
21
  import mcmcli.command.auth
@@ -43,6 +48,35 @@ def list_wallet_balances(
43
48
  admin.list_wallet_balances()
44
49
 
45
50
 
51
+ @app.command()
52
+ def block_item(
53
+ item_id: str = typer.Option(help="Item ID"),
54
+ account_id: str = typer.Option(None, help="The Ad Account ID is applicable only for MSPI catalogs. If this value is provided, only the item associated with the specified seller ID will be removed from ad serving. If it is not provided, the specified item will be removed for all sellers in the MSPI catalog."),
55
+ to_curl: bool = typer.Option(False, help="Generate the curl command instead of executing it."),
56
+ profile: str = typer.Option("default", help="Profile name of the MCM CLI."),
57
+ ):
58
+ """
59
+ Item Kill Switch Command.
60
+ This API immediately blocks an item or an ad account item from appearing in ads by marking it as “blocked.”
61
+ """
62
+ timestamp = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%S.%fZ")
63
+
64
+ # print(f"invoked block_item(item_id={item_id}, account_id={account_id}, blocked='Requested at {timestamp}')");
65
+ admin = _create_admin_command(profile)
66
+ if admin is None:
67
+ return
68
+
69
+ curl, error, result = admin.block_item(item_id=item_id, account_id=account_id, to_curl=to_curl)
70
+ if curl:
71
+ print(curl)
72
+ return
73
+ if error:
74
+ print(f"ERROR: {error.message}", file=sys.stderr, flush=True)
75
+ return
76
+
77
+ print(result.model_dump_json())
78
+ return
79
+
46
80
  class AdminCommand:
47
81
  def __init__(
48
82
  self,
@@ -63,6 +97,36 @@ class AdminCommand:
63
97
  "Authorization": f"Bearer {token}"
64
98
  }
65
99
 
100
+ def block_item(
101
+ self,
102
+ item_id,
103
+ account_id,
104
+ to_curl,
105
+ ) -> tuple[
106
+ Optional[CurlString],
107
+ Optional[Error],
108
+ Optional[ItemBlockingResult],
109
+ ]:
110
+ _api_url = f"{self.api_base_url}/item-status-bulk"
111
+ _requested_at = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%S.%fZ")
112
+ _payload = {
113
+ "items": [{
114
+ "item_id": item_id,
115
+ "seller_id": account_id,
116
+ "updated_time": _requested_at,
117
+ "blocked": f'Requested at {_requested_at}',
118
+ }]
119
+ }
120
+ if account_id is None:
121
+ del _payload["items"][0]["seller_id"]
122
+
123
+ curl, error, json_obj = api_request('POST', to_curl, _api_url, self.headers, _payload)
124
+ if curl:
125
+ return curl, None, None
126
+ if error:
127
+ return None, error, None
128
+ return None, None, ItemBlockingResult(**json_obj)
129
+
66
130
  def list_wallet_balances(
67
131
  self
68
132
  ):
@@ -0,0 +1,54 @@
1
+ # Copyright 2023 Moloco, Inc
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ from pydantic import BaseModel
16
+ from typing import Optional
17
+
18
+ #
19
+ # API response dataclasse of the item kill switch API
20
+ #
21
+ # The example response is as below:
22
+ # {
23
+ # "success_items": [
24
+ # {
25
+ # "item_id": "item_1",
26
+ # "seller_id": "seller_1",
27
+ # "region": ""
28
+ # }
29
+ # ],
30
+ # "failure_items": [
31
+ # {
32
+ # "item_id": "item_2",
33
+ # "seller_id": "seller_2",
34
+ # "region": "",
35
+ # "message": "rpc error: code = Internal desc = ad account not found"
36
+ # }
37
+ # ]
38
+ # }
39
+
40
+ class SucceededItemBlockingAttempt(BaseModel):
41
+ item_id: str
42
+ seller_id: str
43
+ region: str
44
+
45
+ class FailedItemBlockingAttempt(BaseModel):
46
+ item_id: str
47
+ seller_id: str
48
+ region: str
49
+ message: str
50
+
51
+
52
+ class ItemBlockingResult(BaseModel):
53
+ success_items: list[SucceededItemBlockingAttempt]
54
+ failure_items: list[FailedItemBlockingAttempt]
@@ -18,7 +18,7 @@ from setuptools import setup, find_packages
18
18
 
19
19
  setup(
20
20
  name='mcm-cli',
21
- version='1.3.1',
21
+ version='1.4.0',
22
22
  description='A command-line interface for Moloco Commerde Media',
23
23
  long_description=open('README.md').read(),
24
24
  long_description_content_type='text/markdown',
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes