api

package
v0.0.0-...-b9085d8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Copyright (C) 2020 Synopsys, Inc.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (C) 2020 Synopsys, Inc.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (C) 2020 Synopsys, Inc.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (C) 2020 Synopsys, Inc.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (C) 2020 Synopsys, Inc.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (C) 2020 Synopsys, Inc.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (C) 2020 Synopsys, Inc.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (C) 2020 Synopsys, Inc.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunMetricsTests

func RunMetricsTests()

Types

type Client

type Client struct {
	URL         string
	Email       string
	Password    string
	AuthToken   string
	RestyClient *resty.Client
	// contains filtered or unexported fields
}

func NewClient

func NewClient(url string, email string, password string) *Client

func (*Client) Authenticate

func (client *Client) Authenticate() error

func (*Client) CreateRoleAssignment

func (client *Client) CreateRoleAssignment(userId string, roleId string, projectId string, orgId string) (string, error)

func (*Client) CreateServiceAccount

func (client *Client) CreateServiceAccount(email string, name string, orgId string, password string) (*CreateUserResponse, error)

func (*Client) CreateUser

func (client *Client) CreateUser(email string, name string, orgId string) (*CreateUserResponse, error)

func (*Client) DownloadCli

func (client *Client) DownloadCli(dir string, osType OSType) (string, error)

func (*Client) GetAccessToken

func (client *Client) GetAccessToken(tokenName string) (*CreateAccessTokenResponse, error)

func (*Client) GetEntitlementsForOrganization

func (client *Client) GetEntitlementsForOrganization(orgId string) (*GetEntitlementsForOrganizationResponse, error)

func (*Client) GetEntitlementsForProject

func (client *Client) GetEntitlementsForProject(projectID string) (*GetEntitlementsForProjectResponse, error)

func (*Client) GetGroups

func (client *Client) GetGroups() (*GetGroupsResponse, error)

func (*Client) GetJobs

func (client *Client) GetJobs(limit int) (*GetJobsResponse, error)

func (*Client) GetJson

func (client *Client) GetJson(params map[string]interface{}, result interface{}, pathTemplate string, pathArgs ...interface{}) (string, error)

func (*Client) GetOrganizations

func (client *Client) GetOrganizations() (*GetOrganizationsResponse, error)

func (*Client) GetProjects

func (client *Client) GetProjects(limit int) (*GetProjectsResponse, error)

func (*Client) GetRawJson

func (client *Client) GetRawJson(params map[string]interface{}, result interface{}, pathTemplate string, pathArgs ...interface{}) (string, error)

func (*Client) GetRoleAssignments

func (client *Client) GetRoleAssignments(offset int, limit int) (*GetRoleAssignmentsResponse, error)

func (*Client) GetRoleAssignmentsForProject

func (client *Client) GetRoleAssignmentsForProject(projectId string) (*GetRoleAssignmentsResponse, error)

func (*Client) GetRoleAssignmentsForUser

func (client *Client) GetRoleAssignmentsForUser(email string, offset int, limit int, isServiceAccount bool) (*GetRoleAssignmentsResponse, error)

func (*Client) GetRoles

func (client *Client) GetRoles() (*GetRolesResponse, error)

func (*Client) GetTaxonomies

func (client *Client) GetTaxonomies(tenantId *string, pageLimit int) (*GetTaxonomiesResponse, error)

func (*Client) GetTaxonomyCount

func (client *Client) GetTaxonomyCount() (*GetTaxonomiesResponse, error)

func (*Client) GetTools

func (client *Client) GetTools(limit int) (*GetToolsResponse, error)

func (*Client) GetUserByEmail

func (client *Client) GetUserByEmail(email string) (*GetUsersResponse, error)

func (*Client) GetUsers

func (client *Client) GetUsers(offset int, limit int) (*GetUsersResponse, error)

func (*Client) GetV0Branch

func (client *Client) GetV0Branch(branchId string) (*GetV0BranchResponse, error)

func (*Client) GetV0Revisions

func (client *Client) GetV0Revisions(limit int) (*GetV0RevisionsResponse, error)

func (*Client) GetV0RevisionsByBranch

func (client *Client) GetV0RevisionsByBranch(branchId string, limit int) (*GetV0RevisionsResponse, error)

func (*Client) GetV0RollUpCounts

func (client *Client) GetV0RollUpCounts(projectId string, branchId string, limit int) (*GetV0RollUpCountsResponse, error)

func (*Client) GetV1Issue

func (client *Client) GetV1Issue(projectId string, branchId string, issueId string) (*GetV1IssueResponse, error)

func (*Client) GetV1Issues

func (client *Client) GetV1Issues(projectId string, branchId string, runId string, offset int, limit int) (*GetV1IssuesResponse, error)

func (*Client) GetVinylV0Projects

func (client *Client) GetVinylV0Projects(offset int, limit int) (*GetVinylV0ProjectsResponse, error)

func (*Client) GetVinylV0ProjectsRelatedRuns

func (client *Client) GetVinylV0ProjectsRelatedRuns(projectId string) (*GetVinylV0ProjectsRelatedRunsResponse, error)

func (*Client) GetVinylV0ProjectsRelationshipsRuns

func (client *Client) GetVinylV0ProjectsRelationshipsRuns(projectId string) (*GetVinylV0ProjectsRelationshipsRunsResponse, error)

func (*Client) PostJson

func (client *Client) PostJson(bodyParams map[string]interface{}, result interface{}, pathTemplate string, pathArgs ...interface{}) (string, error)

func (*Client) PostTools

func (client *Client) PostTools() (string, error)

PostTools handles

https://sig-gitlab.internal.synopsys.com/clops/polaris-local/-/blob/master/README.md#temporary-workaround-if-needed-1

func (*Client) QueryV0DiscoveryFilterKeysIssuetoolidValues

func (client *Client) QueryV0DiscoveryFilterKeysIssuetoolidValues() (string, error)

type CreateAccessTokenResponse

type CreateAccessTokenResponse struct {
	Data struct {
		Attributes struct {
			AccessToken string `json:"access-token"`
		} `json:"attributes"`
	} `json:"data"`
}

type CreateUserResponse

type CreateUserResponse struct {
	Data struct {
		Type       string
		Id         string
		Attributes struct {
			Name     string
			Email    string
			Username string
		}
	}
}

type Data

type Data struct {
	Data IdAndType
}

type GetEntitlementsForOrganizationResponse

type GetEntitlementsForOrganizationResponse struct {
	Data []struct {
		Type       string
		Id         string
		Attributes struct {
			Allowed []string
		}
		// TODO relationships
		Links struct {
			Self struct {
				HRef string
			}
		}
	}
}

type GetEntitlementsForProjectResponse

type GetEntitlementsForProjectResponse struct {
	Data []struct {
		Type       string
		Id         string
		Attributes struct {
			Allowed []string
		}
	}
	Meta struct {
		Limit  int
		Offset int
		Total  int
	}
}

type GetGroupsResponse

type GetGroupsResponse struct {
	Data []struct {
		Type       string
		Id         string
		Attributes struct {
			GroupName   string
			DateCreated string `json:"date-created"`
		}
	}
	Meta struct {
		Limit  int
		Offset int
		Total  int
	}
}

type GetJobsResponse

type GetJobsResponse struct {
	Data []struct {
		Type       string
		Id         string
		Attributes struct {
			DateFinished string
			// TODO lots more stuff
			Status struct {
				State    string
				Progress int
			}
		}
	}
	Meta struct {
		Total   int
		Offset  int
		Limit   int
		Filters map[string]string
	}
}

type GetOrganizationsResponse

type GetOrganizationsResponse struct {
	Data []struct {
		Type       string
		Id         string
		Attributes struct {
			OrganizationName string
			Description      string
		}
	}
	Meta struct {
		Limit  int
		Offset int
		Total  int
	}
}

type GetProjectsResponse

type GetProjectsResponse struct {
	Data []struct {
		Type       string
		Id         string
		Attributes struct {
			// TODO properties
			Name string
		}
		Relationships struct {
			Branches          *ProjectRelationshipsJustLinks
			Runs              *ProjectRelationshipsJustLinks
			ProjectPreference *ProjectRelationshipsLinksAndData `json:"project-preference"`
			UserDefaultBranch *ProjectRelationshipsLinksAndData `json:"user-default-branch"`
		}
		Links *struct {
			Self *struct {
				HRef string
				Meta *struct {
					Durable string
				}
			}
		}
		Meta struct {
			Etag           string
			OrganizationId string `json:"organization-id"`
			InTrash        bool   `json:"in-trash"`
		}
	}
	// TODO included, links
	Meta struct {
		// Offset int
		Limit int
		Total int
	}
}

type GetRoleAssignmentsResponse

type GetRoleAssignmentsResponse struct {
	Data []struct {
		Type       string
		Id         string
		Attributes struct {
			ExpiresBy string `json:"expires-by"`
			Object    string
		}
		Relationships map[string]struct {
			Links struct {
				Self    string
				Related string
			}
			Data struct {
				Type string
				Id   string
			}
		}
	}
	Meta struct {
		Limit  int
		Offset int
		Total  int
	}
}

type GetRolesResponse

type GetRolesResponse struct {
	Data []struct {
		Type       string
		Id         string
		Attributes struct {
			RoleName    string
			Permissions struct {
				Organization []string
				Project      []string
			}
		}
	}
	Meta struct {
		Limit  int
		Offset int
		Total  int
	}
}

type GetTaxonomiesResponse

type GetTaxonomiesResponse struct {
	Data []struct {
		TaxonomyType   string `json:"taxonomy-type"`
		Id             string
		OptimisticLock string `json:"optimistic-lock"`
		Taxonomy       struct {
			Taxa []struct {
				Id   string
				Name struct {
					En string
				}
			}
			Name struct {
				En string
			}
			Description struct {
				En string
			}
			Abbreviation struct {
				En string
			}
			// TODO extra
			// TODO depends-on
			RootTaxa []string `json:"root-taxa"`
		}
	}
	Meta struct {
		Total  int
		Offset int
		Limit  int
	}
}

type GetToolsResponse

type GetToolsResponse struct {
	Data []struct {
		Type       string
		Id         string
		Attributes struct {
			Name    string
			Version string
		}
	}
	// TODO included
	Meta struct {
		//Offset int
		Limit int
		Total int
	}
}

type GetUsersResponse

type GetUsersResponse struct {
	Data []struct {
		Type       string
		Id         string
		Attributes struct {
			Owner    bool
			Name     string
			Email    string
			Username string
		}
	}
	Meta struct {
		Limit  int
		Offset int
		Total  int
	}
}

type GetV0BranchResponse

type GetV0BranchResponse struct {
	Data struct {
		Type       string
		Id         string
		Attributes struct {
			Name           string
			MainForProject bool `json:"main-for-project"`
		}
	}
}

type GetV0RevisionsResponse

type GetV0RevisionsResponse struct {
	Data []struct {
		Type       string
		Id         string
		Attributes struct {
			Name                 string
			Timestamp            string
			ModifiedOffTheRecord bool `json:"modified-off-the-record"`
		}
	}
	// TODO Included, Links
	Meta struct {
		Offset int
		Limit  int
		Total  int
	}
}

type GetV0RollUpCountsResponse

type GetV0RollUpCountsResponse struct {
	Data []struct {
		Id            string
		Type          string
		Relationships map[string]struct {
			Data *struct {
				Id   string
				Type string
			}
		}
		Attributes struct {
			Value int
		}
	}
	Included []struct {
		Id         string
		Type       string
		Attributes map[string]interface{} // TODO type?
	}
	Meta struct {
		Offset   int
		Limit    int
		Total    int
		Complete bool
		GroupBy  string `json:"group-by"`
		RunCount int    `json:"run-count"`
	}
}

type GetV1IssueResponse

type GetV1IssueResponse struct {
	Data     V1IssueResponse
	Included []V1IssueIncluded
}

type GetV1IssuesResponse

type GetV1IssuesResponse struct {
	Data     []V1IssueResponse
	Included []V1IssueIncluded
	Meta     struct {
		Total    int
		Offset   int
		Limit    int
		Complete bool
		RunCount int `json:"run-count"`
	}
}

type GetVinylV0ProjectsRelatedRunsResponse

type GetVinylV0ProjectsRelatedRunsResponse struct {
	Data []struct {
		Type       string
		Id         string
		Attributes struct {
			CompletedDate string `json:"completed-date"`
			Segment       bool
			Status        string
			UploadId      string `json:"upload-id"`
			RunType       string `json:"run-type"`
			CreationDate  string `json:"creation-date"`
			Fingerprints  []interface{}
		}
	}
}

type GetVinylV0ProjectsRelationshipsRunsResponse

type GetVinylV0ProjectsRelationshipsRunsResponse struct {
	Data []struct {
		Type string
		Id   string
	}
}

type GetVinylV0ProjectsResponse

type GetVinylV0ProjectsResponse struct {
	Data     []*VinylV0Project
	Included []struct {
		// TODO Type="branch" has different stuff than Type="entitlements"
		Type          string
		Id            string
		Attributes    map[string]interface{}
		Relationships map[string]interface{}
		Links         struct {
			Self struct {
				HRef string
			}
		}
		Meta *struct {
			ETag    string
			InTrash bool `json:"in-trash"`
		}
	}
	Meta struct {
		Offset int
		Limit  int
		Total  int
	}
}

type IdAndType

type IdAndType struct {
	Id   string
	Type string
}

type OSType

type OSType string
const (
	OSTypeMac     OSType = "Mac"
	OSTypeLinux   OSType = "Linux"
	OSTypeWindows OSType = "Windows"
)

...

func MustParseOSType

func MustParseOSType(osType string) OSType

func ParseOSType

func ParseOSType(osType string) (OSType, error)

func (OSType) PlatformType

func (o OSType) PlatformType() string

func (OSType) PolarisCLIUrl

func (o OSType) PolarisCLIUrl(host string) string

func (OSType) String

func (o OSType) String() string

func (*OSType) UnmarshalJSON

func (o *OSType) UnmarshalJSON(data []byte) error

func (*OSType) UnmarshalText

func (o *OSType) UnmarshalText(text []byte) (err error)

type ProjectRelationshipsData

type ProjectRelationshipsData struct {
	Type string
	Id   string
}
type ProjectRelationshipsJustLinks struct {
	Links ProjectRelationshipsLinks
}
type ProjectRelationshipsLinks struct {
	Self    string
	Related string
}

type ProjectRelationshipsLinksAndData

type ProjectRelationshipsLinksAndData struct {
	Links ProjectRelationshipsLinks
	Data  *ProjectRelationshipsData
}

type V1IssueIncluded

type V1IssueIncluded struct {
	Id         string
	Type       string
	Attributes map[string]interface{}
}

type V1IssueResponse

type V1IssueResponse struct {
	Attributes struct {
		FindingKey string `json:"finding-key"`
		IssueKey   string `json:"issue-key"`
		SubTool    string `json:"sub-tool"`
	}
	Id            string
	Type          string
	Relationships struct {
		Path                Data
		ToolDomainService   Data `json:"tool-domain-service-data"`
		IssueType           Data `json:"issue-type"`
		Tool                Data
		LatestObservedOnRun Data `json:"latest-observed-on-run"`
		Transitions         struct {
			Data []IdAndType
		}
		RelatedTaxa struct {
			Data []interface{} // TODO type ?
		} `json:"related-taxa"`
		RelatedIndicators struct {
			Data []interface{} // TODO type ?
		} `json:"related-indicators"`
		IssueKind interface{} `json:"issue-kind"` // TODO type?
		Severity  interface{} // TODO type?
	}
	Links struct {
		Self struct {
			HRef string
		}
	}
}

type VinylV0Project

type VinylV0Project struct {
	Type       string
	Id         string
	Attributes struct {
		Name string
	}
	Relationships map[string]struct {
		Links struct {
			Self    string
			Related string
		}
		Data *struct {
			Type string
			Id   string
		}
	}
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL