/// <summary>
 /// Updates a connection.
 /// </summary>
 /// <param name="id">The id of the connection to update.</param>
 /// <param name="request">The request containing the properties of the connection you wish to update.</param>
 /// <returns>A <see cref="Connection" /> containing the updated connection.</returns>
 public Task <Connection> UpdateAsync(string id, ConnectionUpdateRequest request)
 {
     return(Connection.PatchAsync <Connection>("connections/{id}", request, new Dictionary <string, string>
     {
         { "id", id }
     }));
 }
Example #2
0
        public void OnConnected(Bundle p0)
        {
            Log.Debug("LocClient", "Connected");

            if (currentRequest == ConnectionUpdateRequest.None)
            {
                return;
            }

            if (callbackIntent == null)
            {
                var intent = new Intent(this, typeof(BikrActivityService));
                callbackIntent = PendingIntent.GetService(this, Resource.Id.bikr_intent_location, intent, PendingIntentFlags.UpdateCurrent);
            }
            if (currentRequest == ConnectionUpdateRequest.Start)
            {
                var req = new LocationRequest()
                          .SetInterval(5000)
                          .SetFastestInterval(2000)
                          .SetSmallestDisplacement(5)
                          .SetPriority(LocationRequest.PriorityHighAccuracy);

                api.RequestLocationUpdates(client, req, callbackIntent);
                prevStoredLocation = api.GetLastLocation(client);
                Log.Info("LocClient", "Requested updates");
            }
            else
            {
                api.RemoveLocationUpdates(client, callbackIntent);
                prevStoredLocation = null;
                Log.Info("LocClient", "Finished updates");
            }
            currentRequest = ConnectionUpdateRequest.None;
            client.Disconnect();
        }
Example #3
0
        public void OnConnected(Bundle p0)
        {
            Log.Debug("ActRecognition", "Connected");
            if (currentRequest == ConnectionUpdateRequest.None)
            {
                return;
            }

            if (callbackIntent == null)
            {
                var intent = new Intent(context, typeof(BikrActivityService));
                callbackIntent = PendingIntent.GetService(context, Resource.Id.bikr_intent_activity, intent, PendingIntentFlags.UpdateCurrent);
            }
            if (currentRequest == ConnectionUpdateRequest.Start)
            {
                api.RequestActivityUpdates(client, (int)desiredDelay, callbackIntent);
                Log.Info("ActRecognition", "Enabling activity updates w/ {0}", desiredDelay.ToString());
            }
            else
            {
                api.RemoveActivityUpdates(client, callbackIntent);
                Log.Info("ActRecognition", "Disabling activity updates");
            }
            currentRequest = ConnectionUpdateRequest.None;
            client.Disconnect();
        }
Example #4
0
        public void OnConnected(Bundle p0)
        {
            Log.Debug ("LocClient", "Connected");
            if (currentRequest == ConnectionUpdateRequest.None)
                return;

            if (callbackIntent == null) {
                var intent = new Intent (this, typeof(BikrActivityService));
                callbackIntent = PendingIntent.GetService (this, Resource.Id.bikr_intent_location, intent, PendingIntentFlags.UpdateCurrent);
            }
            if (currentRequest == ConnectionUpdateRequest.Start) {
                var req = new LocationRequest ()
                    .SetInterval (5000)
                    .SetFastestInterval (2000)
                    .SetSmallestDisplacement (5)
                    .SetPriority (LocationRequest.PriorityHighAccuracy);
                client.RequestLocationUpdates (req, callbackIntent);
                prevStoredLocation = client.LastLocation;
                Log.Info ("LocClient", "Requested updates");
            } else {
                client.RemoveLocationUpdates (callbackIntent);
                prevStoredLocation = null;
                Log.Info ("LocClient", "Finished updates");
            }
            currentRequest = ConnectionUpdateRequest.None;
            client.Disconnect ();
        }
Example #5
0
        private static async Task TestConnectionMethods(IManagementApiClient apiClient)
        {
            // Create a new connection
            var newConnectionRequest = new ConnectionCreateRequest
            {
                Name     = "jerrie-new-connection",
                Strategy = "github"
            };
            var newConnection = await apiClient.Connections.CreateAsync(newConnectionRequest);

            // Get a single connection
            var connection = await apiClient.Connections.GetAsync(newConnection.Id);

            // Get all GitHub connections
            var connections = await apiClient.Connections.GetAllAsync("github");

            // Update a connection
            var updateConnectionRequest = new ConnectionUpdateRequest
            {
                Name = "jerrie-updated-connection"
            };

            connection = await apiClient.Connections.UpdateAsync(newConnection.Id, updateConnectionRequest);

            // Delete the connection
            await apiClient.Connections.DeleteAsync(newConnection.Id);
        }
Example #6
0
        public async Task Test_connection_crud_sequence()
        {
            string token = await GenerateManagementApiToken();

            var apiClient = new ManagementApiClient(token, GetVariable("AUTH0_MANAGEMENT_API_URL"));

            // Get all connections before
            var connectionsBefore = await apiClient.Connections.GetAllAsync("github");

            // Create a new connection
            var newConnectionRequest = new ConnectionCreateRequest
            {
                Name     = Guid.NewGuid().ToString("N"),
                Strategy = "github"
            };
            var newConnectionResponse = await apiClient.Connections.CreateAsync(newConnectionRequest);

            newConnectionResponse.Should().NotBeNull();
            newConnectionResponse.Name.Should().Be(newConnectionRequest.Name);
            newConnectionResponse.Strategy.Should().Be(newConnectionRequest.Strategy);

            // Get all connections again
            var connectionsAfter = await apiClient.Connections.GetAllAsync("github");

            connectionsAfter.Count.Should().Be(connectionsBefore.Count + 1);

            // Update a connection
            var updateConnectionRequest = new ConnectionUpdateRequest
            {
                Options = new
                {
                    a = "123"
                },
                Metadata = new
                {
                    b = "456"
                }
            };
            var updateConnectionResponse = await apiClient.Connections.UpdateAsync(newConnectionResponse.Id, updateConnectionRequest);

            string a = updateConnectionResponse.Options.a;

            a.Should().Be("123");
            string b = updateConnectionResponse.Metadata.b;

            b.Should().Be("456");

            // Get a single connection
            var connection = await apiClient.Connections.GetAsync(newConnectionResponse.Id);

            connection.Should().NotBeNull();

            // Delete the connection and ensure we get exception when trying to get connection again
            await apiClient.Connections.DeleteAsync(newConnectionResponse.Id);

            Func <Task> getFunc = async() => await apiClient.Connections.GetAsync(newConnectionResponse.Id);

            getFunc.ShouldThrow <ApiException>().And.ApiError.ErrorCode.Should().Be("inexistent_connection");
        }
Example #7
0
        public async Task Test_connection_crud_sequence()
        {
            var scopes = new
            {
                connections = new
                {
                    actions = new string[] { "read", "create", "delete", "update" }
                }
            };
            string token = GenerateToken(scopes);

            var apiClient = new ManagementApiClient(token, new Uri(GetVariable("AUTH0_MANAGEMENT_API_URL")));

            // Get all connections before
            var connectionsBefore = await apiClient.Connections.GetAllAsync("github");

            // Create a new connection
            var newConnectionRequest = new ConnectionCreateRequest
            {
                Name = Guid.NewGuid().ToString("N"),
                Strategy = "github"
            };
            var newConnectionResponse = await apiClient.Connections.CreateAsync(newConnectionRequest);
            newConnectionResponse.Should().NotBeNull();
            newConnectionResponse.Name.Should().Be(newConnectionRequest.Name);
            newConnectionResponse.Strategy.Should().Be(newConnectionRequest.Strategy);

            // Get all connections again
            var connectionsAfter = await apiClient.Connections.GetAllAsync("github");
            connectionsAfter.Count.Should().Be(connectionsBefore.Count + 1);

            // Update a connection
            var updateConnectionRequest = new ConnectionUpdateRequest
            {
                Options = new
                {
                    a = "123"
                }
            };
            var updateConnectionResponse = await apiClient.Connections.UpdateAsync(newConnectionResponse.Id, updateConnectionRequest);
            //updateConnectionResponse.Name.Should().Be(updateConnectionRequest.Name);

            // Get a single connection
            var connection = await apiClient.Connections.GetAsync(newConnectionResponse.Id);
            connection.Should().NotBeNull();
            //connection.Name.Should().Be(updateConnectionResponse.Name);

            // Delete the connection and ensure we get exception when trying to get connection again
            await apiClient.Connections.DeleteAsync(newConnectionResponse.Id);
            Func<Task> getFunc = async () => await apiClient.Connections.GetAsync(newConnectionResponse.Id);
            getFunc.ShouldThrow<ApiException>().And.ApiError.ErrorCode.Should().Be("inexistent_connection");
        }
        public void OnConnected(Bundle p0)
        {
            Log.Debug ("ActRecognition", "Connected");
            if (currentRequest == ConnectionUpdateRequest.None)
                return;

            if (callbackIntent == null) {
                var intent = new Intent (context, typeof(BikrActivityService));
                callbackIntent = PendingIntent.GetService (context, Resource.Id.bikr_intent_activity, intent, PendingIntentFlags.UpdateCurrent);
            }
            if (currentRequest == ConnectionUpdateRequest.Start) {
                client.RequestActivityUpdates ((int)desiredDelay, callbackIntent);
                Log.Info ("ActRecognition", "Enabling activity updates w/ {0}", desiredDelay.ToString ());
            } else {
                client.RemoveActivityUpdates (callbackIntent);
                Log.Info ("ActRecognition", "Disabling activity updates");
            }
            currentRequest = ConnectionUpdateRequest.None;
            client.Disconnect ();
        }
Example #9
0
 void SetLocationUpdateEnabled(bool enabled)
 {
     if (currentRequest != ConnectionUpdateRequest.None)
     {
         return;
     }
     currentRequest = enabled ? ConnectionUpdateRequest.Start : ConnectionUpdateRequest.Stop;
     if (client == null)
     {
         client = CreateGoogleClient();
     }
     if (!(client.IsConnected || client.IsConnecting))
     {
         client.Connect();
     }
     if (enabled)
     {
         TripDebugLog.StartBikeTrip();
     }
 }
Example #10
0
 public void SetTrackingEnabled(bool enabled, TrackingDelay desiredDelay = TrackingDelay.Long)
 {
     this.desiredDelay = desiredDelay;
     if (!enabled)
     {
         StopCurrentLocationTracking();
     }
     if (currentRequest != ConnectionUpdateRequest.None)
     {
         return;
     }
     currentRequest = enabled ? ConnectionUpdateRequest.Start : ConnectionUpdateRequest.Stop;
     if (client == null)
     {
         client = CreateGoogleClient();
     }
     if (!(client.IsConnected || client.IsConnecting))
     {
         client.Connect();
     }
 }
Example #11
0
        public async Task Test_connection_crud_sequence()
        {
            // Get all connections before
            var connectionsBefore = await _apiClient.Connections.GetAllAsync(new GetConnectionsRequest
            {
                Strategy = new[] { "github" }
            }, new PaginationInfo());

            // Create a new connection
            var newConnectionRequest = new ConnectionCreateRequest
            {
                Name     = "Temp-Int-Test-" + MakeRandomName(),
                Strategy = "github"
            };
            var newConnectionResponse = await _apiClient.Connections.CreateAsync(newConnectionRequest);

            newConnectionResponse.Should().NotBeNull();
            newConnectionResponse.Name.Should().Be(newConnectionRequest.Name);
            newConnectionResponse.Strategy.Should().Be(newConnectionRequest.Strategy);

            // Get all connections again
            var connectionsAfter = await _apiClient.Connections.GetAllAsync(new GetConnectionsRequest
            {
                Strategy = new[] { "github" }
            }, new PaginationInfo());

            connectionsAfter.Count.Should().Be(connectionsBefore.Count + 1);

            // Update a connection
            var updateConnectionRequest = new ConnectionUpdateRequest
            {
                Options = new
                {
                    a = "123"
                },
                Metadata = new
                {
                    b = "456"
                }
            };
            var updateConnectionResponse = await _apiClient.Connections.UpdateAsync(newConnectionResponse.Id, updateConnectionRequest);

            string a = updateConnectionResponse.Options.a;

            a.Should().Be("123");
            string b = updateConnectionResponse.Metadata.b;

            b.Should().Be("456");

            // Get a single connection
            var connection = await _apiClient.Connections.GetAsync(newConnectionResponse.Id);

            connection.Should().NotBeNull();

            // Delete the connection and ensure we get exception when trying to get connection again
            await _apiClient.Connections.DeleteAsync(newConnectionResponse.Id);

            Func <Task> getFunc = async() => await _apiClient.Connections.GetAsync(newConnectionResponse.Id);

            getFunc.Should().Throw <ErrorApiException>().And.ApiError.ErrorCode.Should().Be("inexistent_connection");
        }
Example #12
0
 public Task <Connection> Update(string id, ConnectionUpdateRequest request)
 {
     return(UpdateAsync(id, request));
 }
Example #13
0
 /// <summary>
 /// Updates a connection.
 /// </summary>
 /// <param name="id">The id of the connection to update.</param>
 /// <param name="request">The request containing the properties of the connection you wish to update.</param>
 /// <returns>A <see cref="Connection" /> containing the updated connection.</returns>
 public Task<Connection> UpdateAsync(string id, ConnectionUpdateRequest request)
 {
     return Connection.PatchAsync<Connection>("connections/{id}", request, new Dictionary<string, string>
     {
         {"id", id}
     });
 }
Example #14
0
 public Task<Connection> Update(string id, ConnectionUpdateRequest request)
 {
     return UpdateAsync(id, request);
 }
Example #15
0
        private static async Task TestConnectionMethods(IManagementApiClient apiClient)
        {
            // Create a new connection
            var newConnectionRequest = new ConnectionCreateRequest
            {
                Name = "jerrie-new-connection",
                Strategy = "github"
            };
            var newConnection = await apiClient.Connections.CreateAsync(newConnectionRequest);

            // Get a single connection
            var connection = await apiClient.Connections.GetAsync(newConnection.Id);

            // Get all GitHub connections
            var connections = await apiClient.Connections.GetAllAsync("github");

            // Update a connection
            var updateConnectionRequest = new ConnectionUpdateRequest
            {
                Name = "jerrie-updated-connection"
            };
            connection = await apiClient.Connections.UpdateAsync(newConnection.Id, updateConnectionRequest);

            // Delete the connection
            await apiClient.Connections.DeleteAsync(newConnection.Id);
        }
 public void SetTrackingEnabled(bool enabled, TrackingDelay desiredDelay = TrackingDelay.Long)
 {
     this.desiredDelay = desiredDelay;
     if (!enabled)
         StopCurrentLocationTracking ();
     if (currentRequest != ConnectionUpdateRequest.None)
         return;
     currentRequest = enabled ? ConnectionUpdateRequest.Start : ConnectionUpdateRequest.Stop;
     if (client == null)
         client = new ActivityRecognitionClient (context, this, this);
     if (!(client.IsConnected || client.IsConnecting))
         client.Connect ();
 }
Example #17
0
 void SetLocationUpdateEnabled(bool enabled)
 {
     if (currentRequest != ConnectionUpdateRequest.None)
         return;
     currentRequest = enabled ? ConnectionUpdateRequest.Start : ConnectionUpdateRequest.Stop;
     if (client == null)
         client = new LocationClient (this, this, this);
     if (!(client.IsConnected || client.IsConnecting))
         client.Connect ();
     if (enabled)
         TripDebugLog.StartBikeTrip ();
 }
 /// <summary>
 /// Updates a connection.
 /// </summary>
 /// <param name="id">The id of the connection to update.</param>
 /// <param name="request">The <see cref="ConnectionUpdateRequest"/> containing the properties of the connection you wish to update.</param>
 /// <returns>The <see cref="Connection"/> that has been updated.</returns>
 public Task <Connection> UpdateAsync(string id, ConnectionUpdateRequest request)
 {
     return(Connection.SendAsync <Connection>(new HttpMethod("PATCH"), BuildUri($"connections/{EncodePath(id)}"), request, DefaultHeaders));
 }