Skip to content

Commit

Permalink
Clean up python SDK get methods
Browse files Browse the repository at this point in the history
Add docstrings and standardize with the updated
CustomResource get method.
  • Loading branch information
lblackstone committed Aug 23, 2019
1 parent e754c73 commit bbc55b1
Show file tree
Hide file tree
Showing 176 changed files with 2,781 additions and 519 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- Document await logic in the SDKs. (https://github.com/pulumi/pulumi-kubernetes/pull/711).
- Document await timeouts and how to override. (https://github.com/pulumi/pulumi-kubernetes/pull/718).
- Improve CustomResource for Python SDK. (https://github.com/pulumi/pulumi-kubernetes/pull/700).
- Clean up Python SDK get methods. (https://github.com/pulumi/pulumi-kubernetes/pull/740).
- Don't populate `.status` in input types (https://github.com/pulumi/pulumi-kubernetes/pull/635).

## 1.0.0-beta.1 (August 13, 2019)
Expand Down
6 changes: 6 additions & 0 deletions pkg/gen/python-templates/CustomResource.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ def __init__(self, resource_name, api_version, kind, spec=None, metadata=None, o
@staticmethod
def get(resource_name, api_version, kind, id, opts=None):
"""
Get the state of an existing `CustomResource` resource, as identified by `id`.
Typically this ID is of the form [namespace]/[name]; if [namespace] is omitted,
then (per Kubernetes convention) the ID becomes default/[name].
Pulumi will keep track of this resource using `resource_name` as the Pulumi ID.
:param str resource_name: _Unique_ name used to register this resource with Pulumi.
:param str api_version: The API version of the apiExtensions.CustomResource we
wish to select, as specified by the CustomResourceDefinition that defines it on the
Expand Down
19 changes: 16 additions & 3 deletions pkg/gen/python-templates/kind.py.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,22 @@ class {{Kind}}(pulumi.CustomResource):
opts)

@staticmethod
def get(name: str, id: Input[str], opts: Optional[ResourceOptions] = None):
opts = ResourceOptions(id=id) if opts is None else opts.merge(ResourceOptions(id=id))
return {{Kind}}(name, opts)
def get(resource_name, id, opts=None):
"""
Get the state of an existing `{{Kind}}` resource, as identified by `id`.
Typically this ID is of the form [namespace]/[name]; if [namespace] is omitted,
then (per Kubernetes convention) the ID becomes default/[name].

Pulumi will keep track of this resource using `resource_name` as the Pulumi ID.

:param str resource_name: _Unique_ name used to register this resource with Pulumi.
:param pulumi.Input[str] id: An ID for the Kubernetes resource to retrieve.
Takes the form [namespace]/[name] or [name].
:param Optional[pulumi.ResourceOptions] opts: A bag of options that control this
resource's behavior.
"""
opts = ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))
return {{Kind}}(resource_name, opts)

def translate_output_property(self, prop: str) -> str:
return tables._CASING_FORWARD_TABLE.get(prop) or prop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,22 @@ def __init__(self, resource_name, opts=None, metadata=None, webhooks=None, __nam
opts)

@staticmethod
def get(name: str, id: Input[str], opts: Optional[ResourceOptions] = None):
opts = ResourceOptions(id=id) if opts is None else opts.merge(ResourceOptions(id=id))
return MutatingWebhookConfiguration(name, opts)
def get(resource_name, id, opts=None):
"""
Get the state of an existing `MutatingWebhookConfiguration` resource, as identified by `id`.
Typically this ID is of the form [namespace]/[name]; if [namespace] is omitted,
then (per Kubernetes convention) the ID becomes default/[name].
Pulumi will keep track of this resource using `resource_name` as the Pulumi ID.
:param str resource_name: _Unique_ name used to register this resource with Pulumi.
:param pulumi.Input[str] id: An ID for the Kubernetes resource to retrieve.
Takes the form [namespace]/[name] or [name].
:param Optional[pulumi.ResourceOptions] opts: A bag of options that control this
resource's behavior.
"""
opts = ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))
return MutatingWebhookConfiguration(resource_name, opts)

def translate_output_property(self, prop: str) -> str:
return tables._CASING_FORWARD_TABLE.get(prop) or prop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,22 @@ def __init__(self, resource_name, opts=None, items=None, metadata=None, __name__
opts)

@staticmethod
def get(name: str, id: Input[str], opts: Optional[ResourceOptions] = None):
opts = ResourceOptions(id=id) if opts is None else opts.merge(ResourceOptions(id=id))
return MutatingWebhookConfigurationList(name, opts)
def get(resource_name, id, opts=None):
"""
Get the state of an existing `MutatingWebhookConfigurationList` resource, as identified by `id`.
Typically this ID is of the form [namespace]/[name]; if [namespace] is omitted,
then (per Kubernetes convention) the ID becomes default/[name].
Pulumi will keep track of this resource using `resource_name` as the Pulumi ID.
:param str resource_name: _Unique_ name used to register this resource with Pulumi.
:param pulumi.Input[str] id: An ID for the Kubernetes resource to retrieve.
Takes the form [namespace]/[name] or [name].
:param Optional[pulumi.ResourceOptions] opts: A bag of options that control this
resource's behavior.
"""
opts = ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))
return MutatingWebhookConfigurationList(resource_name, opts)

def translate_output_property(self, prop: str) -> str:
return tables._CASING_FORWARD_TABLE.get(prop) or prop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,22 @@ def __init__(self, resource_name, opts=None, metadata=None, webhooks=None, __nam
opts)

@staticmethod
def get(name: str, id: Input[str], opts: Optional[ResourceOptions] = None):
opts = ResourceOptions(id=id) if opts is None else opts.merge(ResourceOptions(id=id))
return ValidatingWebhookConfiguration(name, opts)
def get(resource_name, id, opts=None):
"""
Get the state of an existing `ValidatingWebhookConfiguration` resource, as identified by `id`.
Typically this ID is of the form [namespace]/[name]; if [namespace] is omitted,
then (per Kubernetes convention) the ID becomes default/[name].
Pulumi will keep track of this resource using `resource_name` as the Pulumi ID.
:param str resource_name: _Unique_ name used to register this resource with Pulumi.
:param pulumi.Input[str] id: An ID for the Kubernetes resource to retrieve.
Takes the form [namespace]/[name] or [name].
:param Optional[pulumi.ResourceOptions] opts: A bag of options that control this
resource's behavior.
"""
opts = ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))
return ValidatingWebhookConfiguration(resource_name, opts)

def translate_output_property(self, prop: str) -> str:
return tables._CASING_FORWARD_TABLE.get(prop) or prop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,22 @@ def __init__(self, resource_name, opts=None, items=None, metadata=None, __name__
opts)

@staticmethod
def get(name: str, id: Input[str], opts: Optional[ResourceOptions] = None):
opts = ResourceOptions(id=id) if opts is None else opts.merge(ResourceOptions(id=id))
return ValidatingWebhookConfigurationList(name, opts)
def get(resource_name, id, opts=None):
"""
Get the state of an existing `ValidatingWebhookConfigurationList` resource, as identified by `id`.
Typically this ID is of the form [namespace]/[name]; if [namespace] is omitted,
then (per Kubernetes convention) the ID becomes default/[name].
Pulumi will keep track of this resource using `resource_name` as the Pulumi ID.
:param str resource_name: _Unique_ name used to register this resource with Pulumi.
:param pulumi.Input[str] id: An ID for the Kubernetes resource to retrieve.
Takes the form [namespace]/[name] or [name].
:param Optional[pulumi.ResourceOptions] opts: A bag of options that control this
resource's behavior.
"""
opts = ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))
return ValidatingWebhookConfigurationList(resource_name, opts)

def translate_output_property(self, prop: str) -> str:
return tables._CASING_FORWARD_TABLE.get(prop) or prop
Expand Down
6 changes: 6 additions & 0 deletions sdk/python/pulumi_kubernetes/apiextensions/CustomResource.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ def __init__(self, resource_name, api_version, kind, spec=None, metadata=None, o
@staticmethod
def get(resource_name, api_version, kind, id, opts=None):
"""
Get the state of an existing `CustomResource` resource, as identified by `id`.
Typically this ID is of the form [namespace]/[name]; if [namespace] is omitted,
then (per Kubernetes convention) the ID becomes default/[name].
Pulumi will keep track of this resource using `resource_name` as the Pulumi ID.
:param str resource_name: _Unique_ name used to register this resource with Pulumi.
:param str api_version: The API version of the apiExtensions.CustomResource we
wish to select, as specified by the CustomResourceDefinition that defines it on the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,22 @@ def __init__(self, resource_name, opts=None, spec=None, metadata=None, __name__=
opts)

@staticmethod
def get(name: str, id: Input[str], opts: Optional[ResourceOptions] = None):
opts = ResourceOptions(id=id) if opts is None else opts.merge(ResourceOptions(id=id))
return CustomResourceDefinition(name, opts)
def get(resource_name, id, opts=None):
"""
Get the state of an existing `CustomResourceDefinition` resource, as identified by `id`.
Typically this ID is of the form [namespace]/[name]; if [namespace] is omitted,
then (per Kubernetes convention) the ID becomes default/[name].
Pulumi will keep track of this resource using `resource_name` as the Pulumi ID.
:param str resource_name: _Unique_ name used to register this resource with Pulumi.
:param pulumi.Input[str] id: An ID for the Kubernetes resource to retrieve.
Takes the form [namespace]/[name] or [name].
:param Optional[pulumi.ResourceOptions] opts: A bag of options that control this
resource's behavior.
"""
opts = ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))
return CustomResourceDefinition(resource_name, opts)

def translate_output_property(self, prop: str) -> str:
return tables._CASING_FORWARD_TABLE.get(prop) or prop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,22 @@ def __init__(self, resource_name, opts=None, items=None, metadata=None, __name__
opts)

@staticmethod
def get(name: str, id: Input[str], opts: Optional[ResourceOptions] = None):
opts = ResourceOptions(id=id) if opts is None else opts.merge(ResourceOptions(id=id))
return CustomResourceDefinitionList(name, opts)
def get(resource_name, id, opts=None):
"""
Get the state of an existing `CustomResourceDefinitionList` resource, as identified by `id`.
Typically this ID is of the form [namespace]/[name]; if [namespace] is omitted,
then (per Kubernetes convention) the ID becomes default/[name].
Pulumi will keep track of this resource using `resource_name` as the Pulumi ID.
:param str resource_name: _Unique_ name used to register this resource with Pulumi.
:param pulumi.Input[str] id: An ID for the Kubernetes resource to retrieve.
Takes the form [namespace]/[name] or [name].
:param Optional[pulumi.ResourceOptions] opts: A bag of options that control this
resource's behavior.
"""
opts = ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))
return CustomResourceDefinitionList(resource_name, opts)

def translate_output_property(self, prop: str) -> str:
return tables._CASING_FORWARD_TABLE.get(prop) or prop
Expand Down
19 changes: 16 additions & 3 deletions sdk/python/pulumi_kubernetes/apiregistration/v1/APIService.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,22 @@ def __init__(self, resource_name, opts=None, metadata=None, spec=None, __name__=
opts)

@staticmethod
def get(name: str, id: Input[str], opts: Optional[ResourceOptions] = None):
opts = ResourceOptions(id=id) if opts is None else opts.merge(ResourceOptions(id=id))
return APIService(name, opts)
def get(resource_name, id, opts=None):
"""
Get the state of an existing `APIService` resource, as identified by `id`.
Typically this ID is of the form [namespace]/[name]; if [namespace] is omitted,
then (per Kubernetes convention) the ID becomes default/[name].
Pulumi will keep track of this resource using `resource_name` as the Pulumi ID.
:param str resource_name: _Unique_ name used to register this resource with Pulumi.
:param pulumi.Input[str] id: An ID for the Kubernetes resource to retrieve.
Takes the form [namespace]/[name] or [name].
:param Optional[pulumi.ResourceOptions] opts: A bag of options that control this
resource's behavior.
"""
opts = ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))
return APIService(resource_name, opts)

def translate_output_property(self, prop: str) -> str:
return tables._CASING_FORWARD_TABLE.get(prop) or prop
Expand Down
19 changes: 16 additions & 3 deletions sdk/python/pulumi_kubernetes/apiregistration/v1/APIServiceList.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,22 @@ def __init__(self, resource_name, opts=None, items=None, metadata=None, __name__
opts)

@staticmethod
def get(name: str, id: Input[str], opts: Optional[ResourceOptions] = None):
opts = ResourceOptions(id=id) if opts is None else opts.merge(ResourceOptions(id=id))
return APIServiceList(name, opts)
def get(resource_name, id, opts=None):
"""
Get the state of an existing `APIServiceList` resource, as identified by `id`.
Typically this ID is of the form [namespace]/[name]; if [namespace] is omitted,
then (per Kubernetes convention) the ID becomes default/[name].
Pulumi will keep track of this resource using `resource_name` as the Pulumi ID.
:param str resource_name: _Unique_ name used to register this resource with Pulumi.
:param pulumi.Input[str] id: An ID for the Kubernetes resource to retrieve.
Takes the form [namespace]/[name] or [name].
:param Optional[pulumi.ResourceOptions] opts: A bag of options that control this
resource's behavior.
"""
opts = ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))
return APIServiceList(resource_name, opts)

def translate_output_property(self, prop: str) -> str:
return tables._CASING_FORWARD_TABLE.get(prop) or prop
Expand Down
19 changes: 16 additions & 3 deletions sdk/python/pulumi_kubernetes/apiregistration/v1beta1/APIService.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,22 @@ def __init__(self, resource_name, opts=None, metadata=None, spec=None, __name__=
opts)

@staticmethod
def get(name: str, id: Input[str], opts: Optional[ResourceOptions] = None):
opts = ResourceOptions(id=id) if opts is None else opts.merge(ResourceOptions(id=id))
return APIService(name, opts)
def get(resource_name, id, opts=None):
"""
Get the state of an existing `APIService` resource, as identified by `id`.
Typically this ID is of the form [namespace]/[name]; if [namespace] is omitted,
then (per Kubernetes convention) the ID becomes default/[name].
Pulumi will keep track of this resource using `resource_name` as the Pulumi ID.
:param str resource_name: _Unique_ name used to register this resource with Pulumi.
:param pulumi.Input[str] id: An ID for the Kubernetes resource to retrieve.
Takes the form [namespace]/[name] or [name].
:param Optional[pulumi.ResourceOptions] opts: A bag of options that control this
resource's behavior.
"""
opts = ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))
return APIService(resource_name, opts)

def translate_output_property(self, prop: str) -> str:
return tables._CASING_FORWARD_TABLE.get(prop) or prop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,22 @@ def __init__(self, resource_name, opts=None, items=None, metadata=None, __name__
opts)

@staticmethod
def get(name: str, id: Input[str], opts: Optional[ResourceOptions] = None):
opts = ResourceOptions(id=id) if opts is None else opts.merge(ResourceOptions(id=id))
return APIServiceList(name, opts)
def get(resource_name, id, opts=None):
"""
Get the state of an existing `APIServiceList` resource, as identified by `id`.
Typically this ID is of the form [namespace]/[name]; if [namespace] is omitted,
then (per Kubernetes convention) the ID becomes default/[name].
Pulumi will keep track of this resource using `resource_name` as the Pulumi ID.
:param str resource_name: _Unique_ name used to register this resource with Pulumi.
:param pulumi.Input[str] id: An ID for the Kubernetes resource to retrieve.
Takes the form [namespace]/[name] or [name].
:param Optional[pulumi.ResourceOptions] opts: A bag of options that control this
resource's behavior.
"""
opts = ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))
return APIServiceList(resource_name, opts)

def translate_output_property(self, prop: str) -> str:
return tables._CASING_FORWARD_TABLE.get(prop) or prop
Expand Down
19 changes: 16 additions & 3 deletions sdk/python/pulumi_kubernetes/apps/v1/ControllerRevision.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,22 @@ def __init__(self, resource_name, opts=None, revision=None, data=None, metadata=
opts)

@staticmethod
def get(name: str, id: Input[str], opts: Optional[ResourceOptions] = None):
opts = ResourceOptions(id=id) if opts is None else opts.merge(ResourceOptions(id=id))
return ControllerRevision(name, opts)
def get(resource_name, id, opts=None):
"""
Get the state of an existing `ControllerRevision` resource, as identified by `id`.
Typically this ID is of the form [namespace]/[name]; if [namespace] is omitted,
then (per Kubernetes convention) the ID becomes default/[name].
Pulumi will keep track of this resource using `resource_name` as the Pulumi ID.
:param str resource_name: _Unique_ name used to register this resource with Pulumi.
:param pulumi.Input[str] id: An ID for the Kubernetes resource to retrieve.
Takes the form [namespace]/[name] or [name].
:param Optional[pulumi.ResourceOptions] opts: A bag of options that control this
resource's behavior.
"""
opts = ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))
return ControllerRevision(resource_name, opts)

def translate_output_property(self, prop: str) -> str:
return tables._CASING_FORWARD_TABLE.get(prop) or prop
Expand Down
Loading

0 comments on commit bbc55b1

Please sign in to comment.