remove demo code change

This commit is contained in:
Adil Hafeez 2024-12-05 14:53:05 -08:00
parent 5e182b6c09
commit 63d7d91267
38 changed files with 0 additions and 3068 deletions

View file

@ -1,2 +0,0 @@
# Function calling
This demo shows arch gateway interacting with ACM rest APIs.

View file

@ -1,116 +0,0 @@
openapi: 3.0.0
info:
version: 2.12.0
title: ACM API for cluster management
description: This is the API for managing clusters using ACM - https://docs.redhat.com/en/documentation/red_hat_advanced_cluster_management_for_kubernetes/2.12/html/apis/apis#tags
contact:
name: Katanemo Labs Inc.
email: support@katanemo.com
url: https://katanemo.com
paths:
/cluster.open-cluster-management.io/v1/managedclusters:
get:
summary: Query your clusters for more details.
operationId: listManagedClusters
responses:
"200":
description: List of managed clusters
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/ManagedCluster"
post:
summary: Create a cluster
operationId: createCluster
requestBody:
description: Details about the service, including the text-representation of the service APIs.
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/ManagedCluster"
responses:
"200":
description: cluster created successfully
content:
application/json:
schema:
$ref: "#/components/schemas/ManagedCluster"
/cluster.open-cluster-management.io/v1/managedclusters/{cluster_name}:
get:
summary: Query a single cluster for more details
operationId: getCluster
parameters:
- name: cluster_name
in: path
description: The name of the cluster to retrieve
required: true
schema:
type: string
responses:
"200":
description: Cluster details
content:
application/json:
schema:
$ref: "#/components/schemas/ManagedCluster"
delete:
summary: Delete a single cluster
responses:
"200":
description: Cluster details
content:
application/json:
schema:
$ref: "#/components/schemas/ManagedCluster"
components:
schemas:
ManagedCluster:
title: managed cluster details
type: object
properties:
apiVersion:
type: string
enum:
- cluster.open-cluster-management.io/v1
kind:
type: string
enum:
- ManagedCluster
metadata:
$ref: "#/components/schemas/Metadata"
spec:
$ref: "#/components/schemas/Spec"
status:
type: string
Metadata:
title: metadata details
type: object
properties:
name:
type: string
labels:
type: object
additionalProperties:
type: string
Spec:
title: spec details
type: object
properties:
hubAcceptsClient:
type: boolean
managedClusterClientConfigs:
type: array
items:
$ref: "#/components/schemas/ManagedClusterClientConfig"
ManagedClusterClientConfig:
title: managed cluster client config details
type: object
properties:
url:
type: string
caBundle:
type: string

View file

@ -1,72 +0,0 @@
.travis.yaml
.openapi-generator-ignore
README.md
tox.ini
git_push.sh
test-requirements.txt
setup.py
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/
venv/
.python-version
# Translations
*.mo
*.pot
# Django stuff:
*.log
# Sphinx documentation
docs/_build/
# PyBuilder
target/
#Ipython Notebook
.ipynb_checkpoints

View file

@ -1,66 +0,0 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/
venv/
.venv/
.python-version
.pytest_cache
# Translations
*.mo
*.pot
# Django stuff:
*.log
# Sphinx documentation
docs/_build/
# PyBuilder
target/
#Ipython Notebook
.ipynb_checkpoints

View file

@ -1,23 +0,0 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.
# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md

View file

@ -1,26 +0,0 @@
.dockerignore
.gitignore
.travis.yml
Dockerfile
README.md
git_push.sh
openapi_server/__init__.py
openapi_server/__main__.py
openapi_server/controllers/__init__.py
openapi_server/controllers/default_controller.py
openapi_server/controllers/security_controller.py
openapi_server/encoder.py
openapi_server/models/__init__.py
openapi_server/models/base_model.py
openapi_server/models/managed_cluster.py
openapi_server/models/managed_cluster_client_config.py
openapi_server/models/metadata.py
openapi_server/models/spec.py
openapi_server/openapi/openapi.yaml
openapi_server/test/__init__.py
openapi_server/typing_utils.py
openapi_server/util.py
requirements.txt
setup.py
test-requirements.txt
tox.ini

View file

@ -1 +0,0 @@
7.11.0-SNAPSHOT

View file

@ -1,14 +0,0 @@
# ref: https://docs.travis-ci.com/user/languages/python
language: python
python:
- "3.2"
- "3.3"
- "3.4"
- "3.5"
- "3.6"
- "3.7"
- "3.8"
# command to install dependencies
install: "pip install -r requirements.txt"
# command to run tests
script: nosetests

View file

@ -1,16 +0,0 @@
FROM python:3-alpine
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY requirements.txt /usr/src/app/
RUN pip3 install --no-cache-dir -r requirements.txt
COPY . /usr/src/app
EXPOSE 8080
ENTRYPOINT ["python3"]
CMD ["-m", "openapi_server"]

View file

@ -1,49 +0,0 @@
# OpenAPI generated server
## Overview
This server was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the
[OpenAPI-Spec](https://openapis.org) from a remote server, you can easily generate a server stub. This
is an example of building a OpenAPI-enabled Flask server.
This example uses the [Connexion](https://github.com/zalando/connexion) library on top of Flask.
## Requirements
Python 3.5.2+
## Usage
To run the server, please execute the following from the root directory:
```
pip3 install -r requirements.txt
python3 -m openapi_server
```
and open your browser to here:
```
http://localhost:8080/ui/
```
Your OpenAPI definition lives here:
```
http://localhost:8080/openapi.json
```
To launch the integration tests, use tox:
```
sudo pip install tox
tox
```
## Running with Docker
To run the server on a Docker container, please execute the following from the root directory:
```bash
# building the image
docker build -t openapi_server .
# starting up a container
docker run -p 8080:8080 openapi_server
```

View file

@ -1,57 +0,0 @@
#!/bin/sh
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
#
# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com"
git_user_id=$1
git_repo_id=$2
release_note=$3
git_host=$4
if [ "$git_host" = "" ]; then
git_host="github.com"
echo "[INFO] No command line input provided. Set \$git_host to $git_host"
fi
if [ "$git_user_id" = "" ]; then
git_user_id="GIT_USER_ID"
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
fi
if [ "$git_repo_id" = "" ]; then
git_repo_id="GIT_REPO_ID"
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
fi
if [ "$release_note" = "" ]; then
release_note="Minor update"
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
fi
# Initialize the local directory as a Git repository
git init
# Adds the files in the local repository and stages them for commit.
git add .
# Commits the tracked changes and prepares them to be pushed to a remote repository.
git commit -m "$release_note"
# Sets the new remote
git_remote=$(git remote)
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
git pull origin master
# Pushes (Forces) the changes in the local repository up to the remote repository
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
git push origin master 2>&1 | grep -v 'To https'

View file

@ -1,21 +0,0 @@
#!/usr/bin/env python3
import connexion
from openapi_server import encoder
def main():
app = connexion.App(__name__, specification_dir="./openapi/")
app.app.json_encoder = encoder.JSONEncoder
app.add_api(
"openapi.yaml",
arguments={"title": "ACM API for cluster management"},
pythonic_params=True,
)
app.run(port=8080)
if __name__ == "__main__":
main()

View file

@ -1,84 +0,0 @@
import connexion
from typing import Dict
from typing import Tuple
from typing import Union
from openapi_server.models.managed_cluster import ManagedCluster # noqa: E501
from openapi_server.models.metadata import Metadata # noqa: E501
from openapi_server.models.spec import Spec # noqa: E501
from openapi_server import util
managed_cluster = {
"test1": ManagedCluster(
"cluster.open-cluster-management.io/v1",
"ManagedCluster",
Metadata("test1"),
Spec(True, None),
"test1 cluster in service",
),
}
def cluster_open_cluster_management_io_v1_managedclusters_cluster_name_delete(): # noqa: E501
"""Delete a single cluster
# noqa: E501
:rtype: Union[ManagedCluster, Tuple[ManagedCluster, int], Tuple[ManagedCluster, int, Dict[str, str]]
"""
return "do some magic!"
def create_cluster(
api_version=None, kind=None, metadata=None, spec=None, status=None
): # noqa: E501
"""Create a cluster
# noqa: E501
:param api_version:
:type api_version: str
:param kind:
:type kind: str
:param metadata:
:type metadata: dict | bytes
:param spec:
:type spec: dict | bytes
:param status:
:type status: str
:rtype: Union[ManagedCluster, Tuple[ManagedCluster, int], Tuple[ManagedCluster, int, Dict[str, str]]
"""
if connexion.request.is_json:
metadata = Metadata.from_dict(connexion.request.get_json()) # noqa: E501
if connexion.request.is_json:
spec = Spec.from_dict(connexion.request.get_json()) # noqa: E501
return "do some magic!"
def get_cluster(cluster_name): # noqa: E501
"""Query a single cluster for more details
# noqa: E501
:param cluster_name: The name of the cluster to retrieve
:type cluster_name: str
:rtype: Union[ManagedCluster, Tuple[ManagedCluster, int], Tuple[ManagedCluster, int, Dict[str, str]]
"""
if cluster_name in managed_cluster:
return managed_cluster[cluster_name]
else:
return "Cluster not found", 404
def list_managed_clusters(): # noqa: E501
"""Query your clusters for more details.
# noqa: E501
:rtype: Union[List[ManagedCluster], Tuple[List[ManagedCluster], int], Tuple[List[ManagedCluster], int, Dict[str, str]]
"""
return list(managed_cluster.values())

View file

@ -1,88 +0,0 @@
import connexion
from typing import Dict
from typing import Tuple
from typing import Union
from openapi_server.models.managed_cluster import ManagedCluster # noqa: E501
from openapi_server.models.metadata import Metadata # noqa: E501
from openapi_server.models.spec import Spec # noqa: E501
from openapi_server import util
managed_cluster = {
"test1": ManagedCluster(
"cluster.open-cluster-management.io/v1",
"ManagedCluster",
Metadata("test1"),
Spec(True, None),
"test1 cluster in service",
),
}
def cluster_open_cluster_management_io_v1_managedclusters_cluster_name_delete(): # noqa: E501
"""Delete a single cluster
# noqa: E501
:rtype: Union[ManagedCluster, Tuple[ManagedCluster, int], Tuple[ManagedCluster, int, Dict[str, str]]
"""
return "do some magic!"
def create_cluster(
api_version=None, kind=None, metadata=None, spec=None, status=None
): # noqa: E501
"""Create a cluster
# noqa: E501
:param api_version:
:type api_version: str
:param kind:
:type kind: str
:param metadata:
:type metadata: dict | bytes
:param spec:
:type spec: dict | bytes
:param status:
:type status: str
:rtype: Union[ManagedCluster, Tuple[ManagedCluster, int], Tuple[ManagedCluster, int, Dict[str, str]]
"""
if connexion.request.is_json:
request_json = connexion.request.get_json()
if "metadata" in request_json:
metadata = Metadata.from_dict(request_json["metadata"]) # noqa: E501
if "spec" in request_json:
spec = Spec.from_dict(request_json["spec"]) # noqa: E501
cluster = ManagedCluster(api_version, kind, metadata, spec, status)
managed_cluster[metadata.name] = cluster
return "cluster created", 200
def get_cluster(cluster_name): # noqa: E501
"""Query a single cluster for more details
# noqa: E501
:param cluster_name: The name of the cluster to retrieve
:type cluster_name: str
:rtype: Union[ManagedCluster, Tuple[ManagedCluster, int], Tuple[ManagedCluster, int, Dict[str, str]]
"""
if cluster_name in managed_cluster:
return managed_cluster[cluster_name]
else:
return "Cluster not found", 404
def list_managed_clusters(): # noqa: E501
"""Query your clusters for more details.
# noqa: E501
:rtype: Union[List[ManagedCluster], Tuple[List[ManagedCluster], int], Tuple[List[ManagedCluster], int, Dict[str, str]]
"""
return list(managed_cluster.values())

View file

@ -1 +0,0 @@
from typing import List

View file

@ -1,19 +0,0 @@
from connexion.apps.flask_app import FlaskJSONEncoder
from openapi_server.models.base_model import Model
class JSONEncoder(FlaskJSONEncoder):
include_nulls = False
def default(self, o):
if isinstance(o, Model):
dikt = {}
for attr in o.openapi_types:
value = getattr(o, attr)
if value is None and not self.include_nulls:
continue
attr = o.attribute_map[attr]
dikt[attr] = value
return dikt
return FlaskJSONEncoder.default(self, o)

View file

@ -1,8 +0,0 @@
# flake8: noqa
# import models into model package
from openapi_server.models.managed_cluster import ManagedCluster
from openapi_server.models.managed_cluster_client_config import (
ManagedClusterClientConfig,
)
from openapi_server.models.metadata import Metadata
from openapi_server.models.spec import Spec

View file

@ -1,70 +0,0 @@
import pprint
import typing
from openapi_server import util
T = typing.TypeVar("T")
class Model:
# openapiTypes: The key is attribute name and the
# value is attribute type.
openapi_types: typing.Dict[str, type] = {}
# attributeMap: The key is attribute name and the
# value is json key in definition.
attribute_map: typing.Dict[str, str] = {}
@classmethod
def from_dict(cls: typing.Type[T], dikt) -> T:
"""Returns the dict as a model"""
return util.deserialize_model(dikt, cls)
def to_dict(self):
"""Returns the model properties as a dict
:rtype: dict
"""
result = {}
for attr in self.openapi_types:
value = getattr(self, attr)
if isinstance(value, list):
result[attr] = list(
map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)
)
elif hasattr(value, "to_dict"):
result[attr] = value.to_dict()
elif isinstance(value, dict):
result[attr] = dict(
map(
lambda item: (item[0], item[1].to_dict())
if hasattr(item[1], "to_dict")
else item,
value.items(),
)
)
else:
result[attr] = value
return result
def to_str(self):
"""Returns the string representation of the model
:rtype: str
"""
return pprint.pformat(self.to_dict())
def __repr__(self):
"""For `print` and `pprint`"""
return self.to_str()
def __eq__(self, other):
"""Returns true if both objects are equal"""
return self.__dict__ == other.__dict__
def __ne__(self, other):
"""Returns true if both objects are not equal"""
return not self == other

View file

@ -1,186 +0,0 @@
from datetime import date, datetime # noqa: F401
from typing import List, Dict # noqa: F401
from openapi_server.models.base_model import Model
from openapi_server.models.metadata import Metadata
from openapi_server.models.spec import Spec
from openapi_server import util
from openapi_server.models.metadata import Metadata # noqa: E501
from openapi_server.models.spec import Spec # noqa: E501
class ManagedCluster(Model):
"""NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Do not edit the class manually.
"""
def __init__(
self, api_version=None, kind=None, metadata=None, spec=None, status=None
): # noqa: E501
"""ManagedCluster - a model defined in OpenAPI
:param api_version: The api_version of this ManagedCluster. # noqa: E501
:type api_version: str
:param kind: The kind of this ManagedCluster. # noqa: E501
:type kind: str
:param metadata: The metadata of this ManagedCluster. # noqa: E501
:type metadata: Metadata
:param spec: The spec of this ManagedCluster. # noqa: E501
:type spec: Spec
:param status: The status of this ManagedCluster. # noqa: E501
:type status: str
"""
self.openapi_types = {
"api_version": str,
"kind": str,
"metadata": Metadata,
"spec": Spec,
"status": str,
}
self.attribute_map = {
"api_version": "apiVersion",
"kind": "kind",
"metadata": "metadata",
"spec": "spec",
"status": "status",
}
self._api_version = api_version
self._kind = kind
self._metadata = metadata
self._spec = spec
self._status = status
@classmethod
def from_dict(cls, dikt) -> "ManagedCluster":
"""Returns the dict as a model
:param dikt: A dict.
:type: dict
:return: The ManagedCluster of this ManagedCluster. # noqa: E501
:rtype: ManagedCluster
"""
return util.deserialize_model(dikt, cls)
@property
def api_version(self) -> str:
"""Gets the api_version of this ManagedCluster.
:return: The api_version of this ManagedCluster.
:rtype: str
"""
return self._api_version
@api_version.setter
def api_version(self, api_version: str):
"""Sets the api_version of this ManagedCluster.
:param api_version: The api_version of this ManagedCluster.
:type api_version: str
"""
allowed_values = ["cluster.open-cluster-management.io/v1"] # noqa: E501
if api_version not in allowed_values:
raise ValueError(
"Invalid value for `api_version` ({0}), must be one of {1}".format(
api_version, allowed_values
)
)
self._api_version = api_version
@property
def kind(self) -> str:
"""Gets the kind of this ManagedCluster.
:return: The kind of this ManagedCluster.
:rtype: str
"""
return self._kind
@kind.setter
def kind(self, kind: str):
"""Sets the kind of this ManagedCluster.
:param kind: The kind of this ManagedCluster.
:type kind: str
"""
allowed_values = ["ManagedCluster"] # noqa: E501
if kind not in allowed_values:
raise ValueError(
"Invalid value for `kind` ({0}), must be one of {1}".format(
kind, allowed_values
)
)
self._kind = kind
@property
def metadata(self) -> Metadata:
"""Gets the metadata of this ManagedCluster.
:return: The metadata of this ManagedCluster.
:rtype: Metadata
"""
return self._metadata
@metadata.setter
def metadata(self, metadata: Metadata):
"""Sets the metadata of this ManagedCluster.
:param metadata: The metadata of this ManagedCluster.
:type metadata: Metadata
"""
self._metadata = metadata
@property
def spec(self) -> Spec:
"""Gets the spec of this ManagedCluster.
:return: The spec of this ManagedCluster.
:rtype: Spec
"""
return self._spec
@spec.setter
def spec(self, spec: Spec):
"""Sets the spec of this ManagedCluster.
:param spec: The spec of this ManagedCluster.
:type spec: Spec
"""
self._spec = spec
@property
def status(self) -> str:
"""Gets the status of this ManagedCluster.
:return: The status of this ManagedCluster.
:rtype: str
"""
return self._status
@status.setter
def status(self, status: str):
"""Sets the status of this ManagedCluster.
:param status: The status of this ManagedCluster.
:type status: str
"""
self._status = status

View file

@ -1,81 +0,0 @@
from datetime import date, datetime # noqa: F401
from typing import List, Dict # noqa: F401
from openapi_server.models.base_model import Model
from openapi_server import util
class ManagedClusterClientConfig(Model):
"""NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Do not edit the class manually.
"""
def __init__(self, url=None, ca_bundle=None): # noqa: E501
"""ManagedClusterClientConfig - a model defined in OpenAPI
:param url: The url of this ManagedClusterClientConfig. # noqa: E501
:type url: str
:param ca_bundle: The ca_bundle of this ManagedClusterClientConfig. # noqa: E501
:type ca_bundle: str
"""
self.openapi_types = {"url": str, "ca_bundle": str}
self.attribute_map = {"url": "url", "ca_bundle": "caBundle"}
self._url = url
self._ca_bundle = ca_bundle
@classmethod
def from_dict(cls, dikt) -> "ManagedClusterClientConfig":
"""Returns the dict as a model
:param dikt: A dict.
:type: dict
:return: The ManagedClusterClientConfig of this ManagedClusterClientConfig. # noqa: E501
:rtype: ManagedClusterClientConfig
"""
return util.deserialize_model(dikt, cls)
@property
def url(self) -> str:
"""Gets the url of this ManagedClusterClientConfig.
:return: The url of this ManagedClusterClientConfig.
:rtype: str
"""
return self._url
@url.setter
def url(self, url: str):
"""Sets the url of this ManagedClusterClientConfig.
:param url: The url of this ManagedClusterClientConfig.
:type url: str
"""
self._url = url
@property
def ca_bundle(self) -> str:
"""Gets the ca_bundle of this ManagedClusterClientConfig.
:return: The ca_bundle of this ManagedClusterClientConfig.
:rtype: str
"""
return self._ca_bundle
@ca_bundle.setter
def ca_bundle(self, ca_bundle: str):
"""Sets the ca_bundle of this ManagedClusterClientConfig.
:param ca_bundle: The ca_bundle of this ManagedClusterClientConfig.
:type ca_bundle: str
"""
self._ca_bundle = ca_bundle

View file

@ -1,81 +0,0 @@
from datetime import date, datetime # noqa: F401
from typing import List, Dict # noqa: F401
from openapi_server.models.base_model import Model
from openapi_server import util
class Metadata(Model):
"""NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Do not edit the class manually.
"""
def __init__(self, name=None, labels=None): # noqa: E501
"""Metadata - a model defined in OpenAPI
:param name: The name of this Metadata. # noqa: E501
:type name: str
:param labels: The labels of this Metadata. # noqa: E501
:type labels: Dict[str, str]
"""
self.openapi_types = {"name": str, "labels": Dict[str, str]}
self.attribute_map = {"name": "name", "labels": "labels"}
self._name = name
self._labels = labels
@classmethod
def from_dict(cls, dikt) -> "Metadata":
"""Returns the dict as a model
:param dikt: A dict.
:type: dict
:return: The Metadata of this Metadata. # noqa: E501
:rtype: Metadata
"""
return util.deserialize_model(dikt, cls)
@property
def name(self) -> str:
"""Gets the name of this Metadata.
:return: The name of this Metadata.
:rtype: str
"""
return self._name
@name.setter
def name(self, name: str):
"""Sets the name of this Metadata.
:param name: The name of this Metadata.
:type name: str
"""
self._name = name
@property
def labels(self) -> Dict[str, str]:
"""Gets the labels of this Metadata.
:return: The labels of this Metadata.
:rtype: Dict[str, str]
"""
return self._labels
@labels.setter
def labels(self, labels: Dict[str, str]):
"""Sets the labels of this Metadata.
:param labels: The labels of this Metadata.
:type labels: Dict[str, str]
"""
self._labels = labels

View file

@ -1,98 +0,0 @@
from datetime import date, datetime # noqa: F401
from typing import List, Dict # noqa: F401
from openapi_server.models.base_model import Model
from openapi_server.models.managed_cluster_client_config import (
ManagedClusterClientConfig,
)
from openapi_server import util
from openapi_server.models.managed_cluster_client_config import (
ManagedClusterClientConfig,
) # noqa: E501
class Spec(Model):
"""NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Do not edit the class manually.
"""
def __init__(
self, hub_accepts_client=None, managed_cluster_client_configs=None
): # noqa: E501
"""Spec - a model defined in OpenAPI
:param hub_accepts_client: The hub_accepts_client of this Spec. # noqa: E501
:type hub_accepts_client: bool
:param managed_cluster_client_configs: The managed_cluster_client_configs of this Spec. # noqa: E501
:type managed_cluster_client_configs: List[ManagedClusterClientConfig]
"""
self.openapi_types = {
"hub_accepts_client": bool,
"managed_cluster_client_configs": List[ManagedClusterClientConfig],
}
self.attribute_map = {
"hub_accepts_client": "hubAcceptsClient",
"managed_cluster_client_configs": "managedClusterClientConfigs",
}
self._hub_accepts_client = hub_accepts_client
self._managed_cluster_client_configs = managed_cluster_client_configs
@classmethod
def from_dict(cls, dikt) -> "Spec":
"""Returns the dict as a model
:param dikt: A dict.
:type: dict
:return: The Spec of this Spec. # noqa: E501
:rtype: Spec
"""
return util.deserialize_model(dikt, cls)
@property
def hub_accepts_client(self) -> bool:
"""Gets the hub_accepts_client of this Spec.
:return: The hub_accepts_client of this Spec.
:rtype: bool
"""
return self._hub_accepts_client
@hub_accepts_client.setter
def hub_accepts_client(self, hub_accepts_client: bool):
"""Sets the hub_accepts_client of this Spec.
:param hub_accepts_client: The hub_accepts_client of this Spec.
:type hub_accepts_client: bool
"""
self._hub_accepts_client = hub_accepts_client
@property
def managed_cluster_client_configs(self) -> List[ManagedClusterClientConfig]:
"""Gets the managed_cluster_client_configs of this Spec.
:return: The managed_cluster_client_configs of this Spec.
:rtype: List[ManagedClusterClientConfig]
"""
return self._managed_cluster_client_configs
@managed_cluster_client_configs.setter
def managed_cluster_client_configs(
self, managed_cluster_client_configs: List[ManagedClusterClientConfig]
):
"""Sets the managed_cluster_client_configs of this Spec.
:param managed_cluster_client_configs: The managed_cluster_client_configs of this Spec.
:type managed_cluster_client_configs: List[ManagedClusterClientConfig]
"""
self._managed_cluster_client_configs = managed_cluster_client_configs

View file

@ -1,163 +0,0 @@
openapi: 3.0.0
info:
contact:
email: support@katanemo.com
name: Katanemo Labs Inc.
url: https://katanemo.com
description: This is the API for managing clusters using ACM - https://docs.redhat.com/en/documentation/red_hat_advanced_cluster_management_for_kubernetes/2.12/html/apis/apis#tags
title: ACM API for cluster management
version: 2.12.0
servers:
- url: /
paths:
/cluster.open-cluster-management.io/v1/managedclusters:
get:
operationId: list_managed_clusters
responses:
"200":
content:
application/json:
schema:
items:
$ref: '#/components/schemas/ManagedCluster'
type: array
description: List of managed clusters
summary: Query your clusters for more details.
x-openapi-router-controller: openapi_server.controllers.default_controller
post:
operationId: create_cluster
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/ManagedCluster'
description: "Details about the service, including the text-representation\
\ of the service APIs."
required: true
responses:
"200":
content:
application/json:
schema:
$ref: '#/components/schemas/ManagedCluster'
description: cluster created successfully
summary: Create a cluster
x-openapi-router-controller: openapi_server.controllers.default_controller
/cluster.open-cluster-management.io/v1/managedclusters/{cluster_name}:
delete:
operationId: cluster_open_cluster_management_io_v1_managedclusters_cluster_name_delete
responses:
"200":
content:
application/json:
schema:
$ref: '#/components/schemas/ManagedCluster'
description: Cluster details
summary: Delete a single cluster
x-openapi-router-controller: openapi_server.controllers.default_controller
get:
operationId: get_cluster
parameters:
- description: The name of the cluster to retrieve
explode: false
in: path
name: cluster_name
required: true
schema:
type: string
style: simple
responses:
"200":
content:
application/json:
schema:
$ref: '#/components/schemas/ManagedCluster'
description: Cluster details
summary: Query a single cluster for more details
x-openapi-router-controller: openapi_server.controllers.default_controller
components:
schemas:
ManagedCluster:
example:
metadata:
name: name
labels:
key: labels
apiVersion: cluster.open-cluster-management.io/v1
kind: ManagedCluster
spec:
hubAcceptsClient: true
managedClusterClientConfigs:
- caBundle: caBundle
url: url
- caBundle: caBundle
url: url
status: status
properties:
apiVersion:
enum:
- cluster.open-cluster-management.io/v1
title: apiVersion
type: string
kind:
enum:
- ManagedCluster
title: kind
type: string
metadata:
$ref: '#/components/schemas/Metadata'
spec:
$ref: '#/components/schemas/Spec'
status:
title: status
type: string
title: managed cluster details
type: object
Metadata:
example:
name: name
labels:
key: labels
properties:
name:
title: name
type: string
labels:
additionalProperties:
type: string
title: labels
type: object
title: metadata details
type: object
Spec:
example:
hubAcceptsClient: true
managedClusterClientConfigs:
- caBundle: caBundle
url: url
- caBundle: caBundle
url: url
properties:
hubAcceptsClient:
title: hubAcceptsClient
type: boolean
managedClusterClientConfigs:
items:
$ref: '#/components/schemas/ManagedClusterClientConfig'
title: managedClusterClientConfigs
type: array
title: spec details
type: object
ManagedClusterClientConfig:
example:
caBundle: caBundle
url: url
properties:
url:
title: url
type: string
caBundle:
title: caBundle
type: string
title: managed cluster client config details
type: object

View file

@ -1,15 +0,0 @@
import logging
import connexion
from flask_testing import TestCase
from openapi_server.encoder import JSONEncoder
class BaseTestCase(TestCase):
def create_app(self):
logging.getLogger("connexion.operation").setLevel("ERROR")
app = connexion.App(__name__, specification_dir="../openapi/")
app.app.json_encoder = JSONEncoder
app.add_api("openapi.yaml", pythonic_params=True)
return app.app

View file

@ -1,89 +0,0 @@
import unittest
from flask import json
from openapi_server.models.managed_cluster import ManagedCluster # noqa: E501
from openapi_server.models.metadata import Metadata # noqa: E501
from openapi_server.models.spec import Spec # noqa: E501
from openapi_server.test import BaseTestCase
class TestDefaultController(BaseTestCase):
"""DefaultController integration test stubs"""
def test_cluster_open_cluster_management_io_v1_managedclusters_cluster_name_delete(
self,
):
"""Test case for cluster_open_cluster_management_io_v1_managedclusters_cluster_name_delete
Delete a single cluster
"""
headers = {
"Accept": "application/json",
}
response = self.client.open(
"/cluster.open-cluster-management.io/v1/managedclusters/{cluster_name}",
method="DELETE",
headers=headers,
)
self.assert200(response, "Response body is : " + response.data.decode("utf-8"))
@unittest.skip("multipart/form-data not supported by Connexion")
def test_create_cluster(self):
"""Test case for create_cluster
Create a cluster
"""
headers = {
"Accept": "application/json",
"Content-Type": "multipart/form-data",
}
data = dict(
api_version="api_version_example",
kind="kind_example",
metadata=openapi_server.Metadata(),
spec=openapi_server.Spec(),
status="status_example",
)
response = self.client.open(
"/cluster.open-cluster-management.io/v1/managedclusters",
method="POST",
headers=headers,
data=data,
content_type="multipart/form-data",
)
self.assert200(response, "Response body is : " + response.data.decode("utf-8"))
def test_get_cluster(self):
"""Test case for get_cluster
Query a single cluster for more details
"""
headers = {
"Accept": "application/json",
}
response = self.client.open(
"/cluster.open-cluster-management.io/v1/managedclusters/{cluster_name}",
method="GET",
headers=headers,
)
self.assert200(response, "Response body is : " + response.data.decode("utf-8"))
def test_list_managed_clusters(self):
"""Test case for list_managed_clusters
Query your clusters for more details.
"""
headers = {
"Accept": "application/json",
}
response = self.client.open(
"/cluster.open-cluster-management.io/v1/managedclusters",
method="GET",
headers=headers,
)
self.assert200(response, "Response body is : " + response.data.decode("utf-8"))
if __name__ == "__main__":
unittest.main()

View file

@ -1,30 +0,0 @@
import sys
if sys.version_info < (3, 7):
import typing
def is_generic(klass):
"""Determine whether klass is a generic class"""
return type(klass) == typing.GenericMeta
def is_dict(klass):
"""Determine whether klass is a Dict"""
return klass.__extra__ == dict
def is_list(klass):
"""Determine whether klass is a List"""
return klass.__extra__ == list
else:
def is_generic(klass):
"""Determine whether klass is a generic class"""
return hasattr(klass, "__origin__")
def is_dict(klass):
"""Determine whether klass is a Dict"""
return klass.__origin__ == dict
def is_list(klass):
"""Determine whether klass is a List"""
return klass.__origin__ == list

View file

@ -1,149 +0,0 @@
import datetime
import typing
from openapi_server import typing_utils
def _deserialize(data, klass):
"""Deserializes dict, list, str into an object.
:param data: dict, list or str.
:param klass: class literal, or string of class name.
:return: object.
"""
if data is None:
return None
if klass in (int, float, str, bool, bytearray):
return _deserialize_primitive(data, klass)
elif klass == object:
return _deserialize_object(data)
elif klass == datetime.date:
return deserialize_date(data)
elif klass == datetime.datetime:
return deserialize_datetime(data)
elif typing_utils.is_generic(klass):
if typing_utils.is_list(klass):
return _deserialize_list(data, klass.__args__[0])
if typing_utils.is_dict(klass):
return _deserialize_dict(data, klass.__args__[1])
else:
return deserialize_model(data, klass)
def _deserialize_primitive(data, klass):
"""Deserializes to primitive type.
:param data: data to deserialize.
:param klass: class literal.
:return: int, long, float, str, bool.
:rtype: int | long | float | str | bool
"""
try:
value = klass(data)
except UnicodeEncodeError:
value = data
except TypeError:
value = data
return value
def _deserialize_object(value):
"""Return an original value.
:return: object.
"""
return value
def deserialize_date(string):
"""Deserializes string to date.
:param string: str.
:type string: str
:return: date.
:rtype: date
"""
if string is None:
return None
try:
from dateutil.parser import parse
return parse(string).date()
except ImportError:
return string
def deserialize_datetime(string):
"""Deserializes string to datetime.
The string should be in iso8601 datetime format.
:param string: str.
:type string: str
:return: datetime.
:rtype: datetime
"""
if string is None:
return None
try:
from dateutil.parser import parse
return parse(string)
except ImportError:
return string
def deserialize_model(data, klass):
"""Deserializes list or dict to model.
:param data: dict, list.
:type data: dict | list
:param klass: class literal.
:return: model object.
"""
instance = klass()
if not instance.openapi_types:
return data
for attr, attr_type in instance.openapi_types.items():
if (
data is not None
and instance.attribute_map[attr] in data
and isinstance(data, (list, dict))
):
value = data[instance.attribute_map[attr]]
setattr(instance, attr, _deserialize(value, attr_type))
return instance
def _deserialize_list(data, boxed_type):
"""Deserializes a list and its elements.
:param data: list to deserialize.
:type data: list
:param boxed_type: class literal.
:return: deserialized list.
:rtype: list
"""
return [_deserialize(sub_data, boxed_type) for sub_data in data]
def _deserialize_dict(data, boxed_type):
"""Deserializes a dict and its elements.
:param data: dict to deserialize.
:type data: dict
:param boxed_type: class literal.
:return: deserialized dict.
:rtype: dict
"""
return {k: _deserialize(v, boxed_type) for k, v in data.items()}

View file

@ -1,13 +0,0 @@
connexion[swagger-ui] >= 2.6.0; python_version>="3.6"
# 2.3 is the last version that supports python 3.4-3.5
connexion[swagger-ui] <= 2.3.0; python_version=="3.5" or python_version=="3.4"
# prevent breaking dependencies from advent of connexion>=3.0
connexion[swagger-ui] <= 2.14.2; python_version>"3.4"
# connexion requires werkzeug but connexion < 2.4.0 does not install werkzeug
# we must peg werkzeug versions below to fix connexion
# https://github.com/zalando/connexion/pull/1044
werkzeug == 0.16.1; python_version=="3.5" or python_version=="3.4"
swagger-ui-bundle >= 0.0.2
python_dateutil >= 2.6.0
setuptools >= 21.0.0
Flask == 2.1.1

View file

@ -1,31 +0,0 @@
import sys
from setuptools import setup, find_packages
NAME = "openapi_server"
VERSION = "1.0.0"
# To install the library, run the following
#
# python setup.py install
#
# prerequisite: setuptools
# http://pypi.python.org/pypi/setuptools
REQUIRES = ["connexion>=2.0.2", "swagger-ui-bundle>=0.0.2", "python_dateutil>=2.6.0"]
setup(
name=NAME,
version=VERSION,
description="ACM API for cluster management",
author_email="support@katanemo.com",
url="",
keywords=["OpenAPI", "ACM API for cluster management"],
install_requires=REQUIRES,
packages=find_packages(),
package_data={"": ["openapi/openapi.yaml"]},
include_package_data=True,
entry_points={"console_scripts": ["openapi_server=openapi_server.__main__:main"]},
long_description="""\
This is the API for managing clusters using ACM - https://docs.redhat.com/en/documentation/red_hat_advanced_cluster_management_for_kubernetes/2.12/html/apis/apis#tags
""",
)

View file

@ -1,4 +0,0 @@
pytest~=7.1.0
pytest-cov>=2.8.1
pytest-randomly>=1.2.3
Flask-Testing==0.8.1

View file

@ -1,11 +0,0 @@
[tox]
envlist = py3
skipsdist=True
[testenv]
deps=-r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
{toxinidir}
commands=
pytest --cov=openapi_server

View file

@ -1,95 +0,0 @@
version: "0.1-beta"
listener:
address: 0.0.0.0
port: 10000
message_format: huggingface
connect_timeout: 0.005s
overrides:
# confidence threshold for prompt target intent matching
prompt_target_intent_matching_threshold: 0.6
endpoints:
acm_service:
endpoint: host.docker.internal:18083
connect_timeout: 0.005s
llm_providers:
- name: gpt-4o-mini
access_key: $OPENAI_API_KEY
provider: openai
model: gpt-4o-mini
default: true
- name: gpt-3.5-turbo-0125
access_key: $OPENAI_API_KEY
provider: openai
model: gpt-3.5-turbo-0125
- name: gpt-4o
access_key: $OPENAI_API_KEY
provider: openai
model: gpt-4o
system_prompt: |
You are a helpful assistant.
prompt_guards:
input_guards:
jailbreak:
on_exception:
message: Looks like you're curious about my abilities, but I can only provide assistance for weather forecasting.
prompt_targets:
- name: listAllClusterDetails
description: Query your clusters for more details.
http_method: GET
endpoint:
name: acm_service
path: /cluster.open-cluster-management.io/v1/managedclusters
- name: getClusterDetails
description: Query a single cluster for more details
http_method: GET
endpoint:
name: acm_service
path: /cluster.open-cluster-management.io/v1/managedclusters/{cluster_name}
parameters:
- name: cluster_name
in_path: true
description: The name of the cluster to retrieve
required: true
type: str
- name: default_target
default: true
description: This is the default target for all unmatched prompts.
system_prompt: |
You are a helpful assistant that can help answer ACM queries. Following is a list of available commands user can ask. Based on question asked, tell me which command you want to execute.
- name: listAllClusterDetails
description: Query your clusters for more details.
http_method: GET
endpoint:
name: acm_service
path: /cluster.open-cluster-management.io/v1/managedclusters
- name: getClusterDetails
description: Query a single cluster for more details
http_method: GET
endpoint:
name: acm_service
path: /cluster.open-cluster-management.io/v1/managedclusters/{cluster_name}
parameters:
- name: cluster_name
in_path: true
description: The name of the cluster to retrieve
required: true
type: str
auto_llm_dispatch_on_response: true
tracing:
random_sampling: 100
trace_arch_internal: true

View file

@ -1,31 +0,0 @@
services:
acm_service:
build:
context: acm_service/
environment:
- OLTP_HOST=http://jaeger:4317
extra_hosts:
- "host.docker.internal:host-gateway"
ports:
- "18083:8080"
chatbot_ui:
build:
context: ../shared/chatbot_ui
ports:
- "18080:8080"
environment:
# this is only because we are running the sample app in the same docker container environemtn as archgw
- CHAT_COMPLETION_ENDPOINT=http://host.docker.internal:10000/v1
extra_hosts:
- "host.docker.internal:host-gateway"
volumes:
- ./arch_config.yaml:/app/arch_config.yaml
jaeger:
build:
context: ../shared/jaeger
ports:
- "16686:16686"
- "4317:4317"
- "4318:4318"

View file

@ -1,5 +0,0 @@
docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli:latest generate \
--skip-validate-spec \
-i /local/acm_api.yaml \
-g python-flask \
-o /local/acm_service \

File diff suppressed because it is too large Load diff

View file

@ -1,47 +0,0 @@
#!/bin/bash
set -e
# Function to start the demo
start_demo() {
# Step 1: Check if .env file exists
if [ -f ".env" ]; then
echo ".env file already exists. Skipping creation."
else
# Step 2: Create `.env` file and set OpenAI key
if [ -z "$OPENAI_API_KEY" ]; then
echo "Error: OPENAI_API_KEY environment variable is not set for the demo."
exit 1
fi
echo "Creating .env file..."
echo "OPENAI_API_KEY=$OPENAI_API_KEY" > .env
echo ".env file created with OPENAI_API_KEY."
fi
# Step 3: Start Arch
echo "Starting Arch with arch_config.yaml..."
archgw up arch_config.yaml
# Step 4: Start Network Agent
echo "Starting Network Agent using Docker Compose..."
docker compose up -d # Run in detached mode
}
# Function to stop the demo
stop_demo() {
# Step 1: Stop Docker Compose services
echo "Stopping Network Agent using Docker Compose..."
docker compose down
# Step 2: Stop Arch
echo "Stopping Arch..."
archgw down
}
# Main script logic
if [ "$1" == "down" ]; then
stop_demo
else
# Default action is to bring the demo up
start_demo
fi