rzfeeser.pokeapi.pokeapi_info (1.0.1) — module

Make lookups to pokeapi.co/v2

| "added in version" 1.0.0 of rzfeeser.pokeapi"

Authors: Russell Zachary Feeser (@rzfeeser)

Install collection

Install with ansible-galaxy collection install rzfeeser.pokeapi:==1.0.1


Add to requirements.yml

  collections:
    - name: rzfeeser.pokeapi
      version: 1.0.1

Description

This module was written to simplify interaction with pokeapi.co/v2 API. See pokeapi.co for documentation on using the v2 API.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# return JSON to pokeapi.co/v2/pokemon/pikachu
- name: make a call to pokeapi
  pokeapi_info:
    resource: pokemon      # (group) describes the resource or group within the pokeapi.co service the user wants
    name: pikachu          # (id) describes the name or id within the resource to search on
  register: results
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: display pokemon/pikachu results
  ansible.builtin.debug:
    var: results
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# return JSON to pokeapi.co/v2/pokemon?limit=100&offset=42
- name: make a call to pokeapi with limit of 10 and offset of 100
  pokeapi_info:
    resource: pokemon
    limit: 100      # stop at 142 (limit to 100 results)
    offset: 42      # start at 43
  register: results
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: display pokemon?limit=100&offset=42 results
  ansible.builtin.debug:
    var: results
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# return JSON to pokeapi.co/v2/berry
- name: make a call to the resource berry
  pokeapi_info:
    resource: berry
  register: results
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: display display berry results
  ansible.builtin.debug:
    var: results

Inputs

    
name:
    description: The name of the resource to lookup. See pokeapi.co/docs/v2 for all possible
      values.
    required: false
    type: str

limit:
    description: The number of results that will be returned with the lookup.
    required: false
    type: int

offset:
    description: The resource index + 1 to begin at. For example, If 42 is passed, then
      resource 43 will be the first result returned.
    required: false
    type: int

resource:
    description: This is the resource to lookup. See pokeapi.co/docs/v2 for all possible
      values. Values include 'ability', 'berry', 'berry-firmness', 'berry-flavor', 'characteristic',
      'contest-effect', 'contest-type', 'egg-group', 'encounter-condition', 'encounter-condition-value',
      'encounter-method', 'evolution-chain', 'evolution-trigger', 'gender', 'generation',
      'growth-rate', 'item', 'item-attribute', 'item-category', 'item-fling-effect', 'item-pocket',
      'language', 'location', 'location-area', 'machine', 'move', 'move-ailment', 'move-battle-style',
      'move-category', 'move-damage-class', 'move-learn-method', 'move-target', 'nature',
      'pal-park-area', 'pokeathlon-stat', 'pokedex', 'pokemon', 'pokemon-color', 'pokemon-form',
      'pokemon-habitat', 'pokemon-shape', 'pokemon-species', 'region', 'stat', 'super-contest-effect',
      'type', 'version', 'version-group'
    required: true
    type: str

Outputs

limit:
  description: The limit that was passed into the module
  returned: always
  sample: 42
  type: int
name:
  description: The name that was passed into the module
  returned: always
  sample: pikachu
  type: str | None
offset:
  description: The offset that was passed into the module
  returned: always
  sample: 100
  type: int
pokeapi_json:
  description: The JSON returned by the lookup to pokeapi.co/v2
  returned: always
  sample:
    count: 64
    next: https://pokeapi.co/api/v2/berry?offset=1&limit=1
    previous: null
    results:
    - name: cheri
      url: https://pokeapi.co/api/v2/berry/1/
  type: dict
resource:
  description: The resource that was passed into the module
  returned: always
  sample: pokemon
  type: str
status_code:
  description: The HTTP status code returned by the lookup to pokeapi.co/v2
  returned: always
  sample: '200'
  type: str