-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create load_data and load_schema APIs [RHELDST-4862]
The load_schema API allows clients to more easily consume the schema.json file that is included in the cdn-definitions package. The load_data API will return a raw dictionary of the chosen data file. This will allow users to access various types of data in a uniform way. In order to encourage a single, consistent method of access to the cdn-definitions data, the legacy access methods and related classes (i.e., PathAlias, rhui_alias, and origin_alias) will be deprecated. A dedicated Python object will no longer need to be created for each new addition to the schema. The load_data API also includes an optional "source" argument to the load_data method. The source parameter allows the user to specify the source of the cdn_definitions JSON or YAML data file. The source could be a URL or a local path in a directory tree. If a source is not specified, the location may be overriden via the CDN_DEFINITIONS_PATH environment variable, which also may either be in the form of a URL or a local path. If neither a source is specified, nor a CDN_DEFINITIONS_PATH environment variable is set, the data.yaml file included in the cdn-definitions package will be used as a source. If that file is unavailable, load_data will attempt to load data from /usr/share/cdn-definitions/data.yaml. If all of the sources are invalid, a RuntimeError will be thrown.
- Loading branch information
1 parent
f2c8dfd
commit 4d85878
Showing
6 changed files
with
178 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
PyYAML | ||
requests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
from ._impl import PathAlias, origin_aliases, rhui_aliases | ||
from ._impl import PathAlias, origin_aliases, rhui_aliases, load_data, load_schema | ||
|
||
__all__ = ["PathAlias", "origin_aliases", "rhui_aliases"] | ||
__all__ = ["PathAlias", "origin_aliases", "rhui_aliases", "load_data", "load_schema"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pytest | ||
jsonschema | ||
requests-mock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters