Skip to content

Instantly share code, notes, and snippets.

View chamilad's full-sized avatar
💭
I may be slow to respond.

Chamila chamilad

💭
I may be slow to respond.
View GitHub Profile
@chamilad
chamilad / filebeat.yml
Created September 21, 2019 05:48
Minimal Filebeat Config for K8s
filebeat.inputs:
- type: container
paths:
- /var/log/containers/*.log
processors:
- add_kubernetes_metadata:
in_cluster: true
processors:
- add_cloud_metadata:
- add_host_metadata:

Keybase proof

I hereby claim:

  • I am chamilad on github.
  • I am chamilad (https://keybase.io/chamilad) on keybase.
  • I have a public key whose fingerprint is 513A 5B38 48E5 5AE1 F32C 70D4 472C C780 0BD9 E991

To claim this, I am signing this object:

@chamilad
chamilad / wso2_filebeat.yml
Created November 28, 2018 08:25
How to point FileBeat to read WSO2 log files
filebeat.prospectors:
- input_type: log
paths:
- /mnt/wso2am-2.6.0/repository/logs/*.log
output.logstash:
hosts: ["logstash.private.deployment.local:5044"]
@chamilad
chamilad / propagate_apis.py
Created November 25, 2018 03:12
Upsert APIs from dev1 to dev2 environments
# 1. Get list of APIs from env1
print "Getting the list of APIs from ENV1..."
all_apis_in_env1 = api_utils.get_all_apis(env1_apimgt_url, env1_access_token, verify_ssl)
#...
#...
#...
# 2. Iterate through APIs and check if exists in env2
print "Checking for API status in ENV2..."
@chamilad
chamilad / make_rest_calls.py
Last active November 25, 2018 02:52
Figure out upsert logic
# If there is no matching API, an API create request is done.
# If a matching API is there, but no matching version, a version would be added
# If both a matching API with a matching version exists, the API would not be created.
for api_request in request_json_content["apis"]:
api_name_exists, api_id = api_utils.api_name_exists(api_request["name"], apimgt_url, access_token,
verify_ssl)
if api_name_exists:
# Check if the same version exists
api_version_exists, _ = api_utils.api_version_exists(api_request["name"], api_request["version"],
@chamilad
chamilad / load_requests.py
Created November 25, 2018 02:43
Parse files containing JSON requests
for api_request_file in glob.glob("api_definitions/*_apis.json"):
request_json_content = json.loads(open(api_request_file).read())
requesting_user = request_json_content["username"]
print "Parsing create requests for [user] %s [department] %s [requests] %s..." % (
requesting_user, request_json_content["department"], len(request_json_content["apis"]))
@chamilad
chamilad / apim_cicd_req-schema.json
Created November 25, 2018 01:59
The JSON Schema for a sample request format for an API CI/CD story
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"username": {
"type": "string"
},
"department": {
"type": "string"
},
@chamilad
chamilad / apim_cicd_req.json
Created November 25, 2018 01:58
Sample request format for an API CI/CD story
{
"username": "Username of the user",
"department": "Department of the user",
"apis": [
{
"name": "SampleAPI_dev1",
"description": "Sample API description",
"context": "/api/dev1/sample",
"version": "v1"
}
#!/bin/bash
# loop, read last line for the input values
while read line; do
# read values from the line delimitted by `|`
consumer_key=$(echo $line | cut -d '|' -f1)
username=$(echo $line | cut -d '|' -f2)
appname=$(echo $line | cut -d '|' -f3)
# get all the access tokens for the consumer key
#!/bin/bash
prev_consumer_key=""
prev_access_token=""
prev_username=""
prev_appname=""
total_count=0
# start looping