pkg/dataplane/internal/client/models_serde.go (376 lines of code) (raw):
// Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.3, generator: @autorest/go@4.0.0-preview.69)
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
// Code generated by @autorest/go. DO NOT EDIT.
package client
import (
"encoding/json"
"fmt"
"reflect"
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
)
// MarshalJSON implements the json.Marshaller interface for type CredRequestDefinition.
func (c CredRequestDefinition) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]any)
populate(objectMap, "customClaims", c.CustomClaims)
populate(objectMap, "delegatedResources", c.DelegatedResources)
populate(objectMap, "identityIds", c.IdentityIDs)
return json.Marshal(objectMap)
}
// UnmarshalJSON implements the json.Unmarshaller interface for type CredRequestDefinition.
func (c *CredRequestDefinition) UnmarshalJSON(data []byte) error {
var rawMsg map[string]json.RawMessage
if err := json.Unmarshal(data, &rawMsg); err != nil {
return fmt.Errorf("unmarshalling type %T: %v", c, err)
}
for key, val := range rawMsg {
var err error
switch key {
case "customClaims":
err = unpopulate(val, "CustomClaims", &c.CustomClaims)
delete(rawMsg, key)
case "delegatedResources":
err = unpopulate(val, "DelegatedResources", &c.DelegatedResources)
delete(rawMsg, key)
case "identityIds":
err = unpopulate(val, "IdentityIDs", &c.IdentityIDs)
delete(rawMsg, key)
}
if err != nil {
return fmt.Errorf("unmarshalling type %T: %v", c, err)
}
}
return nil
}
// MarshalJSON implements the json.Marshaller interface for type CustomClaims.
func (c CustomClaims) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]any)
populate(objectMap, "xms_az_nwperimid", c.XMSAzNwperimid)
populate(objectMap, "xms_az_tm", c.XMSAzTm)
return json.Marshal(objectMap)
}
// UnmarshalJSON implements the json.Unmarshaller interface for type CustomClaims.
func (c *CustomClaims) UnmarshalJSON(data []byte) error {
var rawMsg map[string]json.RawMessage
if err := json.Unmarshal(data, &rawMsg); err != nil {
return fmt.Errorf("unmarshalling type %T: %v", c, err)
}
for key, val := range rawMsg {
var err error
switch key {
case "xms_az_nwperimid":
err = unpopulate(val, "XMSAzNwperimid", &c.XMSAzNwperimid)
delete(rawMsg, key)
case "xms_az_tm":
err = unpopulate(val, "XMSAzTm", &c.XMSAzTm)
delete(rawMsg, key)
}
if err != nil {
return fmt.Errorf("unmarshalling type %T: %v", c, err)
}
}
return nil
}
// MarshalJSON implements the json.Marshaller interface for type DelegatedResource.
func (d DelegatedResource) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]any)
populate(objectMap, "delegation_id", d.DelegationID)
populate(objectMap, "delegation_url", d.DelegationURL)
populate(objectMap, "explicit_identities", d.ExplicitIdentities)
populate(objectMap, "implicit_identity", d.ImplicitIdentity)
populate(objectMap, "internal_id", d.InternalID)
populate(objectMap, "resource_id", d.ResourceID)
return json.Marshal(objectMap)
}
// UnmarshalJSON implements the json.Unmarshaller interface for type DelegatedResource.
func (d *DelegatedResource) UnmarshalJSON(data []byte) error {
var rawMsg map[string]json.RawMessage
if err := json.Unmarshal(data, &rawMsg); err != nil {
return fmt.Errorf("unmarshalling type %T: %v", d, err)
}
for key, val := range rawMsg {
var err error
switch key {
case "delegation_id":
err = unpopulate(val, "DelegationID", &d.DelegationID)
delete(rawMsg, key)
case "delegation_url":
err = unpopulate(val, "DelegationURL", &d.DelegationURL)
delete(rawMsg, key)
case "explicit_identities":
err = unpopulate(val, "ExplicitIdentities", &d.ExplicitIdentities)
delete(rawMsg, key)
case "implicit_identity":
err = unpopulate(val, "ImplicitIdentity", &d.ImplicitIdentity)
delete(rawMsg, key)
case "internal_id":
err = unpopulate(val, "InternalID", &d.InternalID)
delete(rawMsg, key)
case "resource_id":
err = unpopulate(val, "ResourceID", &d.ResourceID)
delete(rawMsg, key)
}
if err != nil {
return fmt.Errorf("unmarshalling type %T: %v", d, err)
}
}
return nil
}
// MarshalJSON implements the json.Marshaller interface for type ErrorResponse.
func (e ErrorResponse) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]any)
populate(objectMap, "error", e.Error)
return json.Marshal(objectMap)
}
// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorResponse.
func (e *ErrorResponse) UnmarshalJSON(data []byte) error {
var rawMsg map[string]json.RawMessage
if err := json.Unmarshal(data, &rawMsg); err != nil {
return fmt.Errorf("unmarshalling type %T: %v", e, err)
}
for key, val := range rawMsg {
var err error
switch key {
case "error":
err = unpopulate(val, "Error", &e.Error)
delete(rawMsg, key)
}
if err != nil {
return fmt.Errorf("unmarshalling type %T: %v", e, err)
}
}
return nil
}
// MarshalJSON implements the json.Marshaller interface for type ErrorResponseError.
func (e ErrorResponseError) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]any)
populate(objectMap, "code", e.Code)
populate(objectMap, "message", e.Message)
return json.Marshal(objectMap)
}
// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorResponseError.
func (e *ErrorResponseError) UnmarshalJSON(data []byte) error {
var rawMsg map[string]json.RawMessage
if err := json.Unmarshal(data, &rawMsg); err != nil {
return fmt.Errorf("unmarshalling type %T: %v", e, err)
}
for key, val := range rawMsg {
var err error
switch key {
case "code":
err = unpopulate(val, "Code", &e.Code)
delete(rawMsg, key)
case "message":
err = unpopulate(val, "Message", &e.Message)
delete(rawMsg, key)
}
if err != nil {
return fmt.Errorf("unmarshalling type %T: %v", e, err)
}
}
return nil
}
// MarshalJSON implements the json.Marshaller interface for type ManagedIdentityCredentials.
func (m ManagedIdentityCredentials) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]any)
populate(objectMap, "authentication_endpoint", m.AuthenticationEndpoint)
populate(objectMap, "cannot_renew_after", m.CannotRenewAfter)
populate(objectMap, "client_id", m.ClientID)
populate(objectMap, "client_secret", m.ClientSecret)
populate(objectMap, "client_secret_url", m.ClientSecretURL)
populate(objectMap, "custom_claims", m.CustomClaims)
populate(objectMap, "delegated_resources", m.DelegatedResources)
populate(objectMap, "delegation_url", m.DelegationURL)
populate(objectMap, "explicit_identities", m.ExplicitIdentities)
populate(objectMap, "internal_id", m.InternalID)
populate(objectMap, "mtls_authentication_endpoint", m.MtlsAuthenticationEndpoint)
populate(objectMap, "not_after", m.NotAfter)
populate(objectMap, "not_before", m.NotBefore)
populate(objectMap, "object_id", m.ObjectID)
populate(objectMap, "renew_after", m.RenewAfter)
populate(objectMap, "tenant_id", m.TenantID)
return json.Marshal(objectMap)
}
// UnmarshalJSON implements the json.Unmarshaller interface for type ManagedIdentityCredentials.
func (m *ManagedIdentityCredentials) UnmarshalJSON(data []byte) error {
var rawMsg map[string]json.RawMessage
if err := json.Unmarshal(data, &rawMsg); err != nil {
return fmt.Errorf("unmarshalling type %T: %v", m, err)
}
for key, val := range rawMsg {
var err error
switch key {
case "authentication_endpoint":
err = unpopulate(val, "AuthenticationEndpoint", &m.AuthenticationEndpoint)
delete(rawMsg, key)
case "cannot_renew_after":
err = unpopulate(val, "CannotRenewAfter", &m.CannotRenewAfter)
delete(rawMsg, key)
case "client_id":
err = unpopulate(val, "ClientID", &m.ClientID)
delete(rawMsg, key)
case "client_secret":
err = unpopulate(val, "ClientSecret", &m.ClientSecret)
delete(rawMsg, key)
case "client_secret_url":
err = unpopulate(val, "ClientSecretURL", &m.ClientSecretURL)
delete(rawMsg, key)
case "custom_claims":
err = unpopulate(val, "CustomClaims", &m.CustomClaims)
delete(rawMsg, key)
case "delegated_resources":
err = unpopulate(val, "DelegatedResources", &m.DelegatedResources)
delete(rawMsg, key)
case "delegation_url":
err = unpopulate(val, "DelegationURL", &m.DelegationURL)
delete(rawMsg, key)
case "explicit_identities":
err = unpopulate(val, "ExplicitIdentities", &m.ExplicitIdentities)
delete(rawMsg, key)
case "internal_id":
err = unpopulate(val, "InternalID", &m.InternalID)
delete(rawMsg, key)
case "mtls_authentication_endpoint":
err = unpopulate(val, "MtlsAuthenticationEndpoint", &m.MtlsAuthenticationEndpoint)
delete(rawMsg, key)
case "not_after":
err = unpopulate(val, "NotAfter", &m.NotAfter)
delete(rawMsg, key)
case "not_before":
err = unpopulate(val, "NotBefore", &m.NotBefore)
delete(rawMsg, key)
case "object_id":
err = unpopulate(val, "ObjectID", &m.ObjectID)
delete(rawMsg, key)
case "renew_after":
err = unpopulate(val, "RenewAfter", &m.RenewAfter)
delete(rawMsg, key)
case "tenant_id":
err = unpopulate(val, "TenantID", &m.TenantID)
delete(rawMsg, key)
}
if err != nil {
return fmt.Errorf("unmarshalling type %T: %v", m, err)
}
}
return nil
}
// MarshalJSON implements the json.Marshaller interface for type MoveIdentityResponse.
func (m MoveIdentityResponse) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]any)
populate(objectMap, "identityUrl", m.IdentityURL)
return json.Marshal(objectMap)
}
// UnmarshalJSON implements the json.Unmarshaller interface for type MoveIdentityResponse.
func (m *MoveIdentityResponse) UnmarshalJSON(data []byte) error {
var rawMsg map[string]json.RawMessage
if err := json.Unmarshal(data, &rawMsg); err != nil {
return fmt.Errorf("unmarshalling type %T: %v", m, err)
}
for key, val := range rawMsg {
var err error
switch key {
case "identityUrl":
err = unpopulate(val, "IdentityURL", &m.IdentityURL)
delete(rawMsg, key)
}
if err != nil {
return fmt.Errorf("unmarshalling type %T: %v", m, err)
}
}
return nil
}
// MarshalJSON implements the json.Marshaller interface for type MoveRequestBodyDefinition.
func (m MoveRequestBodyDefinition) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]any)
populate(objectMap, "targetResourceId", m.TargetResourceID)
return json.Marshal(objectMap)
}
// UnmarshalJSON implements the json.Unmarshaller interface for type MoveRequestBodyDefinition.
func (m *MoveRequestBodyDefinition) UnmarshalJSON(data []byte) error {
var rawMsg map[string]json.RawMessage
if err := json.Unmarshal(data, &rawMsg); err != nil {
return fmt.Errorf("unmarshalling type %T: %v", m, err)
}
for key, val := range rawMsg {
var err error
switch key {
case "targetResourceId":
err = unpopulate(val, "TargetResourceID", &m.TargetResourceID)
delete(rawMsg, key)
}
if err != nil {
return fmt.Errorf("unmarshalling type %T: %v", m, err)
}
}
return nil
}
// MarshalJSON implements the json.Marshaller interface for type UserAssignedIdentityCredentials.
func (u UserAssignedIdentityCredentials) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]any)
populate(objectMap, "authentication_endpoint", u.AuthenticationEndpoint)
populate(objectMap, "cannot_renew_after", u.CannotRenewAfter)
populate(objectMap, "client_id", u.ClientID)
populate(objectMap, "client_secret", u.ClientSecret)
populate(objectMap, "client_secret_url", u.ClientSecretURL)
populate(objectMap, "custom_claims", u.CustomClaims)
populate(objectMap, "mtls_authentication_endpoint", u.MtlsAuthenticationEndpoint)
populate(objectMap, "not_after", u.NotAfter)
populate(objectMap, "not_before", u.NotBefore)
populate(objectMap, "object_id", u.ObjectID)
populate(objectMap, "renew_after", u.RenewAfter)
populate(objectMap, "resource_id", u.ResourceID)
populate(objectMap, "tenant_id", u.TenantID)
return json.Marshal(objectMap)
}
// UnmarshalJSON implements the json.Unmarshaller interface for type UserAssignedIdentityCredentials.
func (u *UserAssignedIdentityCredentials) UnmarshalJSON(data []byte) error {
var rawMsg map[string]json.RawMessage
if err := json.Unmarshal(data, &rawMsg); err != nil {
return fmt.Errorf("unmarshalling type %T: %v", u, err)
}
for key, val := range rawMsg {
var err error
switch key {
case "authentication_endpoint":
err = unpopulate(val, "AuthenticationEndpoint", &u.AuthenticationEndpoint)
delete(rawMsg, key)
case "cannot_renew_after":
err = unpopulate(val, "CannotRenewAfter", &u.CannotRenewAfter)
delete(rawMsg, key)
case "client_id":
err = unpopulate(val, "ClientID", &u.ClientID)
delete(rawMsg, key)
case "client_secret":
err = unpopulate(val, "ClientSecret", &u.ClientSecret)
delete(rawMsg, key)
case "client_secret_url":
err = unpopulate(val, "ClientSecretURL", &u.ClientSecretURL)
delete(rawMsg, key)
case "custom_claims":
err = unpopulate(val, "CustomClaims", &u.CustomClaims)
delete(rawMsg, key)
case "mtls_authentication_endpoint":
err = unpopulate(val, "MtlsAuthenticationEndpoint", &u.MtlsAuthenticationEndpoint)
delete(rawMsg, key)
case "not_after":
err = unpopulate(val, "NotAfter", &u.NotAfter)
delete(rawMsg, key)
case "not_before":
err = unpopulate(val, "NotBefore", &u.NotBefore)
delete(rawMsg, key)
case "object_id":
err = unpopulate(val, "ObjectID", &u.ObjectID)
delete(rawMsg, key)
case "renew_after":
err = unpopulate(val, "RenewAfter", &u.RenewAfter)
delete(rawMsg, key)
case "resource_id":
err = unpopulate(val, "ResourceID", &u.ResourceID)
delete(rawMsg, key)
case "tenant_id":
err = unpopulate(val, "TenantID", &u.TenantID)
delete(rawMsg, key)
}
if err != nil {
return fmt.Errorf("unmarshalling type %T: %v", u, err)
}
}
return nil
}
func populate(m map[string]any, k string, v any) {
if v == nil {
return
} else if azcore.IsNullValue(v) {
m[k] = nil
} else if !reflect.ValueOf(v).IsNil() {
m[k] = v
}
}
func unpopulate(data json.RawMessage, fn string, v any) error {
if data == nil || string(data) == "null" {
return nil
}
if err := json.Unmarshal(data, v); err != nil {
return fmt.Errorf("struct field %s: %v", fn, err)
}
return nil
}