diff --git a/.gitignore b/.gitignore index 4bbc6b206..bdd5055d1 100644 --- a/.gitignore +++ b/.gitignore @@ -66,3 +66,4 @@ target/ # Intellij IDEA files .idea/* *.iml +.vscode diff --git a/examples/create_thirdparty_resource.md b/examples/create_thirdparty_resource.md new file mode 100644 index 000000000..ec5975ad0 --- /dev/null +++ b/examples/create_thirdparty_resource.md @@ -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) +``` \ No newline at end of file diff --git a/scripts/preprocess_spec.py b/scripts/preprocess_spec.py index 618b34122..da5352611 100644 --- a/scripts/preprocess_spec.py +++ b/scripts/preprocess_spec.py @@ -102,7 +102,18 @@ def strip_tags_from_operation_id(operation, _): operation['operationId'] = operation_id +def add_thirdparty_resource_paths(spec): + with open('thirdpartypaths.json', 'r') as third_party_spec_file: + third_party_spec = json.loads(third_party_spec_file.read()) + for path in third_party_spec.keys(): + if path not in spec['paths'].keys(): + spec['paths'][path] = third_party_spec[path] + return spec + + def process_swagger(spec): + spec = add_thirdparty_resource_paths(spec) + apply_func_to_spec_operations(spec, strip_tags_from_operation_id) operation_ids = {} diff --git a/scripts/thirdpartypaths.json b/scripts/thirdpartypaths.json new file mode 100644 index 000000000..5dd01f4cc --- /dev/null +++ b/scripts/thirdpartypaths.json @@ -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" + } + } + } + } + } +} \ No newline at end of file