File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed
src/Nest/XPack/Security/Role Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change 1+ using System ;
2+ using System . Collections . Generic ;
3+ using System . Linq ;
4+ using Newtonsoft . Json ;
5+
6+ namespace Nest
7+ {
8+ [ JsonConverter ( typeof ( ReadAsTypeJsonConverter < FieldSecurity > ) ) ]
9+ public interface IFieldSecurity
10+ {
11+ [ JsonProperty ( "grant" ) ]
12+ Fields Grant { get ; set ; }
13+
14+ [ JsonProperty ( "except" ) ]
15+ Fields Except { get ; set ; }
16+ }
17+ public class FieldSecurity : IFieldSecurity
18+ {
19+ public Fields Grant { get ; set ; }
20+ public Fields Except { get ; set ; }
21+ }
22+
23+ public class FieldSecurityDescriptor < T > : DescriptorBase < FieldSecurityDescriptor < T > , IFieldSecurity > , IFieldSecurity
24+ where T : class
25+ {
26+ Fields IFieldSecurity . Grant { get ; set ; }
27+ Fields IFieldSecurity . Except { get ; set ; }
28+
29+ public FieldSecurityDescriptor < T > Grant ( Func < FieldsDescriptor < T > , IPromise < Fields > > fields ) =>
30+ Assign ( a => a . Grant = fields ? . Invoke ( new FieldsDescriptor < T > ( ) ) ? . Value ) ;
31+
32+ public FieldSecurityDescriptor < T > Grant ( Fields fields ) => Assign ( a => a . Grant = fields ) ;
33+
34+ public FieldSecurityDescriptor < T > Except ( Func < FieldsDescriptor < T > , IPromise < Fields > > fields ) =>
35+ Assign ( a => a . Except = fields ? . Invoke ( new FieldsDescriptor < T > ( ) ) ? . Value ) ;
36+
37+ public FieldSecurityDescriptor < T > Except ( Fields fields ) => Assign ( a => a . Except = fields ) ;
38+
39+ }
40+ }
You can’t perform that action at this time.
0 commit comments