github.com/cilium/cilium@v1.16.2/api/v1/client/policy/policy_client.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  // Copyright Authors of Cilium
     4  // SPDX-License-Identifier: Apache-2.0
     5  
     6  package policy
     7  
     8  // This file was generated by the swagger tool.
     9  // Editing this file might prove futile when you re-run the swagger generate command
    10  
    11  import (
    12  	"fmt"
    13  
    14  	"github.com/go-openapi/runtime"
    15  	"github.com/go-openapi/strfmt"
    16  )
    17  
    18  // New creates a new policy API client.
    19  func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService {
    20  	return &Client{transport: transport, formats: formats}
    21  }
    22  
    23  /*
    24  Client for policy API
    25  */
    26  type Client struct {
    27  	transport runtime.ClientTransport
    28  	formats   strfmt.Registry
    29  }
    30  
    31  // ClientOption is the option for Client methods
    32  type ClientOption func(*runtime.ClientOperation)
    33  
    34  // ClientService is the interface for Client methods
    35  type ClientService interface {
    36  	DeleteFqdnCache(params *DeleteFqdnCacheParams, opts ...ClientOption) (*DeleteFqdnCacheOK, error)
    37  
    38  	DeletePolicy(params *DeletePolicyParams, opts ...ClientOption) (*DeletePolicyOK, error)
    39  
    40  	GetFqdnCache(params *GetFqdnCacheParams, opts ...ClientOption) (*GetFqdnCacheOK, error)
    41  
    42  	GetFqdnCacheID(params *GetFqdnCacheIDParams, opts ...ClientOption) (*GetFqdnCacheIDOK, error)
    43  
    44  	GetFqdnNames(params *GetFqdnNamesParams, opts ...ClientOption) (*GetFqdnNamesOK, error)
    45  
    46  	GetIP(params *GetIPParams, opts ...ClientOption) (*GetIPOK, error)
    47  
    48  	GetIdentity(params *GetIdentityParams, opts ...ClientOption) (*GetIdentityOK, error)
    49  
    50  	GetIdentityEndpoints(params *GetIdentityEndpointsParams, opts ...ClientOption) (*GetIdentityEndpointsOK, error)
    51  
    52  	GetIdentityID(params *GetIdentityIDParams, opts ...ClientOption) (*GetIdentityIDOK, error)
    53  
    54  	GetPolicy(params *GetPolicyParams, opts ...ClientOption) (*GetPolicyOK, error)
    55  
    56  	GetPolicySelectors(params *GetPolicySelectorsParams, opts ...ClientOption) (*GetPolicySelectorsOK, error)
    57  
    58  	PutPolicy(params *PutPolicyParams, opts ...ClientOption) (*PutPolicyOK, error)
    59  
    60  	SetTransport(transport runtime.ClientTransport)
    61  }
    62  
    63  /*
    64  	DeleteFqdnCache deletes matching DNS lookups from the policy generation cache
    65  
    66  	Deletes matching DNS lookups from the cache, optionally restricted by
    67  
    68  DNS name. The removed IP data will no longer be used in generated
    69  policies.
    70  */
    71  func (a *Client) DeleteFqdnCache(params *DeleteFqdnCacheParams, opts ...ClientOption) (*DeleteFqdnCacheOK, error) {
    72  	// TODO: Validate the params before sending
    73  	if params == nil {
    74  		params = NewDeleteFqdnCacheParams()
    75  	}
    76  	op := &runtime.ClientOperation{
    77  		ID:                 "DeleteFqdnCache",
    78  		Method:             "DELETE",
    79  		PathPattern:        "/fqdn/cache",
    80  		ProducesMediaTypes: []string{"application/json"},
    81  		ConsumesMediaTypes: []string{"application/json"},
    82  		Schemes:            []string{"http"},
    83  		Params:             params,
    84  		Reader:             &DeleteFqdnCacheReader{formats: a.formats},
    85  		Context:            params.Context,
    86  		Client:             params.HTTPClient,
    87  	}
    88  	for _, opt := range opts {
    89  		opt(op)
    90  	}
    91  
    92  	result, err := a.transport.Submit(op)
    93  	if err != nil {
    94  		return nil, err
    95  	}
    96  	success, ok := result.(*DeleteFqdnCacheOK)
    97  	if ok {
    98  		return success, nil
    99  	}
   100  	// unexpected success response
   101  	// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
   102  	msg := fmt.Sprintf("unexpected success response for DeleteFqdnCache: API contract not enforced by server. Client expected to get an error, but got: %T", result)
   103  	panic(msg)
   104  }
   105  
   106  /*
   107  DeletePolicy deletes a policy sub tree
   108  */
   109  func (a *Client) DeletePolicy(params *DeletePolicyParams, opts ...ClientOption) (*DeletePolicyOK, error) {
   110  	// TODO: Validate the params before sending
   111  	if params == nil {
   112  		params = NewDeletePolicyParams()
   113  	}
   114  	op := &runtime.ClientOperation{
   115  		ID:                 "DeletePolicy",
   116  		Method:             "DELETE",
   117  		PathPattern:        "/policy",
   118  		ProducesMediaTypes: []string{"application/json"},
   119  		ConsumesMediaTypes: []string{"application/json"},
   120  		Schemes:            []string{"http"},
   121  		Params:             params,
   122  		Reader:             &DeletePolicyReader{formats: a.formats},
   123  		Context:            params.Context,
   124  		Client:             params.HTTPClient,
   125  	}
   126  	for _, opt := range opts {
   127  		opt(op)
   128  	}
   129  
   130  	result, err := a.transport.Submit(op)
   131  	if err != nil {
   132  		return nil, err
   133  	}
   134  	success, ok := result.(*DeletePolicyOK)
   135  	if ok {
   136  		return success, nil
   137  	}
   138  	// unexpected success response
   139  	// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
   140  	msg := fmt.Sprintf("unexpected success response for DeletePolicy: API contract not enforced by server. Client expected to get an error, but got: %T", result)
   141  	panic(msg)
   142  }
   143  
   144  /*
   145  	GetFqdnCache retrieves the list of DNS lookups intercepted from all endpoints
   146  
   147  	Retrieves the list of DNS lookups intercepted from endpoints,
   148  
   149  optionally filtered by DNS name, CIDR IP range or source.
   150  */
   151  func (a *Client) GetFqdnCache(params *GetFqdnCacheParams, opts ...ClientOption) (*GetFqdnCacheOK, error) {
   152  	// TODO: Validate the params before sending
   153  	if params == nil {
   154  		params = NewGetFqdnCacheParams()
   155  	}
   156  	op := &runtime.ClientOperation{
   157  		ID:                 "GetFqdnCache",
   158  		Method:             "GET",
   159  		PathPattern:        "/fqdn/cache",
   160  		ProducesMediaTypes: []string{"application/json"},
   161  		ConsumesMediaTypes: []string{"application/json"},
   162  		Schemes:            []string{"http"},
   163  		Params:             params,
   164  		Reader:             &GetFqdnCacheReader{formats: a.formats},
   165  		Context:            params.Context,
   166  		Client:             params.HTTPClient,
   167  	}
   168  	for _, opt := range opts {
   169  		opt(op)
   170  	}
   171  
   172  	result, err := a.transport.Submit(op)
   173  	if err != nil {
   174  		return nil, err
   175  	}
   176  	success, ok := result.(*GetFqdnCacheOK)
   177  	if ok {
   178  		return success, nil
   179  	}
   180  	// unexpected success response
   181  	// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
   182  	msg := fmt.Sprintf("unexpected success response for GetFqdnCache: API contract not enforced by server. Client expected to get an error, but got: %T", result)
   183  	panic(msg)
   184  }
   185  
   186  /*
   187  	GetFqdnCacheID retrieves the list of DNS lookups intercepted from an endpoint
   188  
   189  	Retrieves the list of DNS lookups intercepted from the specific endpoint,
   190  
   191  optionally filtered by endpoint id, DNS name, CIDR IP range or source.
   192  */
   193  func (a *Client) GetFqdnCacheID(params *GetFqdnCacheIDParams, opts ...ClientOption) (*GetFqdnCacheIDOK, error) {
   194  	// TODO: Validate the params before sending
   195  	if params == nil {
   196  		params = NewGetFqdnCacheIDParams()
   197  	}
   198  	op := &runtime.ClientOperation{
   199  		ID:                 "GetFqdnCacheID",
   200  		Method:             "GET",
   201  		PathPattern:        "/fqdn/cache/{id}",
   202  		ProducesMediaTypes: []string{"application/json"},
   203  		ConsumesMediaTypes: []string{"application/json"},
   204  		Schemes:            []string{"http"},
   205  		Params:             params,
   206  		Reader:             &GetFqdnCacheIDReader{formats: a.formats},
   207  		Context:            params.Context,
   208  		Client:             params.HTTPClient,
   209  	}
   210  	for _, opt := range opts {
   211  		opt(op)
   212  	}
   213  
   214  	result, err := a.transport.Submit(op)
   215  	if err != nil {
   216  		return nil, err
   217  	}
   218  	success, ok := result.(*GetFqdnCacheIDOK)
   219  	if ok {
   220  		return success, nil
   221  	}
   222  	// unexpected success response
   223  	// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
   224  	msg := fmt.Sprintf("unexpected success response for GetFqdnCacheID: API contract not enforced by server. Client expected to get an error, but got: %T", result)
   225  	panic(msg)
   226  }
   227  
   228  /*
   229  	GetFqdnNames lists internal DNS selector representations
   230  
   231  	Retrieves the list of DNS-related fields (names to poll, selectors and
   232  
   233  their corresponding regexes).
   234  */
   235  func (a *Client) GetFqdnNames(params *GetFqdnNamesParams, opts ...ClientOption) (*GetFqdnNamesOK, error) {
   236  	// TODO: Validate the params before sending
   237  	if params == nil {
   238  		params = NewGetFqdnNamesParams()
   239  	}
   240  	op := &runtime.ClientOperation{
   241  		ID:                 "GetFqdnNames",
   242  		Method:             "GET",
   243  		PathPattern:        "/fqdn/names",
   244  		ProducesMediaTypes: []string{"application/json"},
   245  		ConsumesMediaTypes: []string{"application/json"},
   246  		Schemes:            []string{"http"},
   247  		Params:             params,
   248  		Reader:             &GetFqdnNamesReader{formats: a.formats},
   249  		Context:            params.Context,
   250  		Client:             params.HTTPClient,
   251  	}
   252  	for _, opt := range opts {
   253  		opt(op)
   254  	}
   255  
   256  	result, err := a.transport.Submit(op)
   257  	if err != nil {
   258  		return nil, err
   259  	}
   260  	success, ok := result.(*GetFqdnNamesOK)
   261  	if ok {
   262  		return success, nil
   263  	}
   264  	// unexpected success response
   265  	// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
   266  	msg := fmt.Sprintf("unexpected success response for GetFqdnNames: API contract not enforced by server. Client expected to get an error, but got: %T", result)
   267  	panic(msg)
   268  }
   269  
   270  /*
   271  	GetIP lists information about known IP addresses
   272  
   273  	Retrieves a list of IPs with known associated information such as
   274  
   275  their identities, host addresses, Kubernetes pod names, etc.
   276  The list can optionally filtered by a CIDR IP range.
   277  */
   278  func (a *Client) GetIP(params *GetIPParams, opts ...ClientOption) (*GetIPOK, error) {
   279  	// TODO: Validate the params before sending
   280  	if params == nil {
   281  		params = NewGetIPParams()
   282  	}
   283  	op := &runtime.ClientOperation{
   284  		ID:                 "GetIP",
   285  		Method:             "GET",
   286  		PathPattern:        "/ip",
   287  		ProducesMediaTypes: []string{"application/json"},
   288  		ConsumesMediaTypes: []string{"application/json"},
   289  		Schemes:            []string{"http"},
   290  		Params:             params,
   291  		Reader:             &GetIPReader{formats: a.formats},
   292  		Context:            params.Context,
   293  		Client:             params.HTTPClient,
   294  	}
   295  	for _, opt := range opts {
   296  		opt(op)
   297  	}
   298  
   299  	result, err := a.transport.Submit(op)
   300  	if err != nil {
   301  		return nil, err
   302  	}
   303  	success, ok := result.(*GetIPOK)
   304  	if ok {
   305  		return success, nil
   306  	}
   307  	// unexpected success response
   308  	// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
   309  	msg := fmt.Sprintf("unexpected success response for GetIP: API contract not enforced by server. Client expected to get an error, but got: %T", result)
   310  	panic(msg)
   311  }
   312  
   313  /*
   314  GetIdentity retrieves a list of identities that have metadata matching the provided parameters
   315  
   316  Retrieves a list of identities that have metadata matching the provided parameters, or all identities if no parameters are provided.
   317  */
   318  func (a *Client) GetIdentity(params *GetIdentityParams, opts ...ClientOption) (*GetIdentityOK, error) {
   319  	// TODO: Validate the params before sending
   320  	if params == nil {
   321  		params = NewGetIdentityParams()
   322  	}
   323  	op := &runtime.ClientOperation{
   324  		ID:                 "GetIdentity",
   325  		Method:             "GET",
   326  		PathPattern:        "/identity",
   327  		ProducesMediaTypes: []string{"application/json"},
   328  		ConsumesMediaTypes: []string{"application/json"},
   329  		Schemes:            []string{"http"},
   330  		Params:             params,
   331  		Reader:             &GetIdentityReader{formats: a.formats},
   332  		Context:            params.Context,
   333  		Client:             params.HTTPClient,
   334  	}
   335  	for _, opt := range opts {
   336  		opt(op)
   337  	}
   338  
   339  	result, err := a.transport.Submit(op)
   340  	if err != nil {
   341  		return nil, err
   342  	}
   343  	success, ok := result.(*GetIdentityOK)
   344  	if ok {
   345  		return success, nil
   346  	}
   347  	// unexpected success response
   348  	// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
   349  	msg := fmt.Sprintf("unexpected success response for GetIdentity: API contract not enforced by server. Client expected to get an error, but got: %T", result)
   350  	panic(msg)
   351  }
   352  
   353  /*
   354  GetIdentityEndpoints retrieves identities which are being used by local endpoints
   355  */
   356  func (a *Client) GetIdentityEndpoints(params *GetIdentityEndpointsParams, opts ...ClientOption) (*GetIdentityEndpointsOK, error) {
   357  	// TODO: Validate the params before sending
   358  	if params == nil {
   359  		params = NewGetIdentityEndpointsParams()
   360  	}
   361  	op := &runtime.ClientOperation{
   362  		ID:                 "GetIdentityEndpoints",
   363  		Method:             "GET",
   364  		PathPattern:        "/identity/endpoints",
   365  		ProducesMediaTypes: []string{"application/json"},
   366  		ConsumesMediaTypes: []string{"application/json"},
   367  		Schemes:            []string{"http"},
   368  		Params:             params,
   369  		Reader:             &GetIdentityEndpointsReader{formats: a.formats},
   370  		Context:            params.Context,
   371  		Client:             params.HTTPClient,
   372  	}
   373  	for _, opt := range opts {
   374  		opt(op)
   375  	}
   376  
   377  	result, err := a.transport.Submit(op)
   378  	if err != nil {
   379  		return nil, err
   380  	}
   381  	success, ok := result.(*GetIdentityEndpointsOK)
   382  	if ok {
   383  		return success, nil
   384  	}
   385  	// unexpected success response
   386  	// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
   387  	msg := fmt.Sprintf("unexpected success response for GetIdentityEndpoints: API contract not enforced by server. Client expected to get an error, but got: %T", result)
   388  	panic(msg)
   389  }
   390  
   391  /*
   392  GetIdentityID retrieves identity
   393  */
   394  func (a *Client) GetIdentityID(params *GetIdentityIDParams, opts ...ClientOption) (*GetIdentityIDOK, error) {
   395  	// TODO: Validate the params before sending
   396  	if params == nil {
   397  		params = NewGetIdentityIDParams()
   398  	}
   399  	op := &runtime.ClientOperation{
   400  		ID:                 "GetIdentityID",
   401  		Method:             "GET",
   402  		PathPattern:        "/identity/{id}",
   403  		ProducesMediaTypes: []string{"application/json"},
   404  		ConsumesMediaTypes: []string{"application/json"},
   405  		Schemes:            []string{"http"},
   406  		Params:             params,
   407  		Reader:             &GetIdentityIDReader{formats: a.formats},
   408  		Context:            params.Context,
   409  		Client:             params.HTTPClient,
   410  	}
   411  	for _, opt := range opts {
   412  		opt(op)
   413  	}
   414  
   415  	result, err := a.transport.Submit(op)
   416  	if err != nil {
   417  		return nil, err
   418  	}
   419  	success, ok := result.(*GetIdentityIDOK)
   420  	if ok {
   421  		return success, nil
   422  	}
   423  	// unexpected success response
   424  	// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
   425  	msg := fmt.Sprintf("unexpected success response for GetIdentityID: API contract not enforced by server. Client expected to get an error, but got: %T", result)
   426  	panic(msg)
   427  }
   428  
   429  /*
   430  GetPolicy retrieves entire policy tree
   431  
   432  Returns the entire policy tree with all children.
   433  */
   434  func (a *Client) GetPolicy(params *GetPolicyParams, opts ...ClientOption) (*GetPolicyOK, error) {
   435  	// TODO: Validate the params before sending
   436  	if params == nil {
   437  		params = NewGetPolicyParams()
   438  	}
   439  	op := &runtime.ClientOperation{
   440  		ID:                 "GetPolicy",
   441  		Method:             "GET",
   442  		PathPattern:        "/policy",
   443  		ProducesMediaTypes: []string{"application/json"},
   444  		ConsumesMediaTypes: []string{"application/json"},
   445  		Schemes:            []string{"http"},
   446  		Params:             params,
   447  		Reader:             &GetPolicyReader{formats: a.formats},
   448  		Context:            params.Context,
   449  		Client:             params.HTTPClient,
   450  	}
   451  	for _, opt := range opts {
   452  		opt(op)
   453  	}
   454  
   455  	result, err := a.transport.Submit(op)
   456  	if err != nil {
   457  		return nil, err
   458  	}
   459  	success, ok := result.(*GetPolicyOK)
   460  	if ok {
   461  		return success, nil
   462  	}
   463  	// unexpected success response
   464  	// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
   465  	msg := fmt.Sprintf("unexpected success response for GetPolicy: API contract not enforced by server. Client expected to get an error, but got: %T", result)
   466  	panic(msg)
   467  }
   468  
   469  /*
   470  GetPolicySelectors sees what selectors match which identities
   471  */
   472  func (a *Client) GetPolicySelectors(params *GetPolicySelectorsParams, opts ...ClientOption) (*GetPolicySelectorsOK, error) {
   473  	// TODO: Validate the params before sending
   474  	if params == nil {
   475  		params = NewGetPolicySelectorsParams()
   476  	}
   477  	op := &runtime.ClientOperation{
   478  		ID:                 "GetPolicySelectors",
   479  		Method:             "GET",
   480  		PathPattern:        "/policy/selectors",
   481  		ProducesMediaTypes: []string{"application/json"},
   482  		ConsumesMediaTypes: []string{"application/json"},
   483  		Schemes:            []string{"http"},
   484  		Params:             params,
   485  		Reader:             &GetPolicySelectorsReader{formats: a.formats},
   486  		Context:            params.Context,
   487  		Client:             params.HTTPClient,
   488  	}
   489  	for _, opt := range opts {
   490  		opt(op)
   491  	}
   492  
   493  	result, err := a.transport.Submit(op)
   494  	if err != nil {
   495  		return nil, err
   496  	}
   497  	success, ok := result.(*GetPolicySelectorsOK)
   498  	if ok {
   499  		return success, nil
   500  	}
   501  	// unexpected success response
   502  	// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
   503  	msg := fmt.Sprintf("unexpected success response for GetPolicySelectors: API contract not enforced by server. Client expected to get an error, but got: %T", result)
   504  	panic(msg)
   505  }
   506  
   507  /*
   508  PutPolicy creates or update a policy sub tree
   509  */
   510  func (a *Client) PutPolicy(params *PutPolicyParams, opts ...ClientOption) (*PutPolicyOK, error) {
   511  	// TODO: Validate the params before sending
   512  	if params == nil {
   513  		params = NewPutPolicyParams()
   514  	}
   515  	op := &runtime.ClientOperation{
   516  		ID:                 "PutPolicy",
   517  		Method:             "PUT",
   518  		PathPattern:        "/policy",
   519  		ProducesMediaTypes: []string{"application/json"},
   520  		ConsumesMediaTypes: []string{"application/json"},
   521  		Schemes:            []string{"http"},
   522  		Params:             params,
   523  		Reader:             &PutPolicyReader{formats: a.formats},
   524  		Context:            params.Context,
   525  		Client:             params.HTTPClient,
   526  	}
   527  	for _, opt := range opts {
   528  		opt(op)
   529  	}
   530  
   531  	result, err := a.transport.Submit(op)
   532  	if err != nil {
   533  		return nil, err
   534  	}
   535  	success, ok := result.(*PutPolicyOK)
   536  	if ok {
   537  		return success, nil
   538  	}
   539  	// unexpected success response
   540  	// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
   541  	msg := fmt.Sprintf("unexpected success response for PutPolicy: API contract not enforced by server. Client expected to get an error, but got: %T", result)
   542  	panic(msg)
   543  }
   544  
   545  // SetTransport changes the transport on the client
   546  func (a *Client) SetTransport(transport runtime.ClientTransport) {
   547  	a.transport = transport
   548  }