I am trying to use https://github.com/eclipse/egit-github/tree/master/org.eclipse.egit.github.core to create a pull request, but I can't find a way to add reviews to the pull request. The V3 Github API supports adding reviewers as mentioned here, https://developer.github.com/v3/pulls/review_requests/#create-a-review-request. I am trying to create the pull request as follows.
private void createPullRequest(
String repositoryName,
String repositoryOwner,
String pullRequestTitle,
String pullRequestBody,
String branchSource,
String branchDestination
) throws IOException {
logger.info("starting to create pull request");
var gitHubClient = new GitHubClient();
gitHubClient.setCredentials("x", "y");
var repositoryService = new RepositoryService(gitHubClient);
var repository = repositoryService.getRepository(repositoryOwner, repositoryName);
var pullRequestService = new PullRequestService(gitHubClient);
var pullRequest = new PullRequest();
pullRequest.setTitle(pullRequestTitle);
pullRequest.setBody(pullRequestBody);
pullRequest.setHead(
new PullRequestMarker().setRef(branchSource).setLabel(branchSource)
);
pullRequest.setBase(
new PullRequestMarker().setRef(branchDestination).setLabel(branchDestination)
);
logger.info("Finally starting to push PR");
pullRequestService.createPullRequest(repository, pullRequest);
logger.info("PR should be created now");
}
From the documentation it says, it supports 100% of Github V3 API. But I am unable to find any reference in code & online for adding reviewers.
Thanks!
Related
I am currently trying to write a revocation registry definition (revRegDef) to a Hyperledger Indy pool as shown in the Indy Getting Started.
The workflow is like this:
create a schema
using the schemaId, create a credential definition (credDef)
using the credDefId, create a revRegDef
Since I need to use Java, i added the appropriate requests to the ledger to the Java Sample, i uploaded my modified version here.
Creating the schema and credDef works fine, but when I send the last request, i get the following error message:
reason -> client request invalid: InvalidClientRequest("Format of credDefId field is not acceptable.
Expected: 'did:marker:signature_type:schema_ref' or 'did:marker:signature_type:schema_ref:tag'",)
At this point, the mentioned credDefId looks like this: Th7MpTaRZVRYnPiabds81Y:3:CL:Th7MpTaRZVRYnPiabds81Y:2:gvt:1.0:Tag1
while the schemaId is Th7MpTaRZVRYnPiabds81Y:2:gvt:1.0
Obviously the mentioned pattern is not met, but the Ledger.buildCredDefReq() function returns the credDefId like this, so i would expect it to be correct.
Edit: while my old answer worked, it only was a workaround and complete bs.. the following should be the correct way of creating credential schema, credential definition and revocation registry definition.
// Create Credential Schema
String name = "schema_name";
String schemaAttrs = new JSONArray().put("name").put("age").toString();
AnoncredsResults.IssuerCreateSchemaResult schema =
Anoncreds.issuerCreateSchema(verinym, name, "1.0", schemaAttrs).get();
String schemaId = schema.getSchemaId();
String schemaJson = schema.getSchemaJson();
JSONObject schemaRes = new JSONObject(Ledger.signAndSubmitRequest(PoolUtils.getInstance(), wallet, verinym,
Ledger.buildSchemaRequest(verinym, schemaJson).get()
).get());
int schemaSeqNo = schemaRes.getJSONObject("result").getJSONObject("txnMetadata").getInt("seqNo");
schemaJson = new JSONObject(schemaJson).put("seqNo", schemaSeqNo).toString();
// Create Credential Definition
AnoncredsResults.IssuerCreateAndStoreCredentialDefResult credDef =
Anoncreds.issuerCreateAndStoreCredentialDef(
wallet, verinym, schemaJson, "tag", null,
new JSONObject().put("support_revocation", true).toString()
).get();
// creating credDef req and sending it to the ledger
JSONObject credDefRes = new JSONObject(
Ledger.signAndSubmitRequest(
PoolUtils.getInstance(), wallet, verinym,
Ledger.buildCredDefRequest(verinym, credDef.getCredDefJson()).get()
).get()
);
int credSeqNo = credDefRes.getJSONObject("result").getJSONObject("txnMetadata").getInt("seqNo");
// Create Revocation Registry Definition
String tailsWriterConfig = new JSONObject().put("base_dir", "/tmp/indy_tails").put("uri_pattern", "").toString();
BlobStorageWriter tails = BlobStorageWriter.openWriter("default", tailsWriterConfig).get();
AnoncredsResults.IssuerCreateAndStoreRevocRegResult revocRegDef = Anoncreds.issuerCreateAndStoreRevocReg(
wallet, verinym, null, "contractDef", credDefId,
"{}", tails
).get();
JSONObject revocRegDefRes = new JSONObject(
Ledger.signAndSubmitRequest(PoolUtils.getInstance(), wallet, verinym,
Ledger.buildRevocRegDefRequest(verinym, revocRegDef.getRevRegDefJson()).get()
).get());
revocRegDefSeqNo = revocRegDefRes.getJSONObject("result").getJSONObject("txnMetadata").getInt("seqNo");
The learning is that the ledger returns important values for the creation of definition
Furthermore, nowhere was mentioned that you need to create an initial revocation registry entry:
// Create initial revocation entry
JSONObject revocRegEntryRes = new JSONObject(Ledger.signAndSubmitRequest(PoolUtils.getInstance(), wallet, verinym,
Ledger.buildRevocRegEntryRequest(verinym, revocRegDef.getRevRegId(),
"CL_ACCUM", revocRegDef.getRevRegEntryJson()).get()).get());
I am able to create a CNAME record through the AWS console no problem see picture above. But when I try to do the same thing programmatically with the AWS Route53 SDK I keep getting an
com.amazonaws.services.route53.model.InvalidInputException: Invalid
request (Service: AmazonRoute53; Status Code: 400; Error Code:
InvalidInput; Request ID: 7fd7b5d1-5ea8-11e8-a252-7f474094c446)
Here's my attempted code
private static final String QA_HOSTED_ZONE_ID = "UUIDFromConsole";
GetHostedZoneRequest getHostedZoneRequest = new GetHostedZoneRequest(HOSTED_ZONE_ID);
GetHostedZoneResult result = route53Client.getHostedZone(getHostedZoneRequest);
ResourceRecordSet resourceRecordSet = new
ResourceRecordSet("DN4TheRecordSet", RRType.CNAME);
GeoLocation geoLocation = new GeoLocation();
geoLocation.setContinentCode("NA");
geoLocation.setSubdivisionCode("NY");
resourceRecordSet.setGeoLocation(geoLocation);
resourceRecordSet.setTTL(50L);
resourceRecordSet.setGeoLocation(geoLocation);
resourceRecordSet.setSetIdentifier("uniqueid-statecode");Change addStateChange = new Change(ChangeAction.CREATE, resourceRecordSet);
ChangeBatch changeBatch = new ChangeBatch(Arrays.asList(addStateChange));
ChangeResourceRecordSetsRequest changeResourceRecordSetsRequest = new ChangeResourceRecordSetsRequest().withHostedZoneId(HOSTED_ZONE_ID).withChangeBatch(changeBatch);
route53Client.changeResourceRecordSets(changeResourceRecordSetsRequest);
I am also not able to configure the value for the CNAME, meaning where I want to redirect my traffic after it hits the DN4TheRecordSet.This is probably the cause of the invalid error I am receiving in the response.
Please help 🤕
Found the issue.
The InvalidInputException was eluding to the fact of a missing ResourceRecord which corresponds to the value field in the picture above.
Here's the solution above with the addition of a ResourceRecord to the ResourceRecordSet
private static final String QA_HOSTED_ZONE_ID = "UUIDFromConsole";
private static final String REDIRECT_DNS = "DNS to want the cname to route to";
GetHostedZoneRequest getHostedZoneRequest = new GetHostedZoneRequest(HOSTED_ZONE_ID);
GetHostedZoneResult result = route53Client.getHostedZone(getHostedZoneRequest); ResourceRecordSet resourceRecordSet = new ResourceRecordSet("DN4TheRecordSet", RRType.CNAME);
GeoLocation geoLocation = new GeoLocation();
geoLocation.setContinentCode("NA");
geoLocation.setSubdivisionCode("NY");
resourceRecordSet.setGeoLocation(geoLocation);
resourceRecordSet.setTTL(50L);
resourceRecordSet.setGeoLocation(geoLocation);
resourceRecordSet.setSetIdentifier("uniqueid-statecode");
resourceRecordSet.setResourceRecords(Arrays.asList(new ResourceRecord(REDIRECT_DNS))); // This line being missing cause the exception
Change addStateChange = new Change(ChangeAction.CREATE, resourceRecordSet);
ChangeBatch changeBatch = new ChangeBatch(Arrays.asList(addStateChange));
ChangeResourceRecordSetsRequest changeResourceRecordSetsRequest = new ChangeResourceRecordSetsRequest().withHostedZoneId(HOSTED_ZONE_ID).withChangeBatch(changeBatch);
route53Client.changeResourceRecordSets(changeResourceRecordSetsRequest);
See Geolocation Syntax section in this page for example of the payload the sdk creates and sends for your request.
I am trying to write code in Java that can obtain a Security Token from the STS for Azure Pack, which I can then use to authenticate calls to the Azure Pack APIs. Here is example code that Microsoft provides (which works) for obtaining this token in C#:
string windowsAuthSiteEndPoint = EnvironmentToUse + ":30072";
var identityProviderEndpoint = new EndpointAddress(new Uri(windowsAuthSiteEndPoint + "/wstrust/issue/windowstransport"));
var identityProviderBinding = new WS2007HttpBinding(SecurityMode.Transport);
identityProviderBinding.Security.Message.EstablishSecurityContext = false;
identityProviderBinding.Security.Message.ClientCredentialType = MessageCredentialType.None;
identityProviderBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
var trustChannelFactory = new WSTrustChannelFactory(identityProviderBinding, identityProviderEndpoint)
{
TrustVersion = TrustVersion.WSTrust13,
};
var channel = trustChannelFactory.CreateChannel();
var rst = new RequestSecurityToken(RequestTypes.Issue)
{
AppliesTo = new EndpointReference("http://azureservices/AdminSite"),
KeyType = KeyTypes.Bearer,
};
RequestSecurityTokenResponse rstr = null;
SecurityToken token = null;
token = channel.Issue(rst, out rstr);
Here is what I currently have in Java, where I am attempting to do the same thing:
import org.apache.cxf.Bus;
import org.apache.cxf.bus.spring.SpringBusFactory;
import org.apache.cxf.sts.STSConstants;
import org.apache.cxf.ws.security.SecurityConstants;
import org.apache.cxf.ws.security.tokenstore.SecurityToken;
import org.apache.cxf.ws.security.trust.STSClient;
SpringBusFactory springBusFactory = new SpringBusFactory();
Bus bus = springBusFactory.createBus();
STSClient stsClient = new STSClient(bus);
stsClient.setLocation("https://" + endpoint + ":30072/wstrust/issue/windowstransport");
stsClient.setServiceName("{http://schemas.microsoft.com/ws/2008/06/identity/securitytokenservice}SecurityTokenService");
stsClient.setEndpointName("{http://schemas.microsoft.com/ws/2008/06/identity/securitytokenservice}WS2007HttpBinding_IWSTrust13Sync");
stsClient.setKeyType(STSConstants.BEARER_KEY_KEYTYPE);
stsClient.isEnableAppliesTo();
bus.setProperty(SecurityConstants.STS_CLIENT, stsClient);
bus.setProperty(SecurityConstants.STS_APPLIES_TO, "http://azureservices/AdminSite");
SecurityToken securityToken = stsClient.requestSecurityToken();
I get a 401 Unauthorized HTTP response when running my Java test code:
Caused by: org.apache.cxf.transport.http.HTTPException: HTTP response '401: Unauthorized' when communicating with https://endpoint:30072/wstrust/issue/windowstransport
It looks like I'm missing the following pieces of functionality when attempting to recreate what the C# code does, but I can't figure out what the equivalent of the following code would be in Java/using the Apache CXF library:
1) identityProviderBinding.Security.Message.EstablishSecurityContext = false;
2) identityProviderBinding.Security.Message.ClientCredentialType = MessageCredentialType.None;
3) identityProviderBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
It's also possible I'm doing other things wrong as well. Any thoughts or suggestions?
Have you tried using management certificates to authenticate your requests instead of security tokens. https://msdn.microsoft.com/en-us/library/azure/ee460782.aspx#bk_cert has information on how to do it in Azure, but it should not differ much for Azure Pack.
I am learning Amazon Cloud Search but I couldn't find any code in either C# or Java (though I am creating in C# but if I can get code in Java then I can try converting in C#).
This is just 1 code I found in C#: https://github.com/Sitefinity-SDK/amazon-cloud-search-sample/tree/master/SitefinityWebApp.
This is 1 method i found in this code:
public IResultSet Search(ISearchQuery query)
{
AmazonCloudSearchDomainConfig config = new AmazonCloudSearchDomainConfig();
config.ServiceURL = "http://search-index2-cdduimbipgk3rpnfgny6posyzy.eu-west-1.cloudsearch.amazonaws.com/";
AmazonCloudSearchDomainClient domainClient = new AmazonCloudSearchDomainClient("AKIAJ6MPIX37TLIXW7HQ", "DnrFrw9ZEr7g4Svh0rh6z+s3PxMaypl607eEUehQ", config);
SearchRequest searchRequest = new SearchRequest();
List<string> suggestions = new List<string>();
StringBuilder highlights = new StringBuilder();
highlights.Append("{\'");
if (query == null)
throw new ArgumentNullException("query");
foreach (var field in query.HighlightedFields)
{
if (highlights.Length > 2)
{
highlights.Append(", \'");
}
highlights.Append(field.ToUpperInvariant());
highlights.Append("\':{} ");
SuggestRequest suggestRequest = new SuggestRequest();
Suggester suggester = new Suggester();
suggester.SuggesterName = field.ToUpperInvariant() + "_suggester";
suggestRequest.Suggester = suggester.SuggesterName;
suggestRequest.Size = query.Take;
suggestRequest.Query = query.Text;
SuggestResponse suggestion = domainClient.Suggest(suggestRequest);
foreach (var suggest in suggestion.Suggest.Suggestions)
{
suggestions.Add(suggest.Suggestion);
}
}
highlights.Append("}");
if (query.Filter != null)
{
searchRequest.FilterQuery = this.BuildQueryFilter(query.Filter);
}
if (query.OrderBy != null)
{
searchRequest.Sort = string.Join(",", query.OrderBy);
}
if (query.Take > 0)
{
searchRequest.Size = query.Take;
}
if (query.Skip > 0)
{
searchRequest.Start = query.Skip;
}
searchRequest.Highlight = highlights.ToString();
searchRequest.Query = query.Text;
searchRequest.QueryParser = QueryParser.Simple;
var result = domainClient.Search(searchRequest).SearchResult;
//var result = domainClient.Search(searchRequest).SearchResult;
return new AmazonResultSet(result, suggestions);
}
I have already created domain in Amazon Cloud Search using AWS console and uploaded document using Amazon predefine configuration option that is movie Imdb json file provided by Amazon for demo.
But in this method I am not getting how to use this method, like if I want to search Director name then how do I pass in this method as because this method parameter is of type ISearchQuery?
I'd suggest using the official AWS CloudSearch .NET SDK. The library you were looking at seems fine (although I haven't look at it any detail) but the official version is more likely to expose new CloudSearch features as soon as they're released, will be supported if you need to talk to AWS support, etc, etc.
Specifically, take a look at the SearchRequest class -- all its params are strings so I think that obviates your question about ISearchQuery.
I wasn't able to find an example of a query in .NET but this shows someone uploading docs using the AWS .NET SDK. It's essentially the same procedure as querying: creating and configuring a Request object and passing it to the client.
EDIT:
Since you're still having a hard time, here's an example. Bear in mind that I am unfamiliar with C# and have not attempted to run or even compile this but I think it should at least be close to working. It's based off looking at the docs at http://docs.aws.amazon.com/sdkfornet/v3/apidocs/
// Configure the Client that you'll use to make search requests
string queryUrl = #"http://search-<domainname>-xxxxxxxxxxxxxxxxxxxxxxxxxx.us-east-1.cloudsearch.amazonaws.com";
AmazonCloudSearchDomainClient searchClient = new AmazonCloudSearchDomainClient(queryUrl);
// Configure a search request with your query
SearchRequest searchRequest = new SearchRequest();
searchRequest.Query = "potato";
// TODO Set your other params like parser, suggester, etc
// Submit your request via the client and get back a response containing search results
SearchResponse searchResponse = searchClient.Search(searchRequest);
I'm trying to use Yellowfin services from my C# code. They are written on Java, so I've enabed JAX services as they recommend.
So JAX services are running at "localhost:8083/webservices/LegacyReportService?wsdl", and I cannot make them work as specified (I'm running RUNDASHBOARDREPORT method of the ReportService)
That's how I use it:
Web References to the YF services running on my localhost:
Here I call the service
public static reportServiceResponse RunDashboardReport(Int32 reportId, Int32 tabId)
{
var rq = CreateYfRequest("RUNDASHBOARDREPORT");
rq.reportId = reportId;
rq.dashboardTabId = tabId;
using (var srv = new LegacyReportServiceService())
{
var resp = srv.remoteReportCall(rq); // there is no "remoteAdministrationCall" as in the doc
return resp;
}
}
private static reportServiceRequest CreateYfRequest(String command)
{
var rq = new reportServiceRequest
{
loginId = "admin#yellowfin.com.au",
password = "test",
orgId = 1, // This is the primary organization
reportRequest = command
};
return rq;
}
And I get "An exception of type 'System.InvalidOperationException' occurred in System.Xml.dll "
when creating
new LegacyReportServiceService()
I've also tried to add it as a Service Reference, but the result is the same.
The YF team sais "We do have clients that are using .net and C# to develop their integration code. ...The support team has confirmed example code provided in development folder in the Yellowfin directory and WSDL code are accurate and are unable to replicate the errors you’ve identified in your original email."
Please help me to find out, what I'm doing wrong
I've found out that VS generates classes for the web service access from "localhost:8083/webservices/LegacyReportService?xsd=1" and it does that improperly. It makes String[] from original String type.
So editing the generated Reference.cs of the Web Reference did the thing.At least, I've got the response with errorCode 25 "Not authorized".
Try the following code to get rid of response code 25.
rsr.orgId = 1;
rsr.orgIdSpecified = true;
rsr.dashboardTabId = 11111;
rsr.dashboardTabIdSpecified = true;
rsr.reportId = 22222;
rsr.reportIdSpecified = true;
Certain parameters for yellowfin need to explicitly told to read.
Check if this works
reportServiceRequest rq = new reportServiceRequest();
rq.loginId = "admin#xxxxx.com";
rq.password = "xxxxxxx";
rq.orgId = 1;
rq.reportRequest = "RUNDASHBOARDREPORT";
rq.reportId = reportId;
rq.orgIdSpecified = true;
rq.dashboardTabId = 11111;
rq.dashboardTabIdSpecified = true;
rq.reportIdSpecified = true;
rq.dashboardTabId = tabId;
using (var srv = new ServiceReference2.LegacyReportServiceClient())
{
YellowFinIntegrationWithDotNet.ServiceReference2.reportServiceResponse resp = null;
try
{
resp = srv.remoteReportCall(rq); // there is no "remoteAdministrationCall" as in the doc
}
catch (System.Exception ex)
{
MessageBox.Show(ex.InnerException.ToString());
return resp;
}
return resp;
}