/// <summary> /// Get the named REST client /// </summary> public IRestClient GetRestClient(ServiceEndpointType type) { IRestClient retVal = null; this.m_restClients.TryGetValue(type, out retVal); return(retVal); }
/// <summary> /// Creates a new api endpoint behavior /// </summary> public ApiEndpointProviderShim(Type behavior, ServiceEndpointType apiType, String url, ServiceEndpointCapabilities capabilities) { this.ApiType = apiType; this.Url = new string[] { url }; this.Capabilities = capabilities; this.BehaviorType = behavior; }
///GENMHASH:33C1C987DF52CFF94EDF2633458514E4:DE74936B83C8416C09839259665F2BD2 public IReadOnlyDictionary <Models.ServiceEndpointType, System.Collections.Generic.List <Microsoft.Azure.Management.ResourceManager.Fluent.Core.Region> > ServicesWithAccess() { var services = new Dictionary <ServiceEndpointType, List <Region> >(); if (this.Inner.ServiceEndpoints != null) { foreach (var endpoint in this.Inner.ServiceEndpoints) { ServiceEndpointType serviceEndpointType = ServiceEndpointType.Parse(endpoint.Service); if (!services.ContainsKey(serviceEndpointType)) { services.Add(serviceEndpointType, new List <Region>()); } if (endpoint.Locations != null) { List <Region> regions = new List <Region>(); foreach (var location in endpoint.Locations) { regions.Add(Region.Create(location)); } services[serviceEndpointType].AddRange(regions); } } } return(services); }
///GENMHASH:4BBEC5095F134F13806627750ADC9D39:94AECEF6A2216225A2656ED6B352544E public SubnetImpl WithAccessFromService(ServiceEndpointType service) { if (this.Inner.ServiceEndpoints == null) { this.Inner.ServiceEndpoints = new List <ServiceEndpointPropertiesFormat>(); } bool found = false; foreach (var endpoint in this.Inner.ServiceEndpoints) { if (endpoint.Service.Equals(service.ToString(), StringComparison.OrdinalIgnoreCase)) { found = true; break; } } if (!found) { this.Inner .ServiceEndpoints .Add(new ServiceEndpointPropertiesFormat { Service = service.ToString(), Locations = new List <string>() }); } return(this); }
/// <summary> /// Resolves the service from name /// </summary> public static ServiceEndpointOptions ResolveService(String serviceName) { // Look for external services? IEnumerable <ServiceEndpointOptions> services = ApplicationServiceContext.Current.GetService <IConfigurationManager>().GetSection <MetadataConfigurationSection>().Services; if (services == null || services.Count() == 0) { services = ApplicationServiceContext.Current.GetService <IServiceManager>().GetServices().OfType <IApiEndpointProvider>().Select(o => new ServiceEndpointOptions(o)); } var serviceEndpoint = typeof(ServiceEndpointType).GetFields().FirstOrDefault(o => o.GetCustomAttribute <XmlEnumAttribute>()?.Name == serviceName)?.Name; if (!String.IsNullOrEmpty(serviceEndpoint)) { ServiceEndpointType serviceEndpointType = (ServiceEndpointType)Enum.Parse(typeof(ServiceEndpointType), serviceEndpoint); return(services.FirstOrDefault(o => o.ServiceType == serviceEndpointType)); } else { return(null); } }
///GENMHASH:4BF88A9FA8C6CBDE8C9FB8F2E36F2042:2364D37AC0E056BCEDF007BC6849ADD1 public Subnet.Update.IUpdate WithoutAccessFromService(ServiceEndpointType service) { if (this.Inner.ServiceEndpoints != null) { int foundIndex = -1; int i = 0; foreach (var endpoint in this.Inner.ServiceEndpoints) { if (endpoint.Service.Equals(service.ToString(), StringComparison.OrdinalIgnoreCase)) { foundIndex = i; break; } i++; } if (foundIndex != -1) { this.Inner.ServiceEndpoints.RemoveAt(foundIndex); } } return(this); }
/// <summary> /// Specifies that existing access from a service endpoint should be removed. /// </summary> /// <param name="service">The service type.</param> /// <return>The next stage of the definition.</return> Subnet.Update.IUpdate Subnet.Update.IWithServiceEndpoint.WithoutAccessFromService(ServiceEndpointType service) { return(this.WithoutAccessFromService(service)); }
/// <summary> /// Specifies a service endpoint to enable access from. /// </summary> /// <param name="service">The service type.</param> /// <return>The next stage of the definition.</return> Subnet.UpdateDefinition.IWithAttach <Network.Update.IUpdate> Subnet.UpdateDefinition.IWithServiceEndpoint <Network.Update.IUpdate> .WithAccessFromService(ServiceEndpointType service) { return(this.WithAccessFromService(service)); }
/// <summary> /// Specifies a service endpoint to enable access from. /// </summary> /// <param name="service">The service type.</param> /// <return>The next stage of the definition.</return> Subnet.Definition.IWithAttach <Network.Definition.IWithCreateAndSubnet> Subnet.Definition.IWithServiceEndpoint <Network.Definition.IWithCreateAndSubnet> .WithAccessFromService(ServiceEndpointType service) { return(this.WithAccessFromService(service)); }
/// <summary> /// Starts this service handler /// </summary> public bool Start() { RemoteEndpointUtil.Current.AddEndpointProvider(this.GetRemoteEndpointInfo); this.Starting?.Invoke(this, EventArgs.Empty); // Start up each of the services foreach (var itm in ApplicationContext.Current.Configuration.GetSection <AgsConfigurationSection>().Services) { this.m_tracer.TraceInfo("Starting Application Gateway Service {0}..", itm.Name); // Service Behaviors RestService service = new RestService(itm.ServiceType); service.AddServiceBehavior(new AgsAuthorizationServiceBehavior()); service.AddServiceBehavior(new AgsMagicServiceBehavior()); service.AddServiceBehavior(new AgsPermissionPolicyBehavior(itm.ServiceType)); foreach (var bhvr in itm.Behaviors) { this.m_tracer.TraceVerbose("AGS Service {0} has behavior {1}", itm.Name, bhvr.XmlType); service.AddServiceBehavior(this.CreateBehavior <IServiceBehavior>(bhvr)); } // Endpoints foreach (var ep in itm.Endpoints) { this.m_tracer.TraceInfo("\tEndpoint: {0}", ep.Address); var serviceEndpoint = service.AddServiceEndpoint(new Uri(ep.Address), ep.Contract, new RestHttpBinding()); foreach (var bhvr in ep.Behaviors) { this.m_tracer.TraceVerbose("AGS Service {0} endpoint {1} has behavior {2}", itm.Name, ep.Address, bhvr.XmlType); serviceEndpoint.AddEndpointBehavior(this.CreateBehavior <IEndpointBehavior>(bhvr)); } } // Add the specified object to the discovery processor ServiceEndpointType apiType = ServiceEndpointType.Other; if (typeof(IAmiServiceContract).IsAssignableFrom(itm.ServiceType)) { apiType = ServiceEndpointType.AdministrationIntegrationService; } else if (typeof(IHdsiServiceContract).IsAssignableFrom(itm.ServiceType)) { apiType = ServiceEndpointType.HealthDataService; } else if (typeof(IBisServiceContract).IsAssignableFrom(itm.ServiceType)) { apiType = ServiceEndpointType.BusinessIntelligenceService; } else if (typeof(IAuthenticationServiceContract).IsAssignableFrom(itm.ServiceType)) { apiType = ServiceEndpointType.AuthenticationService; } else if (typeof(IApplicationServiceContract).IsAssignableFrom(itm.ServiceType)) { apiType = ServiceEndpointType.Other | ServiceEndpointType.AdministrationIntegrationService; } ApplicationServiceContext.Current.GetService <IServiceManager>().AddServiceProvider(new ApiEndpointProviderShim(itm.ServiceType, apiType, itm.Endpoints.First().Address, (ServiceEndpointCapabilities)this.GetServiceCapabilities(service))); // Start the service this.m_services.Add(service); service.Start(); } this.Started?.Invoke(this, EventArgs.Empty); return(this.IsRunning); }
/// <summary> /// Get the service capabilities /// </summary> public static ServiceEndpointCapabilities GetServiceCapabilities(ServiceEndpointType endpointType) { var svc = ApplicationServiceContext.Current.GetService <IServiceManager>().GetServices().OfType <IApiEndpointProvider>().FirstOrDefault(o => o.ApiType == endpointType); return(svc.Capabilities); }