読者です 読者をやめる 読者になる 読者になる

かれ4

かれこれ4個目のブログ

AWSのサービスの現在のバージョンと認証方法の一覧 (2012/9/23時点)

何に必要かはわからないけど、AWSSDKforPHP 1.5.14 から抜き出し
EMRが2009なのはPHPだから??

service version auth
EC2 2012-07-20 AuthV2Query
EMR 2009-03-31 AuthV2Query
ElastiCache 2012-03-09 AuthV2Query
ElasticBeanstalk 2010-12-01 AuthV2Query
ImportExport 2010-06-01 AuthV2Query
SDB 2009-04-15 AuthV2Query
SNS 2010-03-31 AuthV2Query
SQS 2011-10-01 AuthV2Query
CloudFront 2012-03-15 AuthV2REST
SWF 2012-01-25 AuthV3JSON
DynamoDB 2011-12-05 AuthV4JSON
StorageGateway 2012-04-30 AuthV4JSON
AutoScaling 2011-01-01 AuthV4Query
CloudFormation 2010-05-15 AuthV4Query
CloudSearch 2011-02-01 AuthV4Query
CloudWatch 2010-08-01 AuthV4Query
ELB 2012-06-01 AuthV4Query
IAM 2010-05-08 AuthV4Query
RDS 2012-07-31 AuthV4Query
SES 2010-12-01 AuthV4Query
STS 2011-06-15 AuthV4Query
S3 2006-03-01

抜き出したコードはこれ

<?php
require_once 'AWSSDKforPHP/sdk.class.php';
class AWSVersionChecker {
  const AWSSDK_DIR = '/opt/local/lib/php/AWSSDKforPHP';
  private function get_class_list() {
    $d = dir(self::AWSSDK_DIR . "/services");
    $classes = array();
    while (false !== ($f = $d->read())) {
      if (preg_match("/class/", $f)) {
        $c = file_get_contents(self::AWSSDK_DIR . "/services/" . $f);
        $m = array();
        if (preg_match("/.*class (.*?) extends CFRuntime.*/", $c, $m)) {
          $classes[] = $m[1];
        }
      }
    }
    return $classes;
  }
  public function run() {
    $c = $this->get_class_list();
    foreach ($c as $class_name) {
      $service = new Service($class_name);
      $service->print_summary();
    }
  }
}
class Service {
  private $service_name;
  private $apis = array();
  private $api_version;
  private $auth_class;
  public function print_summary() {
    echo "|" . $this->service_name . "|" . $this->api_version . "|" . $this->auth_class . "|\n";
  }
  public function addApi(API $api) {
    $this->apis[] = $api;
  }
  public function __construct($name) {
    if ($name instanceof ReflectionClass) {
      $this->service_name = $name->getName();
    } else {
      $this->service_name = $name;
    }
    $methods = $this->get_functions($this->service_name);
    foreach ($methods as $method) {
      $this->addApi(new API($method));
    }
    $this->api_version = $this->get_apiversion($this->service_name);
    $this->auth_class = $this->get_auth_class($this->service_name);
  }
  private function get_functions($class_name) {
    $clazz = new ReflectionClass($class_name);
    $methods = $clazz->getMethods();
    $functions = array();
    foreach ($methods as $method) {
      $api = false;
      if ($method->getDeclaringClass()->getName() == $class_name && !$method->isConstructor() && $method->isPublic()) {
        if (preg_match('/.*return CFResponse.*/', $method->__toString())) {
          $a = $method->getName();
          $parameters = $method->getParameters();
          foreach ($parameters as $parameter) {
            if ($parameter->getName() == "opt") {
              $api = true;
            }
          }
          if ($api) {
            $functions[] = $method;
          }
        }
      }
    }
    return $functions;
  }
  private function get_apiversion($class_name) {
    return $this->get_parameter_value($class_name, "api_version");
  }
  private function get_auth_class($class_name) {
    return $this->get_parameter_value($class_name, "auth_class");
  }
  private function get_parameter_value($class_name, $param_name) {
    $clazz = new ReflectionClass($class_name);
    return $clazz->getProperty($param_name)->getValue($clazz->newInstance(array()));
  }
  private function get_parameter(ReflectionMethod $method) {
    $parameters = $method->getParameters();
    $p = array();
    foreach ($parameters as $parameter) {
      $p[] = $parameter;
    }
  }
  private function get_domain($class_name) {
    $clazz = new ReflectionClass($class_name);
    $us = $clazz->getConstant("REGION_US_E1");
    if ($us === false) {
      $us = $clazz->getConstant("DEFAULT_URL");
    }
    $subdomains = explode(".", $us);
    if (count($subdomains) > 0) {
      return $subdomains[0];
    }
    return "unknown";
  }
}
class API {
  private $name;
  private $parameters;
  public function addParameter(APIParameters $param) {
    $this->parameters[] = $param;
  }
  public function __construct($name) {
    if ($name instanceof ReflectionMethod) {
      $this->name = $name->getName();
      foreach ($name->getParameters() as $param) {
        $this->addParameter(new APIParameters($param));
      }
    } else {
      $this->name = $name;
    }
  }
}
class APIParameters {
  public $name;
  public $isRequire;
  public function get_name() {
    return $this->name;
  }
  public function __construct($name, $require = false, $default = null) {
    if ($name instanceof ReflectionParameter) {
      $this->name = $name->getName();
      $this->isRequire = !$name->isOptional();
    } else {
      $this->name = $name;
      $this->isRequire = $require;
    }
  }
}
$stf = new AWSVersionChecker();
$stf->run();