Problems when creating new notes in Simplenote using Simperium - c#

I'm creating an Open Source C# client for Simplenote using Simperium API. Almost everything is ready, but I am facing problems when creating a new note.
How I can create a new note in Simplenote using Simperium API?

Once you have the app id and API key you can create new notes just like creating any Simperium object as referenced in the documentation.
The bucket to post to is note and it'll also need to conform to the schema in the following sample note:
{
"tags" : [ "todo", "later" ],
"systemTags" : [],
"creationDate" : 1335390338.091436,
"modificationDate" : 1335390338.091436,
"deleted" : false,
"shareURL" : "",
"publishURL" : "",
"content" : "new note content!"
}
All fields are needed when creating, but you can just specify the fields that have changed when updating.

Related

Why can't I create a valid style via the mapbox api using the examples they provide?

I amp attempting to create a new mapbox style via the mapbox api. When the create process completes, I am getting a success confirmation back, but I cannot use or view the style after it is created. Based on these docs and these docs, I am sending a payload to this api endpoint:
https://api.mapbox.com/styles/v1/[accountname]
The payload I am sending is this:
{
"version": 8,
"name": "mystyle via api",
"sprite": "mapbox://sprites/mapbox/bright-v8",
"metadata": null,
"sources": {
"mapbox-streets": {
"type": "vector",
"url": "mapbox://mapbox.mapbox-streets-v6"
}
},
"glyphs": null,
"layers": []
}
After sending this payload to the mapbox api, I receive this message back:
{
"version": 8,
"name": "mystyle via api",
"metadata": null,
"sources": {
"mapbox-streets": {
"type": "vector",
"url": "mapbox://mapbox.mapbox-streets-v6"
}
},
"sprite": "mapbox://sprites/[accountname]/ckby5s52p2r9v1hmwgkrzenvw/3teom2ial2ryn2u97lclizpce",
"glyphs": "mapbox://fonts/[accountname]/{fontstack}/{range}.pbf",
"layers": [],
"created": "2020-06-27T21:30:49.047Z",
"id": "ckby5s52p2r9v1hmwgkrzenvw",
"modified": "2020-06-27T21:30:49.047Z",
"owner": "[accountname]",
"visibility": "private"
}
Then I proceed to my account in the portal and I see my new style:
However, something is wrong. The preview icon shows just a transparent graphic. And when I click on the style to view/edit it, I get this cryptic error message "Cannot read property 'mapbox:decompiler' of null":
What am I missing here? I am finding the documentation for this process very spread out through several documents. But I am copying the examples in the snippets verbatim
This is a "valid" style, but it has no layers (see the last field of the JSON), that's why it doesn't display anything. (I know this is verbatim from the example in the Create a style docs)
The key concept here to master is the difference between Sources and Layers. Sources are "data sources": you won't see them unless you have a Layer displaying it. Some types of Sources can contain many layers (see the source-layer property in the Layer object), and/or you might want to display the same source with different stylings across different maps. That's one reason they are separated.
Or, as the Sources docs put it:
Adding a source isn't enough to make data appear on the map because sources don't contain styling details like color or width. Layers refer to a source and give it a visual representation. This makes it possible to style the same source in different ways, like differentiating between types of roads in a highways layer.
Combining the Style object sample with the Layer object sample would give you something like this:
{
"version": 8,
"name": "mystyle via api",
"sprite": "mapbox://sprites/mapbox/bright-v8",
"metadata": null,
"sources": {
"mapbox-streets": {
"type": "vector",
"url": "mapbox://mapbox.mapbox-streets-v6"
}
},
"glyphs": null,
"layers": [
{
"id": "water",
"source": "mapbox-streets",
"source-layer": "water",
"type": "fill",
"paint": {
"fill-color": "#00ffff"
}
}
]
}
Now, keep in mind that the global Mapbox styles contain several layers (maybe up to a couple dozen), with very fine settings such as what type of features should show at which zoom level and with what configurations, etc. Most applications should not need to recreate those from scratch.
If you want to overlay dynamic data (to be decided at runtime), you can use one of the global styles and dynamically add a Layer on top of an untouched default style. The link is for Mapbox GL JS, assuming the UI is browser-based. If the UI is a mobile app, there are corresponding methods in the iOS and Android SDKs.
Now, if you don't need dynamic data at all, consider Mapbox Studio instead. This will allow you to create a custom style (with the default styles as templates if you want) and add/remove layers. For example, if mapbox://styles/mapbox/streets-v11 is almost a perfect fit, but you don't need to (say) show small town names, you can create a custom template in Mapbox Studio and remove just that. In the end, it will you give you a style ID which you can just put into your map like a default (global) style.
Also note that, depending on your case, you may combine both approaches.

AWS Lambda - C# - Environment Variables only load null

-Using Visual Studio 2017-
I am having trouble reading any configuration for a database connection string for my function to consume.
Most information I come across says to use Environment Variables, but I seem to be doing that wrong, or there is missing information.
If I hard-code the connection string in it works without trouble.
Both
var value = Environment.GetEnvironmentVariable("ConStr");
and any variation of
var value = Environment.GetEnvironmentVariable("ConStr",EnvironmentVariableTarget.Machine/Process/User);
only return me null values.
I have configured the variable in the aws-lambda-tools-defaults.json as directed by most sources
{
"Information" : [blah],
"profile" : "****",
"region" : "****",
"configuration" : "****",
"framework" : "netcoreapp2.1",
"function-runtime" : "dotnetcore2.1",
"function-memory-size" : 256,
"function-timeout" : 30,
"function-handler" : "****::****:****/****/****",
"function-name" : "arn:aws****:****/****/****",
"function-role" : "****",
"tracing-mode" : "PassThrough",
"environment-variables" : "ConStr=FooBar;",
"function-description" : ""
}
I can see the value populate in the publish profile when uploading. I can see the values uploaded properly to AWS Lambda through the console. All instances still fail to access the data.
Several sources also talk about a 'Serverless.template' file that I can not find in my files, and no full example is given. Is this what I'm missing? If so can someone break down how to implement that?

How to use a ServiceBus Trigger with a topic/subscription in an Azure Function

I'd like to create an Azure Function that is triggered when a new message is added to a topic/subscription.
For the moment I've created an Azure Function using the ServiceBusQueueTrigger C# Template and I've set the Queue Name to
topicPath + "/Subscriptions/" + subscriptionName
But I've got this exception:
Microsoft.ServiceBus: Cannot get entity 'topic-test/Subscriptions/subscription-test' because it is not of type QueueDescription. Check that you are using method(s) with the correct entity type. System.Runtime.Serialization: Error in line 1 position 1762. Expecting element 'QueueDescription' from namespace 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'.. Encountered 'None' with name '', namespace ''. .
I thought the Azure Function was using the MessagingFactory.CreateMessageReceiver to initialize the message pump but not.
Is there any support for topic/subscription for the moment ?
Yes topics are supported, but our UI and templates are behind on that unfortunately - we'll be releasing some updates soon addressing these issues.
For now, you can use the Advanced Editor to edit your trigger binding directly. There you can specify your subscriptionName and topicName values. Here's an example:
{
"bindings": [
{
"type": "serviceBusTrigger",
"name": "message",
"direction": "in",
"subscriptionName": "subscription-test",
"topicName": "topic-test",
}
]
}
In general, since Azure Functions is build atop the WebJobs SDK, our various bindings are mapped directly to their SDK counterparts. For example serviceBusTrigger maps to ServiceBusTriggerAttribute which has SubscriptionName/TopicName properties. Therefore, expect to see the same properties in the Function metadata model.

Azure Search SDK Create DataSource

I've been created a datasource by Azure Search SDK.
The Datasource from Azure sql which is a View.
I tyr to setting the DataChangeDetectionPolicy and DataDeletionDetectionPolicy,
but i can't understand how to set this two property.
When i think this two property doesn't supported on the preview sdk,so i try to use REST API to solve this.
I read the article:
MSDN Create Data Source (Azure Search Service REST API)
And use Chrome Extension Postman to set the Data Change Detection Policies.
Url : https://domain.search.windows.net/datasources/temp1?api-version=2015-02-28
body :
{
"#odata.type" : "#Microsoft.Azure.Search.HighWaterMarkChangeDetectionPolicy",
"highWaterMarkColumnName" : "ModifiedDatetime"
}
then i get the 400 bad request .
error message:
{
"error":
{
"code": "",
"message": "The request is invalid. Details: dataSource : Incompatible type kinds were found. The type 'Microsoft.Azure.Search.HighWaterMarkChangeDetectionPolicy' was found to be of kind 'Complex' instead of the expected kind 'Entity'.\r\n"
}
}
So,i have two questions.
1.Is the SDK are not support this function Now?
2.with the REST API , how to solve the error?
Thanks for reply.
Based on the official article, the way to create the datasource for SQL integration for Views is:
{
"name" : "myazuresqldatasource",
"type" : "azuresql",
"credentials" : { "connectionString" : "connection string" },
"container" : { "name" : "table or view name" },
"dataChangeDetectionPolicy" : {
"#odata.type" : "#Microsoft.Azure.Search.HighWaterMarkChangeDetectionPolicy",
"highWaterMarkColumnName" : "[a row version or last_updated column name]"
}
}
The SDK does support data source creation. See https://learn.microsoft.com/en-us/dotnet/api/microsoft.azure.search.models.datasource

RoutingMissingException using NEST IndexMany<>

I've been working on converting my ElasticSearch (ES) 0.9 code to work with ES 1.0. This has required an upgrade of NEST to the latest pre-release version.
I've been trying to bulk index a set of child documents. I've set up their mapping as:
"stocks": {
"_parent": {
"type": "products"
},
"_timestamp": {
"enabled": true
},
"properties": {
"id": {
"type": "integer",
"index": "not_analyzed"
},
"stock": {
"type": "integer",
"index": "not_analyzed"
}
}
}
This was created in ES 0.9. When I've put this into ES 1.0, it automatically adds a Routing property with 'Required' set to 'true'. A search on Google suggests that this was always required to enable a parent-child document setup but the property never explicitly appeared when I examined the documents in my 0.9 shard.
"Ok..." I think to myself. Next, I have the following code block for NEST:
var bulkParams = postQueue.Select(p => new BulkParameters<Stock>(p) { Parent = p.id.ToString()});
IElasticsearchResponse c = ec.IndexMany(bulkParams, null, "stocks").ConnectionStatus;
This returns a NullReferenceException. After some guesswork I added the Id parameter into the BulkParameters:
var bulkParams = postQueue.Select(p => new BulkParameters<Stock>(p) { Id = p.id.ToString(), Parent = p.id.ToString()});
Which seems to work, but the request returns a error response from ES:
400 Bad Request with JSON error message:
error=RoutingMissingException[routing is required for [test_index]/[stocks]/[xx]]
(where xx is the id of the document)
I'm assuming I have to insert a Routing string somewhere, but I do not know where. I've tried adding a 'Routing' parameter into the BulkParameters but that did not work at all. Can anyone please advise?
The support for IndexMany() with wrapped BulkParameters has been removed in NEST 1.0.0 beta 1
If you want to use a bulk with more advanced parameters you now have to use the Bulk() command.
The beta sadly still shipped with the BulkParameters class in the assembly
This has since been removed in the develop branch and will be released in the next beta update.
So what happens now is that you are actually indexing "bulkparameters``1``" type documents and not "stock" with proper individual bulk metadata set.
See here for an example on how to use Bulk() to index many objects at once while configuring advanced parameters for individual items.

Categories