forked from RedHatQE/openshift-python-wrapper
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More resources from class generator (RedHatQE#2009)
* create and convert resources using class generator script * create and convert resources using class generator script * create and convert resources using class generator script * create and convert resources using class generator script
- Loading branch information
Showing
13 changed files
with
3,033 additions
and
82 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
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,31 +1,42 @@ | ||
from ocp_resources.constants import TIMEOUT_4MINUTES | ||
# Generated using https://github.com/RedHatQE/openshift-python-wrapper/blob/main/scripts/resource/README.md | ||
|
||
from typing import Any, Dict, Optional | ||
from ocp_resources.resource import Resource | ||
|
||
|
||
class Namespace(Resource): | ||
""" | ||
Namespace object, inherited from Resource. | ||
Namespace provides a scope for Names. Use of multiple namespaces is | ||
optional. | ||
""" | ||
|
||
api_version = Resource.ApiVersion.V1 | ||
api_version: str = Resource.ApiVersion.V1 | ||
|
||
class Status(Resource.Status): | ||
ACTIVE = "Active" | ||
|
||
def __init__( | ||
self, | ||
name=None, | ||
client=None, | ||
teardown=True, | ||
yaml_file=None, | ||
delete_timeout=TIMEOUT_4MINUTES, | ||
**kwargs, | ||
): | ||
super().__init__( | ||
name=name, | ||
client=client, | ||
teardown=teardown, | ||
yaml_file=yaml_file, | ||
delete_timeout=delete_timeout, | ||
**kwargs, | ||
) | ||
finalizers: Optional[Dict[str, Any]] = None, | ||
**kwargs: Any, | ||
) -> None: | ||
""" | ||
Args: | ||
finalizers(Dict[Any, Any]): Finalizers is an opaque list of values that must be empty to permanently | ||
remove object from storage. More info: | ||
https://kubernetes.io/docs/tasks/administer-cluster/namespaces/ | ||
""" | ||
super().__init__(**kwargs) | ||
|
||
self.finalizers = finalizers | ||
|
||
def to_dict(self) -> None: | ||
super().to_dict() | ||
|
||
if not self.yaml_file: | ||
self.res["spec"] = {} | ||
_spec = self.res["spec"] | ||
|
||
if self.finalizers: | ||
_spec["finalizers"] = self.finalizers |
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,7 +1,18 @@ | ||
# https://docs.openshift.com/container-platform/4.12/operators/operator-reference.html | ||
# Generated using https://github.com/RedHatQE/openshift-python-wrapper/blob/main/scripts/resource/README.md | ||
|
||
from typing import Any | ||
from ocp_resources.resource import Resource | ||
|
||
|
||
class Operator(Resource): | ||
api_group = Resource.ApiGroup.OPERATORS_COREOS_COM | ||
""" | ||
Operator represents a cluster operator. | ||
""" | ||
|
||
api_group: str = Resource.ApiGroup.OPERATORS_COREOS_COM | ||
|
||
def __init__( | ||
self, | ||
**kwargs: Any, | ||
) -> None: | ||
super().__init__(**kwargs) |
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,50 +1,104 @@ | ||
from ocp_resources.constants import TIMEOUT_4MINUTES | ||
# Generated using https://github.com/RedHatQE/openshift-python-wrapper/blob/main/scripts/resource/README.md | ||
|
||
from typing import Any, Dict, Optional | ||
from ocp_resources.resource import Resource | ||
|
||
|
||
class Project(Resource): | ||
""" | ||
Project object. | ||
This is openshift's object which represents Namespace | ||
Projects are the unit of isolation and collaboration in OpenShift. A project | ||
has one or more members, a quota on the resources that the project may | ||
consume, and the security controls on the resources in the project. Within a | ||
project, members may have different roles - project administrators can set | ||
membership, editors can create and manage the resources, and viewers can see | ||
but not access running containers. In a normal cluster project | ||
administrators are not able to alter their quotas - that is restricted to | ||
cluster administrators. | ||
Listing or watching projects will return only projects the user has the | ||
reader role on. | ||
An OpenShift project is an alternative representation of a Kubernetes | ||
namespace. Projects are exposed as editable to end users while namespaces | ||
are not. Direct creation of a project is typically restricted to | ||
administrators, while end users should use the requestproject resource. | ||
Compatibility level 1: Stable within a major release for a minimum of 12 | ||
months or 3 minor releases (whichever is longer). | ||
""" | ||
|
||
api_group = Resource.ApiGroup.PROJECT_OPENSHIFT_IO | ||
api_group: str = Resource.ApiGroup.PROJECT_OPENSHIFT_IO | ||
|
||
class Status(Resource.Status): | ||
ACTIVE = "Active" | ||
|
||
def clean_up(self): | ||
Project(name=self.name).delete(wait=True) | ||
def __init__( | ||
self, | ||
finalizers: Optional[Dict[str, Any]] = None, | ||
**kwargs: Any, | ||
) -> None: | ||
""" | ||
Args: | ||
finalizers(Dict[Any, Any]): Finalizers is an opaque list of values that must be empty to permanently | ||
remove object from storage | ||
""" | ||
super().__init__(**kwargs) | ||
|
||
self.finalizers = finalizers | ||
|
||
def to_dict(self) -> None: | ||
super().to_dict() | ||
|
||
if not self.yaml_file: | ||
self.res["spec"] = {} | ||
_spec = self.res["spec"] | ||
|
||
if self.finalizers: | ||
_spec["finalizers"] = self.finalizers | ||
|
||
def clean_up(self, wait: bool = True) -> bool: | ||
return Project(name=self.name).delete(wait=wait) | ||
|
||
|
||
class ProjectRequest(Resource): | ||
""" | ||
RequestProject object. | ||
Resource which adds Project and grand | ||
full access to user who originated this request | ||
ProjectRequest is the set of options necessary to fully qualify a project | ||
request | ||
Compatibility level 1: Stable within a major release for a minimum of 12 | ||
months or 3 minor releases (whichever is longer). | ||
""" | ||
|
||
api_group = Resource.ApiGroup.PROJECT_OPENSHIFT_IO | ||
api_group: str = Resource.ApiGroup.PROJECT_OPENSHIFT_IO | ||
|
||
def __init__( | ||
self, | ||
name=None, | ||
client=None, | ||
teardown=True, | ||
timeout=TIMEOUT_4MINUTES, | ||
yaml_file=None, | ||
delete_timeout=TIMEOUT_4MINUTES, | ||
**kwargs, | ||
): | ||
super().__init__( | ||
name=name, | ||
client=client, | ||
teardown=teardown, | ||
timeout=timeout, | ||
yaml_file=yaml_file, | ||
delete_timeout=delete_timeout, | ||
**kwargs, | ||
) | ||
|
||
def clean_up(self): | ||
Project(name=self.name).delete(wait=True) | ||
description: Optional[str] = "", | ||
display_name: Optional[str] = "", | ||
**kwargs: Any, | ||
) -> None: | ||
""" | ||
Args: | ||
description(str): Description is the description to apply to a project | ||
display_name(str): DisplayName is the display name to apply to a project | ||
""" | ||
super().__init__(**kwargs) | ||
|
||
self.description = description | ||
self.display_name = display_name | ||
|
||
def to_dict(self) -> None: | ||
super().to_dict() | ||
|
||
if not self.yaml_file: | ||
if self.description: | ||
self.res["description"] = self.description | ||
|
||
if self.display_name: | ||
self.res["displayName"] = self.display_name | ||
|
||
def clean_up(self, wait: bool = True) -> bool: | ||
return Project(name=self.name).delete(wait=wait) |
Oops, something went wrong.