From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <f.gruenbichler@proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by lists.proxmox.com (Postfix) with ESMTPS id 6DA7861040
 for <pve-user@lists.proxmox.com>; Wed, 16 Dec 2020 11:30:27 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id 650511AD46
 for <pve-user@lists.proxmox.com>; Wed, 16 Dec 2020 11:30:27 +0100 (CET)
Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com
 [212.186.127.180])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by firstgate.proxmox.com (Proxmox) with ESMTPS id 993DB1AD3A
 for <pve-user@lists.proxmox.com>; Wed, 16 Dec 2020 11:30:26 +0100 (CET)
Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1])
 by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 5891C450B2;
 Wed, 16 Dec 2020 11:30:26 +0100 (CET)
Date: Wed, 16 Dec 2020 11:30:05 +0100 (CET)
From: =?UTF-8?Q?Fabian_Gr=C3=BCnbichler?= <f.gruenbichler@proxmox.com>
To: Proxmox VE user list <pve-user@lists.proxmox.com>,
 Erik Hollensbe <erik@hollensbe.org>
Message-ID: <832275819.1770.1608114606272@webmail.proxmox.com>
In-Reply-To: <CADHGEEKW+ckrBd9Z3iAaV-VOoL3N_anprA-hmH0fpc=FjKJoZA@mail.gmail.com>
References: <CADHGEEKW+ckrBd9Z3iAaV-VOoL3N_anprA-hmH0fpc=FjKJoZA@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-Priority: 3
Importance: Normal
X-Mailer: Open-Xchange Mailer v7.10.4-Rev14
X-Originating-Client: open-xchange-appsuite
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.025 Adjusted score from AWL reputation of From: address
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 RCVD_IN_DNSWL_MED        -2.3 Sender listed at https://www.dnswl.org/,
 medium trust
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See
 http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more
 information. [proxmox.com]
Subject: Re: [PVE-User] Extracting/leveraging the JSON schema
X-BeenThere: pve-user@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE user list <pve-user.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-user>, 
 <mailto:pve-user-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-user/>
List-Post: <mailto:pve-user@lists.proxmox.com>
List-Help: <mailto:pve-user-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-user>, 
 <mailto:pve-user-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Wed, 16 Dec 2020 10:30:27 -0000

> Erik Hollensbe <erik@hollensbe.org> hat am 16.12.2020 10:48 geschrieben:
> I'd like to extract the JSON schema for use in generating a golang API.
> Judging from brief googling I've seen others have attempted this but I was
> hoping to make an effective dent in the problem. I think it'd be really
> useful in terraform and other orchestration tools that are typically
> written in that language (these days at least).
> 
> I reviewed the pve-common packages, specifically, the PVE::JSONSchema perl
> module and it looks like a parser but not the actual API.

yes, pve-common contains the basic framework, the API itself is distributed over the other packages (mainly pve-storage, pve-container, qemu-server, and the main API daemons and entrypoint in pve-manager).

> Best I can tell from googling and looking at the files in /usr/share/pve is
> that there is a api.js (I forget the exact filename) that contains what I
> seek, unfortunately it is coupled with some additional framework code to
> generate it all, best I can tell?

apidata.js is generated by the following (veeeeery short ;)) perl script:

https://git.proxmox.com/?p=pve-docs.git;a=blob;f=extractapi.pl;h=06d6af4cb2cabe8bbdf514ed03046879bf53c15b;hb=HEAD

it pulls in the main API endpoint (PVE::API2) and the API handler (PVE::RESTHandler). the latter already has all the dumping functionality built-in. it should run on any host that has PVE installed.

> What I'd really like to do is get ya'll up to speed so that your API can be
> consumed by codegen tools that are out there. Let me know how I can help
> and facilitate this. Swagger would be a bold idea/ideal here, if you're up
> for considering something along those lines as well. The swagger/openapi
> codegen tools are dull but effective for a lot of languages.

there have been some efforts like that in the past (mostly from the nodejs camp AFAICT). maybe take a look at https://pve.proxmox.com/wiki/Proxmox_VE_API#Clients and see what other people have done so far ;)
 
> The PVE API is vast and I don't see the feasibility in porting it by hand
> 100%, especially when you consider future maintenance burdens, so something
> that could generate code or dynamically configure a client would be an
> ideal solution assuming it is needed and can be bootstrapped.
> 
> Thanks and I hope this message from a brand new ML user is not too forward
> :)

good luck with your project! don't hesitate to ask if you have further questions (although if they get more technical, I'd suggest switching to pve-devel instead of pve-user :))