Update open api generated components
This commit is contained in:
@@ -1,13 +1,17 @@
|
||||
import os
|
||||
import uuid
|
||||
|
||||
from dotenv import load_dotenv
|
||||
from flask import Flask
|
||||
from pydantic import StrictStr
|
||||
|
||||
from src.controllers.mqtt_forwarder import MQTTForwarder
|
||||
from src.services.mqtt_service import MQTTService
|
||||
from openapi_client import ApiClient, Configuration
|
||||
from openapi_client.api.default_api import DefaultApi # Remplace DefaultApi par le nom de ton endpoint
|
||||
from board_mate.client import ClientApi, ApiClient, Configuration
|
||||
from board_mate.client.models import ClientDto
|
||||
from board_mate.client.exceptions import ApiException
|
||||
|
||||
client_id = "1"
|
||||
load_dotenv()
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
@@ -41,24 +45,26 @@ if __name__ == '__main__':
|
||||
forwarder = MQTTForwarder(client_id, local_broker, api_broker)
|
||||
forwarder.start(f"/customer/telemetry/#", f"/board-mate/{client_id}/telemetry")
|
||||
|
||||
# main.py
|
||||
|
||||
|
||||
# 1️⃣ Configurer la connexion à l'API
|
||||
config = Configuration(
|
||||
host="https://api.monservice.com", # URL de ton API
|
||||
api_key={"Authorization": "Bearer TON_TOKEN"} # Ton token Bearer si nécessaire
|
||||
"""config = Configuration(
|
||||
host="https://192.168.15.120:8000",
|
||||
)
|
||||
config.verify_ssl = False
|
||||
|
||||
# 2️⃣ Créer le client et appeler l'API
|
||||
with ApiClient(config) as client:
|
||||
api_instance = DefaultApi(client) # Remplace par UsersApi, PetsApi, etc. selon ton endpoint
|
||||
with ApiClient(config) as api_client:
|
||||
client_api = ClientApi(api_client)
|
||||
|
||||
new_client = ClientDto(
|
||||
name=StrictStr("Alice Example"),
|
||||
username=StrictStr("alice123"),
|
||||
)
|
||||
|
||||
try:
|
||||
# Appel de l'endpoint GET (méthode générée automatiquement)
|
||||
response = api_instance.get_users() # Remplace par la méthode générée correspondant à ton endpoint
|
||||
print("Réponse de l'API :", response)
|
||||
except Exception as e:
|
||||
print("Erreur lors de la requête :", e)
|
||||
# 5. Call the endpoint
|
||||
response = client_api.create(client_dto=new_client)
|
||||
print("Success:", response.success)
|
||||
print("Message:", response.message)
|
||||
print("Data:", response.data)
|
||||
except ApiException as e:
|
||||
print(f"Exception when calling ClientApi->create: {e}")"""
|
||||
|
||||
app.run(host="0.0.0.0", port=5000, debug=False)
|
||||
app.run(host="0.0.0.0", port=5000, debug=True)
|
||||
|
||||
Reference in New Issue
Block a user