Exemple #1
0
 public Endpoint(ITimeCoordinator timeCoordinator, EndpointIdentity identity, EndpointMetadata metadata, string password = null)
 {
     _timeCoordinator = timeCoordinator;
     Identity         = identity;
     Metadata         = metadata;
     Password         = password;
     UpdateLastModifiedTime();
 }
        public EndpointProxy(IRestEndpoint endpoint, EndpointMetadata metadata, IRestContainer components)
        {
            endpoint.AssertNotNull(nameof(endpoint));
            metadata.AssertNotNull(nameof(metadata));
            components.AssertNotNull(nameof(components));

            _endpoint         = endpoint;
            _metadata         = metadata;
            _modelMapper      = components.Required <RestModelMapper>();
            _resultValidators = components.Resolve <IInvocatioтFilter>().ToList();
        }
Exemple #3
0
        public void HandleMetricsForwarding(EndpointIdentity identity, EndpointMetadata metadata, EndpointHealth health)
        {
            var ed = new EndpointDetails(identity.Id, metadata.Group, metadata.Name, identity.Address, identity.MonitorType);
            var em = new EndpointMetrics(health.CheckTimeUtc, health.ResponseTime.Milliseconds, health.Status.ToString());

            foreach (var f in _forwarders)
            {
                Logger.InfoFormat("Forwarding metrics using {0} forwarder, for endpoint id {1}", f.Key, identity.Id);

                f.Value.ForwardEndpointMetrics(ed, em);
            }
        }
        public void RegisterReader_AddNewReader_VerifyReadReturnsEndpointMetadataCollection()
        {
            string           json             = @"{
  ""fakeApi"": ""1.0.0"",
  ""info"": {
    ""version"": ""v1""
  }
}";
            JObject          jobject          = JObject.Parse(json);
            EndpointMetadata endpointMetadata = new EndpointMetadata(path: "/api/Employees",
                                                                     requestsByMethodAndContentType: new Dictionary <string, IReadOnlyDictionary <string, IReadOnlyList <Parameter> > >());
            EndPointMetaDataReaderStub endPointMetaDataReaderStub = new EndPointMetaDataReaderStub(endpointMetadata);

            EndpointMetadataReader endpointMetadataReader = new EndpointMetadataReader();

            endpointMetadataReader.RegisterReader(endPointMetaDataReaderStub);

            IEnumerable <EndpointMetadata> result = endpointMetadataReader.Read(jobject);

            Assert.Single(result);
            Assert.Equal(endpointMetadata, result.First());
        }
        private static void FillDirectoryInfo(DirectoryStructure parent, EndpointMetadata entry)
        {
            string[] parts = entry.Path.Split('/');

            foreach (string part in parts)
            {
                if (!string.IsNullOrEmpty(part))
                {
                    parent = parent.DeclareDirectory(part);
                }
            }

            RequestInfo dirRequestInfo = new RequestInfo();

            foreach (KeyValuePair <string, IReadOnlyDictionary <string, IReadOnlyList <Parameter> > > requestInfo in entry.AvailableRequests)
            {
                string method = requestInfo.Key;

                foreach (KeyValuePair <string, IReadOnlyList <Parameter> > parameterSetsByContentType in requestInfo.Value)
                {
                    if (string.IsNullOrEmpty(parameterSetsByContentType.Key))
                    {
                        dirRequestInfo.SetFallbackRequestBody(method, GetBodyString(null, parameterSetsByContentType.Value));
                    }

                    dirRequestInfo.SetRequestBody(method, parameterSetsByContentType.Key, GetBodyString(parameterSetsByContentType.Key, parameterSetsByContentType.Value));
                }

                dirRequestInfo.AddMethod(method);
            }

            if (dirRequestInfo.Methods.Count > 0)
            {
                parent.RequestInfo = dirRequestInfo;
            }
        }
Exemple #6
0
 public void EndpointDetected(object sender, EndpointMetadata md)
 {
     _logger.LogInformation("Endpoint detected: " + md.Ip + ":" + md.Port);
 }
Exemple #7
0
 public Endpoint UpdateMetadata(string group, string name, string[] tags, string monitorTag)
 {
     Metadata = new EndpointMetadata(name, group, tags ?? Metadata.Tags, monitorTag, Metadata.RegisteredOnUtc, _timeCoordinator.UtcNow);
     UpdateLastModifiedTime();
     return(this);
 }
Exemple #8
0
 public EndPointMetaDataReaderStub(EndpointMetadata endpointMetadata)
 {
     _endpointMetadata = endpointMetadata;
 }
Exemple #9
0
        public void ReadMetadata_WithMultipleObjectsInApisArray_ReturnsEndpointMetadata()
        {
            string  json    = @"{
  ""swaggerVersion"": ""1.2"",
  ""apis"": [
    {
      ""path"": ""/user/logout"",
      ""operations"": [
        {
          ""method"": ""GET"",
          ""parameters"": []
        }
      ]
    },
    {
      ""path"": ""/user/login"",
      ""operations"": [
        {
          ""method"": ""GET"",
          ""parameters"": [
            {
              ""name"": ""username"",
              ""description"": ""The user name for login"",
              ""required"": true,
              ""type"": ""string"",
              ""paramType"": ""query""
            }
          ]
        }
      ]
    }
  ],
  ""models"": {
    ""User"": {
      ""id"": ""User"",
      ""properties"": {
        ""id"": {
          ""type"": ""integer"",
          ""format"": ""int64""
        },
        ""firstName"": {
          ""type"": ""string""
        }
      }
    }
  }
}";
            JObject jobject = JObject.Parse(json);
            SwaggerV1EndpointMetadataReader swaggerV1EndpointMetadataReader = new SwaggerV1EndpointMetadataReader();

            List <EndpointMetadata> endpointMetadata = swaggerV1EndpointMetadataReader.ReadMetadata(jobject).ToList();

            EndpointMetadata endpointMetadata1 = endpointMetadata[0];
            EndpointMetadata endpointMetadata2 = endpointMetadata[1];

            Assert.Equal(2, endpointMetadata.Count);

            Assert.Equal("/user/logout", endpointMetadata1.Path);
            Assert.Single(endpointMetadata1.AvailableRequests);
            Assert.Equal("GET", endpointMetadata1.AvailableRequests.First().Key);

            Assert.Equal("/user/login", endpointMetadata2.Path);
            Assert.Single(endpointMetadata2.AvailableRequests);
            Assert.Equal("GET", endpointMetadata2.AvailableRequests.First().Key);
        }
 public void RecordEndpointStatistics(EndpointIdentity identity, EndpointMetadata metadata, EndpointHealth stats)
 {
     _statsQueue.Enqueue(Tuple.Create(identity, metadata, stats));
 }
 public Endpoint UpdateMetadata(string group, string name, string[] tags)
 {
     Metadata = new EndpointMetadata(name, group, tags ?? Metadata.Tags);
     UpdateLastModifiedTime();
     return(this);
 }
 public Endpoint(EndpointIdentity identity, EndpointMetadata metadata)
 {
     Identity = identity;
     Metadata = metadata;
     UpdateLastModifiedTime();
 }
Exemple #13
0
 static void EndpointDetected(object sender, EndpointMetadata md)
 {
     Console.WriteLine("Endpoint detected: " + md.Ip + ":" + md.Port);
 }