Add baremetalmachine.GetByComputerName function.

This commit is contained in:
Chris Gunn 2021-04-26 18:02:40 -07:00
Родитель 0b990b432c
Коммит 9eae2aea47
1 изменённых файлов: 13 добавлений и 0 удалений

Просмотреть файл

@ -5,6 +5,7 @@ package baremetalmachine
import ( import (
"context" "context"
"fmt"
"github.com/microsoft/moc-sdk-for-go/services/compute" "github.com/microsoft/moc-sdk-for-go/services/compute"
"github.com/microsoft/moc/pkg/auth" "github.com/microsoft/moc/pkg/auth"
@ -50,3 +51,15 @@ func (c *BareMetalMachineClient) Delete(ctx context.Context, group string, name
func (c *BareMetalMachineClient) Query(ctx context.Context, group, query string) (*[]compute.BareMetalMachine, error) { func (c *BareMetalMachineClient) Query(ctx context.Context, group, query string) (*[]compute.BareMetalMachine, error) {
return c.internal.Query(ctx, group, query) return c.internal.Query(ctx, group, query)
} }
// Get the Virtual Machine by querying for the specified computer name
func (c *BareMetalMachineClient) GetByComputerName(ctx context.Context, group string, computerName string) (*[]compute.BareMetalMachine, error) {
query := fmt.Sprintf("[?baremetalmachineproperties.osprofile.computername=='%s']", computerName)
bmms, err := c.Query(ctx, group, query)
if err != nil {
return nil, err
}
return bmms, nil
}