I am following this documentation:
https://docs.github.com/en/rest/reference/actions#list-repository-workflows
/repos/{owner}/{repo}/actions/workflows
My sample output looks like this:
{
"total_count": 1,
"workflows": [
{
"id": 161335,
"node_id": "MDg6V29ya2Zsb3cxNjEzMzU=",
"name": "CI",
"path": ".github/workflows/blank.yaml",
"state": "active",
"created_at": "2020-01-08T23:48:37.000-08:00",
"updated_at": "2020-01-08T23:50:21.000-08:00",
"url": "https://api.github.com/repos/octo-org/octo-repo/actions/workflows/161335",
"html_url": "https://github.com/octo-org/octo-repo/blob/master/.github/workflows/161335",
"badge_url": "https://github.com/octo-org/octo-repo/workflows/CI/badge.svg"
}
]
}
How do I fetch the workflow yaml file from this output
Given the filename, use the Get repository content API to fetch the file.
For your file, that'd be:
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/octo-org/octo-repo/contents/.github/workflows/blank.yaml
The response JSON will contain a field content, which contains the encoded contents of that workflow.
Workflow yaml file in plain text:
curl \
-H "Accept: application/vnd.github.v3+json" \
https://raw.githubusercontent.com/octo-org/octo-repo/master/.github/workflows/blank.yaml
Related
I am having trouble using Clockify's REST API to filter a detailed report for single project.
Filter Section (see below) of the relevant documentation shows:
"projects": null,
My first question is what "null" means in this context? Does it mean that one cannot use this field?
// FILTERS (OPTIONAL)
"users": {
"ids": ["45fd36c4b0798777049512e2"],
"contains": "CONTAINS",
"status": "ALL"
},
"invoicingState": "ALL",
"approvalState": "ALL",
"userGroups": null,
"clients": null,
--> "projects": null,
"tasks": null,
"tags": {
"ids": ["45fd36c4b0798777049512e2"],
"containedInTimeentry": "DOES_NOT_CONTAIN",
"status": "ALL"
},
An attempt to filter by "project id" or "project name" (below)
curl --request POST \
--url https://reports.api.clockify.me/v1/workspaces/workspace_id/reports/detailed \
--header 'content-type: application/json' \
--header 'X-Api-Key: xxxxxxxxxxxxxxxxxxxxxx' \
--data-raw '{
"dateRangeStart": "2022-06-01T00:00:00.000Z", \
"dateRangeEnd": "2022-10-31T23:59:59.999Z",\
"detailedFilter": { \
"page": 1, \
"pageSize": 50
}, \
----> projects": {["id": ["project_id"]}, \
or
----> projects": {["name": ["project_name"]}, \
"tags": {"ids": ["tag_id"]},
"exportType": "CSV"
}'
returns an empty report (header line only).
"Project","Client","Description","Task","User","Group","Email","Tags","Billable","Start Date","Start Time","End Date","End Time","Duration (h)","Duration (decimal)","Billable Rate (AUD)","Billable Amount (AUD)"
Removing line
"projects": {["id": ["project_id"]},
or replacing the above with:
"projects": null,
or
"non_exiting_key": null,
returns a detailed report for all projects. This tells me that "filtering for project" kind of works and I am not using a correct semantics.
Can anyone see where the problem may be?
Thank you in advance!
I am trying to patch the node condition type status, for example can I turn/replace the Whatever Node Condition type status from false to true and vice versa?
Edit: When I try to patch I am not getting any errors by yet not being updated.
Using Curl - I was able to update:
curl -k -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json-patch+json" -X PATCH APIserver:6443/api/v1/nodes/<node-name>/status --data '[{ "op": "replace", "path": "/status/conditions/-","value": { "type": "WhateverName", "status": "False" }}]'
Patch Example (not working):
oc patch node/<Node-Name> --type='json' -p '[{ "op": "replace", "path": "/status/conditions/0","value": { "type": "QuayState", "status": "True" }}]'
It's not giving errors but it's not changing anything, I am getting this output:
node/<nodeName> patched (no change)
I am new to API's. I have created an API using curl command:
curl --request POST \
--url https://api.sendgrid.com/v3/mail/send \
--header 'Authorization: Bearer <<YOUR_API_KEY>>' \
--header 'Content-Type: application/json' \
--data '{"personalizations":[{"to":[{"email":"john.doe#example.com","name":"John Doe"}],"subject":"Hello, World!"}],"content": [{"type": "text/plain", "value": "Heya!"}],"from":{"email":"sam.smith#example.com","name":"Sam Smith"},"reply_to":{"email":"sam.smith#example.com","name":"Sam Smith"}}'
It worked perfectly for me and it sent out the email.
I was wondering, how do I send an email body with html tags and images. Sorry if this is a basic question and asking here.
In your data that you are sending to the API, you have
"content": [{"type": "text/plain", "value": "Heya!"}]
This is sending your plain text email. To add HTML to this you can add another object to that array with the "type": "text/html".
"content": [{"type": "text/plain", "value": "Heya!"}, { "type": "text/html", value: "<h1>Heya!</h1>" }]
Sending images requires you to base 64 encode the contents of the image and add it to the "attachments" key within the JSON data, along with the filename, content type and content ID if you want to use it for embedding in the email.
"content": [ ... ], "attachments": [{ "content": BASE64_ENCODED_STRING, "type": "image/jpeg", "filename": "catsinhats.jpeg" }]
This blog post has more specifically on how to embed images in emails.
I'm using the latest version of Rundeck (3.3.10) and I'm having trouble getting the latest execution for a job via the Rest API.
If I call api/38/job//executions?max=1 it doesn't seem to bring back the latest execution if it is still running. Ideally, I'd also like to be able get the latest execution Start Time, End Time, User and result for each job in a single API call, but I'd resigned myself to calling the API once per job. There doesn't seem to be any way to sort the executions you get back from the API - they seem to be sorted by status first, so the running jobs appear at the end of the list.
Does anyone know a way around this? Thanks.
Yo can get that information using: executions?status=running&max=1 call.
Script example:
#!/bin/sh
# protocol
protocol="http"
# basic rundeck info
rdeck_host="localhost"
rdeck_port="4440"
rdeck_api="38"
rdeck_token="YRVaZikt64Am85RyLo1nyq8U1Oe4Q8J7 "
# specific api call info
rdeck_job="03f28add-84f2-4013-b8f5-e48feaf5977c"
# api call
curl --location --request GET "$protocol://$rdeck_host:$rdeck_port/api/$rdeck_api/job/$rdeck_job/executions?status=running&max=1" \
--header "Accept: application/json" \
--header "X-Rundeck-Auth-Token: $rdeck_token" \
--header "Content-Type: application/json"
Output:
{
"paging": {
"count": 1,
"total": 1,
"offset": 0,
"max": 1
},
"executions": [
{
"id": 7,
"href": "http://localhost:4440/api/38/execution/7",
"permalink": "http://localhost:4440/project/ProjectEXAMPLE/execution/show/7",
"status": "running",
"project": "ProjectEXAMPLE",
"executionType": "user",
"user": "admin",
"date-started": {
"unixtime": 1617304896289,
"date": "2021-04-01T19:21:36Z"
},
"job": {
"id": "03f28add-84f2-4013-b8f5-e48feaf5977c",
"averageDuration": 13796,
"name": "HelloWorld",
"group": "",
"project": "ProjectEXAMPLE",
"description": "",
"href": "http://localhost:4440/api/38/job/03f28add-84f2-4013-b8f5-e48feaf5977c",
"permalink": "http://localhost:4440/project/ProjectEXAMPLE/job/show/03f28add-84f2-4013-b8f5-e48feaf5977c"
},
"description": "sleep 20; echo \"hi\"",
"argstring": null,
"serverUUID": "630be43c-e71f-4102-be96-d017dd22233e"
}
]
}
I'm trying to use Orion notification to send SMS with Plivo.
This is how I send an SMS directly with Plivo:
curl -X POST https://api.plivo.com/v1/Account/MAMDA5ZDJIMDM1/Message/ -L -u MAMDA5ZDJIM:YzhiNDJjODNhNDkxMjhiYTgxZD -H 'Content-Type: application/json' -d #- <<EOF
{
"src": "0039414141414",
"dst": "0039414747111",
"text": "test SMS"
}
EOF
How should I encode it in Orion? I tried:
curl localhost:1026/v2/subscriptions -s -S --header 'Content-Type: application/json' --header 'Accept: application/json' -d #- <<EOF
{
"description": "A subscription to get info about WS_UPPA_Sensor2",
"subject": {
"entities": [
{
"id": "Sensor1",
"type": "SensingDevice"
}
],
"condition": {
"attrs": [
"temperature"
]
}
},
"notification": {
"httpCustom": {
"url": "https://api.plivo.com/v1/Account/MAMDA5ZDJIMDM1NZVMZD/Message/",
"headers": {
"Authorization": "Basic TUFNREE1WkRKSU1ETTFOWlZNWkQ6WXpoaU5ESmpPRE5oTkRreE1qaGlZVGd4WkRkaE5qYzNPV1ZsTnpZMA=="
},
"payload": "{%22src%22%3A%2200393806412092%22%2C%22dst%22%3A%2200393806412093%22%2C%22text%22%3A%22test%20SMS%20from%20Waziup%22}"
},
"attrs": [
"temperature"
]
},
"expires": "2040-01-01T14:00:00.00Z",
"throttling": 5
}
EOF
Is there another way than percent encoding?
URL encoding (I understand is the one you refer by "percent encoding") is the only one which have an special treatment in custom notifications (details described as part of the Orion documentation).
In fact, taking into account the existing one is complete (I mean, any text can be expressed in the terms of URL encoding) there is no need of adding any other.