github.com/authzed/spicedb@v1.32.1-0.20240520085336-ebda56537386/pkg/datastore/options/zz_generated.query_options.go (about)

     1  // Code generated by github.com/ecordell/optgen. DO NOT EDIT.
     2  package options
     3  
     4  import (
     5  	defaults "github.com/creasty/defaults"
     6  	helpers "github.com/ecordell/optgen/helpers"
     7  )
     8  
     9  type QueryOptionsOption func(q *QueryOptions)
    10  
    11  // NewQueryOptionsWithOptions creates a new QueryOptions with the passed in options set
    12  func NewQueryOptionsWithOptions(opts ...QueryOptionsOption) *QueryOptions {
    13  	q := &QueryOptions{}
    14  	for _, o := range opts {
    15  		o(q)
    16  	}
    17  	return q
    18  }
    19  
    20  // NewQueryOptionsWithOptionsAndDefaults creates a new QueryOptions with the passed in options set starting from the defaults
    21  func NewQueryOptionsWithOptionsAndDefaults(opts ...QueryOptionsOption) *QueryOptions {
    22  	q := &QueryOptions{}
    23  	defaults.MustSet(q)
    24  	for _, o := range opts {
    25  		o(q)
    26  	}
    27  	return q
    28  }
    29  
    30  // ToOption returns a new QueryOptionsOption that sets the values from the passed in QueryOptions
    31  func (q *QueryOptions) ToOption() QueryOptionsOption {
    32  	return func(to *QueryOptions) {
    33  		to.Limit = q.Limit
    34  		to.Sort = q.Sort
    35  		to.After = q.After
    36  	}
    37  }
    38  
    39  // DebugMap returns a map form of QueryOptions for debugging
    40  func (q QueryOptions) DebugMap() map[string]any {
    41  	debugMap := map[string]any{}
    42  	debugMap["Limit"] = helpers.DebugValue(q.Limit, false)
    43  	debugMap["Sort"] = helpers.DebugValue(q.Sort, false)
    44  	debugMap["After"] = helpers.DebugValue(q.After, false)
    45  	return debugMap
    46  }
    47  
    48  // QueryOptionsWithOptions configures an existing QueryOptions with the passed in options set
    49  func QueryOptionsWithOptions(q *QueryOptions, opts ...QueryOptionsOption) *QueryOptions {
    50  	for _, o := range opts {
    51  		o(q)
    52  	}
    53  	return q
    54  }
    55  
    56  // WithOptions configures the receiver QueryOptions with the passed in options set
    57  func (q *QueryOptions) WithOptions(opts ...QueryOptionsOption) *QueryOptions {
    58  	for _, o := range opts {
    59  		o(q)
    60  	}
    61  	return q
    62  }
    63  
    64  // WithLimit returns an option that can set Limit on a QueryOptions
    65  func WithLimit(limit *uint64) QueryOptionsOption {
    66  	return func(q *QueryOptions) {
    67  		q.Limit = limit
    68  	}
    69  }
    70  
    71  // WithSort returns an option that can set Sort on a QueryOptions
    72  func WithSort(sort SortOrder) QueryOptionsOption {
    73  	return func(q *QueryOptions) {
    74  		q.Sort = sort
    75  	}
    76  }
    77  
    78  // WithAfter returns an option that can set After on a QueryOptions
    79  func WithAfter(after Cursor) QueryOptionsOption {
    80  	return func(q *QueryOptions) {
    81  		q.After = after
    82  	}
    83  }
    84  
    85  type ReverseQueryOptionsOption func(r *ReverseQueryOptions)
    86  
    87  // NewReverseQueryOptionsWithOptions creates a new ReverseQueryOptions with the passed in options set
    88  func NewReverseQueryOptionsWithOptions(opts ...ReverseQueryOptionsOption) *ReverseQueryOptions {
    89  	r := &ReverseQueryOptions{}
    90  	for _, o := range opts {
    91  		o(r)
    92  	}
    93  	return r
    94  }
    95  
    96  // NewReverseQueryOptionsWithOptionsAndDefaults creates a new ReverseQueryOptions with the passed in options set starting from the defaults
    97  func NewReverseQueryOptionsWithOptionsAndDefaults(opts ...ReverseQueryOptionsOption) *ReverseQueryOptions {
    98  	r := &ReverseQueryOptions{}
    99  	defaults.MustSet(r)
   100  	for _, o := range opts {
   101  		o(r)
   102  	}
   103  	return r
   104  }
   105  
   106  // ToOption returns a new ReverseQueryOptionsOption that sets the values from the passed in ReverseQueryOptions
   107  func (r *ReverseQueryOptions) ToOption() ReverseQueryOptionsOption {
   108  	return func(to *ReverseQueryOptions) {
   109  		to.ResRelation = r.ResRelation
   110  		to.LimitForReverse = r.LimitForReverse
   111  		to.SortForReverse = r.SortForReverse
   112  		to.AfterForReverse = r.AfterForReverse
   113  	}
   114  }
   115  
   116  // DebugMap returns a map form of ReverseQueryOptions for debugging
   117  func (r ReverseQueryOptions) DebugMap() map[string]any {
   118  	debugMap := map[string]any{}
   119  	debugMap["ResRelation"] = helpers.DebugValue(r.ResRelation, false)
   120  	debugMap["LimitForReverse"] = helpers.DebugValue(r.LimitForReverse, false)
   121  	debugMap["SortForReverse"] = helpers.DebugValue(r.SortForReverse, false)
   122  	debugMap["AfterForReverse"] = helpers.DebugValue(r.AfterForReverse, false)
   123  	return debugMap
   124  }
   125  
   126  // ReverseQueryOptionsWithOptions configures an existing ReverseQueryOptions with the passed in options set
   127  func ReverseQueryOptionsWithOptions(r *ReverseQueryOptions, opts ...ReverseQueryOptionsOption) *ReverseQueryOptions {
   128  	for _, o := range opts {
   129  		o(r)
   130  	}
   131  	return r
   132  }
   133  
   134  // WithOptions configures the receiver ReverseQueryOptions with the passed in options set
   135  func (r *ReverseQueryOptions) WithOptions(opts ...ReverseQueryOptionsOption) *ReverseQueryOptions {
   136  	for _, o := range opts {
   137  		o(r)
   138  	}
   139  	return r
   140  }
   141  
   142  // WithResRelation returns an option that can set ResRelation on a ReverseQueryOptions
   143  func WithResRelation(resRelation *ResourceRelation) ReverseQueryOptionsOption {
   144  	return func(r *ReverseQueryOptions) {
   145  		r.ResRelation = resRelation
   146  	}
   147  }
   148  
   149  // WithLimitForReverse returns an option that can set LimitForReverse on a ReverseQueryOptions
   150  func WithLimitForReverse(limitForReverse *uint64) ReverseQueryOptionsOption {
   151  	return func(r *ReverseQueryOptions) {
   152  		r.LimitForReverse = limitForReverse
   153  	}
   154  }
   155  
   156  // WithSortForReverse returns an option that can set SortForReverse on a ReverseQueryOptions
   157  func WithSortForReverse(sortForReverse SortOrder) ReverseQueryOptionsOption {
   158  	return func(r *ReverseQueryOptions) {
   159  		r.SortForReverse = sortForReverse
   160  	}
   161  }
   162  
   163  // WithAfterForReverse returns an option that can set AfterForReverse on a ReverseQueryOptions
   164  func WithAfterForReverse(afterForReverse Cursor) ReverseQueryOptionsOption {
   165  	return func(r *ReverseQueryOptions) {
   166  		r.AfterForReverse = afterForReverse
   167  	}
   168  }
   169  
   170  type RWTOptionsOption func(r *RWTOptions)
   171  
   172  // NewRWTOptionsWithOptions creates a new RWTOptions with the passed in options set
   173  func NewRWTOptionsWithOptions(opts ...RWTOptionsOption) *RWTOptions {
   174  	r := &RWTOptions{}
   175  	for _, o := range opts {
   176  		o(r)
   177  	}
   178  	return r
   179  }
   180  
   181  // NewRWTOptionsWithOptionsAndDefaults creates a new RWTOptions with the passed in options set starting from the defaults
   182  func NewRWTOptionsWithOptionsAndDefaults(opts ...RWTOptionsOption) *RWTOptions {
   183  	r := &RWTOptions{}
   184  	defaults.MustSet(r)
   185  	for _, o := range opts {
   186  		o(r)
   187  	}
   188  	return r
   189  }
   190  
   191  // ToOption returns a new RWTOptionsOption that sets the values from the passed in RWTOptions
   192  func (r *RWTOptions) ToOption() RWTOptionsOption {
   193  	return func(to *RWTOptions) {
   194  		to.DisableRetries = r.DisableRetries
   195  	}
   196  }
   197  
   198  // DebugMap returns a map form of RWTOptions for debugging
   199  func (r RWTOptions) DebugMap() map[string]any {
   200  	debugMap := map[string]any{}
   201  	debugMap["DisableRetries"] = helpers.DebugValue(r.DisableRetries, false)
   202  	return debugMap
   203  }
   204  
   205  // RWTOptionsWithOptions configures an existing RWTOptions with the passed in options set
   206  func RWTOptionsWithOptions(r *RWTOptions, opts ...RWTOptionsOption) *RWTOptions {
   207  	for _, o := range opts {
   208  		o(r)
   209  	}
   210  	return r
   211  }
   212  
   213  // WithOptions configures the receiver RWTOptions with the passed in options set
   214  func (r *RWTOptions) WithOptions(opts ...RWTOptionsOption) *RWTOptions {
   215  	for _, o := range opts {
   216  		o(r)
   217  	}
   218  	return r
   219  }
   220  
   221  // WithDisableRetries returns an option that can set DisableRetries on a RWTOptions
   222  func WithDisableRetries(disableRetries bool) RWTOptionsOption {
   223  	return func(r *RWTOptions) {
   224  		r.DisableRetries = disableRetries
   225  	}
   226  }