How to add an inventory host to specific group using ansible tower API? So that it will display on related groups list on UI - ansible-tower

I am unable to assign a host to group in ansible tower inventory using rest API's. Any one have worked on it please let me know the request with body.

I found a solution. For me, the problem was that I was searching in api/v2/inventories/{id}/groups/; turns out you actually have to look in api/v2/groups/{id}/hosts/.
Add host to inventory group
URI: {your host}/api/v2/groups/{id}/hosts/
Method: POST
Payload:
{
"name": "{hostname}",
"description": "",
"enabled": true,
"instance_id": "",
"variables": ""
}
This will create a host in the specified group.
In AWX and Ansible Tower, you can navigate to the url in your browser, then you can scroll all the way down, and if you can do a POST, there'll be a form there that has the payload. You can fill it in and post it right there in the browser.
When you are at the inventory group in the normal GUI, you can find the id of the inventory group in the URL.

Related

Create a Sharepoint list in a specific folder with Microsoft graph api

Premise:
I have a folder under the sharepoint site for e.g.
https://... <mycompany-sharepoint-site.com>/
under which we have folder so my url is something like
https://... <mycompany-sharepoint-site.com>/Documents/Sub_folder_1/Sub_folder_2
pertaining to our project.
I need to be able to create a Sharepoint list in the Sub_folder_2 - folder and not at the root level.
With Sharepoint - GraphApi - create list api url
POST https://graph.microsoft.com/v1.0/sites/{site-id}/lists
I will ONLY be able to create at the <mycompany-sharepoint-site.com> level (i.e. at the root level) which is not what I want.
FYI, I already tried (on Postman) to go with the drives//items/<folder_id> - route or I should say attempted to do so but failed.
Any help is greatly appreciated.
If you want to use Graph API to create a folder in SharePoint, please use the following query:
POST /groups/{group-id}/drive/items/{parent-item-id}/children
For more information: https://learn.microsoft.com/en-us/graph/api/driveitem-post-children?view=graph-rest-1.0&tabs=http#http-request
Hope this is helpful.
I don't think that SharePoint supports creating a list inside the folder but you can at least try to create a list and specify the path in the parent reference.
You need to find out the drive id.
POST https://graph.microsoft.com/v1.0/sites/{site_id}/lists
{
"displayName": "Test",
"columns": [
{
"name": "Column1",
"text": {}
},
{
"name": "Column2",
"number": {}
}
],
"list": {
"template": "genericList"
},
"parentReference": {
"driveType": "documentLibrary",
"driveId": "{drive_id}",
"path": "/drives/{drive_id}/root:/Documents/Sub_folder_1/Sub_folder_2"
# or
# "path": "/drives/{drive_id}/root:/Sub_folder_1/Sub_folder_2"
}
}
I don't think it's even possible at all, did you succeed that manually?

Get proper usernames to populate on Superset with Azure SSO instead of ID string

I've finally gotten Azure Single Sign-On (SSO) connected to Apache Superset running via docker-compose, following the Flask docs. Users in my company's Azure group can create and access Superset accounts by logging in with Azure and they are assigned roles based on their identity. This is good.
The usernames they get assigned, however, are long Azure ID strings. These are undesirable in displays. Here's what my account looks like on the List Users screen and on my profile:
How can I modify either my Azure application SSO setup or my Superset config to have Superset populate usernames like SFirke for the account usernames, instead of values like 3ee660ff-a274 ... ?
The security part of my config.py looks like this, almost identical to the Flask template:
OAUTH_PROVIDERS = [
{
"name": "azure",
"icon": "fa-windows",
"token_key": "access_token",
"remote_app": {
"client_id": "CLIENT_ID",
"client_secret": "CLIENT_SECRET",
"api_base_url": "https://login.microsoftonline.com/TENANT_ID/oauth2",
"client_kwargs": {
"scope": "User.read name preferred_username email profile upn groups",
"resource": "RESOURCE_ID",
},
"request_token_url": None,
"access_token_url": "https://login.microsoftonline.com/TENANT_ID/oauth2/token",
"authorize_url": "https://login.microsoftonline.com/TENANT_ID/oauth2/authorize",
},
},
]
EDIT: Looks like the way to go is writing a custom userinfo retrieval method, there's a template on the Flask page linked above and an example used for Superset in this Github comment. I think I would use a line like "id": me["preferred_username"] or "id": me["upn"], based on the field names in the Microsoft docs.
But Microsoft notes that this value can change over time and should not be used for authorization changes. Since the oid value is immutable, and it is hardly visible to the typical user, I plan to just stick to it.

AWS-Console: DynamoDB scan on nested field

I have below table in DynamoDB
{
"id": 1,
"user": {
"age": "26",
"email": "testuser#gmail.com",
"name": "test user"
}
}
Using AWS console, I want to scan all the records whose email address contains gmail.com
I am trying this but it is giving no results.
I am new to AWS, not sure what's wrong here. Is it not possible to scan on nested fields?
I've been trying to figure this out myself but it would seem that nested item scans are not supported through the console.
I'm going based off of this which offer some alternative options via CLI or SDK: https://forums.aws.amazon.com/thread.jspa?messageID=931016

Upload photos to Facebook Sales group album with graph API, using the Source field and not URL

Is there a way to create an album to the SALES groups in Facebook ? when I use the graph API explorer to fetch the user's groups it only brings back the user groups and not the sales groups he / she is part of
Command I used is get > v2.7 > me/groups and it returns
{
"data": [
{
"name": "Shadow Creek Columbus Indiana",
"privacy": "SECRET",
"id": "647651662006143"
}
],
"paging": {
"cursors": {
"before": "NjQ3NjUxNjYyMDA2MTQz",
"after": "NjQ3NjUxNjYyMDA2MTQz"
}
}
}
My second question is, if I were to create an album in the above group and add photos to it using the URL I am able to, however I have a phonegap app and that would be loading the images from the local and not from web, so I need to use the Source field instead of URL. However I am not able to test the same using the explorer. What value should I specify in the Source field ?

I can't read from group wall

I can read users feeds or posts
https://developers.facebook.com/tools/explorer?method=GET&path=me%2Fposts
but when I try to reach a groups feed or posts, I can't. I added auth part but it returns empty JSON. From the groups I tried, one was closed and 2 other are open groups.
https://graph.facebook.com/228955270470492
The above returns this:
{
"id": "228955270470492",
...
"name": "ADI BİLİM",
"privacy": "OPEN",
...
}
Requesting this feed
https://graph.facebook.com/228955270470492/feed?access_token=AAACEdEose0cBAACgceqTZCBg0YA7MifDP02MKVXpZCipHJNHmHqK5OTzDvJaNke2JDxhOxKOTFl6bPOoZCZAdUZAQFFV6lD8GCMTxQHigUQZDZD
results in empty:
{
"data": [
]
}
What I am doing wrong?
This is working fine for me, is your access token for a user who's a member of the group?
If not, the group needs to have visiblity OPEN. You may also need user_groups permission for the user, but I'm guessing you already have that if you're accessing the user's list of groups
Even this group is public I need to auth app "read_stream" from extended permissions. Now I can see feeds :)