Baisc org deletion
This commit is contained in:
parent
e51e465709
commit
5a4dbf755d
|
@ -106,9 +106,12 @@ def run_module():
|
||||||
headers = {
|
headers = {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
}
|
}
|
||||||
|
gitea_url = module.params['gitea_url']
|
||||||
gitea_token = module.params['auth_token']
|
gitea_token = module.params['auth_token']
|
||||||
|
username = module.params['username']
|
||||||
req_org = requests.get(
|
req_org = requests.get(
|
||||||
module.params['gitea_url']+'/api/v1/orgs/'+data['username']+'?access_token='+gitea_token,
|
gitea_url + '/api/v1/orgs/' + username +
|
||||||
|
'?access_token=' + gitea_token,
|
||||||
headers=headers
|
headers=headers
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -127,11 +130,15 @@ def run_module():
|
||||||
"full_name": module.params['name'],
|
"full_name": module.params['name'],
|
||||||
#TODO "location": "string",
|
#TODO "location": "string",
|
||||||
#TODO "repo_admin_change_team_access": true,
|
#TODO "repo_admin_change_team_access": true,
|
||||||
"username": module.params['username'],
|
"username": username,
|
||||||
#TODO "visibility": "public",
|
#TODO "visibility": "public",
|
||||||
#TODO "website": "string"
|
#TODO "website": "string"
|
||||||
}
|
}
|
||||||
create_req = requests.post(gitea_url+'/api/v1/orgs'+'?access_token='+gitea_token, headers=headers, data=json.dumps(data))
|
create_req = requests.post(
|
||||||
|
gitea_url + '/api/v1/orgs' + '?access_token=' + gitea_token,
|
||||||
|
headers=headers,
|
||||||
|
data=json.dumps(data),
|
||||||
|
)
|
||||||
if create_req.status_code != 201:
|
if create_req.status_code != 201:
|
||||||
result['gitea_response'] = create_req.json()
|
result['gitea_response'] = create_req.json()
|
||||||
module.fail_json(msg="Creation failed", **result)
|
module.fail_json(msg="Creation failed", **result)
|
||||||
|
@ -146,7 +153,14 @@ def run_module():
|
||||||
result['gitea_response'] = req_org.json()
|
result['gitea_response'] = req_org.json()
|
||||||
result['state'] = 'absent'
|
result['state'] = 'absent'
|
||||||
if req_org.status_code == 200:
|
if req_org.status_code == 200:
|
||||||
##TODO delete
|
delete_req = requests.delete(
|
||||||
|
gitea_url + '/api/v1/orgs/' + username +
|
||||||
|
'?access_token=' + gitea_token,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
if delete_req.status_code != 204:
|
||||||
|
result['gitea_response'] = create_req.json()
|
||||||
|
module.fail_json(msg="Deletion failed", **result)
|
||||||
result['changed'] = True
|
result['changed'] = True
|
||||||
result['state'] = 'absent'
|
result['state'] = 'absent'
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue