func (m *MachinesClient) Create(ctx context.Context, machine *envelope.Unsigned,
	memberships []envelope.Unsigned, token *MachineTokenCreationSegment) (*apitypes.MachineSegment, error) {

	segment := MachineCreationSegment{
		Machine:     machine,
		Memberships: memberships,
		Tokens:      []MachineTokenCreationSegment{*token},
	}

	req, err := m.client.NewRequest("POST", "/machines", nil, &segment)
	if err != nil {
		log.Printf("Error building POST Machines Request: %s", err)
		return nil, err
	}

	resp := &apitypes.MachineSegment{}
	_, err = m.client.Do(ctx, req, resp)
	if err != nil {
		log.Printf("Failed to create machine: %s", err)
		return nil, err
	}

	return resp, nil
}
// Create requests the registry to create a MachineSegment.
//
// The MachineSegment includes the Machine, it's Memberships, and authorization
// tokens.
Create requests the registry to create a MachineSegment.

The MachineSegment includes the Machine, it's Memberships, and authorization
tokens.
// Create requests the registry to create a MachineSegment . // // The MachineSegment includes the Machine it ' s Memberships and authorization // tokens .
func (m *MachinesClient) Create(ctx context.Context, machine *envelope.Unsigned,
	memberships []envelope.Unsigned, token *MachineTokenCreationSegment) (*apitypes.MachineSegment, error) {
	segment := MachineCreationSegment{
		Machine:     machine,
		Memberships: memberships,
		Tokens:      []MachineTokenCreationSegment{*token},
	}
	req, err := m.client.NewRequest("POST", "/machines", nil, &segment)
	if err != nil {
		log.Printf("Error building POST Machines Request: %s", err)
		return nil, err
	}
	resp := &apitypes.MachineSegment{}
	_, err = m.client.Do(ctx, req, resp)
	if err != nil {
		log.Printf("Failed to create machine: %s", err)
		return nil, err
	}
	return resp, nil
}
func ( m * MachinesClient ) Create ( ctx context . Context , machine * envelope . Unsigned , memberships [ ] envelope . Unsigned , token * MachineTokenCreationSegment ) ( * apitypes . MachineSegment , error ) { segment := MachineCreationSegment { Machine : machine , Memberships : memberships , Tokens : [ ] MachineTokenCreationSegment { * token } , } req , err := m . client . NewRequest ( " " , " " , nil , & segment ) if err != nil { log . Printf ( " " , err ) return nil , err } resp := & apitypes . MachineSegment { } _ , err = m . client . Do ( ctx , req , resp ) if err != nil { log . Printf ( " " , err ) return nil , err } return resp , nil }
Create requests the registry to create a MachineSegment.
Create requests the registry to create a MachineSegment .