Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
synnefo
Commits
ec59c09e
Commit
ec59c09e
authored
Apr 19, 2013
by
Kostas Papadimitriou
Browse files
Store service access url in database
parent
1ee1c1a3
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
snf-astakos-app/astakos/im/management/commands/service-add.py
View file @
ec59c09e
...
@@ -38,7 +38,7 @@ from astakos.im.models import Service
...
@@ -38,7 +38,7 @@ from astakos.im.models import Service
class
Command
(
BaseCommand
):
class
Command
(
BaseCommand
):
args
=
"<name> <
endpoint URL>
"
args
=
"<name> <
service URL> <API URL>
"
help
=
"Register a service"
help
=
"Register a service"
def
handle
(
self
,
*
args
,
**
options
):
def
handle
(
self
,
*
args
,
**
options
):
...
@@ -47,6 +47,7 @@ class Command(BaseCommand):
...
@@ -47,6 +47,7 @@ class Command(BaseCommand):
name
=
args
[
0
]
name
=
args
[
0
]
api_url
=
args
[
1
]
api_url
=
args
[
1
]
url
=
args
[
2
]
try
:
try
:
s
=
Service
.
objects
.
get
(
name
=
name
)
s
=
Service
.
objects
.
get
(
name
=
name
)
...
@@ -61,7 +62,7 @@ class Command(BaseCommand):
...
@@ -61,7 +62,7 @@ class Command(BaseCommand):
raise
CommandError
(
m
)
raise
CommandError
(
m
)
try
:
try
:
s
=
Service
.
objects
.
create
(
name
=
name
,
api_url
=
api_url
)
s
=
Service
.
objects
.
create
(
name
=
name
,
api_url
=
api_url
,
url
=
url
)
except
BaseException
as
e
:
except
BaseException
as
e
:
raise
CommandError
(
"Failed to create service."
)
raise
CommandError
(
"Failed to create service."
)
else
:
else
:
...
...
snf-astakos-app/astakos/im/management/commands/service-list.py
View file @
ec59c09e
...
@@ -43,10 +43,11 @@ class Command(ListCommand):
...
@@ -43,10 +43,11 @@ class Command(ListCommand):
FIELDS
=
{
FIELDS
=
{
"id"
:
(
"id"
,
"ID"
),
"id"
:
(
"id"
,
"ID"
),
"name"
:
(
"name"
,
"Service Name"
),
"name"
:
(
"name"
,
"Service Name"
),
"url"
:
(
"api_url"
,
"Service API url"
),
"url"
:
(
"url"
,
"Service url"
),
"api_url"
:
(
"api_url"
,
"Service API url"
),
"token"
:
(
"auth_token"
,
"Authentication token"
),
"token"
:
(
"auth_token"
,
"Authentication token"
),
"created"
:
(
"auth_token_created"
,
"Token creation date"
),
"created"
:
(
"auth_token_created"
,
"Token creation date"
),
"expires"
:
(
"auth_token_expires"
,
"Token expiration date"
),
"expires"
:
(
"auth_token_expires"
,
"Token expiration date"
),
}
}
fields
=
[
"id"
,
"name"
,
"url"
,
"token"
,
"created"
,
"expires"
]
fields
=
[
"id"
,
"name"
,
"url"
,
"api_url"
,
"token"
,
"created"
,
"expires"
]
snf-astakos-app/astakos/im/management/commands/service-update.py
View file @
ec59c09e
...
@@ -50,6 +50,10 @@ class Command(BaseCommand):
...
@@ -50,6 +50,10 @@ class Command(BaseCommand):
dest
=
'name'
,
dest
=
'name'
,
default
=
None
,
default
=
None
,
help
=
"Set service name"
),
help
=
"Set service name"
),
make_option
(
'--url'
,
dest
=
'url'
,
default
=
None
,
help
=
"Set service url"
),
make_option
(
'--api-url'
,
make_option
(
'--api-url'
,
dest
=
'api_url'
,
dest
=
'api_url'
,
default
=
None
,
default
=
None
,
...
@@ -77,6 +81,7 @@ class Command(BaseCommand):
...
@@ -77,6 +81,7 @@ class Command(BaseCommand):
name
=
options
.
get
(
'name'
)
name
=
options
.
get
(
'name'
)
api_url
=
options
.
get
(
'api_url'
)
api_url
=
options
.
get
(
'api_url'
)
url
=
options
.
get
(
'url'
)
auth_token
=
options
.
get
(
'auth_token'
)
auth_token
=
options
.
get
(
'auth_token'
)
renew_token
=
options
.
get
(
'renew_token'
)
renew_token
=
options
.
get
(
'renew_token'
)
...
@@ -86,6 +91,9 @@ class Command(BaseCommand):
...
@@ -86,6 +91,9 @@ class Command(BaseCommand):
if
api_url
:
if
api_url
:
service
.
api_url
=
api_url
service
.
api_url
=
api_url
if
url
:
service
.
url
=
url
if
auth_token
:
if
auth_token
:
service
.
auth_token
=
auth_token
service
.
auth_token
=
auth_token
...
...
snf-astakos-app/astakos/im/migrations/0032_auto__add_field_service_url.py
0 → 100644
View file @
ec59c09e
This diff is collapsed.
Click to expand it.
snf-astakos-app/astakos/im/models.py
View file @
ec59c09e
...
@@ -121,6 +121,8 @@ def dict_merge(a, b):
...
@@ -121,6 +121,8 @@ def dict_merge(a, b):
class
Service
(
models
.
Model
):
class
Service
(
models
.
Model
):
name
=
models
.
CharField
(
_
(
'Name'
),
max_length
=
255
,
unique
=
True
,
name
=
models
.
CharField
(
_
(
'Name'
),
max_length
=
255
,
unique
=
True
,
db_index
=
True
)
db_index
=
True
)
url
=
models
.
CharField
(
_
(
'Service url'
),
max_length
=
255
,
null
=
True
,
help_text
=
_
(
"URL the service is accessible from"
))
api_url
=
models
.
CharField
(
_
(
'Service API url'
),
max_length
=
255
,
null
=
True
)
api_url
=
models
.
CharField
(
_
(
'Service API url'
),
max_length
=
255
,
null
=
True
)
auth_token
=
models
.
CharField
(
_
(
'Authentication Token'
),
max_length
=
32
,
auth_token
=
models
.
CharField
(
_
(
'Authentication Token'
),
max_length
=
32
,
null
=
True
,
blank
=
True
)
null
=
True
,
blank
=
True
)
...
...
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