Skip to content

Instantly share code, notes, and snippets.

@jamesallman
jamesallman / gpc-example.sh
Last active December 9, 2019 14:45
Example FortiManager API
#!/bin/sh
user=username
pass=password
url=https://172.31.255.100/jsonrpc
id=0
# $1 method
# $2 url
# $3 data
import sys
from pprint import pprint
import requests
class FGT(object):
"""
Base class to provide access to FGT APIs:
. Monitor API

Keybase proof

I hereby claim:

  • I am jamesallman on github.
  • I am jamesallman (https://keybase.io/jamesallman) on keybase.
  • I have a public key ASB1yy6kPakerH41aWfXEJWSS-DoTP4Tz3AVGUKGfxiQPQo

To claim this, I am signing this object:

@jamesallman
jamesallman / Script.ps1
Created November 28, 2017 19:58
PowerShell FortiManager API Examples
#
# Script.ps1
#
function SpeedDial($speedDial)
{
if ($speedDial -match "\d+\.\d+\.\d+\.\d+") { return $speedDial }
if($speedDial -le 255){
$ipLayout = "192.168.",$speedDial,"." -join ""
}else{
@jamesallman
jamesallman / csv.groovy
Created August 11, 2016 18:37
Groovy csv reader
@Grab('org.apache.commons:commons-csv:1.3')
import org.apache.commons.csv.*
def reader = new FileReader("filename.csv")
def records = CSVFormat.DEFAULT.withFirstRecordAsHeader().withIgnoreHeaderCase(true).parse(reader)
records.each {
def field = it.get("field")
}
from optparse import OptionParser
import re
import requests
__author__ = 'jamesallman'
__version__ = '1.0.0'
class FG(object):
class LoginError(Exception):
#!/usr/bin/env python
import requests, sys, re
from time import sleep
class LoginError(Exception):
pass
#!/usr/bin/perl
use strict;
use warnings;
my %HoH;
my %portgroups;
while (<>) {
next unless $. > 1;
chomp;
#!/usr/bin/perl
use strict;
use warnings;
my %address;
my %service;
while (<>) {
next unless $. > 1;
chomp;
#!/usr/bin/perl
use strict;
use warnings;
my %HoH;
while (<>) {
next unless $. > 1;
chomp;
my @csv = split(/,/);