Skip to content
This repository has been archived by the owner on Jul 4, 2024. It is now read-only.

Any examples of programmatic usage? #260

Open
max-arnold opened this issue Aug 30, 2018 · 1 comment
Open

Any examples of programmatic usage? #260

max-arnold opened this issue Aug 30, 2018 · 1 comment

Comments

@max-arnold
Copy link

I want to write some code to automate operations with DNS records and plan to reuse gandi.cli as the base layer for interacting with the API. I have two questions:

  1. Could you please provide an example of how to initialize Gandi API client without relying on any configuration files (and preferably disabling them completely to avoid potential clashes)? The code is full of @classmethods, and this approach is foreign for me. For now, I only need v5 API, but it would be nice if you have examples for both XML-RPC and REST APIs.

  2. Is the code thread-safe? I want to run multiple threads with different API keys, and to me the way you configure the classes seems to be global.

@kalou
Copy link
Contributor

kalou commented Aug 30, 2018

Hi there,

From what I recall there's quite a number of tight couplings in there - if you're planning on using the new LiveDNS API, you'd probably be better off using requests directly (I assume you already checked out https://doc.livedns.gandi.net/)

As you mention there is quite a bit of global and automatic initialization happening, and no config that can be passed around - but instead the slightly annoying GandiModule(GandiConfig), thanks for pointing that out :)

So I'm afraid there's no easy/positive answer for both 1/ and 2/ - of course if someone has another idea I hope they will comment here too, but I'd vote for a slight refactor of this part on our end, and not to use the CLI codebase as a library in the meantime.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants