Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

msd api to return kubernetes network policy object #2396

Merged
merged 1 commit into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions clients/go/msd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,48 @@ func (client MSDClient) EvaluateNetworkPolicyChange(detail *NetworkPolicyChangeI
}
}

func (client MSDClient) PostKubernetesNetworkPolicyRequest(domainName DomainName, serviceName EntityName, request *KubernetesNetworkPolicyRequest, matchingTag string) (*KubernetesNetworkPolicyResponse, string, error) {
var data *KubernetesNetworkPolicyResponse
headers := map[string]string{
"If-None-Match": matchingTag,
}
url := client.URL + "/domain/" + fmt.Sprint(domainName) + "/service/" + fmt.Sprint(serviceName) + "/kubernetesnetworkpolicy"
contentBytes, err := json.Marshal(request)
if err != nil {
return nil, "", err
}
resp, err := client.httpPost(url, headers, contentBytes)
if err != nil {
return nil, "", err
}
defer resp.Body.Close()
switch resp.StatusCode {
case 200, 304:
if 304 != resp.StatusCode {
err = json.NewDecoder(resp.Body).Decode(&data)
if err != nil {
return nil, "", err
}
}
tag := resp.Header.Get(rdl.FoldHttpHeaderName("ETag"))
return data, tag, nil
default:
var errobj rdl.ResourceError
contentBytes, err = io.ReadAll(resp.Body)
if err != nil {
return nil, "", err
}
json.Unmarshal(contentBytes, &errobj)
if errobj.Code == 0 {
errobj.Code = resp.StatusCode
}
if errobj.Message == "" {
errobj.Message = string(contentBytes)
}
return nil, "", errobj
}
}

func (client MSDClient) GetRdlSchema() (*rdl.Schema, error) {
var data *rdl.Schema
url := client.URL + "/schema"
Expand Down
Loading