Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
geomag-algorithms
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ghsc
National Geomagnetism Program
geomag-algorithms
Commits
704ba79d
Commit
704ba79d
authored
4 years ago
by
Cain, Payton David
Browse files
Options
Downloads
Patches
Plain Diff
Change hostname, request.get with params, null metadata, typer option
parent
4b3c6abb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!146
Release CMO metadata to production
,
!65
Metadata client
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
geomagio/apiclient/MetadataFactory.py
+7
-8
7 additions, 8 deletions
geomagio/apiclient/MetadataFactory.py
geomagio/apiclient/metadata.py
+3
-1
3 additions, 1 deletion
geomagio/apiclient/metadata.py
with
10 additions
and
9 deletions
geomagio/apiclient/MetadataFactory.py
+
7
−
8
View file @
704ba79d
...
@@ -14,7 +14,7 @@ class MetadataFactory(object):
...
@@ -14,7 +14,7 @@ class MetadataFactory(object):
def
__init__
(
def
__init__
(
self
,
self
,
url
:
str
=
"
http://{}/ws/secure/metadata
"
.
format
(
url
:
str
=
"
http://{}/ws/secure/metadata
"
.
format
(
os
.
getenv
(
"
ED
GE_HOST
"
,
"
127.0.0.1:8000
"
)
os
.
getenv
(
"
GE
OMAG_API
_HOST
"
,
"
127.0.0.1:8000
"
)
),
),
token
:
str
=
os
.
getenv
(
"
GITLAB_API_TOKEN
"
),
token
:
str
=
os
.
getenv
(
"
GITLAB_API_TOKEN
"
),
):
):
...
@@ -28,7 +28,10 @@ class MetadataFactory(object):
...
@@ -28,7 +28,10 @@ class MetadataFactory(object):
def
get_metadata
(
self
,
query
:
MetadataQuery
)
->
Union
[
List
[
Metadata
],
Metadata
]:
def
get_metadata
(
self
,
query
:
MetadataQuery
)
->
Union
[
List
[
Metadata
],
Metadata
]:
args
=
parse_params
(
query
=
query
)
args
=
parse_params
(
query
=
query
)
responses
=
requests
.
get
(
url
=
f
"
{
self
.
url
}{
args
}
"
,
headers
=
self
.
header
)
if
"
id
"
in
args
:
self
.
url
=
f
"
{
self
.
url
}
/
{
args
[
'
id
'
]
}
"
args
=
{}
responses
=
requests
.
get
(
url
=
self
.
url
,
params
=
args
,
headers
=
self
.
header
)
try
:
try
:
metadata
=
parse_obj_as
(
Union
[
List
[
Metadata
],
Metadata
],
responses
.
json
())
metadata
=
parse_obj_as
(
Union
[
List
[
Metadata
],
Metadata
],
responses
.
json
())
except
:
except
:
...
@@ -42,10 +45,6 @@ class MetadataFactory(object):
...
@@ -42,10 +45,6 @@ class MetadataFactory(object):
return
response
return
response
def
update_metadata
(
self
,
metadata
:
Metadata
)
->
requests
.
Response
:
def
update_metadata
(
self
,
metadata
:
Metadata
)
->
requests
.
Response
:
if
metadata
.
metadata
is
None
:
metadata
.
metadata
=
self
.
get_metadata
(
query
=
MetadataQuery
(
**
metadata
.
dict
())
).
metadata
response
=
requests
.
put
(
response
=
requests
.
put
(
url
=
f
"
{
self
.
url
}
/
{
metadata
.
id
}
"
,
data
=
metadata
.
json
(),
headers
=
self
.
header
url
=
f
"
{
self
.
url
}
/
{
metadata
.
id
}
"
,
data
=
metadata
.
json
(),
headers
=
self
.
header
)
)
...
@@ -65,7 +64,7 @@ def parse_params(query: MetadataQuery) -> str:
...
@@ -65,7 +64,7 @@ def parse_params(query: MetadataQuery) -> str:
if
key
==
"
category
"
:
if
key
==
"
category
"
:
element
=
element
.
value
element
=
element
.
value
elif
key
==
"
id
"
:
elif
key
==
"
id
"
:
return
f
"
/
{
element
}
"
return
{
"
id
"
:
element
}
args
[
key
]
=
element
args
[
key
]
=
element
return
f
"
?
{
urllib
.
parse
.
urlencode
(
args
)
}
"
return
args
This diff is collapsed.
Click to expand it.
geomagio/apiclient/metadata.py
+
3
−
1
View file @
704ba79d
...
@@ -15,7 +15,9 @@ def main():
...
@@ -15,7 +15,9 @@ def main():
def
client
(
def
client
(
action
:
str
,
action
:
str
=
typer
.
Option
(
default
=
"
get
"
,
help
=
"
get(default), delete, create, or update
"
),
url
:
str
=
"
http://{}/ws/secure/metadata
"
.
format
(
url
:
str
=
"
http://{}/ws/secure/metadata
"
.
format
(
os
.
getenv
(
"
GEOMAG_API_HOST
"
,
"
127.0.0.1:8000
"
)
os
.
getenv
(
"
GEOMAG_API_HOST
"
,
"
127.0.0.1:8000
"
)
),
),
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment