We use the following code to communicate with DynamoDB:
using (var client = AWSClientFactory.CreateAmazonDynamoDBClient(RegionEndpoint.USEast1))
{
var table = Table.LoadTable(client, "Users");
var item = await table.GetItemAsync(id);
}
How can I force AWS.SDK for .NET to always use SSL connections? This is very important as we want to store user data including passwords in DynamoDB.
Here is a code snippet that will allow you to set the endpoint explicitly:
AmazonDynamoDBConfig config = new AmazonDynamoDBConfig();
config.ServiceURL = "https://dynamodb.us-east-1.amazonaws.com";
var client = new AmazonDynamoDBClient(config);
Feel free to replace the region (us-east-1) with any other AWS region.
This example is based on the documentation available here on setting the endpoint: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/TestingDotNetApiSamples.html
Related
I have a project that uses CloudTableClient and query the cosmos db in this way:
var table = cloudTableClient.GetTableReference(tableName);
var cosmosResult = await table.ExecuteQuerySegmentedAsync(GetTableQuery<DynamicTableEntity>(queryOptions), tableContinuationToken, GetTableRequestOptions(requestOptions), operationContext);
If I use CosmosClient, I can set the ConnetionMode
CosmosClient client = new CosmosClient(connectionString,
new CosmosClientOptions
{
ConnectionMode = ConnectionMode.Gateway // ConnectionMode.Direct is the default
});
However, with CouldTableClient, seems I can't find an option to set this. Is it possible to use Direct Mode with CouldTableClient or I actually need to move everything to CosmosClient in order to do it.
I'm struggling to figure out how the smart device management API works.
The end goal is to fetch a status of my nest thermostat on an ongoing basis for logging purposes, using service account credentials:
await using var stream = new FileStream(path, FileMode.Open, FileAccess.Read);
var credential = GoogleCredential.FromStream(stream)
.CreateScoped(SmartDeviceManagementService.ScopeConstants.SdmService);
var service = new SmartDeviceManagementService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential
});
This appears to be correct, however when I try and call service.Enterprises.Devices.List() it requires a parent ID in the format of "^enterprises/[^/]+/devices/[^/]+$ But I do not know how to acquire this parent ID to begin testing my code.
Does anyone know how to obtain these strings which seem to be necessary to use the API?
Have you registered from a project id via the Device Access Console?
https://console.nest.google.com/device-access
That seems to be what you're looking for.
I am trying to get transfer related data from stripe
TransferService service = new TransferService();
TransferListOptions stripeTransferList = new TransferListOptions
{
Destination = accountId,
Limit = 100
};
var list = await service.ListAsync(stripeTransferList);
var finalData = list.FirstOrDefault(x => x.DestinationPaymentId == paymentId);
so when I try to search paymentId from that list I was not able to find any because the page limit is 100 only
Limit = 100
how to fetch all the data and filter from that??
The stripe-dotnet library supports automatic pagination and it's documented here.
This lets you paginate through all the data in your account based on specific criteria that you passed as parameters. For example you can list all Transfer objects made to a specific connected account this way:
TransferService service = new TransferService();
TransferListOptions listOptions = new TransferListOptions
{
Destination = "acct_123456",
Limit = 100
};
foreach (var transfer in service.ListAutoPaging(listOptions)) {
// Do something with this Transfer
}
Now, this allows you to iterate over every Transfer but if you have a lot of data this could be quite slow. An alternative would be to start from the charge id, the py_123456 that you have from your connected account. If you know which account this charge was created on, you can fetch it directly via the API. This is done using the Retrieve Charge API along with passing the connected account id as documented here.
The Charge resource has the source_transfer property which is the id of the Transfer (tr_123) from the platform that created this charge. You can also use the Expand feature, which lets you fetch the entire Transfer object back to get some detailed information about it.
The code would look like this
var transferOptions = new TransferGetOptions{};
transferOptions.AddExpand("source_transfer");
var requestOptions = new RequestOptions();
requestOptions.StripeAccount = "acct_12345";
TransferService service = new TransferService();
Charge charge = service.Get(transferOptions, requestOptions);
// Access information about the charge or the associated transfer
var transferId = charge.SourceTransfer.Id;
var transferAmount = charge.SourceTransfer.TransferData.Amount;
How can we create an agreement using a library document using a library document which will be singed by two signers? I know how to do the same using echo sign web application using this tutorial: https://helpx.adobe.com/sign/help/send-agreement---multiple-signers.html
I have created a template document in my dashboard for reuse purpose and I have added fields for recipients as well. But when I create agreement using that library document and from that agreement I create signing url. But both URLs only allow one of them to sign. If the second signer opens their link, the document shows as already signed. Can anyone tell me how can I create and have my both signers complete the agreement using Rest API?
please change your lines of code from
//Create recipient set info
var recipientSetInfo = new agreementsModel.RecipientSetInfo();
recipientSetInfo.setRecipientSetMemberInfos(recipientSetMemberInfos);
recipientSetInfo.setRecipientSetRole(agreementsModel.RecipientSetInfo.RecipientSetRoleEnum.SIGNER);
recipientSetInfo.setRecipientSetName("fjenning#adobe.com");
var recipientSetInfos = [];
recipientSetInfos.push(recipientSetInfo);
to this
var recipientSetInfos = [];
//Create recipient set info
for (var i = 0; i < recipientSetMemberInfos.length; i++) {
var recipientSetInfo = new agreementsModel.RecipientSetInfo();
recipientSetInfo.setRecipientSetMemberInfos(recipientSetMemberInfos[i]);
recipientSetInfo.setRecipientSetRole(agreementsModel.RecipientSetInfo.RecipientSetRoleEnum.SIGNER);
recipientSetInfo.setSigningOrder("SEQUENTIAL");
recipientSetInfo.setRecipientSetName(" Recepients");
recipientSetInfos.push(recipientSetInfo);
}
Is it possible to connect the one App to more than one cloud SQL database?
I can connect to a single cloud SQL database within the App settings (projectName:regionName:instanceName/databaseName).
But I want to add models from more than one existing Cloud SQL database to my single App.
When Creating External Data Models, there is no option or settings to configure another/additional google cloud SQL database.
Any advise appreciated if there's a way to work around this?
Reference: Connect your app to an existing Google Cloud SQL database:
https://developers.google.com/appmaker/models/cloudsql#connect_your_app_to_an_existing_google_cloud_sql_database
John
Just tried this out:
App Maker server scripts have access to Google Service APIs. The JDBC class allows you to connect to Cloud SQL after adding 10 whitelisted IPs.
From: https://developers.google.com/apps-script/guides/jdbc add the following IPs to your access control in Cloud console:
64.18.0.0/20
64.233.160.0/19
66.102.0.0/20
66.249.80.0/20
72.14.192.0/18
74.125.0.0/16
173.194.0.0/16
207.126.144.0/20
209.85.128.0/17
216.239.32.0/19
I put this bit in a server script and attached it to a button and checked the output log and found that it worked.
function Connect() {
var address = 'instance_ip';
var user = 'username';
var pw = 'password';
var db = 'database_name';
var dbUrl = 'jdbc:mysql://' + address + '/' + db;
// read some rows
function readFrom() {
var conn = Jdbc.getConnection(dbUrl, user, pw);
var start = new Date();
var stmt = conn.createStatement();
stmt.setMaxRows(100);
var results = stmt.executeQuery('SELECT * FROM table_name');
var numCols = results.getMetaData().getColumnCount();
while (results.next()) {
var rowString = '';
for(var col = 0; col < numCols; col++) {
rowString += results.getString(col + 1) + '\t';
}
console.log(rowString);
}
results.close();
stmt.close();
}
readFrom();
}
Using this, you could have as many connections as you like. But this would not allow App Maker to recognize it as a datasource. You'd have to manually process the results until this feature is officially supported. (I like the idea and will make a repo library for this.)