-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Register a data source and its associated configuration class 1. First decorate the class with @data_source decorator 2. Then impelment vdk_data_sources_register to register the class as below ``` @hookimpl def vdk_data_sources_register(self, data_source_factory: IDataSourceFactory): data_source_factory.register_data_source_class(AutoGeneratedDataSource) ```
- Loading branch information
1 parent
3900373
commit 7f05c82
Showing
6 changed files
with
137 additions
and
39 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
25 changes: 25 additions & 0 deletions
25
projects/vdk-plugins/vdk-data-sources/src/vdk/plugin/data_sources/hook_spec.py
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Copyright 2021-2023 VMware, Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
from vdk.api.plugin.hook_markers import hookspec | ||
from vdk.plugin.data_sources.factory import IDataSourceFactory | ||
|
||
|
||
class DataSourcesHookSpec: | ||
@hookspec(historic=True) | ||
def vdk_data_sources_register(self, data_source_factory: IDataSourceFactory): | ||
""" | ||
Register a data source and its associated configuration class. | ||
:param data_source_factory: the factory where the data sources should be registered. Provide those param: | ||
:name: The name identifier for the data source | ||
:data_source_class: The data source class that implements `IDataSource`. Only the type. Not an instance of it! | ||
Example:: | ||
data_source_factory.register_data_source_class(data_source_class=CsvDataSource) | ||
#where CsvDataSource is like | ||
@data_source(name="csv", config_class=CsvDataSourceConfig) | ||
CsvDataSource(IDataSource): | ||
... | ||
""" |
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
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