-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ oum: replace ocm-org-ids option with query
- Loading branch information
Showing
7 changed files
with
137 additions
and
18 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
Empty file.
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,14 @@ | ||
# qenerate: plugin=pydantic_v1 | ||
|
||
query OUMOrganizations($name: String) { | ||
organizations: ocm_instances_v1(name: $name) { | ||
name | ||
environment { | ||
...OCMEnvironment | ||
} | ||
orgId | ||
disable { | ||
...DisableAutomations | ||
} | ||
} | ||
} |
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,96 @@ | ||
""" | ||
Generated by qenerate plugin=pydantic_v1. DO NOT MODIFY MANUALLY! | ||
""" | ||
from collections.abc import Callable # noqa: F401 # pylint: disable=W0611 | ||
from datetime import datetime # noqa: F401 # pylint: disable=W0611 | ||
from enum import Enum # noqa: F401 # pylint: disable=W0611 | ||
from typing import ( # noqa: F401 # pylint: disable=W0611 | ||
Any, | ||
Optional, | ||
Union, | ||
) | ||
|
||
from pydantic import ( # noqa: F401 # pylint: disable=W0611 | ||
BaseModel, | ||
Extra, | ||
Field, | ||
Json, | ||
) | ||
|
||
from reconcile.gql_definitions.fragments.disable import DisableAutomations | ||
from reconcile.gql_definitions.fragments.ocm_environment import OCMEnvironment | ||
|
||
|
||
DEFINITION = """ | ||
fragment DisableAutomations on DisableClusterAutomations_v1 { | ||
integrations | ||
} | ||
fragment OCMEnvironment on OpenShiftClusterManagerEnvironment_v1 { | ||
name | ||
description | ||
labels | ||
url | ||
accessTokenClientId | ||
accessTokenUrl | ||
accessTokenClientSecret { | ||
... VaultSecret | ||
} | ||
} | ||
fragment VaultSecret on VaultSecret_v1 { | ||
path | ||
field | ||
version | ||
format | ||
} | ||
query OUMOrganizations($name: String) { | ||
organizations: ocm_instances_v1(name: $name) { | ||
name | ||
environment { | ||
...OCMEnvironment | ||
} | ||
orgId | ||
disable { | ||
...DisableAutomations | ||
} | ||
} | ||
} | ||
""" | ||
|
||
|
||
class ConfiguredBaseModel(BaseModel): | ||
class Config: | ||
smart_union=True | ||
extra=Extra.forbid | ||
|
||
|
||
class OpenShiftClusterManagerV1(ConfiguredBaseModel): | ||
name: str = Field(..., alias="name") | ||
environment: OCMEnvironment = Field(..., alias="environment") | ||
org_id: str = Field(..., alias="orgId") | ||
disable: Optional[DisableAutomations] = Field(..., alias="disable") | ||
|
||
|
||
class OUMOrganizationsQueryData(ConfiguredBaseModel): | ||
organizations: Optional[list[OpenShiftClusterManagerV1]] = Field(..., alias="organizations") | ||
|
||
|
||
def query(query_func: Callable, **kwargs: Any) -> OUMOrganizationsQueryData: | ||
""" | ||
This is a convenience function which queries and parses the data into | ||
concrete types. It should be compatible with most GQL clients. | ||
You do not have to use it to consume the generated data classes. | ||
Alternatively, you can also mime and alternate the behavior | ||
of this function in the caller. | ||
Parameters: | ||
query_func (Callable): Function which queries your GQL Server | ||
kwargs: optional arguments that will be passed to the query function | ||
Returns: | ||
OUMOrganizationsQueryData: queried data parsed into generated classes | ||
""" | ||
raw_data: dict[Any, Any] = query_func(DEFINITION, **kwargs) | ||
return OUMOrganizationsQueryData(**raw_data) |
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