question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[QUESTION] How am I supposed to enter account name in script?

See original GitHub issue

Let’s say that I have an account registered with email ‘Bill.gates@microsoft.com’. What should I put as parameter when using cf.zones.get? I tried different combinations but only if I provide my account ID I’m able to retrieve the zone list.

This is what I expect to work:

def main():

    cf = CloudFlare.CloudFlare(profile='Cloudflare')
    zones = cf.zones.get(
        params={'per_page': 200,
                'name': 'Bill.gates@microsoft.com'})
    for zone in zones:
        zone_name = zone['name']
        zone_id = zone['id']
        print("id={} - name={}".format(zone_id, zone_name))

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
mahtincommented, Aug 3, 2022

Sorry, there was a typo (now corrected) in my first account … I was typing too fast! 😃 It’s …

     'account.name': 'the-account-name',

You can test all this with the command line cli4 program. For example …

$ cli4 account.name="THE-ACCOUNT-NAME" /zones | jq -c ".[]|.id,.name" | paste - - 
"00000000000000000000000000000000"	"example.com"
"00000000000000000000000000000000"	"example.net"
$

You were correct in your read of https://api.cloudflare.com/#zone-list-zones and I was wrong with the param account. The documentation is correct and its account.name (or account.id if you already know the 32 digit account number already.

Hope that gets you back on track (and don’t forget that you can test quickly with cli4.

0reactions
mahtincommented, Aug 3, 2022

FYI: If you use the https://dash.cloudflare.com/ site, you can change your account name so it’s a simpler string.

Your example above is beyond the Python library; however, any param passed that is not part of the API is ignored. The following shows that. This is valid:

$ cli4 account.name="ONE-OF-MY-ACCOUNTS" /zones | jq -c ".[]|.id,.name" | paste - - | wc -l
4
$

This is ignored (and all my zones from all my accounts are shown):

$ cli4 accountwhatever="xyz" per_page=1000 /zones | jq -c ".[]|.id,.name" | paste - - 
131
$

Hence I think the issue is the exact spelling (and/or) character encoding of your account name (that’s why I recommend changing it via the dashboard (or even via the API). Oh … run this command:

$ cli4 /accounts | jq -c ".[]|.id,.name" | paste - - 
"00000000000000000000000000000000"	"Martin Levy"
"00000000000000000000000000000000"	"XXXXX"
"00000000000000000000000000000000"	"YYYYYYYYYYY"
"00000000000000000000000000000000"	"ZZZ"
$

Hope that helps.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Linux shell script add a user with a password - nixCraft
Enter username : roja Enter password : HIDDEN User has been added to system! Now user roja can login with a password called...
Read more >
Issue with user account creation PS script - TechNet - Microsoft
I am having an issue with a script that I have been modifying to create AD accounts from a CSV file that gets...
Read more >
how to confirm the user name else allowed to enter a custom ...
Write -Host $firstname = Read-Host "Enter in the First Name" ... Do{ Write-Host $confirm = Read-Host "Is [$logonname] correct or would you ...
Read more >
How To Prompt A User For Input In A PowerShell Script
A simple way to begin the journey to automation is to write scripts and prompt for user input. In this video, Jason will...
Read more >
Active Directory Automated User Creation - YouTube
Create User Accounts with Powershell - Create your Active Directory Accounts quick and easily with this Powershell Script.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found