Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions conjur_api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,23 +200,23 @@ async def set(self, variable_id: str, value: str) -> str:
"""
await self._api.set_variable(variable_id, value)

async def load_policy_file(self, policy_name: str, policy_file: str) -> dict:
async def load_policy_file(self, policy_name: str, policy_file: str, dry_run: False) -> dict:
"""
Applies a file-based policy to the Conjur instance
"""
return await self._api.load_policy_file(policy_name, policy_file)
return await self._api.load_policy_file(policy_name, policy_file, dry_run)

async def replace_policy_file(self, policy_name: str, policy_file: str) -> dict:
async def replace_policy_file(self, policy_name: str, policy_file: str, dry_run: False) -> dict:
"""
Replaces a file-based policy defined in the Conjur instance
"""
return await self._api.replace_policy_file(policy_name, policy_file)
return await self._api.replace_policy_file(policy_name, policy_file, dry_run)

async def update_policy_file(self, policy_name: str, policy_file: str) -> dict:
async def update_policy_file(self, policy_name: str, policy_file: str, dry_run: False) -> dict:
"""
Replaces a file-based policy defined in the Conjur instance
"""
return await self._api.update_policy_file(policy_name, policy_file)
return await self._api.update_policy_file(policy_name, policy_file, dry_run)

async def rotate_other_api_key(self, resource: Resource) -> str:
"""
Expand Down
19 changes: 12 additions & 7 deletions conjur_api/http/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ async def set_variable(self, variable_id: str, value: str) -> str:

async def _load_policy_file(
self, policy_id: str, policy_file: str,
http_verb: HttpVerb) -> dict:
http_verb: HttpVerb, dry_run: bool) -> dict:
"""
This method is used to load, replace or update a file-based policy into the desired
name.
Expand All @@ -504,32 +504,37 @@ async def _load_policy_file(
if api_token is None:
raise MissingApiTokenException()

query = {}
if dry_run:
query = { 'dryRun': 'true' }

response = await invoke_endpoint(http_verb, ConjurEndpoint.POLICIES, params,
policy_data, api_token=api_token,
ssl_verification_metadata=self.ssl_verification_data,
query=query,
proxy_params=self._connection_info.proxy_params)
return response.json

async def load_policy_file(self, policy_id: str, policy_file: str) -> dict:
async def load_policy_file(self, policy_id: str, policy_file: str, dry_run: bool) -> dict:
"""
This method is used to load a file-based policy into the desired
name.
"""
return await self._load_policy_file(policy_id, policy_file, HttpVerb.POST)
return await self._load_policy_file(policy_id, policy_file, HttpVerb.POST, dry_run)

async def replace_policy_file(self, policy_id: str, policy_file: str) -> dict:
async def replace_policy_file(self, policy_id: str, policy_file: str, dry_run: bool) -> dict:
"""
This method is used to replace a file-based policy into the desired
policy ID.
"""
return await self._load_policy_file(policy_id, policy_file, HttpVerb.PUT)
return await self._load_policy_file(policy_id, policy_file, HttpVerb.PUT, dry_run)

async def update_policy_file(self, policy_id: str, policy_file: str) -> dict:
async def update_policy_file(self, policy_id: str, policy_file: str, dry_run: bool) -> dict:
"""
This method is used to update a file-based policy into the desired
policy ID.
"""
return await self._load_policy_file(policy_id, policy_file, HttpVerb.PATCH)
return await self._load_policy_file(policy_id, policy_file, HttpVerb.PATCH, dry_run)

async def rotate_other_api_key(self, resource: Resource) -> str:
"""
Expand Down