Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CONF
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UvA
CONF
Commits
9eab6201
Commit
9eab6201
authored
Apr 03, 2020
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added semaphore api definition
parent
6c4561c2
Changes
14
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
2123 additions
and
76 deletions
+2123
-76
drip-deployer.iml
deployer/.idea/drip-deployer.iml
+1
-1
misc.xml
deployer/.idea/misc.xml
+1
-1
semaphore_helper.py
deployer/service/semaphore_helper.py
+16
-16
semaphore-2.2.0.yaml
openAPI/API/semaphore-2.2.0.yaml
+1923
-0
misc.xml
semaphore-python-client-generated/.idea/misc.xml
+1
-1
semaphore-python-client-generated.iml
...ent-generated/.idea/semaphore-python-client-generated.iml
+1
-1
requirements.txt
semaphore-python-client-generated/requirements.txt
+1
-1
api_client.py
...re-python-client-generated/semaphore_client/api_client.py
+3
-0
semaphore_helper.py
...hon-client-generated/semaphore_client/semaphore_helper.py
+100
-0
test-requirements.txt
semaphore-python-client-generated/test-requirements.txt
+2
-1
test_helper.py
semaphore-python-client-generated/test/test_helper.py
+0
-28
test_login.py
semaphore-python-client-generated/test/test_login.py
+8
-13
test_task.py
semaphore-python-client-generated/test/test_task.py
+56
-7
workspace.xml
sure_tosca-client_python_stubs/.idea/workspace.xml
+10
-6
No files found.
deployer/.idea/drip-deployer.iml
View file @
9eab6201
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
<content
url=
"file://$MODULE_DIR$"
>
<content
url=
"file://$MODULE_DIR$"
>
<excludeFolder
url=
"file://$MODULE_DIR$/venv"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/venv"
/>
</content>
</content>
<orderEntry
type=
"jdk"
jdkName=
"Python 3.
8
(deployer)"
jdkType=
"Python SDK"
/>
<orderEntry
type=
"jdk"
jdkName=
"Python 3.
7
(deployer)"
jdkType=
"Python SDK"
/>
<orderEntry
type=
"sourceFolder"
forTests=
"false"
/>
<orderEntry
type=
"sourceFolder"
forTests=
"false"
/>
</component>
</component>
<component
name=
"PyDocumentationSettings"
>
<component
name=
"PyDocumentationSettings"
>
...
...
deployer/.idea/misc.xml
View file @
9eab6201
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<project
version=
"4"
>
<component
name=
"ProjectRootManager"
version=
"2"
project-jdk-name=
"Python 3.
8
(deployer)"
project-jdk-type=
"Python SDK"
/>
<component
name=
"ProjectRootManager"
version=
"2"
project-jdk-name=
"Python 3.
7
(deployer)"
project-jdk-type=
"Python SDK"
/>
</project>
</project>
\ No newline at end of file
deployer/service/semaphore_helper.py
View file @
9eab6201
...
@@ -26,22 +26,22 @@ class SemaphoreHelper:
...
@@ -26,22 +26,22 @@ class SemaphoreHelper:
self
.
projects_api
=
api
.
ProjectsApi
(
api_client
=
api_client
)
self
.
projects_api
=
api
.
ProjectsApi
(
api_client
=
api_client
)
def
create_project_if_not_exists
(
self
,
name
,
git_url
,
private_key
,
inventory_contents
,
playbook_name
):
#
def create_project_if_not_exists(self, name, git_url, private_key,inventory_contents,playbook_name):
the_project
=
self
.
create_project
(
name
)
#
the_project = self.create_project(name)
key
=
self
.
create_ssh_key
(
name
,
the_project
.
id
,
private_key
)
#
key = self.create_ssh_key(name,the_project.id,private_key)
inventory
=
self
.
create_inventory
(
name
,
the_project
.
id
,
key
.
id
,
inventory_contents
)
#
inventory= self.create_inventory(name,the_project.id,key.id,inventory_contents)
repository
=
self
.
create_repository
(
name
,
the_project
.
id
,
key
.
id
,
git_url
)
#
repository = self.create_repository(name,the_project.id,key.id,git_url)
#
template
=
self
.
create_template
(
the_project
.
id
,
key
.
id
,
inventory
.
id
,
repository
.
id
,
playbook_name
)
#
template = self.create_template(the_project.id,key.id,inventory.id,repository.id,playbook_name)
#
task
=
Task
(
template_id
=
template
.
id
,
playbook
=
playbook_name
)
#
task = Task(template_id=template.id, playbook=playbook_name)
self
.
project_api
.
project_project_id_tasks_post
(
the_project
.
id
,
task
)
#
self.project_api.project_project_id_tasks_post(the_project.id, task)
#
tasks
=
self
.
project_api
.
project_project_id_tasks_get
(
the_project
.
id
)
#
tasks = self.project_api.project_project_id_tasks_get(the_project.id)
for
task
in
tasks
:
#
for task in tasks:
print
(
task
)
#
print(task)
#
return
the_project
#
return the_project
def
find_projects_by_name
(
self
,
name
):
def
find_projects_by_name
(
self
,
name
):
projects
=
self
.
projects_api
.
projects_get
()
projects
=
self
.
projects_api
.
projects_get
()
...
...
openAPI/API/semaphore-2.2.0.yaml
0 → 100644
View file @
9eab6201
openapi
:
3.0.0
info
:
title
:
SEMAPHORE
description
:
Semaphore API
version
:
2.2.0-oas3
servers
:
-
url
:
http://localhost:3000/api
-
url
:
https://localhost:3000/api
security
:
-
bearer
:
[]
-
cookie
:
[]
tags
:
-
name
:
authentication
description
:
Authentication, Logout & API Tokens
-
name
:
project
description
:
Everything related to a project
-
name
:
user
description
:
User-related API
paths
:
/ping
:
get
:
summary
:
PING test
responses
:
"
200"
:
description
:
Successful "PONG" reply
headers
:
content-type
:
style
:
simple
explode
:
false
schema
:
type
:
string
x-example
:
text/plain; charset=utf-8
content
:
text/plain
:
schema
:
$ref
:
'
#/components/schemas/Pong'
security
:
[]
/ws
:
get
:
summary
:
Websocket handler
responses
:
"
200"
:
description
:
OK
"
403"
:
description
:
not authenticated
servers
:
-
url
:
ws://localhost:3000/api
-
url
:
ws://localhost:3000/api
-
url
:
wss://localhost:3000/api
-
url
:
wss://localhost:3000/api
/info
:
get
:
summary
:
Fetches information about semaphore
description
:
you must be authenticated to use this
responses
:
"
200"
:
description
:
ok
content
:
application/json
:
schema
:
$ref
:
'
#/components/schemas/InfoType'
text/plain; charset=utf-8
:
schema
:
$ref
:
'
#/components/schemas/InfoType'
/upgrade
:
get
:
summary
:
Check if new updates available and fetch /info
responses
:
"
200"
:
description
:
ok
content
:
application/json
:
schema
:
$ref
:
'
#/components/schemas/InfoType'
text/plain; charset=utf-8
:
schema
:
$ref
:
'
#/components/schemas/InfoType'
"
204"
:
description
:
no update
post
:
summary
:
Upgrade the server
responses
:
"
200"
:
description
:
Server binary was replaced by new version, server has shut
down.
/auth/login
:
post
:
tags
:
-
authentication
summary
:
Performs Login
description
:
|
Upon success you will be logged in
requestBody
:
content
:
application/json
:
schema
:
$ref
:
'
#/components/schemas/Login'
required
:
true
responses
:
"
204"
:
description
:
You are logged in
"
400"
:
description
:
something in body is missing / is invalid
security
:
[]
/auth/logout
:
post
:
tags
:
-
authentication
summary
:
Destroys current session
responses
:
"
204"
:
description
:
Your session was successfully nuked
/user
:
get
:
tags
:
-
user
summary
:
Fetch logged in user
responses
:
"
200"
:
description
:
User
content
:
application/json
:
schema
:
$ref
:
'
#/components/schemas/User'
text/plain; charset=utf-8
:
schema
:
$ref
:
'
#/components/schemas/User'
/user/tokens
:
get
:
tags
:
-
authentication
-
user
summary
:
Fetch API tokens for user
responses
:
"
200"
:
description
:
API Tokens
content
:
application/json
:
schema
:
type
:
array
items
:
$ref
:
'
#/components/schemas/APIToken'
text/plain; charset=utf-8
:
schema
:
type
:
array
items
:
$ref
:
'
#/components/schemas/APIToken'
post
:
tags
:
-
authentication
-
user
summary
:
Create an API token
responses
:
"
201"
:
description
:
API Token
content
:
application/json
:
schema
:
$ref
:
'
#/components/schemas/APIToken'
text/plain; charset=utf-8
:
schema
:
$ref
:
'
#/components/schemas/APIToken'
/user/tokens/{api_token_id}
:
delete
:
tags
:
-
authentication
-
user
summary
:
Expires API token
parameters
:
-
name
:
api_token_id
in
:
path
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
string
example
:
kwofd61g93-yuqvex8efmhjkgnbxlo8mp1tin6spyhu=
responses
:
"
204"
:
description
:
Expired API Token
/users
:
get
:
tags
:
-
user
summary
:
Fetches all users
responses
:
"
200"
:
description
:
Users
content
:
application/json
:
schema
:
type
:
array
items
:
$ref
:
'
#/components/schemas/User'
text/plain; charset=utf-8
:
schema
:
type
:
array
items
:
$ref
:
'
#/components/schemas/User'
post
:
tags
:
-
user
summary
:
Creates a user
requestBody
:
$ref
:
'
#/components/requestBodies/UserRequest'
responses
:
"
201"
:
description
:
User created
content
:
application/json
:
schema
:
$ref
:
'
#/components/schemas/User'
text/plain; charset=utf-8
:
schema
:
$ref
:
'
#/components/schemas/User'
"
400"
:
description
:
User creation failed
/users/{user_id}
:
get
:
tags
:
-
user
summary
:
Fetches a user profile
parameters
:
-
name
:
user_id
in
:
path
description
:
User ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
2
responses
:
"
200"
:
description
:
User profile
content
:
application/json
:
schema
:
$ref
:
'
#/components/schemas/User'
text/plain; charset=utf-8
:
schema
:
$ref
:
'
#/components/schemas/User'
put
:
tags
:
-
user
summary
:
Updates user details
parameters
:
-
name
:
user_id
in
:
path
description
:
User ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
2
requestBody
:
$ref
:
'
#/components/requestBodies/UserRequest'
responses
:
"
204"
:
description
:
User Updated
delete
:
tags
:
-
user
summary
:
Deletes user
parameters
:
-
name
:
user_id
in
:
path
description
:
User ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
2
responses
:
"
204"
:
description
:
User deleted
/users/{user_id}/password
:
post
:
tags
:
-
user
summary
:
Updates user password
parameters
:
-
name
:
user_id
in
:
path
description
:
User ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
2
requestBody
:
content
:
application/json
:
schema
:
$ref
:
'
#/components/schemas/body'
required
:
true
responses
:
"
204"
:
description
:
Password updated
/projects
:
get
:
tags
:
-
projects
summary
:
Get projects
responses
:
"
200"
:
description
:
List of projects
content
:
application/json
:
schema
:
type
:
array
items
:
$ref
:
'
#/components/schemas/Project'
text/plain; charset=utf-8
:
schema
:
type
:
array
items
:
$ref
:
'
#/components/schemas/Project'
post
:
tags
:
-
projects
summary
:
Create a new project
requestBody
:
content
:
application/json
:
schema
:
$ref
:
'
#/components/schemas/ProjectRequest'
required
:
true
responses
:
"
201"
:
description
:
Created project
/events
:
get
:
summary
:
Get Events related to Semaphore and projects you are part of
responses
:
"
200"
:
description
:
Array of events in chronological order
content
:
application/json
:
schema
:
type
:
array
items
:
$ref
:
'
#/components/schemas/Event'
text/plain; charset=utf-8
:
schema
:
type
:
array
items
:
$ref
:
'
#/components/schemas/Event'
/events/last
:
get
:
summary
:
Get last 200 Events related to Semaphore and projects you are part
of
responses
:
"
200"
:
description
:
Array of events in chronological order
content
:
application/json
:
schema
:
type
:
array
items
:
$ref
:
'
#/components/schemas/Event'
text/plain; charset=utf-8
:
schema
:
type
:
array
items
:
$ref
:
'
#/components/schemas/Event'
/project/{project_id}
:
get
:
tags
:
-
project
summary
:
Fetch project
parameters
:
-
name
:
project_id
in
:
path
description
:
Project ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
1
responses
:
"
200"
:
description
:
Project
content
:
application/json
:
schema
:
$ref
:
'
#/components/schemas/Project'
text/plain; charset=utf-8
:
schema
:
$ref
:
'
#/components/schemas/Project'
put
:
tags
:
-
project
summary
:
Update project
parameters
:
-
name
:
project_id
in
:
path
description
:
Project ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
1
requestBody
:
content
:
application/json
:
schema
:
$ref
:
'
#/components/schemas/body_1'
required
:
true
responses
:
"
204"
:
description
:
Project saved
delete
:
tags
:
-
project
summary
:
Delete project
parameters
:
-
name
:
project_id
in
:
path
description
:
Project ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
1
responses
:
"
204"
:
description
:
Project deleted
/project/{project_id}/events
:
get
:
tags
:
-
project
summary
:
Get Events related to this project
parameters
:
-
name
:
project_id
in
:
path
description
:
Project ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
1
responses
:
"
200"
:
description
:
Array of events in chronological order
content
:
application/json
:
schema
:
type
:
array
items
:
$ref
:
'
#/components/schemas/Event'
text/plain; charset=utf-8
:
schema
:
type
:
array
items
:
$ref
:
'
#/components/schemas/Event'
/project/{project_id}/users
:
get
:
tags
:
-
project
summary
:
Get users linked to project
parameters
:
-
name
:
project_id
in
:
path
description
:
Project ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
1
-
name
:
sort
in
:
query
description
:
sorting name
required
:
true
style
:
form
explode
:
true
schema
:
type
:
string
enum
:
-
name
-
username
-
email
-
admin
example
:
email
-
name
:
order
in
:
query
description
:
ordering manner
required
:
true
style
:
form
explode
:
true
schema
:
type
:
string
enum
:
-
asc
-
desc
example
:
desc
responses
:
"
200"
:
description
:
Users
content
:
application/json
:
schema
:
type
:
array
items
:
$ref
:
'
#/components/schemas/User'
text/plain; charset=utf-8
:
schema
:
type
:
array
items
:
$ref
:
'
#/components/schemas/User'
post
:
tags
:
-
project
summary
:
Link user to project
parameters
:
-
name
:
project_id
in
:
path
description
:
Project ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
1
requestBody
:
content
:
application/json
:
schema
:
$ref
:
'
#/components/schemas/body_2'
required
:
true
responses
:
"
204"
:
description
:
User added
/project/{project_id}/users/{user_id}
:
delete
:
tags
:
-
project
summary
:
Removes user from project
parameters
:
-
name
:
project_id
in
:
path
description
:
Project ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
1
-
name
:
user_id
in
:
path
description
:
User ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
2
responses
:
"
204"
:
description
:
User removed
/project/{project_id}/users/{user_id}/admin
:
post
:
tags
:
-
project
summary
:
Makes user admin
parameters
:
-
name
:
project_id
in
:
path
description
:
Project ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
1
-
name
:
user_id
in
:
path
description
:
User ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
2
responses
:
"
204"
:
description
:
User made administrator
delete
:
tags
:
-
project
summary
:
Revoke admin privileges
parameters
:
-
name
:
project_id
in
:
path
description
:
Project ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
1
-
name
:
user_id
in
:
path
description
:
User ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
2
responses
:
"
204"
:
description
:
User admin privileges revoked
/project/{project_id}/keys
:
get
:
tags
:
-
project
summary
:
Get access keys linked to project
parameters
:
-
name
:
project_id
in
:
path
description
:
Project ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
1
-
name
:
Key type
in
:
query
description
:
Filter by key type
required
:
false
style
:
form
explode
:
true
schema
:
type
:
string
enum
:
-
ssh
-
aws
-
gcloud
-
do
example
:
ssh
-
name
:
sort
in
:
query
description
:
sorting name
required
:
true
style
:
form
explode
:
true
schema
:
type
:
string
enum
:
-
name
-
type
example
:
type
-
name
:
order
in
:
query
description
:
ordering manner
required
:
true
style
:
form
explode
:
true
schema
:
type
:
string
enum
:
-
asc
-
desc
example
:
asc
responses
:
"
200"
:
description
:
Access Keys
content
:
application/json
:
schema
:
type
:
array
items
:
$ref
:
'
#/components/schemas/AccessKey'
text/plain; charset=utf-8
:
schema
:
type
:
array
items
:
$ref
:
'
#/components/schemas/AccessKey'
post
:
tags
:
-
project
summary
:
Add access key
parameters
:
-
name
:
project_id
in
:
path
description
:
Project ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
1
requestBody
:
$ref
:
'
#/components/requestBodies/AccessKeyRequest'
responses
:
"
204"
:
description
:
Access Key created
"
400"
:
description
:
Bad type
/project/{project_id}/keys/{key_id}
:
put
:
tags
:
-
project
summary
:
Updates access key
parameters
:
-
name
:
project_id
in
:
path
description
:
Project ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
1
-
name
:
key_id
in
:
path
description
:
key ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
3
requestBody
:
$ref
:
'
#/components/requestBodies/AccessKeyRequest'
responses
:
"
204"
:
description
:
Key updated
"
400"
:
description
:
Bad type
delete
:
tags
:
-
project
summary
:
Removes access key
parameters
:
-
name
:
project_id
in
:
path
description
:
Project ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
1
-
name
:
key_id
in
:
path
description
:
key ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
3
responses
:
"
204"
:
description
:
access key removed
/project/{project_id}/repositories
:
get
:
tags
:
-
project
summary
:
Get repositories
parameters
:
-
name
:
project_id
in
:
path
description
:
Project ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
1
-
name
:
sort
in
:
query
description
:
sorting name
required
:
true
style
:
form
explode
:
true
schema
:
type
:
string
enum
:
-
name
-
git_url
-
ssh_key
-
name
:
order
in
:
query
description
:
ordering manner
required
:
true
style
:
form
explode
:
true
schema
:
type
:
string
format
:
asc/desc
enum
:
-
asc
-
desc
responses
:
"
200"
:
description
:
repositories
content
:
application/json
:
schema
:
type
:
array
items
:
$ref
:
'
#/components/schemas/Repository'
text/plain; charset=utf-8
:
schema
:
type
:
array
items
:
$ref
:
'
#/components/schemas/Repository'
post
:
tags
:
-
project
summary
:
Add repository
parameters
:
-
name
:
project_id
in
:
path
description
:
Project ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
1
requestBody
:
content
:
application/json
:
schema
:
$ref
:
'
#/components/schemas/RepositoryRequest'
required
:
true
responses
:
"
204"
:
description
:
Repository created
/project/{project_id}/repositories/{repository_id}
:
delete
:
tags
:
-
project
summary
:
Removes repository
parameters
:
-
name
:
project_id
in
:
path
description
:
Project ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
1
-
name
:
repository_id
in
:
path
description
:
repository ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
4
responses
:
"
204"
:
description
:
repository removed
/project/{project_id}/inventory
:
get
:
tags
:
-
project
summary
:
Get inventory
parameters
:
-
name
:
project_id
in
:
path
description
:
Project ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
1
-
name
:
sort
in
:
query
description
:
sorting name
required
:
true
style
:
form
explode
:
true
schema
:
type
:
string
enum
:
-
name
-
type
-
name
:
order
in
:
query
description
:
ordering manner
required
:
true
style
:
form
explode
:
true
schema
:
type
:
string
enum
:
-
asc
-
desc
responses
:
"
200"
:
description
:
inventory
content
:
application/json
:
schema
:
type
:
array
items
:
$ref
:
'
#/components/schemas/Inventory'
text/plain; charset=utf-8
:
schema
:
type
:
array
items
:
$ref
:
'
#/components/schemas/Inventory'
post
:
tags
:
-
project
summary
:
create inventory
parameters
:
-
name
:
project_id
in
:
path
description
:
Project ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
1
requestBody
:
$ref
:
'
#/components/requestBodies/InventoryRequest'
responses
:
"
201"
:
description
:
inventory created
content
:
application/json
:
schema
:
$ref
:
'
#/components/schemas/Inventory'
text/plain; charset=utf-8
:
schema
:
$ref
:
'
#/components/schemas/Inventory'
/project/{project_id}/inventory/{inventory_id}
:
put
:
tags
:
-
project
summary
:
Updates inventory
parameters
:
-
name
:
project_id
in
:
path
description
:
Project ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
1
-
name
:
inventory_id
in
:
path
description
:
inventory ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
5
requestBody
:
$ref
:
'
#/components/requestBodies/InventoryRequest'
responses
:
"
204"
:
description
:
Inventory updated
delete
:
tags
:
-
project
summary
:
Removes inventory
parameters
:
-
name
:
project_id
in
:
path
description
:
Project ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
1
-
name
:
inventory_id
in
:
path
description
:
inventory ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
5
responses
:
"
204"
:
description
:
inventory removed
/project/{project_id}/environment
:
get
:
tags
:
-
project
summary
:
Get environment
parameters
:
-
name
:
project_id
in
:
path
description
:
Project ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
1
-
name
:
sort
in
:
query
description
:
sorting name
required
:
true
style
:
form
explode
:
true
schema
:
type
:
string
format
:
name
example
:
db-deploy
-
name
:
order
in
:
query
description
:
ordering manner
required
:
true
style
:
form
explode
:
true
schema
:
type
:
string
format
:
asc/desc
example
:
desc
responses
:
"
200"
:
description
:
environment
content
:
application/json
:
schema
:
type
:
array
items
:
$ref
:
'
#/components/schemas/Environment'
text/plain; charset=utf-8
:
schema
:
type
:
array
items
:
$ref
:
'
#/components/schemas/Environment'
post
:
tags
:
-
project
summary
:
Add environment
parameters
:
-
name
:
project_id
in
:
path
description
:
Project ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
1
requestBody
:
$ref
:
'
#/components/requestBodies/EnvironmentRequest'
responses
:
"
204"
:
description
:
Environment created
/project/{project_id}/environment/{environment_id}
:
put
:
tags
:
-
project
summary
:
Update environment
parameters
:
-
name
:
project_id
in
:
path
description
:
Project ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
1
-
name
:
environment_id
in
:
path
description
:
environment ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
6
requestBody
:
$ref
:
'
#/components/requestBodies/EnvironmentRequest'
responses
:
"
204"
:
description
:
Environment Updated
delete
:
tags
:
-
project
summary
:
Removes environment
parameters
:
-
name
:
project_id
in
:
path
description
:
Project ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
1
-
name
:
environment_id
in
:
path
description
:
environment ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
6
responses
:
"
204"
:
description
:
environment removed
/project/{project_id}/templates
:
get
:
tags
:
-
project
summary
:
Get template
parameters
:
-
name
:
project_id
in
:
path
description
:
Project ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
1
-
name
:
sort
in
:
query
description
:
sorting name
required
:
true
style
:
form
explode
:
true
schema
:
type
:
string
enum
:
-
alias
-
playbook
-
ssh_key
-
inventory
-
environment
-
repository
-
name
:
order
in
:
query
description
:
ordering manner
required
:
true
style
:
form
explode
:
true
schema
:
type
:
string
enum
:
-
asc
-
desc
responses
:
"
200"
:
description
:
template
content
:
application/json
:
schema
:
type
:
array
items
:
$ref
:
'
#/components/schemas/Template'
text/plain; charset=utf-8
:
schema
:
type
:
array
items
:
$ref
:
'
#/components/schemas/Template'
post
:
tags
:
-
project
summary
:
create template
parameters
:
-
name
:
project_id
in
:
path
description
:
Project ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
1
requestBody
:
$ref
:
'
#/components/requestBodies/TemplateRequest'
responses
:
"
201"
:
description
:
template created
content
:
application/json
:
schema
:
$ref
:
'
#/components/schemas/Template'
text/plain; charset=utf-8
:
schema
:
$ref
:
'
#/components/schemas/Template'
/project/{project_id}/templates/{template_id}
:
put
:
tags
:
-
project
summary
:
Updates template
parameters
:
-
name
:
project_id
in
:
path
description
:
Project ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
1
-
name
:
template_id
in
:
path
description
:
template ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
7
requestBody
:
$ref
:
'
#/components/requestBodies/TemplateRequest'
responses
:
"
204"
:
description
:
template updated
delete
:
tags
:
-
project
summary
:
Removes template
parameters
:
-
name
:
project_id
in
:
path
description
:
Project ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
1
-
name
:
template_id
in
:
path
description
:
template ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
7
responses
:
"
204"
:
description
:
template removed
/project/{project_id}/tasks
:
get
:
tags
:
-
project
summary
:
Get Tasks related to current project
parameters
:
-
name
:
project_id
in
:
path
description
:
Project ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
1
responses
:
"
200"
:
description
:
Array of tasks in chronological order
content
:
application/json
:
schema
:
type
:
array
items
:
$ref
:
'
#/components/schemas/Task'
text/plain; charset=utf-8
:
schema
:
type
:
array
items
:
$ref
:
'
#/components/schemas/Task'
post
:
tags
:
-
project
summary
:
Starts a job
parameters
:
-
name
:
project_id
in
:
path
description
:
Project ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
1
requestBody
:
content
:
application/json
:
schema
:
$ref
:
'
#/components/schemas/body_3'
required
:
true
responses
:
"
201"
:
description
:
Task queued
content
:
application/json
:
schema
:
$ref
:
'
#/components/schemas/Task'
text/plain; charset=utf-8
:
schema
:
$ref
:
'
#/components/schemas/Task'
/project/{project_id}/tasks/last
:
get
:
tags
:
-
project
summary
:
Get last 200 Tasks related to current project
parameters
:
-
name
:
project_id
in
:
path
description
:
Project ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
1
responses
:
"
200"
:
description
:
Array of tasks in chronological order
content
:
application/json
:
schema
:
type
:
array
items
:
$ref
:
'
#/components/schemas/Task'
text/plain; charset=utf-8
:
schema
:
type
:
array
items
:
$ref
:
'
#/components/schemas/Task'
/project/{project_id}/tasks/{task_id}
:
get
:
tags
:
-
project
summary
:
Get a single task
parameters
:
-
name
:
project_id
in
:
path
description
:
Project ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
1
-
name
:
task_id
in
:
path
description
:
task ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
8
responses
:
"
200"
:
description
:
Task
content
:
application/json
:
schema
:
$ref
:
'
#/components/schemas/Task'
text/plain; charset=utf-8
:
schema
:
$ref
:
'
#/components/schemas/Task'
delete
:
tags
:
-
project
summary
:
Deletes task (including output)
parameters
:
-
name
:
project_id
in
:
path
description
:
Project ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
1
-
name
:
task_id
in
:
path
description
:
task ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
8
responses
:
"
204"
:
description
:
task deleted
/project/{project_id}/tasks/{task_id}/output
:
get
:
tags
:
-
project
summary
:
Get task output
parameters
:
-
name
:
project_id
in
:
path
description
:
Project ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
1
-
name
:
task_id
in
:
path
description
:
task ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
8
responses
:
"
200"
:
description
:
output
content
:
application/json
:
schema
:
type
:
array
items
:
$ref
:
'
#/components/schemas/TaskOutput'
text/plain; charset=utf-8
:
schema
:
type
:
array
items
:
$ref
:
'
#/components/schemas/TaskOutput'
components
:
schemas
:
Pong
:
type
:
string
x-example
:
pong
Login
:
type
:
object
properties
:
auth
:
type
:
string
description
:
Username/Email address
x-example
:
user@semaphore.com
password
:
type
:
string
description
:
Password
format
:
password
UserRequest
:
type
:
object
properties
:
name
:
type
:
string
x-example
:
Integration Test User
username
:
type
:
string
x-example
:
test-user
email
:
type
:
string
x-example
:
test@ansiblesemaphore.test
alert
:
type
:
boolean
admin
:
type
:
boolean
User
:
type
:
object
properties
:
id
:
minimum
:
1
type
:
integer
name
:
type
:
string
username
:
type
:
string
email
:
type
:
string
created
:
pattern
:
^\d{4}-(?:0[0-9]{1}|1[0-2]{1})-[0-9]{2}T\d{2}:\d{2}:\d{2}Z$
type
:
string
alert
:
type
:
boolean
admin
:
type
:
boolean
APIToken
:
type
:
object
properties
:
id
:
type
:
string
created
:
pattern
:
^\d{4}-(?:0[0-9]{1}|1[0-2]{1})-[0-9]{2}T\d{2}:\d{2}:\d{2}Z$
type
:
string
expired
:
type
:
boolean
user_id
:
minimum
:
1
type
:
integer
ProjectRequest
:
type
:
object
properties
:
name
:
type
:
string
alert
:
type
:
boolean
Project
:
type
:
object
properties
:
id
:
minimum
:
1
type
:
integer
name
:
type
:
string
created
:
pattern
:
^\d{4}-(?:0[0-9]{1}|1[0-2]{1})-[0-9]{2}T\d{2}:\d{2}:\d{2}Z$
type
:
string
alert
:
type
:
boolean
AccessKeyRequest
:
type
:
object
properties
:
name
:
type
:
string
type
:
type
:
string
enum
:
-
ssh
-
aws
-
gcloud
-
do
project_id
:
minimum
:
1
type
:
integer
x-example
:
2
key
:
type
:
string
secret
:
type
:
string
AccessKey
:
type
:
object
properties
:
id
:
type
:
integer
name
:
type
:
string
type
:
type
:
string
enum
:
-
ssh
-
aws
-
gcloud
-
do
project_id
:
type
:
integer
key
:
type
:
string
secret
:
type
:
string
EnvironmentRequest
:
type
:
object
properties
:
name
:
type
:
string
project_id
:
minimum
:
1
type
:
integer
password
:
type
:
string
json
:
type
:
string
Environment
:
type
:
object
properties
:
id
:
minimum
:
1
type
:
integer
name
:
type
:
string
project_id
:
minimum
:
1
type
:
integer
password
:
type
:
string
json
:
type
:
string
InventoryRequest
:
type
:
object
properties
:
name
:
type
:
string
project_id
:
minimum
:
1
type
:
integer
inventory
:
type
:
string
key_id
:
minimum
:
1
type
:
integer
ssh_key_id
:
minimum
:
1
type
:
integer
type
:
type
:
string
enum
:
-
static
-
file
Inventory
:
type
:
object
properties
:
id
:
type
:
integer
name
:
type
:
string
project_id
:
type
:
integer
inventory
:
type
:
string
key_id
:
type
:
integer
ssh_key_id
:
type
:
integer
type
:
type
:
string
enum
:
-
static
-
file
RepositoryRequest
:
type
:
object
properties
:
name
:
type
:
string
project_id
:
type
:
integer
git_url
:
type
:
string
ssh_key_id
:
type
:
integer
Repository
:
type
:
object
properties
:
id
:
type
:
integer
name
:
type
:
string
project_id
:
type
:
integer
git_url
:
type
:
string
ssh_key_id
:
type
:
integer
Task
:
type
:
object
properties
:
id
:
type
:
integer
example
:
23
template_id
:
type
:
integer
status
:
type
:
string
debug
:
type
:
boolean
playbook
:
type
:
string
environment
:
type
:
string
TaskOutput
:
type
:
object
properties
:
task_id
:
type
:
integer
example
:
23
task
:
type
:
string
time
:
type
:
string
format
:
date-time
output
:
type
:
string
TemplateRequest
:
type
:
object
properties
:
ssh_key_id
:
minimum
:
1
type
:
integer
project_id
:
minimum
:
1
type
:
integer
inventory_id
:
minimum
:
1
type
:
integer
repository_id
:
minimum
:
1
type
:
integer
environment_id
:
minimum
:
1
type
:
integer
alias
:
type
:
string
playbook
:
type
:
string
arguments
:
type
:
string
override_args
:
type
:
boolean
Template
:
type
:
object
properties
:
id
:
minimum
:
1
type
:
integer
ssh_key_id
:
minimum
:
1
type
:
integer
project_id
:
minimum
:
1
type
:
integer
inventory_id
:
minimum
:
1
type
:
integer
repository_id
:
type
:
integer
environment_id
:
minimum
:
1
type
:
integer
alias
:
type
:
string
playbook
:
type
:
string
arguments
:
type
:
string
override_args
:
type
:
boolean
Event
:
type
:
object
properties
:
project_id
:
type
:
integer
object_id
:
type
:
integer
object_type
:
type
:
string
description
:
type
:
string
InfoType
:
type
:
object
properties
:
version
:
type
:
string
updateBody
:
type
:
string
update
:
$ref
:
'
#/components/schemas/InfoType_update'
body
:
type
:
object
properties
:
password
:
type
:
string
format
:
password
body_1
:
type
:
object
properties
:
name
:
type
:
string
body_2
:
type
:
object
properties
:
user_id
:
minimum
:
2
type
:
integer
admin
:
type
:
boolean
body_3
:
type
:
object
properties
:
template_id
:
type
:
integer
debug
:
type
:
boolean
dry_run
:
type
:
boolean
playbook
:
type
:
string
environment
:
type
:
string
InfoType_update
:
type
:
object
properties
:
tag_name
:
type
:
string
parameters
:
project_id
:
name
:
project_id
in
:
path
description
:
Project ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
1
user_id
:
name
:
user_id
in
:
path
description
:
User ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
2
key_id
:
name
:
key_id
in
:
path
description
:
key ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
3
repository_id
:
name
:
repository_id
in
:
path
description
:
repository ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
4
inventory_id
:
name
:
inventory_id
in
:
path
description
:
inventory ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
5
environment_id
:
name
:
environment_id
in
:
path
description
:
environment ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
6
template_id
:
name
:
template_id
in
:
path
description
:
template ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
7
task_id
:
name
:
task_id
in
:
path
description
:
task ID
required
:
true
style
:
simple
explode
:
false
schema
:
type
:
integer
example
:
8
requestBodies
:
InventoryRequest
:
content
:
application/json
:
schema
:
$ref
:
'
#/components/schemas/InventoryRequest'
required
:
true
UserRequest
:
content
:
application/json
:
schema
:
$ref
:
'
#/components/schemas/UserRequest'
required
:
true
AccessKeyRequest
:
content
:
application/json
:
schema
:
$ref
:
'
#/components/schemas/AccessKeyRequest'
required
:
true
EnvironmentRequest
:
content
:
application/json
:
schema
:
$ref
:
'
#/components/schemas/EnvironmentRequest'
required
:
true
TemplateRequest
:
content
:
application/json
:
schema
:
$ref
:
'
#/components/schemas/TemplateRequest'
required
:
true
securitySchemes
:
cookie
:
type
:
apiKey
name
:
Cookie
in
:
header
bearer
:
type
:
apiKey
name
:
Authorization
in
:
header
semaphore-python-client-generated/.idea/misc.xml
View file @
9eab6201
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<project
version=
"4"
>
<component
name=
"ProjectRootManager"
version=
"2"
project-jdk-name=
"Python
2
.7 (semaphore-python-client-generated)"
project-jdk-type=
"Python SDK"
/>
<component
name=
"ProjectRootManager"
version=
"2"
project-jdk-name=
"Python
3
.7 (semaphore-python-client-generated)"
project-jdk-type=
"Python SDK"
/>
</project>
</project>
\ No newline at end of file
semaphore-python-client-generated/.idea/semaphore-python-client-generated.iml
View file @
9eab6201
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
<content
url=
"file://$MODULE_DIR$"
>
<content
url=
"file://$MODULE_DIR$"
>
<excludeFolder
url=
"file://$MODULE_DIR$/venv"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/venv"
/>
</content>
</content>
<orderEntry
type=
"jdk"
jdkName=
"Python
2
.7 (semaphore-python-client-generated)"
jdkType=
"Python SDK"
/>
<orderEntry
type=
"jdk"
jdkName=
"Python
3
.7 (semaphore-python-client-generated)"
jdkType=
"Python SDK"
/>
<orderEntry
type=
"sourceFolder"
forTests=
"false"
/>
<orderEntry
type=
"sourceFolder"
forTests=
"false"
/>
</component>
</component>
<component
name=
"PyDocumentationSettings"
>
<component
name=
"PyDocumentationSettings"
>
...
...
semaphore-python-client-generated/requirements.txt
View file @
9eab6201
...
@@ -2,4 +2,4 @@ certifi >= 14.05.14
...
@@ -2,4 +2,4 @@ certifi >= 14.05.14
six >= 1.10
six >= 1.10
python_dateutil >= 2.5.3
python_dateutil >= 2.5.3
setuptools >= 21.0.0
setuptools >= 21.0.0
urllib3
>= 1.15.1
urllib3
== 1.25.8
semaphore-python-client-generated/semaphore_client/api_client.py
View file @
9eab6201
...
@@ -638,3 +638,6 @@ class ApiClient(object):
...
@@ -638,3 +638,6 @@ class ApiClient(object):
if
klass_name
:
if
klass_name
:
instance
=
self
.
__deserialize
(
data
,
klass_name
)
instance
=
self
.
__deserialize
(
data
,
klass_name
)
return
instance
return
instance
semaphore-python-client-generated/semaphore_client/semaphore_helper.py
0 → 100644
View file @
9eab6201
import
os
import
sys
import
urllib3
from
semaphore_client
import
Configuration
,
ApiClient
,
api
,
ProjectRequest
,
Login
,
Repository
,
Inventory
,
\
AccessKeyRequest
,
InventoryRequest
,
RepositoryRequest
,
TemplateRequest
,
Task
class
SemaphoreHelper
:
def
__init__
(
self
,
semaphore_base_url
,
username
,
password
):
self
.
init_semaphore_client
(
semaphore_base_url
,
username
,
password
)
def
init_semaphore_client
(
self
,
polemarch_base_url
,
username
,
password
):
configuration
=
Configuration
()
configuration
.
host
=
polemarch_base_url
configuration
.
username
=
username
configuration
.
password
=
password
api_client
=
ApiClient
(
configuration
=
configuration
)
if
not
api_client
.
cookie
:
self
.
authentication_api
=
api
.
AuthenticationApi
(
api_client
=
api_client
)
login_body
=
Login
(
auth
=
username
,
password
=
password
)
self
.
authentication_api
.
auth_login_post
(
login_body
)
tokens
=
self
.
authentication_api
.
user_tokens_get
()
self
.
default_api
=
api
.
DefaultApi
(
api_client
=
api_client
)
self
.
project_api
=
api
.
ProjectApi
(
api_client
=
api_client
)
self
.
user_api
=
api
.
UserApi
(
api_client
=
api_client
)
self
.
projects_api
=
api
.
ProjectsApi
(
api_client
=
api_client
)
def
find_projects_by_name
(
self
,
name
):
projects
=
self
.
projects_api
.
projects_get
()
projects_with_name
=
[]
for
project
in
projects
:
if
project
.
name
==
name
:
projects_with_name
.
append
(
project
)
return
projects_with_name
def
project_with_name_exists
(
self
,
name
):
projects
=
self
.
find_projects_by_name
(
name
)
if
not
projects
:
return
False
return
True
def
create_project
(
self
,
name
):
project_request
=
ProjectRequest
(
name
=
name
)
self
.
projects_api
.
projects_post
(
project_request
)
projects
=
self
.
find_projects_by_name
(
name
)
return
projects
[
len
(
projects
)
-
1
]
.
id
def
create_ssh_key
(
self
,
name
,
project_id
,
private_key
):
key_request
=
AccessKeyRequest
(
name
=
name
,
type
=
'ssh'
,
project_id
=
project_id
,
secret
=
private_key
)
self
.
project_api
.
project_project_id_keys_post
(
project_id
,
key_request
)
keys
=
self
.
project_api
.
project_project_id_keys_get
(
project_id
,
name
,
'asc'
,
key_type
=
'ssh'
)
return
keys
[
len
(
keys
)
-
1
]
.
id
def
create_inventory
(
self
,
name
,
project_id
,
ssh_key_id
,
inventory_contents
):
inventory_request
=
InventoryRequest
(
name
=
name
,
project_id
=
project_id
,
inventory
=
inventory_contents
,
ssh_key_id
=
ssh_key_id
,
type
=
'static'
)
self
.
project_api
.
project_project_id_inventory_post
(
project_id
,
inventory_request
)
inventories
=
self
.
project_api
.
project_project_id_inventory_get
(
project_id
,
name
,
'asc'
)
return
inventories
[
len
(
inventories
)
-
1
]
.
id
def
create_repository
(
self
,
name
,
project_id
,
key_id
,
git_url
):
repository_request
=
RepositoryRequest
(
name
=
name
,
project_id
=
project_id
,
git_url
=
git_url
,
ssh_key_id
=
key_id
)
self
.
project_api
.
project_project_id_repositories_post
(
project_id
,
repository
=
repository_request
)
repositories
=
self
.
project_api
.
project_project_id_repositories_get
(
project_id
,
name
,
'asc'
)
return
repositories
[
len
(
repositories
)
-
1
]
.
id
def
create_template
(
self
,
project_id
,
key_id
,
inventory_id
,
repository_id
,
playbook_name
):
template_request
=
TemplateRequest
(
ssh_key_id
=
key_id
,
project_id
=
project_id
,
inventory_id
=
inventory_id
,
repository_id
=
repository_id
,
alias
=
playbook_name
,
playbook
=
playbook_name
)
self
.
project_api
.
project_project_id_templates_post
(
project_id
,
template_request
)
templates
=
self
.
project_api
.
project_project_id_templates_get
(
project_id
,
playbook_name
,
'asc'
)
return
templates
[
len
(
templates
)
-
1
]
.
id
def
execute_task
(
self
,
project_id
,
template_id
,
playbook_name
):
task
=
Task
(
template_id
=
template_id
,
playbook
=
playbook_name
)
self
.
project_api
.
project_project_id_tasks_post
(
project_id
,
task
)
tasks
=
self
.
project_api
.
project_project_id_tasks_get
(
project_id
)
return
tasks
[
len
(
tasks
)
-
1
]
.
id
def
get_task
(
self
,
project_id
,
task_id
):
return
self
.
project_api
.
project_project_id_tasks_task_id_get
(
project_id
,
task_id
)
@
classmethod
def
service_is_up
(
cls
,
url
):
code
=
None
try
:
http
=
urllib3
.
PoolManager
()
r
=
http
.
request
(
'HEAD'
,
url
)
except
Exception
as
e
:
return
False
return
True
\ No newline at end of file
semaphore-python-client-generated/test-requirements.txt
View file @
9eab6201
coverage>=4.0.3
coverage>=4.0.3
nose>=1.3.7
nose>=1.3.7
pluggy>=0.3.1
pluggy>=0.
1
3.1
py>=1.4.31
py>=1.4.31
randomize>=0.13
randomize>=0.13
names==0.3.0
\ No newline at end of file
semaphore-python-client-generated/test/test_helper.py
deleted
100644 → 0
View file @
6c4561c2
from
semaphore_client
import
Configuration
,
ApiClient
,
Login
,
api
class
TestHelper
:
def
__init__
(
self
,
semaphore_base_url
=
None
,
semaphore_username
=
None
,
semaphore_password
=
None
):
if
not
semaphore_base_url
:
self
.
semaphore_base_url
=
'http://localhost:3000/api'
if
not
semaphore_username
:
self
.
semaphore_username
=
'admin'
if
not
semaphore_password
:
self
.
semaphore_password
=
'password'
self
.
init_semaphore_client
()
def
init_semaphore_client
(
self
):
configuration
=
Configuration
()
configuration
.
host
=
self
.
semaphore_base_url
configuration
.
username
=
self
.
semaphore_username
configuration
.
password
=
self
.
semaphore_password
self
.
api_client
=
ApiClient
(
configuration
=
configuration
)
self
.
authentication_api
=
api
.
AuthenticationApi
(
api_client
=
self
.
api_client
)
self
.
default_api
=
api
.
DefaultApi
(
api_client
=
self
.
api_client
)
self
.
project_api
=
api
.
ProjectApi
(
api_client
=
self
.
api_client
)
self
.
user_api
=
api
.
UserApi
(
api_client
=
self
.
api_client
)
self
.
projects_api
=
api
.
ProjectsApi
(
api_client
=
self
.
api_client
)
\ No newline at end of file
semaphore-python-client-generated/test/test_login.py
View file @
9eab6201
...
@@ -19,31 +19,26 @@ import semaphore_client
...
@@ -19,31 +19,26 @@ import semaphore_client
from
semaphore_client
import
APIToken
from
semaphore_client
import
APIToken
from
semaphore_client.models.login
import
Login
# noqa: E501
from
semaphore_client.models.login
import
Login
# noqa: E501
from
semaphore_client.rest
import
ApiException
from
semaphore_client.rest
import
ApiException
from
test.test_helper
import
TestHelper
from
semaphore_client.semaphore_helper
import
SemaphoreHelper
class
TestLogin
(
unittest
.
TestCase
):
class
TestLogin
(
unittest
.
TestCase
):
"""Login unit test stubs"""
"""Login unit test stubs"""
def
setUp
(
self
):
def
setUp
(
self
):
self
.
helper
=
TestHelper
()
self
.
semaphore_base_url
=
'http://localhost:3000/api'
pass
if
SemaphoreHelper
.
service_is_up
(
self
.
semaphore_base_url
):
self
.
username
=
'admin'
self
.
password
=
'password'
def
tearDown
(
self
):
def
tearDown
(
self
):
pass
pass
def
testLogin
(
self
):
def
testLogin
(
self
):
"""Test Login"""
"""Test Login"""
login
=
semaphore_client
.
models
.
login
.
Login
()
# noq
if
SemaphoreHelper
.
service_is_up
(
self
.
semaphore_base_url
):
login
.
password
=
self
.
helper
.
semaphore_password
self
.
helper
=
SemaphoreHelper
(
self
.
semaphore_base_url
,
self
.
username
,
self
.
password
)
login
.
auth
=
self
.
helper
.
semaphore_username
self
.
helper
.
authentication_api
.
auth_login_post
(
login
)
cookie
=
self
.
helper
.
authentication_api
.
api_client
.
cookie
self
.
assertIsNotNone
(
cookie
)
tokens
=
self
.
helper
.
authentication_api
.
user_tokens_get
()
self
.
assertIsNotNone
(
tokens
)
newToken
=
self
.
helper
.
authentication_api
.
user_tokens_post
()
self
.
assertIsNotNone
(
newToken
)
...
...
semaphore-python-client-generated/test/test_task.py
View file @
9eab6201
...
@@ -14,26 +14,75 @@
...
@@ -14,26 +14,75 @@
from
__future__
import
absolute_import
from
__future__
import
absolute_import
import
unittest
import
unittest
import
yaml
import
semaphore_client
import
semaphore_client
from
semaphore_client.models.task
import
Task
# noqa: E501
from
semaphore_client.models.task
import
Task
# noqa: E501
from
semaphore_client.rest
import
ApiException
from
semaphore_client.rest
import
ApiException
from
semaphore_client.semaphore_helper
import
SemaphoreHelper
import
names
yaml
.
Dumper
.
ignore_aliases
=
lambda
*
args
:
True
class
TestTask
(
unittest
.
TestCase
):
class
TestTask
(
unittest
.
TestCase
):
"""Task unit test stubs"""
"""Task unit test stubs"""
def
setUp
(
self
):
def
setUp
(
self
):
pass
self
.
semaphore_base_url
=
'http://localhost:3000/api'
if
SemaphoreHelper
.
service_is_up
(
self
.
semaphore_base_url
):
self
.
username
=
'admin'
self
.
password
=
'password'
self
.
project_name
=
names
.
get_first_name
()
self
.
private_key
=
'-----BEGIN RSA PRIVATE KEY-----MIIEowIBAAKCAQEAg0blRNV6cm3RTiivpzE8HR4JzKZRVIBZ7bxeNoMz0'
\
'-----END RSA PRIVATE KEY-----'
vms
=
[]
vm
=
{}
vm
[
'role'
]
=
'master'
vm
[
'public_ip'
]
=
'192.168.1.10'
vm
[
'user_name'
]
=
'user_name'
vms
.
append
(
vm
)
vm
[
'role'
]
=
'worker'
vm
[
'public_ip'
]
=
'192.168.1.11'
vm
[
'role'
]
=
'worker'
vm
[
'public_ip'
]
=
'192.168.1.12'
vms
.
append
(
vm
)
self
.
inventory_contents
=
yaml
.
dump
(
self
.
build_yml_inventory
(
vms
),
default_flow_style
=
False
)
self
.
git_url
=
'https://github.com/skoulouzis/playbooks.git'
self
.
playbook_name
=
'get_ip_addresses.yaml'
self
.
semaphore_helper
=
SemaphoreHelper
(
self
.
semaphore_base_url
,
self
.
username
,
self
.
password
)
def
tearDown
(
self
):
def
tearDown
(
self
):
pass
pass
def
testTask
(
self
):
def
testTask
(
self
):
"""Test Task"""
if
SemaphoreHelper
.
service_is_up
(
self
.
semaphore_base_url
):
# FIXME: construct object with mandatory attributes with example values
project_id
=
self
.
semaphore_helper
.
create_project
(
self
.
project_name
)
# model = semaphore_client.models.task.Task() # noqa: E501
key_id
=
self
.
semaphore_helper
.
create_ssh_key
(
self
.
project_name
,
project_id
,
self
.
private_key
)
pass
inventory_id
=
self
.
semaphore_helper
.
create_inventory
(
self
.
project_name
,
project_id
,
key_id
,
self
.
inventory_contents
)
repository_id
=
self
.
semaphore_helper
.
create_repository
(
self
.
project_name
,
project_id
,
key_id
,
self
.
git_url
)
template_id
=
self
.
semaphore_helper
.
create_template
(
project_id
,
key_id
,
inventory_id
,
repository_id
,
self
.
playbook_name
)
task_id
=
self
.
semaphore_helper
.
execute_task
(
project_id
,
template_id
,
self
.
playbook_name
)
task
=
self
.
semaphore_helper
.
get_task
(
project_id
,
task_id
)
def
build_yml_inventory
(
self
,
vms
):
inventory
=
{}
all
=
{}
vars
=
{
'ansible_ssh_common_args'
:
'-o StrictHostKeyChecking=no'
}
vars
[
'ansible_ssh_user'
]
=
vms
[
0
][
'user_name'
]
children
=
{}
for
vm
in
vms
:
role
=
vm
[
'role'
]
public_ip
=
vm
[
'public_ip'
]
if
role
not
in
children
:
hosts
=
{}
else
:
hosts
=
children
[
role
]
hosts
[
public_ip
]
=
vars
children
[
role
]
=
hosts
all
[
'children'
]
=
children
inventory
[
'all'
]
=
all
return
inventory
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
sure_tosca-client_python_stubs/.idea/workspace.xml
View file @
9eab6201
...
@@ -2,12 +2,16 @@
...
@@ -2,12 +2,16 @@
<project
version=
"4"
>
<project
version=
"4"
>
<component
name=
"ChangeListManager"
>
<component
name=
"ChangeListManager"
>
<list
default=
"true"
id=
"3f84153d-6ed1-4691-94d6-53105266f15e"
name=
"Default Changelist"
comment=
""
>
<list
default=
"true"
id=
"3f84153d-6ed1-4691-94d6-53105266f15e"
name=
"Default Changelist"
comment=
""
>
<change
beforePath=
"$PROJECT_DIR$/../deployer/test/test_deployer.py"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/../deployer/test/test_deployer.py"
afterDir=
"false"
/>
<change
afterPath=
"$PROJECT_DIR$/../semaphore-python-client-generated/semaphore_client/semaphore_helper.py"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/../deployer/.idea/drip-deployer.iml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/../deployer/.idea/drip-deployer.iml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/../deployer/.idea/misc.xml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/../deployer/.idea/misc.xml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/../deployer/service/semaphore_helper.py"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/../deployer/service/semaphore_helper.py"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/../semaphore-python-client-generated/.idea/misc.xml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/../semaphore-python-client-generated/.idea/misc.xml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/../semaphore-python-client-generated/.idea/semaphore-python-client-generated.iml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/../semaphore-python-client-generated/.idea/semaphore-python-client-generated.iml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/../semaphore-python-client-generated/test-requirements.txt"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/../semaphore-python-client-generated/test-requirements.txt"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/../semaphore-python-client-generated/test/test_helper.py"
beforeDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/../semaphore-python-client-generated/test/test_login.py"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/../semaphore-python-client-generated/test/test_login.py"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/.idea/workspace.xml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/.idea/workspace.xml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/.idea/workspace.xml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/.idea/workspace.xml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/sure_tosca_client/api_client.py"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/sure_tosca_client/api_client.py"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/test/test_default_api.py"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/test/test_default_api.py"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/../sure_tosca-flask-server/sure_tosca/service/tosca_template_service.py"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/../sure_tosca-flask-server/sure_tosca/service/tosca_template_service.py"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/../sure_tosca-flask-server/sure_tosca/test/test_default_controller.py"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/../sure_tosca-flask-server/sure_tosca/test/test_default_controller.py"
afterDir=
"false"
/>
</list>
</list>
<option
name=
"SHOW_DIALOG"
value=
"false"
/>
<option
name=
"SHOW_DIALOG"
value=
"false"
/>
<option
name=
"HIGHLIGHT_CONFLICTS"
value=
"true"
/>
<option
name=
"HIGHLIGHT_CONFLICTS"
value=
"true"
/>
...
@@ -26,7 +30,7 @@
...
@@ -26,7 +30,7 @@
</component>
</component>
<component
name=
"PropertiesComponent"
>
<component
name=
"PropertiesComponent"
>
<property
name=
"RunOnceActivity.ShowReadmeOnStart"
value=
"true"
/>
<property
name=
"RunOnceActivity.ShowReadmeOnStart"
value=
"true"
/>
<property
name=
"last_opened_file_path"
value=
"$PROJECT_DIR$
/../sure_tosca-flask-server
"
/>
<property
name=
"last_opened_file_path"
value=
"$PROJECT_DIR$"
/>
<property
name=
"settings.editor.selected.configurable"
value=
"com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable"
/>
<property
name=
"settings.editor.selected.configurable"
value=
"com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable"
/>
</component>
</component>
<component
name=
"RunManager"
>
<component
name=
"RunManager"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment