github.com/goharbor/go-client@v0.210.0/pkg/sdk/v2.0/client/immutable/immutable_client.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package immutable
     4  
     5  // This file was generated by the swagger tool.
     6  // Editing this file might prove futile when you re-run the swagger generate command
     7  
     8  import (
     9  	"context"
    10  
    11  	"github.com/go-openapi/runtime"
    12  
    13  	strfmt "github.com/go-openapi/strfmt"
    14  )
    15  
    16  //go:generate mockery -name API -inpkg
    17  
    18  // API is the interface of the immutable client
    19  type API interface {
    20  	/*
    21  	   CreateImmuRule adds an immutable tag rule to current project
    22  
    23  	   This endpoint add an immutable tag rule to the project
    24  	*/
    25  	CreateImmuRule(ctx context.Context, params *CreateImmuRuleParams) (*CreateImmuRuleCreated, error)
    26  	/*
    27  	   DeleteImmuRule deletes the immutable tag rule*/
    28  	DeleteImmuRule(ctx context.Context, params *DeleteImmuRuleParams) (*DeleteImmuRuleOK, error)
    29  	/*
    30  	   ListImmuRules lists all immutable tag rules of current project
    31  
    32  	   This endpoint returns the immutable tag rules of a project
    33  	*/
    34  	ListImmuRules(ctx context.Context, params *ListImmuRulesParams) (*ListImmuRulesOK, error)
    35  	/*
    36  	   UpdateImmuRule updates the immutable tag rule or enable or disable the rule*/
    37  	UpdateImmuRule(ctx context.Context, params *UpdateImmuRuleParams) (*UpdateImmuRuleOK, error)
    38  }
    39  
    40  // New creates a new immutable API client.
    41  func New(transport runtime.ClientTransport, formats strfmt.Registry, authInfo runtime.ClientAuthInfoWriter) *Client {
    42  	return &Client{
    43  		transport: transport,
    44  		formats:   formats,
    45  		authInfo:  authInfo,
    46  	}
    47  }
    48  
    49  /*
    50  Client for immutable API
    51  */
    52  type Client struct {
    53  	transport runtime.ClientTransport
    54  	formats   strfmt.Registry
    55  	authInfo  runtime.ClientAuthInfoWriter
    56  }
    57  
    58  /*
    59  CreateImmuRule adds an immutable tag rule to current project
    60  
    61  This endpoint add an immutable tag rule to the project
    62  */
    63  func (a *Client) CreateImmuRule(ctx context.Context, params *CreateImmuRuleParams) (*CreateImmuRuleCreated, error) {
    64  
    65  	result, err := a.transport.Submit(&runtime.ClientOperation{
    66  		ID:                 "CreateImmuRule",
    67  		Method:             "POST",
    68  		PathPattern:        "/projects/{project_name_or_id}/immutabletagrules",
    69  		ProducesMediaTypes: []string{"application/json"},
    70  		ConsumesMediaTypes: []string{"application/json"},
    71  		Schemes:            []string{"http", "https"},
    72  		Params:             params,
    73  		Reader:             &CreateImmuRuleReader{formats: a.formats},
    74  		AuthInfo:           a.authInfo,
    75  		Context:            ctx,
    76  		Client:             params.HTTPClient,
    77  	})
    78  	if err != nil {
    79  		return nil, err
    80  	}
    81  	return result.(*CreateImmuRuleCreated), nil
    82  
    83  }
    84  
    85  /*
    86  DeleteImmuRule deletes the immutable tag rule
    87  */
    88  func (a *Client) DeleteImmuRule(ctx context.Context, params *DeleteImmuRuleParams) (*DeleteImmuRuleOK, error) {
    89  
    90  	result, err := a.transport.Submit(&runtime.ClientOperation{
    91  		ID:                 "DeleteImmuRule",
    92  		Method:             "DELETE",
    93  		PathPattern:        "/projects/{project_name_or_id}/immutabletagrules/{immutable_rule_id}",
    94  		ProducesMediaTypes: []string{"application/json"},
    95  		ConsumesMediaTypes: []string{"application/json"},
    96  		Schemes:            []string{"http", "https"},
    97  		Params:             params,
    98  		Reader:             &DeleteImmuRuleReader{formats: a.formats},
    99  		AuthInfo:           a.authInfo,
   100  		Context:            ctx,
   101  		Client:             params.HTTPClient,
   102  	})
   103  	if err != nil {
   104  		return nil, err
   105  	}
   106  	return result.(*DeleteImmuRuleOK), nil
   107  
   108  }
   109  
   110  /*
   111  ListImmuRules lists all immutable tag rules of current project
   112  
   113  This endpoint returns the immutable tag rules of a project
   114  */
   115  func (a *Client) ListImmuRules(ctx context.Context, params *ListImmuRulesParams) (*ListImmuRulesOK, error) {
   116  
   117  	result, err := a.transport.Submit(&runtime.ClientOperation{
   118  		ID:                 "ListImmuRules",
   119  		Method:             "GET",
   120  		PathPattern:        "/projects/{project_name_or_id}/immutabletagrules",
   121  		ProducesMediaTypes: []string{"application/json"},
   122  		ConsumesMediaTypes: []string{"application/json"},
   123  		Schemes:            []string{"http", "https"},
   124  		Params:             params,
   125  		Reader:             &ListImmuRulesReader{formats: a.formats},
   126  		AuthInfo:           a.authInfo,
   127  		Context:            ctx,
   128  		Client:             params.HTTPClient,
   129  	})
   130  	if err != nil {
   131  		return nil, err
   132  	}
   133  	return result.(*ListImmuRulesOK), nil
   134  
   135  }
   136  
   137  /*
   138  UpdateImmuRule updates the immutable tag rule or enable or disable the rule
   139  */
   140  func (a *Client) UpdateImmuRule(ctx context.Context, params *UpdateImmuRuleParams) (*UpdateImmuRuleOK, error) {
   141  
   142  	result, err := a.transport.Submit(&runtime.ClientOperation{
   143  		ID:                 "UpdateImmuRule",
   144  		Method:             "PUT",
   145  		PathPattern:        "/projects/{project_name_or_id}/immutabletagrules/{immutable_rule_id}",
   146  		ProducesMediaTypes: []string{"application/json"},
   147  		ConsumesMediaTypes: []string{"application/json"},
   148  		Schemes:            []string{"http", "https"},
   149  		Params:             params,
   150  		Reader:             &UpdateImmuRuleReader{formats: a.formats},
   151  		AuthInfo:           a.authInfo,
   152  		Context:            ctx,
   153  		Client:             params.HTTPClient,
   154  	})
   155  	if err != nil {
   156  		return nil, err
   157  	}
   158  	return result.(*UpdateImmuRuleOK), nil
   159  
   160  }