Skip to content

Commit

Permalink
update fleet api
Browse files Browse the repository at this point in the history
  • Loading branch information
gurevichdmitry committed Nov 10, 2024
1 parent b6e7eb8 commit cda9daa
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
17 changes: 12 additions & 5 deletions tests/fleet_api/common_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ def get_enrollment_token(cfg: Munch, policy_id: str) -> str:
url=url,
auth=cfg.auth,
)
response_obj = munchify(response)

api_keys = munchify(response.get("list", []))
if cfg.stack_version.startswith("9."):
api_keys = munchify(response.get("items", []))
api_key = ""
for item in response_obj.list:
for item in api_keys:
if item.policy_id == policy_id:
api_key = item.api_key
break
Expand Down Expand Up @@ -318,7 +319,10 @@ def get_package_version(
)

cloud_security_posture_version = None
for package in response["response"]:
packages = response.get("response", [])
if cfg.stack_version.startswith("9."):
packages = response.get("items", [])
for package in packages:
if package.get("name", "") == package_name:
cloud_security_posture_version = package.get("version", "")
break
Expand Down Expand Up @@ -365,7 +369,10 @@ def get_package(
auth=cfg.auth,
params={"params": request_params},
)
return response.get("response", {})
package_data = response.get("response", {})
if cfg.stack_version.startswith("9."):
package_data = response.get("item", {})
return package_data
except APICallException as api_ex:
logger.error(
f"API call failed, status code {api_ex.status_code}. Response: {api_ex.response_text}",
Expand Down
5 changes: 4 additions & 1 deletion tests/fleet_api/package_policy_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ def create_integration(cfg: Munch, pkg_policy: dict, agent_policy_id: str, data:
auth=cfg.auth,
params={"json": pkg_policy},
)
package_policy_id = munchify(response).item.id
policy_data = response.get("response", {}).get("item", {})
if cfg.stack_version.startswith("9."):
policy_data = response.get("item", {})
package_policy_id = policy_data.get("id", "")
logger.info(f"Package policy '{package_policy_id}' created successfully")
return package_policy_id
except APICallException as api_ex:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
):
logger.warning(f"{INTEGRATION_NAME} is not supported in version {package_version}")
sys.exit(0)
logger.info(f"Package version: {package_version}")
update_package_version(
cfg=cnfg.elk_config,
package_name=PACKAGE_NAME,
Expand Down

0 comments on commit cda9daa

Please sign in to comment.