Open momcilo78 opened 4 years ago
Hi,
Yes there is a plan towards implementing the V2 API in a non breaking way.
I will look into it in the next weeks.
Thanks
Hi,
At the moment I am checking for possible API wrappers around artifactory, since we automate the installation of our artifactory servers with ansible. Aside from developing roles and playbooks, we will engage into ansible module development in order to improve the performance of our playbooks. We have the need for the artifactory python API wrapper. We have a choice between writing our own using the existing one. We prefer not create forks for the sake of creating variants.
I hope you do not mind me asking some more questions related to contribution model.
BR, Moma
I'm open to ideas and suggestions, there wasn't much activity around the package/repository since it's first release, but that can change!
Thank you for showing interest!
Any update on this? Do you have ideas/plans on how to implement this?
For now I've monkeypatched the permission targets v2 API in like so:
class MyClass:
def __init__(self, settings: dict, artifactory_api: rtpy.Rtpy) -> None:
self.__artifactory = artifactory_api
self.__add_permission_targets_v2_api(self.__artifactory)
def __add_permission_targets_v2_api(self, target):
def get_permission_targets_v2(self: RtpySecurity, **kwargs):
"""
Get the permission targets list.
Parameters
----------
**kwargs
Keyword arguments
"""
api_method = self._category + "Get Permission Targets V2"
target = 'v2/' + self._prefix + "permissions"
return self._request("GET", target, api_method, kwargs)
def get_permission_target_details_v2(self, permission_target_name, **kwargs):
"""
Get the details of an Artifactory Permission Target.
Parameters
----------
permission_target_name: str
Name of the permission target
**kwargs
Keyword arguments
"""
api_method = self._category + "Get Permission Target Details V2"
target = 'v2/' + self._prefix + "permissions/" + permission_target_name
return self._request("GET", target, api_method, kwargs)
def is_permission_target_available_v2(self, permission_target_name, **kwargs):
"""
Get the existence details of an Artifactory Permission Target.
Parameters
----------
permission_target_name: str
Name of the permission target
**kwargs
Keyword arguments
"""
api_method = self._category + "Is Permission Target Available V2"
target = 'v2/' + self._prefix + "permissions/" + permission_target_name
# TODO: turn into boolean return somehow..
# 200 = OK
# 404 = not found
return self._request("HEAD", target, api_method, kwargs)
def create_permission_target_v2(self, params, **kwargs):
"""
Create a new permission target in Artifactory.
Parameters
----------
params: dict
Settings of the permission target
**kwargs
Keyword arguments
"""
api_method = self._category + "Create Permission Target V2"
permission_target_name = params["name"]
target = 'v2/' + self._prefix + "permissions/" + permission_target_name
return self._request("POST", target, api_method, kwargs, params=params)
def update_permission_target_v2(self, params, **kwargs):
"""
Update an existing permission target in Artifactory.
Parameters
----------
params: dict
Settings of the permission target
**kwargs
Keyword arguments
"""
api_method = self._category + "Update Permission Target V2"
permission_target_name = params["name"]
target = 'v2/' + self._prefix + "permissions/" + permission_target_name
return self._request("PUT", target, api_method, kwargs, params=params)
def get_permission_targets_for_user_v2(self, username, **kwargs):
"""
Get the details of all Artifactory Permission Targets applicable to user.
Parameters
----------
username: str
Name of the user
**kwargs
Keyword arguments
"""
api_method = self._category + "Get Permission Targets for User V2"
target = 'v2/' + self._prefix + "permissions/users/" + username
return self._request("GET", target, api_method, kwargs)
def get_permission_targets_for_group_v2(self, groupname, **kwargs):
"""
Get the details of all Artifactory Permission Targets applicable to group.
Parameters
----------
groupname: str
Name of the user
**kwargs
Keyword arguments
"""
api_method = self._category + "Get Permission Targets for Group V2"
target = 'v2/' + self._prefix + "permissions/groups/" + groupname
return self._request("GET", target, api_method, kwargs)
def delete_permission_target_v2(self, permission_target_name, **kwargs):
"""
Delete an Artifactory permission target.
Parameters
----------
permission_target_name: str
Name of the permission target
**kwargs
Keyword arguments
"""
api_method = self._category + "Delete Permission Target V2"
target = 'v2/' + self._prefix + "permissions/" + permission_target_name
return self._request("DELETE", target, api_method, kwargs)
target.security.get_permission_targets_v2 = types.MethodType(
get_permission_targets_v2, target.security
)
target.security.get_permission_target_details_v2 = types.MethodType(
get_permission_target_details_v2, target.security
)
target.security.is_permission_target_available_v2 = types.MethodType(
is_permission_target_available_v2, target.security
)
target.security.create_permission_target_v2 = types.MethodType(
create_permission_target_v2, target.security
)
target.security.update_permission_target_v2 = types.MethodType(
update_permission_target_v2, target.security
)
target.security.get_permission_targets_for_user_v2 = types.MethodType(
get_permission_targets_for_user_v2, target.security
)
target.security.get_permission_targets_for_group_v2 = types.MethodType(
get_permission_targets_for_group_v2, target.security
)
target.security.delete_permission_target_v2 = types.MethodType(
delete_permission_target_v2, target.security
)
Hi, I haven't gotten around to implementing a proper solution for the V2 endpoints, feel free to submit a Pull/Merge request to the develop branch!
Hi,
During the rollout of artifactory based on ansible scripts we became aware of the additional V2 API, documented here: https://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API+V2
At the moment it includes the number of extensions related to handling of permissions including:
Can you confirm if there is plan toward implementing this V2 API, and what would be the best way to including into the present API wrapper? E.g. I would expect that existing API still works, while the users can still chose to work with V2 for extended feature set.
BR, Moma