Package: pycfdns
Manage DNS Records hosted by CloudflareCloudflareDNS API Python Wrapper.Quick startInstallationpython3-mpipinstallpycfdnsExample usage...importaiohttpfrompycfdnsimportClient...asyncwithaiohttp.ClientSession()asclient_session:client=Client(api_token="abc123",client_session=client_session)zones=awaitclient.list_zones()print(zones)...APIBelow is a quick overview of the classes and methods that are available in this package.This package usesmypyto ensure it is strictly typed, and all API modesl are created asTypedDictobjects.Anything that is not exported in the base of the module (in the__init__.pyfile) are considered internal to this package and will change wihtout any notice, yoo should consider not using anything not found there.ClientTheClientclassis your entrypoint to this package, this is what's providing the methods described below.This method accepts the folowing arguments:ArgumentTypeDescriptionapi_tokenstrThis is your personal API token to interface with theCloudflare API, you can generate this token here:https://developers.cloudflare.com/api/tokens/createclient_sessionClientSessionThis neesd to be an instance ofClientSessionfrom theaiohttppacakge.timeoutint | NoneThis determines how long an API call can use (in seconds) before it times out, the default is10seconds.List ZonesTheClient.list_zonesmethodcan be used to list all zones available with theapi_tokenpassed to theClientobject.This method takes no arguments....client=Client(session=session,api_token="abc123")zones=awaitclient.list_zones()...Thezonesvariable in this example will be a list ofZoneModelobjects.List RecordsTheClient.list_dns_recordsmethodcan be used to list all records within a zone.This method accepts the folowing arguments:ArgumentTypeDescriptionzone_idstrThe ID of the zone to list records for.namestr | NoneIf this is passed in it will only match record matching the name.typestr | NoneIf this is passed in it will only match record matching the type....client=Client(api_token="abc123",client_session=client_session)records=awaitclient.list_dns_records()...Therecordsvariable in this example will be a list ofRecordModelobjects.Update RecordTheClient.update_dns_recordmethodcan be used to update a record in a zone.This method accepts the folowing arguments:ArgumentTypeDescriptionzone_idstrThe ID of the zone the record exist in.record_idstrThe ID of the record to list records for.record_namestrThe name of the record.record_typestrThe type of the record.record_contentstrThe content of the record.record_commentstr | NoneThe comment of the record.record_proxiedbool | NoneThe proxied state of the record.record_tagslist[str] | NoneThe tags of the record.record_ttlint | NoneThe TTL value of the record....client=Client(api_token="abc123",client_session=client_session)record=awaitclient.update_dns_record(zone_id="abc123",record_id="abc123",record_name="abc",record_content="1.1.1.1",record_type="A")...Therecordvariable in this example will be aRecordModelobjectrepresenting the updated record.ExceptionsThis package have 2 defined exceptions:AuthenticationException, this will be raised when the Cloudflare API returns a status code assosiated with authentication issues.ComunicationException, this will be raised when there are issues communicating with theCloudflare API.VersioningThis package follows theSemVerframework to determine how to set the version.PublishingThis package is published toPyPIwhen a newGitHubrelease is made.The publishing itself is handled inGitHub actionswiththis workflow.A history of release actions can be found here.There is no fixed schedule for when a new version is published.DisclaimerThis Python wrapper for the Cloudflare API is an independent project and is not endorsed, sponsored, or affiliated with Cloudflare, Inc. The use of Cloudflare's name, trademarks, and other intellectual property is for descriptive purposes only. All rights to Cloudflare's name, trademarks, and other intellectual property belong to Cloudflare, Inc. Use this wrapper at your own risk and ensure that you abide by Cloudflare's terms of service and API usage guidelines.