Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add the missing documentation #92

Merged
merged 1 commit into from
Jan 2, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 61 additions & 2 deletions plugins/filter/subkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,67 @@
import subprocess
import json

DOCUMENTATION = '''
name: subkey_inspect
author: Parity Technologies
version_added: "1.10.8"
short_description: Inspects crypto keys using the Subkey utility
description:
- Filter that runs the Subkey inspect command to analyze cryptographic keys
- Supports various networks and schemes
- Can output public key information
- Returns JSON formatted data about the key
options:
uri:
description: The URI or key to inspect
type: str
required: true
network:
description: The network to use for the inspection
type: str
required: false
default: ''
scheme:
description: The cryptographic scheme to use
type: str
required: false
default: ''
public:
description: Whether to only show public key information
type: bool
required: false
default: false
'''

EXAMPLES = '''
# Basic key inspection
- debug:
msg: "{{ 'key_uri' | subkey_inspect }}"

# Inspect with specific network
- debug:
msg: "{{ 'key_uri' | subkey_inspect(network='kusama') }}"

# Inspect with specific scheme and show only public info
- debug:
msg: "{{ 'key_uri' | subkey_inspect(scheme='sr25519', public=true) }}"
'''

RETURN = '''
ss58:
description: The SS58 address of the key
type: str
sample: "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY"
public_key:
description: The public key in hex format
type: str
sample: "0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d"
account_id:
description: The account ID
type: str
sample: "d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d"
'''


def subkey_inspect(uri, network='', scheme='', public=False):
"""Run subkey inspect command and return output."""
Expand Down Expand Up @@ -55,5 +116,3 @@ def filters(self):
return {
'subkey_inspect': subkey_inspect
}