I was trying to create a build definition. I tried as below one.
But i do think the code below doesn't create a buildDefinition. Like it asks for BuildDefinitionRef in the code "newBuild["BuildDefinition"] = ;" I am unable to know what exactly to put which reference.
RallyRestApi RestApi = new RallyRestApi("_abcd","https://rally1.rallydev.com");
String workspaceRef = "/workspace/27154845988";
String projectRef = "/project/48152113168";
DynamicJsonObject newBuild = new DynamicJsonObject();
newBuild["Workspace"] = workspaceRef;
newBuild["Duration"] = 0.75;
newBuild["Message"] = "Master 4683 Success";
//newBuild["CreationDate"] = "";
newBuild["Status"] = "FAILURE";
newBuild["Number"] = "4683";
// newBuild["Uri"] = "http://jenkins-build:8080/hudson/view/master/job/master-deploy/4683/";
// newBuild["BuildDefinition"] = ;
If any body has any idea of first how to create the BuildDefinition.
BuildDefinition should be a createable type in WSAPI. You just need to create that first, and then when you're creating your Build object just pass the ref of the created BuildDefinition:
newBuild["BuildDefinition"] = "/builddefinition/12345";
Related
I have the following code where I am stuck a little bit:
var indexBuilder = Builders<T>.IndexKeys;
if (setting.IsDescending)
indexBuilder.Descending(setting.Column);
else
indexBuilder.Ascending(setting.Column);
var indexOptions = new CreateIndexOptions();
if (setting.IsUnique)
indexOptions.Unique = true;
var model = new CreateIndexModel<T>(indexBuilder, indexOptions);
I got the following error:
Argument 1: cannot convert from 'MongoDB.Driver.IndexKeysDefinitionBuilder' to 'MongoDB.Driver.IndexKeysDefinition'
I am not sure why as I have done the same as it is in official documentation.
You need to create a variable with IndexKeysDefinition<T> and pass it to the CreateIndexModel as below:
IndexKeysDefinition<T> index;
var indexBuilder = Builders<T>.IndexKeys;
if (setting.IsDescending)
index = indexBuilder.Descending(setting.Column);
else
index = indexBuilder.Ascending(setting.Column);
var indexOptions = new CreateIndexOptions();
if (setting.IsUnique)
indexOptions.Unique = true;
var model = new CreateIndexModel<T>(index, indexOptions);
Demo
Using the .Net AWSSDK.EventBridge I created a rule:
var client = new AmazonEventBridgeClient();
string ruleName = "SomeRule";
var putRuleRequest = new Amazon.EventBridge.Model.PutRuleRequest()
{
Name = ruleName,
ScheduleExpression = "rate(10 minutes)",
State = RuleState.ENABLED
}
await client.PutRuleAsync(putRuleRequest);
var target = new Amazon.EventBridge.Model.Target();
target.Arn = "ARN_LAMBDA_FUNCTION";
target.Id = "LAMBDA_FUNCTION_NAME";
target.Input = JsonSerializer.Serialize(new { someId, someDate});
var targetList = new List<Amazon.EventBridge.Model.Target>();
targetList.Add(target);
var putTargetRequest = new Amazon.EventBridge.Model.PutTargetsRequest()
{
Rule = ruleName,
Targets = targetList
};
await client.PutTargetsAsync(putTargetRequest);
The Lambda function is already created so I put the ARN and name on the Target. The idea is that there is one function but multiple rules will call it.
The rule, schedule, and target to the function are created when I run the code but the problem is that the function can't be triggered by the rule. When I edit the rule, update it in the AWS Console without changing anything the trigger works.
What am I missing?
After searching through I found out I was missing the permission for Lambda.
//This line replaces the code above
var putRuleResponse = client.PutRuleAsync(putRuleRequest).Result;
var lp = new Amazon.Lambda.Model.AddPermissionRequest();
lp.FunctionName = FUNCTION_ARN;
lp.Action = "lambda:InvokeFunction";
lp.SourceArn = putRuleResponse.RuleArn;
lp.Principal = "events.amazonaws.com";
lp.StatementId = "SomeStatement";
var lambdaClient = new AmazonLambdaClient();
await lambdaClient.AddPermissionAsync(lp);
I am trying out the Amazon MWS samples. How do I initialise request.ASINList with a list of ASINs?
My ASINs are in strings.
// Create a request.
GetLowestOfferListingsForASINRequest request = new GetLowestOfferListingsForASINRequest();
string sellerId = "example";
request.SellerId = sellerId;
string mwsAuthToken = "example";
request.MWSAuthToken = mwsAuthToken;
string marketplaceId = "example";
request.MarketplaceId = marketplaceId;
ASINListType asinList = new ASINListType();
request.ASINList = asinList;
string itemCondition = "example";
request.ItemCondition = itemCondition;
bool excludeMe = true;
request.ExcludeMe = excludeMe;
return this.client.GetLowestOfferListingsForASIN(request);
I can't seem to implicitly or explicitly cast a list or array of strings to ASINListType.
Don't know c# but in PHP you have to create an object of class "MarketplaceWebServiceProducts_Model_ASINListType"
e.g.
$asin_list = new MarketplaceWebServiceProducts_Model_ASINListType();
$asin_list->setASIN($asin_array);
$request->setASINList($asin_list);
Your request.ASINList needs to be assigned to an ASINListType. So instantiate that object, and assign your ASINs to it's ASIN property. This is just one way of doing it, but I typically do it very quickly this way:
var asinListType = new ASINListType();
asinListType.ASIN = new List<string> { "B00005TQI7", "B00AVO5XRK", etc, etc };
request.ASINList = asinListType;
Currently I need to create a folder on a Sharepoint repository using it CMIS implementation so I am using the web services it offers on the path http://(server)/_vti_bin/cmis/soap. I implemented the code based on this example https://chemistry.apache.org/java/opencmis-cookbook.html but Sharepoint does not return the rootFolderId so the method getChildren returns nothing. Finally based on a query using the discovery service I retrieve the root folder id, but now the problem is I can't create a sub folder. This is my code:
Object.cmisPropertyId p1 = new Object.cmisPropertyId();
p1.propertyDefinitionId = "cmis:baseTypeId";
p1.value = new string[1];
p1.value[0] = "cmis:folder";
propertiesType.Items.SetValue(p1, 0);
Object.cmisPropertyString p2 = new Object.cmisPropertyString();
p2.propertyDefinitionId = "cmis:name";
p2.value = new string[1];
p2.value[0] = "mytest";
propertiesType.Items.SetValue(p2, 1);
Object.cmisPropertyString p3 = new Object.cmisPropertyString();
p3.propertyDefinitionId = "cmis:path";
p3.value = new string[1];
p3.value[0] = "Rep/f1/mytest";
propertiesType.Items.SetValue(p3, 2);
Object.cmisPropertyId p4 = new Object.cmisPropertyId();
p4.propertyDefinitionId = "cmis:objectTypeId";
p4.value = new string[1];
p4.value[0] = "cmis:folder";
propertiesType.Items.SetValue(p4, 3);
Object.cmisPropertyId p5 = new Object.cmisPropertyId();
p5.propertyDefinitionId = "cmis:parentId";
p5.value = new string[1];
p5.value[0] = "268";
propertiesType.Items.SetValue(p5, 4);
Object.cmisPropertyString p6 = new Object.cmisPropertyString();
p6.propertyDefinitionId = "Author";
p6.value = new string[1];
p6.value[0] = "theAuthor";
propertiesType.Items.SetValue(p6, 5);
Object.cmisPropertyId p7 = new Object.cmisPropertyId();
p7.propertyDefinitionId = "cmis:allowedChildObjectTypeIds";
p7.value = new string[3];
p7.value[0] = "cmis:document";
p7.value[1] = "0x010100C98D402E3C78834C873469CE4F41E2C300B0A3B5E8A3E51543977DFDCE95850082";
p7.value[2] = "cmis:folder";
propertiesType.Items.SetValue(p7, 6);
var result = objectService.createFolder(repositoryInfo.repositoryId, propertiesType, null, null, null, null, ref extType);
It always return null, I'm not sure how to pass correctly the arguments to the service for make the creation works. I don't know where to find logs o something that tell me what I am doing wrong.
Thank you
PD: I need to use this aproach because is a modification to an existing code that already use the Sharepoint CMIS services.
You try to update readonly properties. See CMIS 1.0
http://docs.oasis-open.org/cmis/CMIS/v1.1/CMIS-v1.1.html
Sample on Java
Folder root = session.getRootFolder();
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
properties.put(PropertyIds.NAME, "a new folder");
Folder newFolder = root.createFolder(properties);
The key is "session". You should create session to CMIS Repository(Atom or WSDL binding). Session will provide you ability to create/retrieve folders/documents
I have an Amazon EC2 instance and I need to be able to create an AMI (image) from it programmatically. I'm trying the following:
CreateImageRequest rq = new CreateImageRequest();
rq.InstanceId = myInstanceID;
rq.Name = instance.KeyName;
rq.Description = "stam";
rq.NoReboot = true;
IAmazonEC2 ec2;
AmazonEC2Config ec2conf = new AmazonEC2Config();
ec2 = AWSClientFactory.CreateAmazonEC2Client(ec2conf);
// CreateImageResponse imageResp;
Amazon.EC2.Model.CreateImageResponse imageResp = null;
try
{
imageResp = ec2.CreateImage(rq);
}
catch (AmazonServiceException ase)
{
MessageBox.Show(ase.Message);
}
The result is always an AmazonServiceException saying that there is a NameResolutionFailure.
How do I overcome this? I tried different possible "name" possibilities but cannot find the right one.
string amiID = ConfigurationManager.AppSettings[AmazonConstants.AwsImageId];
string keyPairName = ConfigurationManager.AppSettings[AmazonConstants.AwsKeyPair];
List<string> groups = new List<string>() { ConfigurationManager.AppSettings[AmazonConstants.AwsSecurityGroupId] };
var launchRequest = new RunInstancesRequest()
{
ImageId = amiID,
InstanceType = ConfigurationManager.AppSettings[AmazonConstants.AwsInstanceType],
MinCount = 1,
MaxCount = 1,
KeyName = keyPairName,
SecurityGroupIds = groups,
SubnetId = ConfigurationManager.AppSettings[AmazonConstants.AwsSubnetId]
};
RunInstancesResponse runInstancesResponse = amazonEc2client.RunInstances(launchRequest);
RunInstancesResult runInstancesResult = runInstancesResponse.RunInstancesResult;
Reservation reservation = runInstancesResult.Reservation;
Problem eventually solved!
it turned out thyat some codelines were doing things which were already done already and removing this part:
IAmazonEC2 ec2;
AmazonEC2Config ec2conf = new AmazonEC2Config();
ec2 = AWSClientFactory.CreateAmazonEC2Client(ec2conf);
// CreateImageResponse imageResp;
Amazon.EC2.Model.CreateImageResponse imageResp = null;
Made things clearer and no wrong repetitions happened! Now it works!