Can't get cn from Policy Response of OpenAM - openam

All.
I’m trying to config OpenAM, J2EEAgent and OpenIG. I want to get cn when I get Policy Response of OpenAM. so I config com.sun.identity.agents.config.response.attribute.fetch.mode
= HTTP_HEADER. However I can’t get cn in the Policy Response.
I have two questions.
1, How do I configure to get cn in the Policy Response?
2, I search uid(OpenIG managed) from cn using SqlAttributesFilter
when OpenIG get the Policy Response. I made config.json of OpenIG. Please check it.
{
"_comment" : "Sample OpenIG config for form login.",
"heap":[
{
"name":"DispatchHandler",
"type":"DispatchHandler",
"config":{
"bindings":[
{
"condition": "${matches(exchange.request.uri.path,'^/openig') != null}",
"handler":"LoginChain"
},
{
"handler":"OutgoingChain"
}
],
"baseURI":"http://test.co.jp:7070/"
}
},
{
"name":"LoginChain",
"type":"Chain",
"config":{
"filters":["SqlAttributesFilter"],
"handler":"LoginRedirectHandler"
}
},
{
"name": "SqlAttributesFilter",
"type": "SqlAttributesFilter",
"config": {
"dataSource": "java:comp/env/jdbc/postgresql",
"preparedStatement":
"SELECT uid
FROM user_table WHERE cn = ?;",
"parameters": [
"${exchange.request.headers['cn'][0]}"
],
"target" : "${exchange.credentials}"
}
},
{
"name":"LoginRedirectHandler",
"type":"StaticResponseHandler",
"config":{
"status":302,
"reason":"Found",
"headers":{
"Location":[
"http://test.co.jp:5050/testsp/index.html?j_site=${exchange.credentials.site}&j_uid=${exchange.credentials.uid}"
],
"Cache-Control":["no-cache"],
"Pragma":["no-cache"]
}
}
},
{
"name":"OutgoingChain",
"type":"Chain",
"config":{
"filters":[
"CaptureFilter"
],
"handler":"ClientHandler"
}
},
{
"name":"ClientHandler",
"type":"ClientHandler",
"config":{
}
},
{
"name":"CaptureFilter",
"type":"CaptureFilter",
"config":{
"captureEntity":true,
"file":"/home/test/.openig/config/gateway.log"
}
},
{
"name":"LogSink",
"comment":"Default sink for logging information.",
"type":"ConsoleLogSink",
"config":{
"level":"DEBUG"
}
}
],
"handler": "DispatchHandler"
}
Please give me your help.
Regard.

1) by modifying the policy that suppose to match your protected resource, and adding "cn" to the list of attributes.
Alternatively you could just modify your agent configuration, so instead of using response attributes, you set up attribute mapping for profile attributes.

Related

Sap Commerce Cloud cannot generate build with custom addon

I've installed in my local environment customgigyaaddon (an extended version of gigyaloginaddon), injected in my customstorefront and added to localextensions.xml and compiled without any problems, however, when I try to generate a build of this same version in sap commerce cloud, it throws me the following exception :
/opt/workspace/build/commerce-
suite/hybris/bin/platform/resources/ant/antmacros.xml:587:
java.lang.IllegalArgumentException: cannot merge namespace ((customgigyaaddon)) into
((<merged>)) due to duplicate type code 'gigyaconfig2cmssite' : GigyaConfig2CMSSite::
((customgigyaaddon))::YRelation[customgigyaaddon-items.xml:14(RelationTypeTagListener)]
<>GigyaConfig2CMSSite::((gigyaservices))::YRelation[gigyaservices-
items.xml:65(RelationTypeTagListener)]
My localextensions-cloud.xml is exactly the same as my localextensions.xml and in the manifest.json I've declared the addon injection as follows:
{
"commerceSuiteVersion":"2105",
"enableImageProcessingService": true,
"extensionPacks" : [
{
"name" : "hybris-commerce-integrations",
"version" : "2108.2"
}
],
"extensions":[
"sapymktcommon",
"sapymktclickstream",
"sapymktrecommendation",
"sapymktrecommendationbuffer",
"sapymktrecommendationwebservices",
"cloudmediaconversion",
"mediaconversionbackoffice",
"sapymktsegmentation",
"sapymktsegmentationb2b",
"sapymktsegmentationwebservices",
"personalizationymkt",
"integrationbackoffice",
"outboundsyncbackoffice",
"sapymktdatareplication",
"assistedservicestorefront"
],
"useConfig":{
"properties":[
{
"location":"config/local-dev.properties",
"persona":"development"
},
{
"location":"config/local-stag.properties",
"persona":"staging"
},
{
"location":"config/local-prd.properties",
"persona":"production"
}
],
"extensions":{
"location":"/config/localextensions-cloud.xml"
},
"solr":{
"location":"customSolr"
}
},
"storefrontAddons":[
{
"addons":["commerceorgsamplesaddon","smarteditaddon","textfieldconfiguratortemplateaddon","customerticketingaddon","orderselfserviceaddon","consignmenttrackingaddon","marketplaceaddon","notificationaddon","customerinterestsaddon","stocknotificationaddon","customaddon","configurablebundleaddon","sapymktrecommendationaddon"],
"storefronts":["customstorefront"],
"template":"yacceleratorstorefront"
},
{
"addons":["customgigyaaddon"],
"storefronts":["customstorefront"],
"template":"yacceleratorstorefront"
}
],
"aspects":[
{
"name":"backoffice",
"webapps":[
{
"name":"mediaweb",
"contextPath":"/medias"
},
{
"name":"backoffice",
"contextPath":"/backoffice"
},
{
"name":"hac",
"contextPath":"/hac"
},
{
"name":"dathubadapter",
"contextPath":"/datahubadapter"
},
{
"name":"oauth2",
"contextPath":"/authorizationserver"
},
{
"name": "customstorefront",
"contextPath": "/valet"
}
{
"name": "personalizationsmartedit",
"contextPath": "/personalizationsmartedit"
},
{
"name": "personalizationpromotionssmartedit",
"contextPath": "/personalizationpromotionssmartedit"
},
{
"name": "personalizationwebservices",
"contextPath": "/personalizationwebservices"
},
{
"name": "personalizationsearchsmartedit",
"contextPath": "/personalizationsearchsmartedit"
},
{
"name":"previewwebservices",
"contextPath":"/previewwebservices"
},
{
"name":"permissionswebservices",
"contextPath":"/permissionswebservices"
},
{
"name":"ycommercewebservices",
"contextPath":"/rest"
}
]
}
],
"webapps":[
{
"name":"customstorefront",
"contextPath":"/custom"
}
]
},
{
"name":"backgroundProcessing",
"properties":[
{
"key":"cluster.node.groups",
"value":"integration,yHotfolderCandidate"
}
],
"webapps":[
{
"name":"hac",
"contextPath":"/hac"
},
{
"name":"mediaweb",
"contextPath":"/medias"
}
]
}
]
}
],
"properties": [
{
"key":"configFile",
"value":"/opt/hybris/bin/custom/resources/update-config.json"
}
]
}
Looking the exception it looks like there is already an relation gigyaconfig2cmssite declared in gigyaservices-items.xml, however this is not true since this specific relation is only declared in customgigyaservices-items.xml.
Am I missing something? I feel really lost
if you analyzed the issue as follows:customgigyaaddon-items.xml and gigyaservices-items.xml, both contain the entry.
Otherwise, have you tried to ant clean all the platform? Also, set generate and auto-create as false and removed the extends.

uploading files - nodejs with typescript and tsoa and swagger

I build a web api with nodejs and express. I used tsoa to generate my routes and a swagger.json file.
I want to be able to upload files via the swagger landing page. I followed the instructions on this page: https://tsoa-community.github.io/docs/file-upload.html
My tsoa.json looks like this:
{
"entryFile": "src/app.ts",
"noImplicitAdditionalProperties": "throw-on-extras",
"controllerPathGlobs": [
"src/**/*.controller.ts"
],
"spec": {
"basePath" : "/",
"description": "",
"outputDirectory": "dist/api/public",
"specVersion": 3,
"specMerging": "recursive",
"paths": {
"/admin/commands/create": {
"post": {
"consumes": [
"multipart/form-data"
],
"parameters": [
{
"in": "formData",
"name": "randomFileIsHere",
"required": true,
"type": "file"
}
]
}
}
}
},
"routes": {
"routesDir": "src/api"
}
}
My controller:
#Tags("Admin Commands")
#Route("admin/commands")
export class AdminCommandController extends Controller
{
#Post('create')
public async CreateCommand(#Request() request: express.Request): Promise<void>
{
try{
await this.handleFile(request);
}
catch {
throw new Error("Error uploading file.");
}
console.log("No error");
}
private handleFile(request: express.Request): Promise<any> {
const multerSingle = multer().single("randomFileIsHere");
return new Promise((resolve, reject) => {
multerSingle(request, undefined, async (error: Error) => {
if (error) {
reject("error");
}
resolve("file will be in request.randomFileIsHere");
});
});
}
}
but when I use the tsoa swagger command to generate the the swagger.json the multipart/form-data is not added to my swagger.json. If I manually add the multipart/form-data to my swagger.json the input field on my swagger landing page is a text field instead of a file field.
"paths": {
"/admin/commands/create": {
"post": {
"operationId": "CreateCommand",
"consumes": [
"multipart/form-data"
],
"parameters": [
{
"in": "formData",
"name": "randomFileIsHere",
"required": true,
"type": "file"
}
],
"responses": {
"204": {
"description": "No content"
}
},
"tags": [
"Admin Commands"
],
"security": []
}
}
}
What am I missing or doing wrong? Furthermore, if this would work, how do i extract the file from the request. The documentation says the file will be added to the randomFileIsHere property of the request object, but if i call request.randomFileIsHere it will obviously throw an error.
I also tried to follow official documents. I was able to save the uploaded file, but codes didnt looked clean to me. Then I realised there is a #UploadedFile decorator. You can add it and read file directly.
#Post("profile-photo")
public async uploadProfilePhoto(#UploadedFile() profilePhoto) {
console.log(profilePhoto)
}
Using a HTTP testing tool ,like Postman, define a field named "profilePhoto" and select a file. You should be able to see it on server terminal.
I think that you can do something like that:
import fs from 'fs';
#Post("profile-photo")
public async uploadProfilePhoto(#UploadedFile('formInputNameForPhoto') profilePhoto) {
fs.writeFileSync('./photo', profilePhoto.buffer);
}
Here is the answer which helped me understand how can I save "ready" multer file object.

How to get Session Entities to work as part of Dialogflow detect intent

I have an Entity that is supposed to be updated on a per-session basis with user-specific information. This had worked when I was using Dialogflow v1, and I thought it had worked with v2, but I'm now having significant problems with it.
I believe I am setting the Session Entity information correctly, but for the Intent that uses it, it only matches when a value from the Developer Entity is used.
How can I get it to use the Session Entity? Am I doing something wrong when updating it? Am I using the wrong Session ID? Is there a way I can better verify or test that I'm using the correct ID or that I'm updating the Entity correctly? Is this just a bug?
Documentation of everything follows.
The project is configured to use v2 and to allow for beta features, although I've tried this without the beta features as well.
There are only three Intents. A Fallback Intent to capture failures, a Welcome Intent that gets the welcome event, and the "entry" intent that is supposed to capture the entry code which should match the "code" Entity. All of them use a webhook for fulfillment.
The Fallback Intent
The Welcome Intent
The "entry" Intent
As shown in the "entry" Intent, it uses the "code" Entity, which is the only Developer Entity in the system
The code has most of the Dialogflow specific work in a separate module that uses the "dialogflow" module from npm to set the Session Entity. (Note this is different than the dialogflow-fulfillment module, which is used to handle fulfillment. I'm using the multivocal library for fulfillment, but that shouldn't matter.) (It also uses firebase functions to run on, but I don't think any of these are relevant.)
From the package.json:
"dependencies": {
"dialogflow": "^0.9.0",
"firebase-admin": "~7.0.0",
"firebase-functions": "^2.2.0",
"multivocal": "^0.11.1"
},
This is imported as dialogflow, specifying the API version to use:
const dialogflow = require('dialogflow').v2beta1;
The functions I show below call envToConfig(env) which takes the environment (a multivocal concept that just stores relevant information, including the Dialogflow parent and certificate information) and returns the configuration that needs to be passed to dialogflow.SessionEntityTypesClient( config ). Given no errors are thrown in further calls, it appears to work correctly.
The makeEntityType( name, entityMap ) function takes a map of values to be used for the entities in a SessionEntityType and returns an object that will be used to build a full SessionEntityType. The name provided here is the display name.
function makeEntityType( name, entityMap ){
let ret = {
displayName: name,
entities: []
};
Object.keys( entityMap ).map( key => {
let val = entityMap[key];
let entity = {
value: key,
synonyms: [key, ...val]
};
ret.entities.push( entity );
});
return ret;
}
exports.makeEntityType = makeEntityType;
The result from this is passed to setSessionEntity( env, entityType ) along with the multivocal environment, which contains some information we use in the session. It makes sure the name and entityOverrideMode are set correctly in the entityType and then tries to create it. I've tried using PATCH as well, and it behaves the same way. It also does a bunch of logging, that I'll show later when it runs to prove it actually works.
function setSessionEntity( env, entityType ){
const config = envToConfig( env );
const client = new dialogflow.SessionEntityTypesClient( config );
let parent = env.dialogflow.parent;
if( entityType.displayName && !entityType.name ){
entityType.name = `${parent}/entityTypes/${entityType.displayName}`;
}
if( !entityType.entityOverrideMode ){
entityType.entityOverrideMode = 'ENTITY_OVERRIDE_MODE_OVERRIDE';
}
console.log('setSessionEntity parent',parent);
const request = {
parent: parent,
sessionEntityType: entityType
};
console.log('setSessionEntity request',JSON.stringify(request,null,1));
return client.createSessionEntityType( request )
.then( create => {
console.log('setSessionEntity created',JSON.stringify(create,null,1));
return Promise.resolve( env );
})
.catch( err => {
console.error('setSessionEntity problem creating',err);
return Promise.resolve( env );
})
}
exports.setSessionEntity = setSessionEntity;
For debugging, I also have a function that lists the session entities:
function listSessionEntities( env ){
let parent = env.dialogflow && env.dialogflow.parent;
console.log('listSessionEntities parent', parent);
if( !parent ){
return Promise.resolve( env );
}
const config = envToConfig( env );
const client = new dialogflow.SessionEntityTypesClient( config );
const request = {
parent: parent
};
return client.listSessionEntityTypes(request)
.then( result => {
console.log('listSessionEntities', JSON.stringify(result,null,1));
})
.catch( err => {
console.log('listSessionEntities err', err);
})
.then( () => Promise.resolve( env ) );
}
exports.listSessionEntities = listSessionEntities;
The code that calls this imports it as Dialogflow:
const Dialogflow = require('./dialogflow');
As part of all the webhook calls, the listSessionEntities() function is called before any specific handler is:
function debugSessionEntities( env ){
return Dialogflow.listSessionEntities( env );
}
When the Welcome Intent is triggered, it sets the "code" Session Entity to have two new types that should override the type that was defined in the "code" Developer Entity:
function handleWelcome( env ){
const entityType = Dialogflow.makeEntityType('code',{
'alpha': [],
'bravo': []
});
return Dialogflow.setSessionEntity( env, entityType )
.then( env => Multivocal.handleDefault( env ) );
}
When I run this through the simulator, it doesn't pick up on the Session Entity Types that are set, but do still respond to the Developer Entity Type. (Using a real device works the same way.)
In the simulator, this is what it reports in the Request tab for the Welcome Intent:
{
"responseId": "55a9eb06-ce05-48f9-8a56-b993fa512aee",
"queryResult": {
"queryText": "GOOGLE_ASSISTANT_WELCOME",
"action": "multivocal.welcome",
"parameters": {},
"allRequiredParamsPresent": true,
"fulfillmentText": "Hello! How can I help you?",
"fulfillmentMessages": [
{
"text": {
"text": [
"Greetings! How can I assist?"
]
}
}
],
"outputContexts": [
{
"name": "projects/session-test-XXXXX/agent/sessions/ABwppHFGTpcFtHOOo6ehQfKys9AnH14V5-RhzrNKsea6y6L5zgv4eN-j3IesfuqSsKMc7qRt1CAOhkUYA9XXXXXX/contexts/google_assistant_welcome"
},
{
"name": "projects/session-test-XXXXX/agent/sessions/ABwppHFGTpcFtHOOo6ehQfKys9AnH14V5-RhzrNKsea6y6L5zgv4eN-j3IesfuqSsKMc7qRt1CAOhkUYA9XXXXXX/contexts/actions_capability_screen_output"
},
{
"name": "projects/session-test-XXXXX/agent/sessions/ABwppHFGTpcFtHOOo6ehQfKys9AnH14V5-RhzrNKsea6y6L5zgv4eN-j3IesfuqSsKMc7qRt1CAOhkUYA9XXXXXX/contexts/actions_capability_audio_output"
},
{
"name": "projects/session-test-XXXXX/agent/sessions/ABwppHFGTpcFtHOOo6ehQfKys9AnH14V5-RhzrNKsea6y6L5zgv4eN-j3IesfuqSsKMc7qRt1CAOhkUYA9XXXXXX/contexts/actions_capability_account_linking"
},
{
"name": "projects/session-test-XXXXX/agent/sessions/ABwppHFGTpcFtHOOo6ehQfKys9AnH14V5-RhzrNKsea6y6L5zgv4eN-j3IesfuqSsKMc7qRt1CAOhkUYA9XXXXXX/contexts/google_assistant_input_type_keyboard"
},
{
"name": "projects/session-test-XXXXX/agent/sessions/ABwppHFGTpcFtHOOo6ehQfKys9AnH14V5-RhzrNKsea6y6L5zgv4eN-j3IesfuqSsKMc7qRt1CAOhkUYA9XXXXXX/contexts/actions_capability_media_response_audio"
},
{
"name": "projects/session-test-XXXXX/agent/sessions/ABwppHFGTpcFtHOOo6ehQfKys9AnH14V5-RhzrNKsea6y6L5zgv4eN-j3IesfuqSsKMc7qRt1CAOhkUYA9XXXXXX/contexts/actions_capability_web_browser"
}
],
"intent": {
"name": "projects/session-test-XXXXX/agent/intents/ca79c951-4d75-4b2b-acd4-7dac2f81856e",
"displayName": "welcome"
},
"intentDetectionConfidence": 1,
"languageCode": "en-us"
},
"originalDetectIntentRequest": {
"source": "google",
"version": "2",
"payload": {
"isInSandbox": true,
"surface": {
"capabilities": [
{
"name": "actions.capability.SCREEN_OUTPUT"
},
{
"name": "actions.capability.ACCOUNT_LINKING"
},
{
"name": "actions.capability.AUDIO_OUTPUT"
},
{
"name": "actions.capability.MEDIA_RESPONSE_AUDIO"
},
{
"name": "actions.capability.WEB_BROWSER"
}
]
},
"requestType": "SIMULATOR",
"inputs": [
{
"rawInputs": [
{
"query": "Talk to my test app",
"inputType": "KEYBOARD"
}
],
"intent": "actions.intent.MAIN"
}
],
"user": {
"userStorage": "{\"UserId\":\"ABwppHHd40lIZ1o0bRERAKlHNtNcS2qFtz7NbRQnb31AQDFuV41VPFQivXwwpQGtv_5SlsZNp0N3kxalIIXXXXXX\",\"NumVisits\":1}",
"lastSeen": "2019-05-18T19:12:38Z",
"locale": "en-US",
"userId": "ABwppHHd40lIZ1o0bRERAKlHNtNcS2qFtz7NbRQnb31AQDFuV41VPFQivXwwpQGtv_5SlsZNp0N3kxalIIXXXXXX"
},
"conversation": {
"conversationId": "ABwppHFGTpcFtHOOo6ehQfKys9AnH14V5-RhzrNKsea6y6L5zgv4eN-j3IesfuqSsKMc7qRt1CAOhkUYA9XXXXXX",
"type": "NEW"
},
"availableSurfaces": [
{
"capabilities": [
{
"name": "actions.capability.AUDIO_OUTPUT"
},
{
"name": "actions.capability.WEB_BROWSER"
},
{
"name": "actions.capability.SCREEN_OUTPUT"
}
]
}
]
}
},
"session": "projects/session-test-XXXXX/agent/sessions/ABwppHFGTpcFtHOOo6ehQfKys9AnH14V5-RhzrNKsea6y6L5zgv4eN-j3IesfuqSsKMc7qRt1CAOhkUYA9XXXXXX"
}
Most notable from that is the session attribute set at the bottom from that. The code uses this as the parent and session values when building the
The request objects for the other two Intents are similar, and all have the same value for session. None of the response objects are notable in any way.
When the Welcome Intent is triggered, the call to listSessionEntities(), unsurprisingly, shows there aren't any yet:
info: listSessionEntities parent projects/session-test-XXXXX/agent/sessions/ABwppHFGTpcFtHOOo6ehQfKys9AnH14V5-RhzrNKsea6y6L5zgv4eN-j3IesfuqSsKMc7qRt1CAOhkUYA9XXXXXX
info: listSessionEntities [
[],
null,
null
]
The parent appears to have the correct value from the session however.
When the handler for the Welcome Intent goes and creates the Session Entity, things appear to work ok:
info: setSessionEntity request {
"parent": "projects/session-test-XXXXX/agent/sessions/ABwppHFGTpcFtHOOo6ehQfKys9AnH14V5-RhzrNKsea6y6L5zgv4eN-j3IesfuqSsKMc7qRt1CAOhkUYA9XXXXXX",
"sessionEntityType": {
"displayName": "code",
"entities": [
{
"value": "alpha",
"synonyms": [
"alpha"
]
},
{
"value": "bravo",
"synonyms": [
"bravo"
]
}
],
"name": "projects/session-test-XXXXX/agent/sessions/ABwppHFGTpcFtHOOo6ehQfKys9AnH14V5-RhzrNKsea6y6L5zgv4eN-j3IesfuqSsKMc7qRt1CAOhkUYA9XXXXXX/entityTypes/code",
"entityOverrideMode": "ENTITY_OVERRIDE_MODE_OVERRIDE"
}
}
info: setSessionEntity created [
{
"entities": [
{
"synonyms": [
"alpha"
],
"value": "alpha"
},
{
"synonyms": [
"bravo"
],
"value": "bravo"
}
],
"name": "projects/session-test-XXXXX/agent/sessions/ABwppHFGTpcFtHOOo6ehQfKys9AnH14V5-RhzrNKsea6y6L5zgv4eN-j3IesfuqSsKMc7qRt1CAOhkUYA9XXXXXX/entityTypes/code",
"entityOverrideMode": "ENTITY_OVERRIDE_MODE_OVERRIDE"
},
null,
null
]
The parent appears to be the same as the session, and the name appears to follow the correct format, including the additional part that has the "/entityTypes/" followed by the display name.
When I try calling it with the code "alpha", which should trigger the "entry" Intent, it instead triggers the Fallback Intent. The call to listSessionEntities() seems to show the "code" Entity with the Entity Types we expect, even tho there was no match for "alpha".
info: listSessionEntities parent projects/session-test-XXXXX/agent/sessions/ABwppHFGTpcFtHOOo6ehQfKys9AnH14V5-RhzrNKsea6y6L5zgv4eN-j3IesfuqSsKMc7qRt1CAOhkUYA9XXXXXX
info: listSessionEntities [
[
{
"entities": [
{
"synonyms": [
"alpha"
],
"value": "alpha"
},
{
"synonyms": [
"bravo"
],
"value": "bravo"
}
],
"name": "projects/session-test-XXXXX/agent/sessions/ABwppHFGTpcFtHOOo6ehQfKys9AnH14V5-RhzrNKsea6y6L5zgv4eN-j3IesfuqSsKMc7qRt1CAOhkUYA9XXXXXX/entityTypes/code",
"entityOverrideMode": "ENTITY_OVERRIDE_MODE_OVERRIDE"
}
],
null,
null
]
Again, everything looks correct. When I try it again with "zulu", it shows the same thing for the call to listSessionEntites(), but this time it matches the "entry" Intent, since "zulu" is one of the Entity Types for "code" that is defined as a Developer Entity.
This is where I am stuck. Everything looks correct. It looks like the Session Entity should be set correctly for this session. It looks like it should be using those values. But it never seems to do so.
What is going on? All help would be greatly appreciated. (Did you even read till the end of the question? If so - thank you! I know it's long, but wanted to be as complete as possible.)
This appears to be a bug - I've gotten feedback from other developers that they're seeing the same problem, sometimes on previously working code.
A bug has been opened at https://issuetracker.google.com/issues/133166381 to track the issue. Star it to indicate you have similar problems and to track progress.

How can we list all the branches in a repo using github graphQL api?

I am trying to check if a branch already exists in repo for that first I need to get all the open branches present.
query searhbranches {
repositoryOwner(login: "username"){
repository(name: "config-replica"){
name
[branches] // something like this but its not available
}
}
}
You want to look at the refs node inside repository. Here's an example query that works for me:
{
repository(owner: "desktop", name: "desktop") {
refs(first: 50, refPrefix:"refs/heads/") {
nodes {
name
}
}
}
}
This is what it returns:
{
"data": {
"repository": {
"refs": {
"nodes": [
{
"name": "add-lfs-path-lookup"
},
{
"name": "add-notes-lookup-to-parser"
},
{
"name": "ahead-behind-toggle-spike"
},
{
"name": "all-stash-functions"
},
...
]
}
}
}
}
...

search query in elasticsearch

I have documents like the below in my elasticsearch
{"method":"POST","url":"/saas/services/1.0/account/*/purchase/*/subscription/cancel"}
{"method":"POST","url":"/saas/services/1.0/account/*/purchase/*/cancel"}
I am searching these documents using node.js client. Below is the query I am sending.
Example 1 type : DSL
client.search({
index: 'my_node',
body: {
query: {
bool: {
must: {
match: { method: 'POST' },
match: { url: '/saas/services/1.0/account/*/purchase/*/cancel' }
}
}
}
}
}
Output
I am getting the other record with subscription cancel. The query is not matching the exact document. I tried the below query , it worked for this case but not working for few other test cases.
document
{"method":"POST","url":"/paas/service/1.0/act/*/purchase"}}
{"method":"GET","url":"/paas/service/1.0/act/*/purchase"}}
{"method":"PUT","url":"/paas/service/1.0/act/*/purchase"}}
Example 2 type : query string
client.search({
index: 'my_node',
q: 'method: POST AND url: /saas/services/1.0/account/*/purchase'
}
Output
I get the GET purchase document regardless of other two. Tried for few other documents, the method argument is not getting recognized.
How do I write elasticsearch query to search through the documents to match both the properties of method and url. i had tried query time boosting for the url but doesn't seem to work.
Edit - Mapping information
{
"nodeclient": {
"mappings": {
"logs": {
"properties": {
"method": {
"type": "string" },
"url": {
"type": "string" }
} } }
}
}
Try add quotation marks
client.search({ index: 'my_node', body: { "query": { "bool": { "must": {
"match": { "method": 'POST' }, "match": { "url":
'/saas/services/1.0/account//purchase//cancel' } } } } } }
I tried optimizing the query with Mirage plugin for elasticsearch queries. I was trying with different examples and saw the responses. Below is my final query that works for my scenario
{
"query": {
"bool": {
"must": [
{ "match_phrase": { "url": uri }},
{ "match": { "method": http } }
]}
}
match_phrase suited better for the url parameter. Also I missed the array part inside the must clause.

Resources