-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create Access Key #129
base: master
Are you sure you want to change the base?
Create Access Key #129
Conversation
Thanks, I'll continue review here. |
I'm not sure why TravisCI succeeded and AppVeyor failed, but are your tests hitting the real server? |
Strange, its coming from the last commit - I didn't see a problem in it. |
The tests don't seem to be mocked, so if it was succeeding before it was because you hadn't switched the keys. |
Keen.NET.Test/KeenClientTest.cs
Outdated
var client = new KeenClient(settings); | ||
|
||
if (UseMocks) | ||
client.AccessKeys = new AccessKeysMock(settings, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the idea is just to do unit testing on the CreateAccessKey()
method of the KeenClient
, we can just leverage Moq instead of creating a separate class, which might be simpler.
Keen/AccessKey/AccessKey.cs
Outdated
namespace Keen.Core.AccessKey | ||
{ | ||
/// <summary> | ||
/// Modal for AccessKey object |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: "Modal"->"Model", and we should elaborate on XML doc comments on any public members.
Keen/AccessKey/AccessKey.cs
Outdated
public ISet<string> Allowed { get; set; } | ||
} | ||
|
||
public class Quaries |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: "Quaries"->"Queries"
Keen/AccessKey/AccessKey.cs
Outdated
public Writes Writes { get; set; } | ||
public Datasets Datasets { get; set; } | ||
public CachedQueries CachedQueries { get; set; } | ||
public Quaries Queries { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: "Quaries"->"Queries"
Keen/AccessKey/AccessKey.cs
Outdated
|
||
} | ||
|
||
public class SavedQueries |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All these public types should have XML doc comments.
Keen/AccessKey/AccessKeys.cs
Outdated
public class AccessKeys : IAccessKeys | ||
{ | ||
private readonly IKeenHttpClient _keenHttpClient; | ||
private readonly string _acceskeyRelativeUrl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: "_acceskey..."->"_accessKey...",
{ | ||
jsonResponse = JObject.Parse(responseString); | ||
} | ||
catch (Exception) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this because you were seeing a 404 error or something similar and it's actually OK in this case to swallow the exception? Then will we throw below? I know we do this elsewhere, and we should really keep the inner exception around for context, but that's another issue. At least if that's the case, let's put a comment here explaining the empty catch(){}
block.
Keen/KeenClient.cs
Outdated
|
||
/// <summary> | ||
/// </summary> | ||
public void CreateAccessKey(AccessKey.AccessKey accessKey) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need the namespace qualification?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes since namespace and class have the same name, even though I used the namespace, C# fails to understand, AccessKey
is a class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If that's the case it seems like we should rename to AccessKeys
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean the namespace? We have another class called AccessKeys
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, or does that cause other problems?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah in that sense, we may need to go for AccessKeys = new AccessKeys.AccessKeys(_prjSettings, keenHttpClientProvider);
in the KeenClient.cs
Keen/AccessKey/AccessKey.cs
Outdated
public string Key { get; set; } | ||
public Options Options { get; set; } | ||
|
||
internal AccessKey(string name, bool isActive, ISet<string> permitted, Options options) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the properties all remain public, is it useful to have an internal constructor instead of using object initializer notation and giving the Key
auto-prop a default?
Keen.NET.Test/KeenClientTest.cs
Outdated
|
||
HashSet<string> permissions = new HashSet<string>() { "queries" }; | ||
List<Core.Query.QueryFilter> qFilters = new List<Core.Query.QueryFilter>() { new Core.Query.QueryFilter("customer.id", Core.Query.QueryFilter.FilterOperator.Equals(), "asdf12345z") }; | ||
CachedQueries cachedQuaries = new CachedQueries(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: "cachedQuaries"->"cachedQueries"
|
||
///<summary> | ||
///</summary> | ||
private async Task<JObject> CreateAccessKeyAsync(AccessKey.AccessKey accessKey) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need the namespace qualification?
Keen/AccessKey/IAccessKeys.cs
Outdated
|
||
namespace Keen.Core.AccessKey | ||
{ | ||
public interface IAccessKeys |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll want to flesh out XML doc comments here.
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Linq; | ||
using Newtonsoft.Json.Serialization; | ||
using System; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget to organize and remove unnecessary using
s.
/// </summary> | ||
/// <param name="accesskey"></param> | ||
/// <returns></returns> | ||
Task<JObject> CreateAccessKey(AccessKey accesskey); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We prefer Task-returning methods to use the ...Async(...)
naming guideline.
Keen.NET.Test/KeenClientTest.cs
Outdated
@@ -46,6 +47,43 @@ public static void ResetEnv() | |||
} | |||
|
|||
[TestFixture] | |||
public class AccessKeysTest : TestBase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should break this out into another file.
Keen.NET.Test/KeenClientTest.cs
Outdated
})); | ||
|
||
HashSet<string> permissions = new HashSet<string>() { "queries" }; | ||
List<Core.Query.QueryFilter> qFilters = new List<Core.Query.QueryFilter>() { new Core.Query.QueryFilter("customer.id", Core.Query.QueryFilter.FilterOperator.Equals(), "asdf12345z") }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If/when you create a new file for Access Key tests, I'd recommend adding using Keen.Core.Query;
and dispensing with the explicit namespace here.
Keen/AccessKey/AccessKeys.cs
Outdated
throw new KeenException("An API WriteKey is required to add events."); | ||
} | ||
|
||
var xcontent = accesskey.ToString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this xcontent
var we have here?
Agreed to all of your changes. |
@IshamMohamed Are you actively working on this for the rest of the week? What's your ideal timeline for making these suggested revisions? Do you have plans to add the other Access Keys APIs to this, or to leave that for another PR? |
Yes I will be. Will finish the suggested revisions before end of this week and start working on the other APIs - but I don't really know if I need another PR for it? do I? |
Well we'll need to approve and merges changes to master. Speaking of, you'll need to merge from master to get the latest and deal with any potential merge conflicts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed
Reviewed all your changed and accepted them. Will work a bit on improving code coverage later today - and come back to some of your questions as well. |
Ok, if you push some more changes I should be able to review over the weekend. Thanks! |
@IshamMohamed Let me know when you have something ready for review again. I'd love to get AccessKey creation checked in so we can flesh out the rest of the functionality around AccessKeys. |
@masojus can you please let me know, what has to be done to improve the code coverage? |
Also, there are some huge changes in |
Okay, I merged master and will push a branch...I'll probably create a new PR tomorrow. You missed several of the comments and changes I requested in this PR, so we'll have to go through and clean those things up. Expect to see those changes tomorrow. |
Take a look at jm_CreateAccessKey_PR129 to see how things are going with porting this to the new project structure and starting some clean up. I'll make more progress tomorrow and ask for review. |
This is the pull request for the "Create Access Key"