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

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package scan
     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 scan client
    19  type API interface {
    20  	/*
    21  	   GetReportLog gets the log of the scan report
    22  
    23  	   Get the log of the scan report*/
    24  	GetReportLog(ctx context.Context, params *GetReportLogParams) (*GetReportLogOK, error)
    25  	/*
    26  	   ScanArtifact scans the artifact
    27  
    28  	   Scan the specified artifact*/
    29  	ScanArtifact(ctx context.Context, params *ScanArtifactParams) (*ScanArtifactAccepted, error)
    30  	/*
    31  	   StopScanArtifact cancellings a scan job for a particular artifact
    32  
    33  	   Cancelling a scan job for a particular artifact*/
    34  	StopScanArtifact(ctx context.Context, params *StopScanArtifactParams) (*StopScanArtifactAccepted, error)
    35  }
    36  
    37  // New creates a new scan API client.
    38  func New(transport runtime.ClientTransport, formats strfmt.Registry, authInfo runtime.ClientAuthInfoWriter) *Client {
    39  	return &Client{
    40  		transport: transport,
    41  		formats:   formats,
    42  		authInfo:  authInfo,
    43  	}
    44  }
    45  
    46  /*
    47  Client for scan API
    48  */
    49  type Client struct {
    50  	transport runtime.ClientTransport
    51  	formats   strfmt.Registry
    52  	authInfo  runtime.ClientAuthInfoWriter
    53  }
    54  
    55  /*
    56  GetReportLog gets the log of the scan report
    57  
    58  Get the log of the scan report
    59  */
    60  func (a *Client) GetReportLog(ctx context.Context, params *GetReportLogParams) (*GetReportLogOK, error) {
    61  
    62  	result, err := a.transport.Submit(&runtime.ClientOperation{
    63  		ID:                 "getReportLog",
    64  		Method:             "GET",
    65  		PathPattern:        "/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/scan/{report_id}/log",
    66  		ProducesMediaTypes: []string{"text/plain"},
    67  		ConsumesMediaTypes: []string{"application/json"},
    68  		Schemes:            []string{"http", "https"},
    69  		Params:             params,
    70  		Reader:             &GetReportLogReader{formats: a.formats},
    71  		AuthInfo:           a.authInfo,
    72  		Context:            ctx,
    73  		Client:             params.HTTPClient,
    74  	})
    75  	if err != nil {
    76  		return nil, err
    77  	}
    78  	return result.(*GetReportLogOK), nil
    79  
    80  }
    81  
    82  /*
    83  ScanArtifact scans the artifact
    84  
    85  Scan the specified artifact
    86  */
    87  func (a *Client) ScanArtifact(ctx context.Context, params *ScanArtifactParams) (*ScanArtifactAccepted, error) {
    88  
    89  	result, err := a.transport.Submit(&runtime.ClientOperation{
    90  		ID:                 "scanArtifact",
    91  		Method:             "POST",
    92  		PathPattern:        "/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/scan",
    93  		ProducesMediaTypes: []string{"application/json"},
    94  		ConsumesMediaTypes: []string{"application/json"},
    95  		Schemes:            []string{"http", "https"},
    96  		Params:             params,
    97  		Reader:             &ScanArtifactReader{formats: a.formats},
    98  		AuthInfo:           a.authInfo,
    99  		Context:            ctx,
   100  		Client:             params.HTTPClient,
   101  	})
   102  	if err != nil {
   103  		return nil, err
   104  	}
   105  	return result.(*ScanArtifactAccepted), nil
   106  
   107  }
   108  
   109  /*
   110  StopScanArtifact cancellings a scan job for a particular artifact
   111  
   112  Cancelling a scan job for a particular artifact
   113  */
   114  func (a *Client) StopScanArtifact(ctx context.Context, params *StopScanArtifactParams) (*StopScanArtifactAccepted, error) {
   115  
   116  	result, err := a.transport.Submit(&runtime.ClientOperation{
   117  		ID:                 "stopScanArtifact",
   118  		Method:             "POST",
   119  		PathPattern:        "/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/scan/stop",
   120  		ProducesMediaTypes: []string{"application/json"},
   121  		ConsumesMediaTypes: []string{"application/json"},
   122  		Schemes:            []string{"http", "https"},
   123  		Params:             params,
   124  		Reader:             &StopScanArtifactReader{formats: a.formats},
   125  		AuthInfo:           a.authInfo,
   126  		Context:            ctx,
   127  		Client:             params.HTTPClient,
   128  	})
   129  	if err != nil {
   130  		return nil, err
   131  	}
   132  	return result.(*StopScanArtifactAccepted), nil
   133  
   134  }