Michael Shipper
and 1 contributors

NAME

Net::AppDynamics::REST - AppDynamics AnyEvent Friendly REST Client

SYNOPSIS

  use Net::AppDynamics::REST;

  my $obj=Net::AppDynamics::REST->new(PASS=>'password',USER=>'Username',SERVER=>'SERVERNAME');

  # to get a list of applications in a non blocking context
  my $resut=$obj->list_applications;

  # get a list of applications in a non blocking context
  use AnyEvent;

  $obj->que_list_applications(sub {
    my ($self,$id,$result,$request,$response)=@_;
  });
  $ojb->agent->run_next;
  AnyEvent::Loop::run;

DESCRIPTION

Appdynamics AnyEvent friendly Rest client.

OO Declarations

Required

  USER: Sets the user appd
  PASS: Sets the password
  SERVER: Sets the server

Optional

  logger: sets the logging object
  CUSTOMER: default customer1
  PORT: default 8090
  PROTO: default http
  cache_max_age: how long to keep the cache for in seconds
    default value is 3600
  agent: Gets/Sets the AnyEvent::HTTP::MultiGet object we will use

For Internal use

  data_cache: Data structure used to cache object resolion

Moo::Roles

This module makes use of the following roles: HTTP::MultiGet::Role, Log::LogMethods and Data::Result::Moo

OO Methods

  • my $url=$self->base_url

    Creates the base url for a request.

  • my $request=$self->create_get($path,%args);

    Create a request object for $path with the required arguments

  • my $result=$self->new_true({qw( some data )});

    Returns a new true Data::Result object.

  • my $result=$self->new_false("why this failed")

    Returns a new false Data::Result object

NonBlocking interfaces

All methods with a prefix of que_xxx are considered non blocking interfaces.

Default Callback arguments:

  my $code=sub {
    # 0: this Net::AppDynamics::REST Object
    # 1: id, for internal use
    # 2: Data::Result Final object ( if failed, it will say why it failed )
    # 3: HTTP::Request Last Object|undef
    # 4: HTTP::Response Last Object|undef
    my ($self,$id,$result,$request,$response)=@_;
  };

Blocking Interfaces

All interfaces that are prefixed with que_xxx have a corisponding blocking method that is simply the xxx portion of the method name.

Example Non Blocking version of que_list_applicatinos:

  my $result->list_applicatinos();

When called without the que context the methods provides the more traditional blocking style inteface. When called in a blocking context only the Data::Result Object is returned.

Application Model API

  • my $id=$self->que_list_applicatinos

    Queues a requst to fetch the list of all applications

  • my $id=$self->que_list_tiers($cb,$application);

    Queues a request to fetch the list of tiers within a given application

  • my $id=$self->que_list_tiers($cb,$application,$tier);

    Ques a request for the details of the application tier

  • my $id=$self->que_list_business_transactions($cb,$application)

    Queues a request to fetch the list of business transactions for a given application

  • my $id=$self->que_list_nodes($cb,$application)

    Ques a request to all the nodes in a given application

  • my $id=$self->que_list_nodes($cb,$application,$node)

    Queues a request to list the details of a node in a given tier

  • my $id=$self->que_list_backends($cb,$application)

    Queues a request to list the backends for a given application

  • my $id=$self->que_walk_all($cb)

    Queues a request to walk everything.. $cb arguments are different in this caes, $cb is called with the following arguments. Keep in mind this walks every single object in mass and up to 20 requests are run at a time ( by default ), so this can put a strain on your controler if run too often.

      my $cb=sub {
        # 0: this Net::AppDynamics::REST Object
        # 1: id, for internal use
        # 2: Data::Result Final object ( if failed, it will say why it failed )
        # 3: HTTP::Request Last Object|undef
        # 4: HTTP::Response Last Object|undef
        # 5: method ( wich method this result set is for ) 
        # 6: application ( undef the method is list_applications )
        my ($self,$id,$result,$request,$response,$method,$application)=@_;
      };

    The structure of $result->get_data when true contains the following anonymous hash.

    Objects are listed by ids ids: Anonymous hash of ids to object refrerences

      # keys used to map names to object ids
      applications, business_transactions, tiers, nodes
        Each element contains an anonymous hash of of an array refres
          Each element in the array ref refres back to an ids object.

Alert and Respond API

  • my $id=$self->que_health_rule_violations($cb,$app,%args);

    Queues a health rule violation lookup

    Example ( defaults if no arguments are passed ):

      my $id=$self->que_health_rule_violations($cb,"PRODUCTION",'time-range-type'=>'BEFORE_NOW','duration-in-mins'=>15);

    For more details, please see: https://docs.appdynamics.com/display/PRO43/Alert+and+Respond+API#AlertandRespondAPI-RetrieveAllHealthRuleViolationsinaBusinessApplication

  • my $id=$self->que_resolve($cb,$type,$name);

    Used to resolve tiers, nodes, business_transactions, and applications to thier application's id.

     cb:  standard callback
     type: String representing the typpe of object to resolve (tiers|nodes|business_transactions|applications);
     name: name to be resolved

    Uses the internal cache to resolve the object, if the internal cache is out of date or empty the cache will be refreshed.

  • my $id=$self->que_check_cache($cb);

    Queues a cache check. The resolve cache is refreshed if it is too old.

  • my $id=$self->que_find_health_rule_violations($cb,$type,$name,%args)

    Queues a a $sellf->que_health_rule_violations($internal_cb,%args)

    The result when true will cointain health rules on anything that resolved.

    See: que_health_rule_violations and que_resolve for more information

Configuration Import and Export API

This section documents the Configuration Import and Export API.

  • my $id=$self->que_export_policies($cb,$app)

    Queues the exporting of a policy

Bugs and Patches

Please report bugs and submit patches via https://rt.cpan.org

Todo

This module is pretty sparse in what it can do, this is the pre 1.0 release.. mostly becase the api is only partially implemented at best.

See Also

https://docs.appdynamics.com/display/PRO43/AppDynamics+APIs

AnyEvent::HTTP::MultiGet

AUTHOR

Michael Shipper mailto:AKALINUX@CPAN.ORG