GithubHelp home page GithubHelp logo

snider / php-clouddns Goto Github PK

View Code? Open in Web Editor NEW
17.0 5.0 10.0 286 KB

A PHP Binding to the Rackspace Cloud DNS API Created for my own use, since no public php API lib was out at that time available

PHP 100.00%

php-clouddns's Introduction

== Project Spring Clean ==

It is time for this lirary to get updated so it is a little more modern, when it was made things were just done diffrently. If you have a idea, im open to impliment it... if you look at my history of acepting pull requests i have a 100% aceptance rate so please dont fork and run with this on your own... if you want i will just add you as a developer once you have done a few pull requests.

during project Spring Clean i want to use getters for listing records, namespace the project, add a PSR-3 style logger, adopt PSR-1/PSR-2 and debating with myself if a trait would be handy... not sure tho its not like a file storage system, any thoughts?

Rackspace DNS PHP API ...

please register any issues to: https://github.com/snider/php-cloudDNS/issues/

Copyright (C) 2011 Paul Lashbrook

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/gpl-3.0.txt.

@author Paul Lashbrook

@contributor Alon Ben David @ CoolGeex.com @contributor zeut @ GitHub - reported a fix for limiting... totally forgot that bit! @contributor idfbobby @ github - updated the create_domain() function to include comments and ttl @contributor diegoiglesias @ github - updated authentication code to cater for new style accounts.

CHANGES

27/3/2012 Reported by Zeut

  • fixed a ssl peer veify error for people with old versions of curl

26/3/2012 Reported by Zeut, fixed by Paul Lashbrook

  • Updated php Docs
  • Added pagination list_domains() list_subdomains() list_records() list_domain_search() list_domain_details()
  • search_domains alias added

08/09/2011 Paul Lashbrook

  • added import_domain()
  • added alias function delete_domain()
  • relaxed data type checking
  • fixed callback waiting until timeout

30/08/2011 Alon Ben David @ CoolGeex.com

  • Class name now rackDNS
  • callback function to cycle through registered call backs with timeout in place
  • Added support to US rackspace DNS API
  • delete_domain Now called delete_domains (accept int for one domain OR array for multiple domains)
  • added modify_domain function to modify domain configuration
  • added domain_import function to import BIND9 format string
  • created a sample.php file with code samples

PHP API binding to Rackspace Cloud DNS (US & UK)

This is strictly for PHP5 since PHP4 should be forgotten forever.

PLEASE NOTE: any help suggestions/requests welcome

Server communication code originally from and slightly adapted, thanks to the work of that author making this was relatively easy

you made get errors trying to establish an ssl conection to rackspace, if you get this you have a old version of Curl installed meaning the CA list is outdated.

just run $dns->set_cabundle(true); before you try to do a API action

@link http://snider.github.com/php-cloudDNS/ via https://github.com/eyecreate/Rackspace-Cloud-PHP-Library

All API Methods Implemented So Far: Check sample.php for code sample

$dns = new rackDNS($rs_user,$rs_api_key); //($user, $key, $endpoint = 'UK') $endpoint can be UK or US

// Show all domains avalible $dns->list_domains(50,0); //($limit = 10, $offset = 0)

$dns->list_subdomains($sampleID);//($domainID)

$dns->domain_export($sampleID);//($domainID)

$dns->list_records($sampleID);//($domainID)

$dns->list_record_details($sampleID,$recID);//($domainID,$recordID)

$dns->domain_import($sampleImport);

$dns->list_domain_search('domain.com');

$dns->modify_domain($sampleID,'[email protected]'); //($domainID = false , $email = false , $ttl = 86400 , $comment = 'Modify Domain Using rackDNS API')

$dns->delete_domains($sampleID);

$dns->delete_domain_record($domainID,$recordID)

$dns->list_domain_details($domainID = false, $showRecords = false, $showSubdomains = false);

$dns->import_domain('domain.com');

$dns->create_domain($name = false, $email = false, $records = array());

$dns->create_domain_record($domainID = false, $records = array());

$dns->create_domain_record_helper($type = false, $name = false, $data = false, $ttl = 86400, $priority = false);

example use:

$dns = new rackDNS(RS_USER,RS_API_KEY);

// make a new dns zone $records = array($dns->create_domain_record_helper('MX','originalwebware.com','mail.originalwebware.com',86400,2), $dns->create_domain_record_helper('a','originalwebware.com','192.168.0.1',86400)); name, email, comment, ttl, records $results = $dns->create_domain('originalwebware.com', '[email protected]', 'a comment', 3600, $records);

// add a new record(s) to a dns zone $records = array($dns->create_domain_record_helper('MX','originalwebware.co.uk','mail.originalwebware.co.uk',86400,2), $dns->create_domain_record_helper('a','originalwebware.co.uk','192.168.0.1',86400)); $results = $dns->create_domain_record(123456,$records);

$dns->getLastResponseStatus(); //returns status code $dns->getLastResponseMessage();//returns status message

php-clouddns's People

Contributors

alexshepherd-hydrant avatar alonbendavid avatar diegoiglesias avatar dotcomfy avatar marklocker avatar snider avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

php-clouddns's Issues

TTL & Comments on Create Domain

I've added comment and TTL on the create domain function. I've included the code, hope it helps! :)

public function create_domain($name = false, $email = false, $comment = false, $ttl = 3600, $records = array(),     $showDetails = false) {
    if (! $email || ! $name ) {
        return false;
    }

    $postData = array (
            'domains' => array (
                    array (
                            'name' => $name,
                            'emailAddress' => $email,
                            'ttl' => $ttl,
                            'comment' => $comment,
                            'recordsList' => array (
                                    'records' => $records ) ) ) );

    $url = '/domains';

    $url .= $showDetails == true ? '?showDetails=true' : '';

    $call = $this->makeApiCall ( $url, $postData, 'POST' );

    //@todo make callback function to cycle through registered call backs
    $timeout = time () + self::TIMEOUT;

    while ( $call ['status'] == 'RUNNING' && $timeout > time () ) {
        $this->callbacks [] = $call;
        usleep ( self::SLEEPTIME );

        $url = explode ( 'status', $call ['callbackUrl'] );

        $url = array_pop ( $url );
        $url .= $showDetails == true ? '?showDetails=true' : '';

        $call = $this->makeApiCall ( '/status' . $url );

    }
    return $call;
} 

add a callback function

a callback function for async functions so if one wanted they could call back minutes or hours later as the result is saved for 24 hours...

could internally use it and have a option to just return the callback url for the programmer save and use later

API Updates

as of the 9th september 2011 the api will be running a new version. the area impacted is callbacks

API Contract Change
This release will contain a change to the API that will break the current behavior of asynchronous callbacks and require modifications to your code.

Previously, the object returned by the asynchronous call would simply return 202, a job id and status monitor URL when called. If the job succeeded, a 200 response was returned along with the object (or a 204 for delete operations). If the job were to fail, the service returned the error code along with the error object.

With this release, the behavior will be modified to return 202, a job id, job status, status monitor URL, request verb, request URL, and request data (if any).

When the status monitor URL is queried and the job is still running, return 202 and:
    job id, status monitor URL, and status (default) OR
    job id, job status, status monitor URL, request verb, request URL, and request data (if any) (?showDetails=true)
When the status monitor URL is queried and the job has succeeded, return a 200 and:
    job id, job status, and status monitor URL (default) OR
    job id, job status, status monitor URL, request verb, request URL, request data (if any), and response (if any) (?showDetails=true)
When the status monitor URL is queried and the job has failed, return a 200 and:
    job id, job status, and status monitor URL (default) OR
    job id, job status, status monitor URL, request verb, request URL, request data (if any), and error (?showDetails=true)

Libcurl ssl peer verification error

== new details ==
please see coments below, this is now dealing with a libcurl ssl issue

original title: list_domain_details() should have limit and offset arguments
There might be other places where similar changes are needed, but I bumped into this one specifically. I have re-written the function thusly:

public function list_domain_details($domainID = false, $showRecords = false, $showSubdomains = false, $limit=false, $offset=false) {
    if ($domainID == false || ! is_numeric ( $domainID )) {
        return false;
    }

    $showRecords = ($showRecords == false) ? 'false' : 'true';
    $showRecords = ($showSubdomains == false) ? 'false' : 'true';
    $limit       = ($limit != false && $limit > 0) ? "&limit=$limit" : '';
    $offset      = ($offset != false && $offset >= 0) ? "&offset=$offset" : '';

    $url = "/domains/$domainID?showRecords=$showRecords&showSubdomains=$showSubdomains{$limit}{$offset}";

    return $this->makeApiCall ( $url );
}

remove curl dependancy

curl is just lazy, and a lil slow. by removing curl usage the api would work for more people and run faster.

there might be some issues stopping this but should...

Authentication token reuse

allow a auth token to be provided to the class so that it can use the RS more efficiently

maybe a public property that the developer can set prior to using api functions using a token returned from a previous API call within the 24 hour window a token is normally valid for

Cannot raise the limit over 100

Hello,
I need to get records for 3600 domains. The problem I am running into is the limit of 100.
If I change that to saw 200 It seems to break the code. I am sorta at a loss and must be missing something.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.