|
| 1 | +/********************************************************************* |
| 2 | + * Copyright (c) Intel Corporation 2025 |
| 3 | + * SPDX-License-Identifier: Apache-2.0 |
| 4 | + **********************************************************************/ |
| 5 | + |
| 6 | +// Package http facilitates communication with Intel® AMT devices to manage HTTP proxy access point configuration. |
| 7 | +// |
| 8 | +// This service represents the HTTP Proxy Access Points configured for user-initiated connections through Intel AMT firmware. |
| 9 | +package http |
| 10 | + |
| 11 | +import ( |
| 12 | + "encoding/xml" |
| 13 | + |
| 14 | + "github.com/device-management-toolkit/go-wsman-messages/v2/internal/message" |
| 15 | + "github.com/device-management-toolkit/go-wsman-messages/v2/pkg/wsman/base" |
| 16 | + "github.com/device-management-toolkit/go-wsman-messages/v2/pkg/wsman/client" |
| 17 | + "github.com/device-management-toolkit/go-wsman-messages/v2/pkg/wsman/common" |
| 18 | +) |
| 19 | + |
| 20 | +// ProxyAccessPointService struct represents the HTTP Proxy Access Point Service. |
| 21 | +type ProxyAccessPointService struct { |
| 22 | + base.WSManService[ProxyAccessPointResponse] |
| 23 | +} |
| 24 | + |
| 25 | +// ProxyAccessPointResponse represents responses for IPS_HTTPProxyAccessPoint operations. |
| 26 | +type ProxyAccessPointResponse struct { |
| 27 | + *client.Message |
| 28 | + XMLName xml.Name `xml:"Envelope"` |
| 29 | + Header message.Header `xml:"Header"` |
| 30 | + Body ProxyAccessPointBody `xml:"Body"` |
| 31 | +} |
| 32 | + |
| 33 | +// ProxyAccessPointBody represents the body of IPS_HTTPProxyAccessPoint responses. |
| 34 | +type ProxyAccessPointBody struct { |
| 35 | + XMLName xml.Name `xml:"Body"` |
| 36 | + EnumerateResponse common.EnumerateResponse `xml:"EnumerateResponse"` |
| 37 | + PullResponse ProxyAccessPointPullResponse `xml:"PullResponse"` |
| 38 | + GetAndPutResponse HTTPProxyAccessPointItem `xml:"IPS_HTTPProxyAccessPoint"` |
| 39 | +} |
| 40 | + |
| 41 | +// ProxyAccessPointPullResponse represents the pull response for proxy access points. |
| 42 | +type ProxyAccessPointPullResponse struct { |
| 43 | + XMLName xml.Name `xml:"PullResponse"` |
| 44 | + Items []HTTPProxyAccessPointItem `xml:"Items>IPS_HTTPProxyAccessPoint"` |
| 45 | +} |
| 46 | + |
| 47 | +// HTTPProxyAccessPointItem represents an individual HTTP proxy access point configuration. |
| 48 | +type HTTPProxyAccessPointItem struct { |
| 49 | + XMLName xml.Name `xml:"IPS_HTTPProxyAccessPoint"` |
| 50 | + Name string `xml:"Name,omitempty"` |
| 51 | + CreationClassName string `xml:"CreationClassName,omitempty"` |
| 52 | + SystemName string `xml:"SystemName,omitempty"` |
| 53 | + SystemCreationClassName string `xml:"SystemCreationClassName,omitempty"` |
| 54 | + ElementName string `xml:"ElementName,omitempty"` |
| 55 | + AccessInfo string `xml:"AccessInfo,omitempty"` // The proxy address (IP or FQDN) |
| 56 | + InfoFormat int `xml:"InfoFormat,omitempty"` // Format of AccessInfo: 3=IPv4, 4=IPv6, 201=FQDN |
| 57 | + Port int `xml:"Port,omitempty"` // Proxy port |
| 58 | + NetworkDnsSuffix string `xml:"NetworkDnsSuffix,omitempty"` // Domain suffix |
| 59 | +} |
| 60 | + |
| 61 | +// NewHTTPProxyAccessPointServiceWithClient returns a new instance of the ProxyAccessPointService struct. |
| 62 | +func NewHTTPProxyAccessPointServiceWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) ProxyAccessPointService { |
| 63 | + return ProxyAccessPointService{ |
| 64 | + base.NewService[ProxyAccessPointResponse](wsmanMessageCreator, IPSHTTPProxyAccessPoint, client), |
| 65 | + } |
| 66 | +} |
| 67 | + |
| 68 | +// Delete removes the specified HTTP proxy access point instance. |
| 69 | +func (service ProxyAccessPointService) Delete(name string) (response ProxyAccessPointResponse, err error) { |
| 70 | + selector := message.Selector{Name: "Name", Value: name} |
| 71 | + response = ProxyAccessPointResponse{ |
| 72 | + Message: &client.Message{ |
| 73 | + XMLInput: service.Base.Delete(selector), |
| 74 | + }, |
| 75 | + } |
| 76 | + |
| 77 | + // send the message to AMT |
| 78 | + err = service.Base.Execute(response.Message) |
| 79 | + if err != nil { |
| 80 | + return response, err |
| 81 | + } |
| 82 | + |
| 83 | + // put the xml response into the go struct |
| 84 | + err = xml.Unmarshal([]byte(response.XMLOutput), &response) |
| 85 | + if err != nil { |
| 86 | + return response, err |
| 87 | + } |
| 88 | + |
| 89 | + return response, nil |
| 90 | +} |
0 commit comments