forked from kubernetes-client/python
-
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.
Add support for thirdparty resource watch/create/put and delete opera…
…tions (kubernetes-client#216) Add third-party-resources paths to OpenAPI spec to be able to create/update/watch third party resources.
- Loading branch information
1 parent
7a6bae2
commit dab09e0
Showing
4 changed files
with
318 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,3 +66,4 @@ target/ | |
# Intellij IDEA files | ||
.idea/* | ||
*.iml | ||
.vscode |
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,40 @@ | ||
## Creating a Third Party Resource | ||
|
||
``` | ||
from __future__ import print_function | ||
from pprint import pprint | ||
import kubernetes | ||
from kubernetes import config | ||
from kubernetes.rest import ApiException | ||
config.load_kube_config() | ||
api_instance = kubernetes.ThirdPartyResources() | ||
namespace = 'default' | ||
resource = 'repos' | ||
fqdn = 'git.k8s.com' | ||
body = {} | ||
body['apiVersion'] = "git.k8s.com/v1" | ||
body['kind'] = "RePo" | ||
body['metadata'] = {} | ||
body['metadata']['name'] = "blog-repo" | ||
body['repo'] = "github.com/user/my-blog" | ||
body['username'] = "username" | ||
body['password'] = "password" | ||
body['branch'] = "branch" | ||
try: | ||
# Create a Resource | ||
api_response = api_instance.apis_fqdn_v1_namespaces_namespace_resource_post( | ||
namespace, fqdn, resource, body) | ||
pprint(api_response) | ||
except ApiException as e: | ||
print( | ||
"Exception when calling DefaultApi->apis_fqdn_v1_namespaces_namespace_resource_post: %s\n" % | ||
e) | ||
``` |
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 |
---|---|---|
@@ -0,0 +1,266 @@ | ||
{ | ||
"/apis/{fqdn}/v1/{resource}": { | ||
"get": { | ||
"security": [ | ||
{ | ||
"Bearer": [ | ||
|
||
] | ||
} | ||
], | ||
"summary": "Gets Resources", | ||
"description": "Returns a list of Resources", | ||
"tags": [ | ||
"third_party_resources" | ||
], | ||
"parameters": [ | ||
{ | ||
"name": "watch", | ||
"uniqueItems": true, | ||
"type": "boolean", | ||
"description": "Watch for changes to the described resources and return them as a stream of add, update, and remove notifications. Specify resourceVersion.", | ||
"in": "query" | ||
}, | ||
{ | ||
"name": "fqdn", | ||
"in": "path", | ||
"required": true, | ||
"description": "The Third party Resource fqdn", | ||
"type": "string" | ||
}, | ||
{ | ||
"name": "resource", | ||
"in": "path", | ||
"required": true, | ||
"description": "The Resource type", | ||
"type": "string" | ||
} | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "A list of Resources", | ||
"schema": { | ||
"type": "object" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"/apis/{fqdn}/v1/namespaces/{namespace}/{resource}": { | ||
"post": { | ||
"security": [ | ||
{ | ||
"Bearer": [ | ||
|
||
] | ||
} | ||
], | ||
"summary": "Create a Resource", | ||
"description": "Creates a third party resource of the type specified", | ||
"tags": [ | ||
"third_party_resources" | ||
], | ||
"parameters": [ | ||
{ | ||
"name": "namespace", | ||
"in": "path", | ||
"required": true, | ||
"description": "The Resource's namespace", | ||
"type": "string" | ||
}, | ||
{ | ||
"name": "fqdn", | ||
"in": "path", | ||
"required": true, | ||
"description": "The Third party Resource fqdn", | ||
"type": "string" | ||
}, | ||
{ | ||
"name": "resource", | ||
"in": "path", | ||
"required": true, | ||
"description": "The Resource type", | ||
"type": "string" | ||
}, | ||
{ | ||
"name": "body", | ||
"in": "body", | ||
"required": true, | ||
"description": "The JSON schema of the Resource to create.", | ||
"schema": { | ||
"type": "object" | ||
} | ||
} | ||
], | ||
"responses": { | ||
"201": { | ||
"description": "A list of Resources", | ||
"schema": { | ||
"type": "object" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"/apis/{fqdn}/v1/namespaces/{namespace}/{resource}/{name}": { | ||
"get": { | ||
"security": [ | ||
{ | ||
"Bearer": [ | ||
|
||
] | ||
} | ||
], | ||
"summary": "Gets a specific Resource", | ||
"description": "Returns a specific Resource in a namespace", | ||
"tags": [ | ||
"third_party_resources" | ||
], | ||
"parameters": [ | ||
{ | ||
"name": "namespace", | ||
"in": "path", | ||
"required": true, | ||
"description": "The Resource's namespace", | ||
"type": "string" | ||
}, | ||
{ | ||
"name": "name", | ||
"in": "path", | ||
"required": true, | ||
"description": "The Resource's name", | ||
"type": "string" | ||
}, | ||
{ | ||
"name": "fqdn", | ||
"in": "path", | ||
"required": true, | ||
"description": "The Third party Resource fqdn", | ||
"type": "string" | ||
}, | ||
{ | ||
"name": "resource", | ||
"in": "path", | ||
"required": true, | ||
"description": "The Resource type", | ||
"type": "string" | ||
} | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "A single Resource", | ||
"schema": { | ||
"type": "object" | ||
} | ||
} | ||
} | ||
}, | ||
"delete": { | ||
"security": [ | ||
{ | ||
"Bearer": [ | ||
|
||
] | ||
} | ||
], | ||
"summary": "Deletes a specific Resource", | ||
"description": "Deletes the specified Resource in the specified namespace", | ||
"tags": [ | ||
"third_party_resources" | ||
], | ||
"parameters": [ | ||
{ | ||
"name": "body", | ||
"in": "body", | ||
"required": true, | ||
"schema": { | ||
"$ref": "#/definitions/v1.DeleteOptions" | ||
} | ||
}, | ||
{ | ||
"name": "gracePeriodSeconds", | ||
"uniqueItems": true, | ||
"type": "integer", | ||
"description": "The duration in seconds before the object should be deleted. Value must be non-negative integer. The value zero indicates delete immediately. If this value is nil, the default grace period for the specified type will be used. Defaults to a per object value if not specified. zero means delete immediately.", | ||
"in": "query" | ||
}, | ||
{ | ||
"name": "orphanDependents", | ||
"uniqueItems": true, | ||
"type": "boolean", | ||
"description": "Deprecated: please use the PropagationPolicy, this field will be deprecated in 1.7. Should the dependent objects be orphaned. If true/false, the \"orphan\" finalizer will be added to/removed from the object's finalizers list. Either this field or PropagationPolicy may be set, but not both.", | ||
"in": "query" | ||
}, | ||
{ | ||
"name": "propagationPolicy", | ||
"uniqueItems": true, | ||
"type": "string", | ||
"description": "Whether and how garbage collection will be performed. Either this field or OrphanDependents may be set, but not both. The default policy is decided by the existing finalizer set in the metadata.finalizers and the resource-specific default policy.", | ||
"in": "query" | ||
} | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "OK", | ||
"schema": { | ||
"type": "object" | ||
} | ||
} | ||
} | ||
}, | ||
"put": { | ||
"security": [ | ||
{ | ||
"Bearer": [ | ||
|
||
] | ||
} | ||
], | ||
"summary": "Replace a Resource", | ||
"description": "Replaces the specified third party resource of the type specified", | ||
"tags": [ | ||
"third_party_resources" | ||
], | ||
"parameters": [ | ||
{ | ||
"name": "namespace", | ||
"in": "path", | ||
"required": true, | ||
"description": "The Resource's namespace", | ||
"type": "string" | ||
}, | ||
{ | ||
"name": "fqdn", | ||
"in": "path", | ||
"required": true, | ||
"description": "The Third party Resource fqdn", | ||
"type": "string" | ||
}, | ||
{ | ||
"name": "resource", | ||
"in": "path", | ||
"required": true, | ||
"description": "The Resource type", | ||
"type": "string" | ||
}, | ||
{ | ||
"name": "body", | ||
"in": "body", | ||
"required": true, | ||
"description": "The JSON schema of the Resource to create.", | ||
"schema": { | ||
"type": "object" | ||
} | ||
} | ||
], | ||
"responses": { | ||
"201": { | ||
"description": "A list of Resources", | ||
"schema": { | ||
"type": "object" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |