diff --git a/internal/apiclient/v20231101/api.gen.go b/internal/apiclient/v20231101/api.gen.go deleted file mode 100644 index 3872f7d188e9e9292ac7bc064bbe18cacf336c7f..0000000000000000000000000000000000000000 --- a/internal/apiclient/v20231101/api.gen.go +++ /dev/null @@ -1,14770 +0,0 @@ -// Package v20231101 provides primitives to interact with the openapi HTTP API. -// -// Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.3.0 DO NOT EDIT. -package v20231101 - -import ( - "bytes" - "compress/gzip" - "context" - "encoding/base64" - "encoding/json" - "fmt" - "io" - "net/http" - "net/url" - "path" - "strings" - "time" - - "github.com/getkin/kin-openapi/openapi3" - "github.com/oapi-codegen/runtime" - openapi_types "github.com/oapi-codegen/runtime/types" -) - -const ( - JWTScopes = "JWT.Scopes" - MtlsScopes = "mtls.Scopes" -) - -// Defines values for AccountType. -const ( - Browser AccountType = "browser" - Ethernet AccountType = "ethernet" - Vpn AccountType = "vpn" - Wifi AccountType = "wifi" -) - -// Defines values for AcmeAttestationProvisionerAttestationFormats. -const ( - AcmeAttestationProvisionerAttestationFormatsApple AcmeAttestationProvisionerAttestationFormats = "apple" - AcmeAttestationProvisionerAttestationFormatsStep AcmeAttestationProvisionerAttestationFormats = "step" - AcmeAttestationProvisionerAttestationFormatsTpm AcmeAttestationProvisionerAttestationFormats = "tpm" -) - -// Defines values for AcmeProvisionerChallenges. -const ( - Dns01 AcmeProvisionerChallenges = "dns-01" - Http01 AcmeProvisionerChallenges = "http-01" - TlsAlpn01 AcmeProvisionerChallenges = "tls-alpn-01" -) - -// Defines values for AuthorityType. -const ( - AuthorityTypeAdvanced AuthorityType = "advanced" - AuthorityTypeDevops AuthorityType = "devops" - AuthorityTypeManaged AuthorityType = "managed" -) - -// Defines values for DeviceCollectionDeviceType. -const ( - DeviceCollectionDeviceTypeAwsVm DeviceCollectionDeviceType = "aws-vm" - DeviceCollectionDeviceTypeAzureVm DeviceCollectionDeviceType = "azure-vm" - DeviceCollectionDeviceTypeGcpVm DeviceCollectionDeviceType = "gcp-vm" - DeviceCollectionDeviceTypeTpm DeviceCollectionDeviceType = "tpm" -) - -// Defines values for EndpointCertificateInfoType. -const ( - EndpointCertificateInfoTypeSSHHOST EndpointCertificateInfoType = "SSH_HOST" - EndpointCertificateInfoTypeSSHUSER EndpointCertificateInfoType = "SSH_USER" - EndpointCertificateInfoTypeX509 EndpointCertificateInfoType = "X509" -) - -// Defines values for EndpointKeyInfoFormat. -const ( - EndpointKeyInfoFormatCLASSIC EndpointKeyInfoFormat = "CLASSIC" - EndpointKeyInfoFormatDEFAULT EndpointKeyInfoFormat = "DEFAULT" - EndpointKeyInfoFormatOPENSSH EndpointKeyInfoFormat = "OPENSSH" - EndpointKeyInfoFormatPKCS8 EndpointKeyInfoFormat = "PKCS8" - EndpointKeyInfoFormatTSS2 EndpointKeyInfoFormat = "TSS2" -) - -// Defines values for EndpointKeyInfoProtection. -const ( - EndpointKeyInfoProtectionDEFAULT EndpointKeyInfoProtection = "DEFAULT" - EndpointKeyInfoProtectionHARDWARE EndpointKeyInfoProtection = "HARDWARE" - EndpointKeyInfoProtectionHARDWAREATTESTED EndpointKeyInfoProtection = "HARDWARE_ATTESTED" - EndpointKeyInfoProtectionHARDWAREWITHFALLBACK EndpointKeyInfoProtection = "HARDWARE_WITH_FALLBACK" - EndpointKeyInfoProtectionNONE EndpointKeyInfoProtection = "NONE" -) - -// Defines values for EndpointKeyInfoType. -const ( - DEFAULT EndpointKeyInfoType = "DEFAULT" - ECDSAP256 EndpointKeyInfoType = "ECDSA_P256" - ECDSAP384 EndpointKeyInfoType = "ECDSA_P384" - ECDSAP521 EndpointKeyInfoType = "ECDSA_P521" - ED25519 EndpointKeyInfoType = "ED25519" - RSA2048 EndpointKeyInfoType = "RSA_2048" - RSA3072 EndpointKeyInfoType = "RSA_3072" - RSA4096 EndpointKeyInfoType = "RSA_4096" -) - -// Defines values for EndpointReloadInfoMethod. -const ( - AUTOMATIC EndpointReloadInfoMethod = "AUTOMATIC" - CUSTOM EndpointReloadInfoMethod = "CUSTOM" - DBUS EndpointReloadInfoMethod = "DBUS" - PLATFORM EndpointReloadInfoMethod = "PLATFORM" - SIGNAL EndpointReloadInfoMethod = "SIGNAL" -) - -// Defines values for NewAuthorityType. -const ( - NewAuthorityTypeAdvanced NewAuthorityType = "advanced" - NewAuthorityTypeDevops NewAuthorityType = "devops" -) - -// Defines values for NewPlatformPlatformType. -const ( - NewPlatformPlatformTypeAws NewPlatformPlatformType = "aws" - NewPlatformPlatformTypeAzure NewPlatformPlatformType = "azure" - NewPlatformPlatformTypeGcp NewPlatformPlatformType = "gcp" -) - -// Defines values for PlatformPlatformType. -const ( - PlatformPlatformTypeAws PlatformPlatformType = "aws" - PlatformPlatformTypeAzure PlatformPlatformType = "azure" - PlatformPlatformTypeGcp PlatformPlatformType = "gcp" -) - -// Defines values for ProvisionerType. -const ( - ACME ProvisionerType = "ACME" - ACMEATTESTATION ProvisionerType = "ACME_ATTESTATION" - AWS ProvisionerType = "AWS" - AZURE ProvisionerType = "AZURE" - GCP ProvisionerType = "GCP" - JWK ProvisionerType = "JWK" - OIDC ProvisionerType = "OIDC" - SCEP ProvisionerType = "SCEP" - X5C ProvisionerType = "X5C" -) - -// Defines values for ProvisionerWebhookCertType. -const ( - ProvisionerWebhookCertTypeALL ProvisionerWebhookCertType = "ALL" - ProvisionerWebhookCertTypeSSH ProvisionerWebhookCertType = "SSH" - ProvisionerWebhookCertTypeX509 ProvisionerWebhookCertType = "X509" -) - -// Defines values for ProvisionerWebhookKind. -const ( - ENRICHING ProvisionerWebhookKind = "ENRICHING" -) - -// Defines values for ProvisionerWebhookServerType. -const ( - EXTERNAL ProvisionerWebhookServerType = "EXTERNAL" - HOSTEDATTESTATION ProvisionerWebhookServerType = "HOSTED_ATTESTATION" -) - -// Defines values for ScepProvisionerEncryptionAlgorithmIdentifier. -const ( - AES128CBC ScepProvisionerEncryptionAlgorithmIdentifier = "AES_128_CBC" - AES128GCM ScepProvisionerEncryptionAlgorithmIdentifier = "AES_128_GCM" - AES256CBC ScepProvisionerEncryptionAlgorithmIdentifier = "AES_256_CBC" - AES256GCM ScepProvisionerEncryptionAlgorithmIdentifier = "AES_256_GCM" - DESCBC ScepProvisionerEncryptionAlgorithmIdentifier = "DES_CBC" -) - -// Defines values for VpnAccountConnectionType. -const ( - IKEv2 VpnAccountConnectionType = "IKEv2" - IPSec VpnAccountConnectionType = "IPSec" - SSL VpnAccountConnectionType = "SSL" -) - -// Defines values for VpnAccountVendor. -const ( - Cisco VpnAccountVendor = "Cisco" - F5 VpnAccountVendor = "F5" - Juniper VpnAccountVendor = "Juniper" -) - -// Defines values for X509CertificateRevocationReason. -const ( - AACOMPROMISE X509CertificateRevocationReason = "AA_COMPROMISE" - AFFILIATIONCHANGED X509CertificateRevocationReason = "AFFILIATION_CHANGED" - CACOMPROMISE X509CertificateRevocationReason = "CA_COMPROMISE" - CERTIFICATEHOLD X509CertificateRevocationReason = "CERTIFICATE_HOLD" - CESSATIONOFOPERATION X509CertificateRevocationReason = "CESSATION_OF_OPERATION" - KEYCOMPROMISE X509CertificateRevocationReason = "KEY_COMPROMISE" - PRIVILEGEWITHDRAWN X509CertificateRevocationReason = "PRIVILEGE_WITHDRAWN" - SUPERSEDED X509CertificateRevocationReason = "SUPERSEDED" - UNSPECIFIED X509CertificateRevocationReason = "UNSPECIFIED" -) - -// Defines values for X509IssuerKeyVersion. -const ( - ECSIGNP256SHA256 X509IssuerKeyVersion = "EC_SIGN_P256_SHA256" - ECSIGNP384SHA384 X509IssuerKeyVersion = "EC_SIGN_P384_SHA384" - RSASIGNPKCS12048SHA256 X509IssuerKeyVersion = "RSA_SIGN_PKCS1_2048_SHA256" - RSASIGNPKCS13072SHA256 X509IssuerKeyVersion = "RSA_SIGN_PKCS1_3072_SHA256" - RSASIGNPKCS14096SHA256 X509IssuerKeyVersion = "RSA_SIGN_PKCS1_4096_SHA256" - RSASIGNPKCS14096SHA512 X509IssuerKeyVersion = "RSA_SIGN_PKCS1_4096_SHA512" - RSASIGNPSS2048SHA256 X509IssuerKeyVersion = "RSA_SIGN_PSS_2048_SHA256" - RSASIGNPSS3072SHA256 X509IssuerKeyVersion = "RSA_SIGN_PSS_3072_SHA256" - RSASIGNPSS4096SHA256 X509IssuerKeyVersion = "RSA_SIGN_PSS_4096_SHA256" - RSASIGNPSS4096SHA512 X509IssuerKeyVersion = "RSA_SIGN_PSS_4096_SHA512" -) - -// Defines values for PostAuthJSONBodyAudience. -const ( - StepAgent PostAuthJSONBodyAudience = "step-agent" -) - -// Account defines model for account. -type Account struct { - Id *string `json:"id,omitempty"` - Name string `json:"name"` - Type AccountType `json:"type"` - union json.RawMessage -} - -// AccountType defines model for Account.Type. -type AccountType string - -// AcmeAttestationProvisioner A [provisioner](https://smallstep.com/docs/step-ca/provisioners/#acme) that enables automation with the [device-attest-01 challenge of the ACME protocol](https://smallstep.com/blog/acme-managed-device-attestation-explained/). -type AcmeAttestationProvisioner struct { - // AttestationFormats The allowed attestation formats for the device-attest-01 challenge. Valid values are `apple`, `step`, and `tpm`. The apple format is for Apple devices, and adds trust for Apple's CAs. The step format is for non-TPM devices that can issue attestation certificates, such as YubiKey PIV. It adds trust for Yubico's root CA. The tpm format is for TPMs and does not trust any CAs by default. - AttestationFormats []AcmeAttestationProvisionerAttestationFormats `json:"attestationFormats"` - - // AttestationRoots A trust bundle of root certificates in PEM format that will be used to verify attestation certificates. The default value depends on the value of attestationFormats. If provided, this PEM bundle will override the CA trust established by setting attestationFormats to apple or step. At least one root certificate is required when using the tpm attestationFormat. - AttestationRoots *[]string `json:"attestationRoots,omitempty"` - - // ForceCN Force one of the SANs to become the Common Name, if a Common Name is not provided. - ForceCN *bool `json:"forceCN,omitempty"` - - // RequireEAB Only ACME clients that have been preconfigured with valid EAB credentials will be able to create an account with this provisioner. - RequireEAB *bool `json:"requireEAB,omitempty"` -} - -// AcmeAttestationProvisionerAttestationFormats defines model for AcmeAttestationProvisioner.AttestationFormats. -type AcmeAttestationProvisionerAttestationFormats string - -// AcmeProvisioner A [provisioner](https://smallstep.com/docs/step-ca/provisioners/#acme) that enables automation with the [ACME protocol](https://smallstep.com/docs/step-ca/acme-basics/#acme-challenges). -type AcmeProvisioner struct { - // Challenges Which ACME challenge types are allowed. - Challenges []AcmeProvisionerChallenges `json:"challenges"` - - // ForceCN Force one of the SANs to become the Common Name, if a Common Name is not provided. - ForceCN *bool `json:"forceCN,omitempty"` - - // RequireEAB Only ACME clients that have been preconfigured with valid EAB credentials will be able to create an account with this provisioner. Must be `true` for all new provisioners. - RequireEAB bool `json:"requireEAB"` -} - -// AcmeProvisionerChallenges defines model for AcmeProvisioner.Challenges. -type AcmeProvisionerChallenges string - -// AttestationAuthority An attestation authority used with the device-attest-01 ACME challenge to verify a device's hardware identity. This object is experimental and subject to change. -type AttestationAuthority struct { - // AttestorIntermediates The pem-encoded list of intermediate certificates used to build a chain of trust to verify the attestation certificates submitted by devices. - AttestorIntermediates *string `json:"attestorIntermediates,omitempty"` - - // AttestorRoots The pem-encoded list of certificates used to verify the attestation certificates submitted by devices. - AttestorRoots string `json:"attestorRoots"` - - // CreatedAt Timestamp in RFC3339 format when the attestation authority was created. - CreatedAt *time.Time `json:"createdAt,omitempty"` - - // Id A UUID identifying this attestation authority. Read only. - Id *string `json:"id,omitempty"` - - // Name The name of the attestation authority. - Name string `json:"name"` - - // Root The pem-encoded root certificate of this attestation authority. This is generated server-side when the attestation authority is created. This certificate should be used in the `attestationRoots` field of an ACME_ATTESTATION provisioner with the `tpm` format. - Root *string `json:"root,omitempty"` - - // Slug A short name for this attestation authority. Read only. - Slug *string `json:"slug,omitempty"` -} - -// Authority An X509 authority hosted by Smallstep. -type Authority struct { - // ActiveRevocation Whether CRL and OCSP are enabled (advanced authorities only). - ActiveRevocation *bool `json:"activeRevocation,omitempty"` - - // AdminEmails Users that have admin access to manage the authority. - AdminEmails *[]string `json:"adminEmails,omitempty"` - - // CreatedAt Timestamp when the authority was created. - CreatedAt time.Time `json:"createdAt"` - - // Domain The domain where the authority can be reached. - Domain string `json:"domain"` - - // Fingerprint The SHA-256 digest of the authority's root certificate in hex format. - Fingerprint *string `json:"fingerprint,omitempty"` - - // Id A UUID identifying this authority. - Id string `json:"id"` - - // Name The name of the authority. - Name string `json:"name"` - - // Root The root certificate in pem format. - Root *string `json:"root,omitempty"` - - // Type One of the available authority types - Type AuthorityType `json:"type"` -} - -// AuthorityCsr A certificate signing request for an X509 advanced authority with an external root. -type AuthorityCsr struct { - // AuthorityID A UUID identifying the authority. - AuthorityID string `json:"authorityID"` - - // Csr A certificate sigining request for the authority's intermediate issuer in pem format. - Csr string `json:"csr"` - - // Id A UUID identifying this CSR. - Id string `json:"id"` -} - -// AuthorityType One of the available authority types -type AuthorityType string - -// AwsAccounts The list of AWS account IDs that are allowed to use an AWS cloud provisioner. -type AwsAccounts = []string - -// AwsDisableCustomSANs By default custom SANs are valid, but if this option is set to `true` only the SANs available in the instance identity document will be valid. These are the private IP and the DNS ip-<private-ip>.<region>.compute.internal. -type AwsDisableCustomSANs = bool - -// AwsPlatform Configuration for an AWS platform. -type AwsPlatform struct { - AccountId string `json:"accountId"` - - // Name A friendly name for this AWS account. - Name string `json:"name"` - - // RoleArn A role ARN that allows the Smallstep Platform to manage resources on your behalf. - RoleArn *string `json:"roleArn,omitempty"` -} - -// AwsProvisioner The [AWS provisioner](https://smallstep.com/docs/step-ca/provisioners/#aws) grants a certificate to an Amazon EC2 instance using the Instance Identity Document. -type AwsProvisioner struct { - // Accounts The list of AWS account IDs that are allowed to use an AWS cloud provisioner. - Accounts AwsAccounts `json:"accounts"` - - // DisableCustomSANs By default custom SANs are valid, but if this option is set to `true` only the SANs available in the instance identity document will be valid. These are the private IP and the DNS ip-<private-ip>.<region>.compute.internal. - DisableCustomSANs *AwsDisableCustomSANs `json:"disableCustomSANs,omitempty"` - - // DisableTrustOnFirstUse By default only one certificate will be granted per instance, but if the option is set to `true` this limit is not set and different tokens can be used to get different certificates. - DisableTrustOnFirstUse *bool `json:"disableTrustOnFirstUse,omitempty"` - - // InstanceAge The maximum age of an instance that should be allowed to obtain a certificate. Limits certificate issuance to new instances to mitigate the risk of credential-misuse from instances that don't need a certificate. Parsed as a [Golang duration](https://pkg.go.dev/time#ParseDuration). - InstanceAge *InstanceAge `json:"instanceAge,omitempty"` -} - -// AwsVM Configuration for an AWS provisioner for a device collection of AWS VMs. -type AwsVM struct { - // Accounts The list of AWS account IDs that are allowed to use an AWS cloud provisioner. - Accounts AwsAccounts `json:"accounts"` - - // DisableCustomSANs By default custom SANs are valid, but if this option is set to `true` only the SANs available in the instance identity document will be valid. These are the private IP and the DNS ip-<private-ip>.<region>.compute.internal. - DisableCustomSANs *AwsDisableCustomSANs `json:"disableCustomSANs,omitempty"` -} - -// AzureAudience Defaults to https://management.azure.com/ but it can be changed if necessary. -type AzureAudience = string - -// AzureDisableCustomSANs By default custom SANs are valid, but if this option is set to `true` only the SANs available in the token will be valid, in Azure only the virtual machine name is available. -type AzureDisableCustomSANs = bool - -// AzurePlatform Microsoft Azure -type AzurePlatform struct { - // ClientId The client ID of an Azure Service Principal that allows the Smallstep Platform to manage resources on your behalf. - ClientId *string `json:"clientId,omitempty"` - - // ClientSecret The client secret of an Azure Service Principal that allows the Smallstep Platform to manage resources on your behalf. - ClientSecret *string `json:"clientSecret,omitempty"` - - // Name A friendly name for this Azure connection - Name string `json:"name"` - - // ResourceGroups A list of resource groups that are allowed to enroll with the Smallstep Platform. - ResourceGroups []string `json:"resourceGroups"` - - // TenantId The Azure Entra tenant ID - TenantId string `json:"tenantId"` -} - -// AzureProvisioner The [Azure provisioner](https://smallstep.com/docs/step-ca/provisioners/#azure) grants certificates to Microsoft Azure instances using the managed identities tokens. -type AzureProvisioner struct { - // Audience Defaults to https://management.azure.com/ but it can be changed if necessary. - Audience *AzureAudience `json:"audience,omitempty"` - - // DisableCustomSANs By default custom SANs are valid, but if this option is set to `true` only the SANs available in the token will be valid, in Azure only the virtual machine name is available. - DisableCustomSANs *AzureDisableCustomSANs `json:"disableCustomSANs,omitempty"` - - // DisableTrustOnFirstUse By default only one certificate will be granted per instance, but if the option is set to true this limit is not set and different tokens can be used to get different certificates. - DisableTrustOnFirstUse *bool `json:"disableTrustOnFirstUse,omitempty"` - - // ResourceGroups The list of resource group names that are allowed to use this provisioner. - ResourceGroups AzureResourceGroups `json:"resourceGroups"` - - // TenantID The Azure account tenant ID for this provisioner. This ID is the Directory ID available in the Azure Active Directory properties. - TenantID AzureTenantID `json:"tenantID"` -} - -// AzureResourceGroups The list of resource group names that are allowed to use this provisioner. -type AzureResourceGroups = []string - -// AzureTenantID The Azure account tenant ID for this provisioner. This ID is the Directory ID available in the Azure Active Directory properties. -type AzureTenantID = string - -// AzureVM defines model for azureVM. -type AzureVM struct { - // Audience Defaults to https://management.azure.com/ but it can be changed if necessary. - Audience *AzureAudience `json:"audience,omitempty"` - - // DisableCustomSANs By default custom SANs are valid, but if this option is set to `true` only the SANs available in the token will be valid, in Azure only the virtual machine name is available. - DisableCustomSANs *AzureDisableCustomSANs `json:"disableCustomSANs,omitempty"` - - // ResourceGroups The list of resource group names that are allowed to use this provisioner. - ResourceGroups AzureResourceGroups `json:"resourceGroups"` - - // TenantID The Azure account tenant ID for this provisioner. This ID is the Directory ID available in the Azure Active Directory properties. - TenantID AzureTenantID `json:"tenantID"` -} - -// BasicAuth Configures provisioner webhook requests to include an Authorization header with these credentials. Optional for `EXTERNAL` webhook servers; not allowed with hosted webhook servers. At most one of `bearerToken` and `basicAuth` may be set. -type BasicAuth struct { - Password string `json:"password"` - Username string `json:"username"` -} - -// BasicConstraints defines model for basicConstraints. -type BasicConstraints struct { - IsCA bool `json:"isCA"` - MaxPathLen int `json:"maxPathLen"` -} - -// BrowserAccount Configuration to use a client certificate. -type BrowserAccount = map[string]interface{} - -// CertificateField A certificate field that takes a single string value, e.g. Common Name. -type CertificateField struct { - union json.RawMessage -} - -// CertificateFieldDeviceMetadata defines model for certificateFieldDeviceMetadata. -type CertificateFieldDeviceMetadata struct { - DeviceMetadata string `json:"deviceMetadata"` -} - -// CertificateFieldList A certificate field that accepts multiple string values, e.g. SANs. -type CertificateFieldList struct { - // DeviceMetadata A value populated from a key in the device's metadata. - DeviceMetadata *[]string `json:"deviceMetadata,omitempty"` - - // Static A literal value. - Static *[]string `json:"static,omitempty"` -} - -// CertificateFieldStatic defines model for certificateFieldStatic. -type CertificateFieldStatic struct { - Static string `json:"static"` -} - -// Collection A collection of instances. -type Collection struct { - // CreatedAt Timestamp in RFC3339 format when the collections was created - CreatedAt time.Time `json:"createdAt"` - - // DisplayName A user-friendly name for the collection. - DisplayName string `json:"displayName"` - - // InstanceCount The number of instances in the collection. - InstanceCount int `json:"instanceCount"` - - // SchemaURI Reference to a schema that all instances in the collection must conform to. - SchemaURI *string `json:"schemaURI,omitempty"` - - // Slug A lowercase name identifying the collection. - Slug string `json:"slug"` - - // UpdatedAt Timestamp in RFC3339 format when the collections was last updated - UpdatedAt time.Time `json:"updatedAt"` -} - -// CollectionInstance An instance in a collection. -type CollectionInstance struct { - // CreatedAt Timestamp in RFC3339 format when the instance was added to the collection. - CreatedAt time.Time `json:"createdAt"` - - // Data The instance data. - Data interface{} `json:"data"` - Id string `json:"id"` - - // UpdatedAt Timestamp in RFC3339 format when the instance was last changed. - UpdatedAt time.Time `json:"updatedAt"` -} - -// DeviceCollection Configuration to create a new device collection. -type DeviceCollection struct { - // AuthorityID A UUID identifying the authority to issue certificates for the agent running on devices in the collection. - AuthorityID string `json:"authorityID"` - - // DeviceType Must match the deviceTypeConfiguration. Cannot be changed. - DeviceType DeviceCollectionDeviceType `json:"deviceType"` - DeviceTypeConfiguration DeviceCollection_DeviceTypeConfiguration `json:"deviceTypeConfiguration"` - DisplayName string `json:"displayName"` - Slug string `json:"slug"` -} - -// DeviceCollectionDeviceType Must match the deviceTypeConfiguration. Cannot be changed. -type DeviceCollectionDeviceType string - -// DeviceCollection_DeviceTypeConfiguration defines model for DeviceCollection.DeviceTypeConfiguration. -type DeviceCollection_DeviceTypeConfiguration struct { - union json.RawMessage -} - -// DeviceCollectionAccount defines model for deviceCollectionAccount. -type DeviceCollectionAccount struct { - // AccountID Identifier of the account. - AccountID string `json:"accountID"` - - // AuthorityID A UUID identifying the authority to issue certificates for the account on devices in the collection. - AuthorityID string `json:"authorityID"` - - // CertificateInfo Details on a managed certificate. - CertificateInfo *EndpointCertificateInfo `json:"certificateInfo,omitempty"` - - // DisplayName A friendly name for the device collection account. Also used as the Common Name, if no static SANs are provided. - DisplayName string `json:"displayName"` - - // Hooks The collection of commands to run when a certificate for a managed endpoint is signed or renewed. - Hooks *EndpointHooks `json:"hooks,omitempty"` - - // KeyInfo The attributes of the cryptographic key. - KeyInfo *EndpointKeyInfo `json:"keyInfo,omitempty"` - - // ReloadInfo The properties used to reload a service. - ReloadInfo *EndpointReloadInfo `json:"reloadInfo,omitempty"` - - // Slug Used as the identifier for the device collection account. - Slug string `json:"slug"` - union json.RawMessage -} - -// DistinguishedName Name used in x509 certificates -type DistinguishedName struct { - CommonName *string `json:"commonName,omitempty"` - Country *string `json:"country,omitempty"` - EmailAddress *string `json:"emailAddress,omitempty"` - Locality *string `json:"locality,omitempty"` - Organization *string `json:"organization,omitempty"` - OrganizationalUnit *string `json:"organizationalUnit,omitempty"` - PostalCode *string `json:"postalCode,omitempty"` - Province *string `json:"province,omitempty"` - SerialNumber *string `json:"serialNumber,omitempty"` - StreetAddress *string `json:"streetAddress,omitempty"` -} - -// Email Email is a subresource of an SSH User. -type Email struct { - Email *string `json:"email,omitempty"` - Primary *bool `json:"primary,omitempty"` -} - -// EndpointCertificateInfo Details on a managed certificate. -type EndpointCertificateInfo struct { - // CrtFile The filepath where the certificate is to be stored. - CrtFile *string `json:"crtFile,omitempty"` - - // Duration The certificate lifetime. Parsed as a [Golang duration](https://pkg.go.dev/time#ParseDuration). - Duration *string `json:"duration,omitempty"` - - // Gid GID of the files where the certificate is stored. - Gid *int `json:"gid,omitempty"` - - // KeyFile The filepath where the key is to be stored. - KeyFile *string `json:"keyFile,omitempty"` - - // Mode Permission bits of the files where the certificate is stored. - Mode *int `json:"mode,omitempty"` - - // RootFile The filepath where the root certificate is to be stored. - RootFile *string `json:"rootFile,omitempty"` - - // Type The type of certificate. - Type EndpointCertificateInfoType `json:"type"` - - // Uid UID of the files where the certificate is stored. - Uid *int `json:"uid,omitempty"` -} - -// EndpointCertificateInfoType The type of certificate. -type EndpointCertificateInfoType string - -// EndpointHook A list of commands to run before and after a certificate is granted. -type EndpointHook struct { - // After List of commands to run after the operation. - After *[]string `json:"after,omitempty"` - - // Before List of commands to run before the operation. - Before *[]string `json:"before,omitempty"` - - // OnError List of commands to run when the operation fails. - OnError *[]string `json:"onError,omitempty"` - - // Shell The shell to use to execute the commands. - Shell *string `json:"shell,omitempty"` -} - -// EndpointHooks The collection of commands to run when a certificate for a managed endpoint is signed or renewed. -type EndpointHooks struct { - // Renew A list of commands to run before and after a certificate is granted. - Renew *EndpointHook `json:"renew,omitempty"` - - // Sign A list of commands to run before and after a certificate is granted. - Sign *EndpointHook `json:"sign,omitempty"` -} - -// EndpointKeyInfo The attributes of the cryptographic key. -type EndpointKeyInfo struct { - // Format The format used to encode the private key. For X509 keys the default format is PKCS#8. The classic format is PKCS#1 for RSA keys, SEC 1 for ECDSA keys, and PKCS#8 for ED25519 keys. For SSH keys the default format is always the OPENSSH format. When a hardware module is used to store the keys the default will be a JSON representation of the key, except on Linux where tss2 will be used. - Format *EndpointKeyInfoFormat `json:"format,omitempty"` - - // Protection Whether to use a hardware module to store the private key for a workload certificate. If set to `NONE` no hardware module will be used. If set to `DEFAULT` a hardware module will only be used with format `TSS2`. `HARDWARE_WITH_FALLBACK` can only be used with the key format `DEFAULT`. - Protection *EndpointKeyInfoProtection `json:"protection,omitempty"` - - // PubFile A CSR or SSH public key to use instead of generating one. - PubFile *string `json:"pubFile,omitempty"` - - // Type The key type used. The current DEFAULT type is ECDSA_P256. - Type *EndpointKeyInfoType `json:"type,omitempty"` -} - -// EndpointKeyInfoFormat The format used to encode the private key. For X509 keys the default format is PKCS#8. The classic format is PKCS#1 for RSA keys, SEC 1 for ECDSA keys, and PKCS#8 for ED25519 keys. For SSH keys the default format is always the OPENSSH format. When a hardware module is used to store the keys the default will be a JSON representation of the key, except on Linux where tss2 will be used. -type EndpointKeyInfoFormat string - -// EndpointKeyInfoProtection Whether to use a hardware module to store the private key for a workload certificate. If set to `NONE` no hardware module will be used. If set to `DEFAULT` a hardware module will only be used with format `TSS2`. `HARDWARE_WITH_FALLBACK` can only be used with the key format `DEFAULT`. -type EndpointKeyInfoProtection string - -// EndpointKeyInfoType The key type used. The current DEFAULT type is ECDSA_P256. -type EndpointKeyInfoType string - -// EndpointReloadInfo The properties used to reload a service. -type EndpointReloadInfo struct { - // Method Ways an endpoint can reload a certificate. `AUTOMATIC` means the process is able to detect and reload new certificates automatically. `CUSTOM` means a custom command must be run to trigger the workload to reload the certificates. `SIGNAL` will configure the agent to send a signal to the process in `pidFile`. `DBUS` will use the systemd system bus to issue a `try-reload-or-restart` job for unit specified by `unitName`. `PLATFORM` uses a method specific to the operating system. - Method EndpointReloadInfoMethod `json:"method"` - - // PidFile File that holds the pid of the process to signal. Required when method is SIGNAL. - PidFile *string `json:"pidFile,omitempty"` - - // Signal The signal to send to a process when a certificate should be reloaded. Required when method is SIGNAL. - Signal *int `json:"signal,omitempty"` - - // UnitName The systemd unit name to reload when a certificate should be reloaded. Required when method is DBUS. - UnitName *string `json:"unitName,omitempty"` -} - -// EndpointReloadInfoMethod Ways an endpoint can reload a certificate. `AUTOMATIC` means the process is able to detect and reload new certificates automatically. `CUSTOM` means a custom command must be run to trigger the workload to reload the certificates. `SIGNAL` will configure the agent to send a signal to the process in `pidFile`. `DBUS` will use the systemd system bus to issue a `try-reload-or-restart` job for unit specified by `unitName`. `PLATFORM` uses a method specific to the operating system. -type EndpointReloadInfoMethod string - -// EnrollmentToken A JWT that can be used to enroll devices with the Smallstep Agent -type EnrollmentToken struct { - // Id The unique identifier of the token - Id *string `json:"id,omitempty"` - - // Secret The JWT itself; this value cannot be retrieved after initially generated and should be kept secret - Secret *string `json:"secret,omitempty"` - - // Title The name of the token - Title *string `json:"title,omitempty"` -} - -// Error defines model for error. -type Error struct { - // Message A description of the error. - Message string `json:"message"` -} - -// EthernetAccount Configuration to connect a device to a protected LAN. -type EthernetAccount struct { - Autojoin *bool `json:"autojoin,omitempty"` - CaChain *string `json:"caChain,omitempty"` - ExternalRadiusServer *bool `json:"externalRadiusServer,omitempty"` - NetworkAccessServerIP *string `json:"networkAccessServerIP,omitempty"` -} - -// ExtraName defines model for extraName. -type ExtraName struct { - Type string `json:"type"` - Value interface{} `json:"value"` -} - -// GcpDisableCustomSANs By default custom SANs are valid, but if this option is set to `true` only the SANs available in the instance identity document will be valid, these are the DNS `<instance-name>.c.<project-id>.internal` and `<instance-name>.<zone>.c.<project-id>.internal`. -type GcpDisableCustomSANs = bool - -// GcpPlatform Google Cloud Platform -type GcpPlatform struct { - // Name A friendly name for this GCP connection - Name string `json:"name"` - - // ProjectIds The project IDs where the resources are located. - ProjectIds []string `json:"projectIds"` - - // ServiceAccountKey A JSON-formatted service account key that allows the Smallstep Platform to manage resources on your behalf. - ServiceAccountKey *string `json:"serviceAccountKey,omitempty"` - - // ServiceAccounts GCE service accounts that are allowed to enroll with the Smallstep Platform. - ServiceAccounts *[]string `json:"serviceAccounts,omitempty"` -} - -// GcpProjectIDs The list of project identifiers that are allowed to use a GCP cloud provisioner. -type GcpProjectIDs = []string - -// GcpProvisioner The [GCP provisioner](https://smallstep.com/docs/step-ca/provisioners/#gcp) grants a certificate to a Google Compute Engine instance using its identity token. At least one service account or project ID must be set. -type GcpProvisioner struct { - // DisableCustomSANs By default custom SANs are valid, but if this option is set to `true` only the SANs available in the instance identity document will be valid, these are the DNS `<instance-name>.c.<project-id>.internal` and `<instance-name>.<zone>.c.<project-id>.internal`. - DisableCustomSANs *GcpDisableCustomSANs `json:"disableCustomSANs,omitempty"` - - // DisableTrustOnFirstUse By default only one certificate will be granted per instance, but if the option is set to `true` this limit is not set and different tokens can be used to get different certificates. - DisableTrustOnFirstUse *bool `json:"disableTrustOnFirstUse,omitempty"` - - // InstanceAge The maximum age of an instance that should be allowed to obtain a certificate. Limits certificate issuance to new instances to mitigate the risk of credential-misuse from instances that don't need a certificate. Parsed as a [Golang duration](https://pkg.go.dev/time#ParseDuration). - InstanceAge *InstanceAge `json:"instanceAge,omitempty"` - - // ProjectIDs The list of project identifiers that are allowed to use a GCP cloud provisioner. - ProjectIDs *GcpProjectIDs `json:"projectIDs,omitempty"` - - // ServiceAccounts The list of service accounts that are allowed to use a GCP cloud provisioner. - ServiceAccounts *GcpServiceAccounts `json:"serviceAccounts,omitempty"` -} - -// GcpServiceAccounts The list of service accounts that are allowed to use a GCP cloud provisioner. -type GcpServiceAccounts = []string - -// GcpVM Configuration for the GCP provisioner for device collections of GCP instances. At least one service account or project ID must be set. -type GcpVM struct { - // DisableCustomSANs By default custom SANs are valid, but if this option is set to `true` only the SANs available in the instance identity document will be valid, these are the DNS `<instance-name>.c.<project-id>.internal` and `<instance-name>.<zone>.c.<project-id>.internal`. - DisableCustomSANs *GcpDisableCustomSANs `json:"disableCustomSANs,omitempty"` - - // ProjectIDs The list of project identifiers that are allowed to use a GCP cloud provisioner. - ProjectIDs *GcpProjectIDs `json:"projectIDs,omitempty"` - - // ServiceAccounts The list of service accounts that are allowed to use a GCP cloud provisioner. - ServiceAccounts *GcpServiceAccounts `json:"serviceAccounts,omitempty"` -} - -// Grant A grant gives permission to all users in a group to access a host with a matching tag. -type Grant struct { - // GroupID A UUID identifying the group this grant is attached to. - GroupID *string `json:"groupID,omitempty"` - - // Id A UUID identifying this grant. - Id *string `json:"id,omitempty"` - - // Name Matched against host tag names. - Name *string `json:"name,omitempty"` - - // Sudo Whether users in the group will have sudo permission on matching hosts. - Sudo *bool `json:"sudo,omitempty"` - - // Value Matched against host tag values. - Value *string `json:"value,omitempty"` -} - -// Group A group is a set of users that have been synced from an identity provider. -type Group struct { - HostGrants *[]Grant `json:"hostGrants,omitempty"` - - // Id A UUID identifying the group. - Id *string `json:"id,omitempty"` - - // Name The name of the group. - Name *string `json:"name,omitempty"` - PosixGroups *[]PosixGroup `json:"posixGroups,omitempty"` - - // Principals Additional principals that will be appended to users' certilficates, in addition to the user's email and POSIX username. - Principals *[]string `json:"principals,omitempty"` -} - -// Host A host where Smallstep has been installed to manage SSH access. -type Host struct { - // Active A host is active until it is unregistered. - Active *bool `json:"active,omitempty"` - - // Bastion Whether or not this host is a bastion. - Bastion *bool `json:"bastion,omitempty"` - - // BastionHostname The hostname of the bastion server required to access this host, if any. - BastionHostname *string `json:"bastionHostname,omitempty"` - - // CreatedAt Timestamp in RFC3339 format when the host was registered. - CreatedAt *time.Time `json:"createdAt,omitempty"` - - // Hostname The hostname detected during installation. - Hostname *string `json:"hostname,omitempty"` - - // Id A UUID identifying this host. - Id *string `json:"id,omitempty"` - Tags *[]Tag `json:"tags,omitempty"` - - // UpdatedAt Timestamp in RFC3339 format when the host was last updated. - UpdatedAt *time.Time `json:"updatedAt,omitempty"` -} - -// IkeV2Config defines model for ikeV2Config. -type IkeV2Config struct { - CaChain *string `json:"caChain,omitempty"` - Eap *bool `json:"eap,omitempty"` - - // RemoteID Typically, the common name of the remote server. Defaults to the remote address. - RemoteID *string `json:"remoteID,omitempty"` -} - -// InstanceAge The maximum age of an instance that should be allowed to obtain a certificate. Limits certificate issuance to new instances to mitigate the risk of credential-misuse from instances that don't need a certificate. Parsed as a [Golang duration](https://pkg.go.dev/time#ParseDuration). -type InstanceAge = string - -// JwkProvisioner A [provisioner](https://smallstep.com/docs/step-ca/provisioners/#jwk) that uses public-key cryptography to sign and validate a JSON Web Token (JWT). -type JwkProvisioner struct { - // EncryptedKey The JWE encrypted private key. - EncryptedKey *string `json:"encryptedKey,omitempty"` - - // Key The public JSON web key. - Key interface{} `json:"key"` -} - -// NameConstraints X509 certificate name constraints. -type NameConstraints struct { - // Critical Whether or not name constraints are marked critical. - Critical *bool `json:"critical,omitempty"` - ExcludedDNSDomains *[]string `json:"excludedDNSDomains,omitempty"` - ExcludedEmailAddresses *[]string `json:"excludedEmailAddresses,omitempty"` - ExcludedIPRanges *[]string `json:"excludedIPRanges,omitempty"` - ExcludedURIDomains *[]string `json:"excludedURIDomains,omitempty"` - PermittedDNSDomains *[]string `json:"permittedDNSDomains,omitempty"` - PermittedEmailAddresses *[]string `json:"permittedEmailAddresses,omitempty"` - PermittedIPRanges *[]string `json:"permittedIPRanges,omitempty"` - PermittedURIDomains *[]string `json:"permittedURIDomains,omitempty"` -} - -// NewAuthority The body of a request to create a new authority. -type NewAuthority struct { - // ActiveRevocation Whether to enable CRL and OCSP on an advanced authority. - ActiveRevocation *bool `json:"activeRevocation,omitempty"` - - // AdminEmails Users that will have admin access to manage the authority. - AdminEmails []string `json:"adminEmails"` - - // IntermediateIssuer A Customized X509 issuer for an authority. - IntermediateIssuer *X509Issuer `json:"intermediateIssuer,omitempty"` - - // Name The name of the authority. - Name string `json:"name"` - - // RootIssuer A Customized X509 issuer for an authority. - RootIssuer *X509Issuer `json:"rootIssuer,omitempty"` - - // Subdomain The new authority will be available at <subdomain>.<team slug>.ca.smallstep.com. - Subdomain string `json:"subdomain"` - - // Type Create either a devops or advanced authority. - Type NewAuthorityType `json:"type"` -} - -// NewAuthorityType Create either a devops or advanced authority. -type NewAuthorityType string - -// NewAuthorityCsr Body of a request to create a new X509 advanced authority with an external root. -type NewAuthorityCsr struct { - // ActiveRevocation Whether to enable CRL and OCSP on the authority. - ActiveRevocation *bool `json:"activeRevocation,omitempty"` - - // IntermediateIssuer A Customized X509 issuer for an authority. - IntermediateIssuer X509Issuer `json:"intermediateIssuer"` - - // Name The name of the authority. - Name string `json:"name"` - - // Subdomain The new authority will be available at <subdomain>.<team slug>.ca.smallstep.com. - Subdomain string `json:"subdomain"` -} - -// NewCollection Body of a request to create a new collection. -type NewCollection struct { - // DisplayName A user-friendly name for the collection. - DisplayName *string `json:"displayName,omitempty"` - - // SchemaURI Reference to a schema that all instances in the collection must conform to. - SchemaURI *string `json:"schemaURI,omitempty"` - - // Slug A lowercase name identifying the collection. - Slug string `json:"slug"` -} - -// NewEnrollmentToken The body of a request to generate a new device enrollment token. -type NewEnrollmentToken struct { - // Title The name of the device enrollment token - Title *string `json:"title,omitempty"` -} - -// NewGrant The body of a request to add a grant to a group. -type NewGrant struct { - // GroupID A UUID identifying the group this grant is attached to. - GroupID string `json:"groupID"` - - // Name Matched against host tag names - Name string `json:"name"` - - // Sudo Whether users in the group will have sudo permission on matching hosts - Sudo *bool `json:"sudo,omitempty"` - - // Value Matched against host tag values - Value *string `json:"value,omitempty"` -} - -// NewPlatform Configuration to create a new platform. -type NewPlatform struct { - DisplayName string `json:"displayName"` - PlatformConfiguration NewPlatform_PlatformConfiguration `json:"platformConfiguration"` - - // PlatformType Determines which set of fields to use in platformConfiguration. Cannot be changed. - PlatformType NewPlatformPlatformType `json:"platformType"` - Slug string `json:"slug"` -} - -// NewPlatform_PlatformConfiguration defines model for NewPlatform.PlatformConfiguration. -type NewPlatform_PlatformConfiguration struct { - union json.RawMessage -} - -// NewPlatformPlatformType Determines which set of fields to use in platformConfiguration. Cannot be changed. -type NewPlatformPlatformType string - -// NewTag The body of a request to add a tag to a host. -type NewTag struct { - // Name The key for the host tag. - Name *string `json:"name,omitempty"` - - // Value The value for the host tag. - Value *string `json:"value,omitempty"` -} - -// OidcProvisioner A [provisioner](https://smallstep.com/docs/step-ca/provisioners/#oauthoidc-single-sign-on) that is configured to trust and accept an OAuth provider's ID tokens for authentication. By default, the issued certificate will use the subject (sub) claim from the identity token as its subject. The value of the token's email claim is also included as an email SAN in the certificate. -type OidcProvisioner struct { - // Admins The emails of admin users in an OpenID Connect provisioner. These users will not have restrictions in the certificates to sign. - Admins *[]string `json:"admins,omitempty"` - - // ClientID The id used to validate the audience in an OpenID Connect token. - ClientID string `json:"clientID"` - - // ClientSecret The secret used to obtain the OpenID Connect tokens. - ClientSecret string `json:"clientSecret"` - - // ConfigurationEndpoint OpenID Connect configuration URL. - ConfigurationEndpoint string `json:"configurationEndpoint"` - - // Domains The domains used to validate the email claim in an OpenID Connect provisioner. - Domains *[]string `json:"domains,omitempty"` - - // Groups The group list used to validate the groups extension in an OpenID Connect token. - Groups *[]string `json:"groups,omitempty"` - - // ListenAddress The callback address used in the OpenID Connect flow. - ListenAddress *string `json:"listenAddress,omitempty"` - - // TenantID The tenant-id used to replace the templatized tenantid value in the OpenID Configuration. - TenantID *string `json:"tenantID,omitempty"` -} - -// Platform A platform with a list of configurations. -type Platform struct { - DisplayName string `json:"displayName"` - PlatformConfigurations []Platform_PlatformConfigurations_Item `json:"platformConfigurations"` - - // PlatformType The type used in platformConfiguration. - PlatformType PlatformPlatformType `json:"platformType"` - Slug string `json:"slug"` -} - -// Platform_PlatformConfigurations_Item defines model for platform.platformConfigurations.Item. -type Platform_PlatformConfigurations_Item struct { - union json.RawMessage -} - -// PlatformPlatformType The type used in platformConfiguration. -type PlatformPlatformType string - -// PosixGroup A POSIX group represents a group that exists on a host with the given group name and gid. -// A managed group will be created or deleted on the host by Smallstep. -// Unmanaged groups must already exist on the host. -// -// An SSH Group may have multiple POSIX groups. -// An SSH User belonging to the group will be a member of the POSIX group when they access the host. -type PosixGroup struct { - // Gid The numeric group ID. - Gid *int `json:"gid,omitempty"` - - // Id A UUID identifying the POSIX group. - Id *string `json:"id,omitempty"` - - // Managed Whether Smallstep should create and delete the group. - Managed *bool `json:"managed,omitempty"` - - // Name The name of the group. - Name *string `json:"name,omitempty"` -} - -// PosixUser A POSIX user is the login user on the SSH Host. It will be generated automatically if not supplied by the team's Identity Provider. -type PosixUser struct { - // Gid The numeric group ID of the user. - Gid *int `json:"gid,omitempty"` - - // HomeDir The user's home directory. - HomeDir *string `json:"homeDir,omitempty"` - - // Shell The user's shell. - Shell *string `json:"shell,omitempty"` - - // Uid The numeric ID of the user. - Uid *int `json:"uid,omitempty"` - - // Username The login name of the user. - Username *string `json:"username,omitempty"` -} - -// Provisioner defines model for provisioner. -type Provisioner struct { - // Claims A set of constraints configuring how this provisioner can be used to issue certificates. - Claims *ProvisionerClaims `json:"claims,omitempty"` - - // CreatedAt Timestamp of when the provisioner was created in RFC 3339 format. Generated server-side. - CreatedAt *time.Time `json:"createdAt,omitempty"` - - // Id A UUID identifying this provisioner. Generated server-side when the provisioner is created. - Id *string `json:"id,omitempty"` - - // Name The name of the provisioner. - Name string `json:"name"` - - // Options Options that apply when issuing certificates with this provisioner. - Options *ProvisionerOptions `json:"options,omitempty"` - - // Type The type of provisioner. - Type ProvisionerType `json:"type"` - union json.RawMessage -} - -// ProvisionerType The type of provisioner. -type ProvisionerType string - -// ProvisionerClaims A set of constraints configuring how this provisioner can be used to issue certificates. -type ProvisionerClaims struct { - // AllowRenewalAfterExpiry Allow renewals for expired certificates generated by this provisioner. - AllowRenewalAfterExpiry *bool `json:"allowRenewalAfterExpiry,omitempty"` - - // DefaultHostSSHCertDuration The default duration for an SSH host certificate generated by this provisioner. Parsed as a [Golang duration](https://pkg.go.dev/time#ParseDuration). - DefaultHostSSHCertDuration *string `json:"defaultHostSSHCertDuration,omitempty"` - - // DefaultTLSCertDuration The default duration for an x509 certificate generated by this provisioner. Parsed as a [Golang duration](https://pkg.go.dev/time#ParseDuration). - DefaultTLSCertDuration *string `json:"defaultTLSCertDuration,omitempty"` - - // DefaultUserSSHCertDuration The default duration for an SSH user certificate generated by this provisioner. Parsed as a [Golang duration](https://pkg.go.dev/time#ParseDuration). - DefaultUserSSHCertDuration *string `json:"defaultUserSSHCertDuration,omitempty"` - - // DisableRenewal Disable renewal for all certificates generated by this provisioner. - DisableRenewal *bool `json:"disableRenewal,omitempty"` - - // EnableSSHCA Allow this provisioner to be used to generate SSH certificates. - EnableSSHCA *bool `json:"enableSSHCA,omitempty"` - - // MaxHostSSHCertDuration The maximum duration for an SSH host certificate generated by this provisioner. Parsed as a [Golang duration](https://pkg.go.dev/time#ParseDuration). - MaxHostSSHCertDuration *string `json:"maxHostSSHCertDuration,omitempty"` - - // MaxTLSCertDuration The maximum duration for an x509 certificate generated by this provisioner. Parsed as a [Golang duration](https://pkg.go.dev/time#ParseDuration). - MaxTLSCertDuration *string `json:"maxTLSCertDuration,omitempty"` - - // MaxUserSSHCertDuration The maximum duration for an SSH user certificate generated by this provisioner. Parsed as a [Golang duration](https://pkg.go.dev/time#ParseDuration). - MaxUserSSHCertDuration *string `json:"maxUserSSHCertDuration,omitempty"` - - // MinHostSSHCertDuration The minimum duration for an SSH host certificate generated by this provisioner. Parsed as a [Golang duration](https://pkg.go.dev/time#ParseDuration). - MinHostSSHCertDuration *string `json:"minHostSSHCertDuration,omitempty"` - - // MinTLSCertDuration The minimum duration for an x509 certificate generated by this provisioner. Parsed as a [Golang duration](https://pkg.go.dev/time#ParseDuration). - MinTLSCertDuration *string `json:"minTLSCertDuration,omitempty"` - - // MinUserSSHCertDuration The minimum duration for an SSH user certificate generated by this provisioner. Parsed as a [Golang duration](https://pkg.go.dev/time#ParseDuration). - MinUserSSHCertDuration *string `json:"minUserSSHCertDuration,omitempty"` -} - -// ProvisionerOptions Options that apply when issuing certificates with this provisioner. -type ProvisionerOptions struct { - // Ssh Options that apply when issuing SSH certificates - Ssh *SshOptions `json:"ssh,omitempty"` - Webhooks *[]ProvisionerWebhook `json:"webhooks,omitempty"` - - // X509 Options that apply when issuing x509 certificates. - X509 *X509Options `json:"x509,omitempty"` -} - -// ProvisionerWebhook A [webhook](https://smallstep.com/docs/step-ca/webhooks/) to call when a certificate request is being processed. -type ProvisionerWebhook struct { - // BasicAuth Configures provisioner webhook requests to include an Authorization header with these credentials. Optional for `EXTERNAL` webhook servers; not allowed with hosted webhook servers. At most one of `bearerToken` and `basicAuth` may be set. - BasicAuth *BasicAuth `json:"basicAuth,omitempty"` - - // BearerToken Webhook requests will include an Authorization header with the token. Optional for `EXTERNAL` webhook servers; not allowed with hosted webhook servers. At most one of `bearerToken` and `basicAuth` may be set. - BearerToken *string `json:"bearerToken,omitempty"` - CertType ProvisionerWebhookCertType `json:"certType"` - - // CollectionSlug For HOSTED_ATTESTATION webhooks, the collectionSlug is a reference to the collection that holds the devices that may be issued certificates. This collection must already exist. Required for `HOSTED_ATTESTATION` webhook servers; not allowed for `EXTERNAL`. - CollectionSlug *string `json:"collectionSlug,omitempty"` - - // DisableTLSClientAuth The CA will not send a client certificate when requested by the webhook server. Optional for `EXTERNAL` webhook servers; not allowed with hosted webhook servers. - DisableTLSClientAuth *bool `json:"disableTLSClientAuth,omitempty"` - - // Id UUID identifying this webhook. Generated server-side when the webhook is created. Will be sent to the webhook server in every request in the `X-Smallstep-Webhook-ID` header. - Id *string `json:"id,omitempty"` - - // Kind The webhook kind indicates how and when it is called. - // - // ENRICHING webhooks are called before rendering the certificate template. They have two functions. First, they must allow the certificate request or it will be aborted. Second, they can return additional data to be referenced in the certificate template. The payload sent to the webhook server varies based on whether an X509 or SSH certificate is to be signed and based on the type of provisioner. - Kind ProvisionerWebhookKind `json:"kind"` - - // Name The name of the webhook. For `ENRICHING` webhooks, the returned data can be referenced in the certificate under the path `.Webhooks.<name>`. Must be unique to the provisioner. - Name string `json:"name"` - - // Secret The shared secret used to authenticate the payload sent to the webhook server. Generated server-side. This is returned only for `EXTERNAL` webhook servers and only once, at the time of creation. - Secret *string `json:"secret,omitempty"` - - // ServerType An EXTERNAL webhook server is not operated by Smallstep. The caller must use the returned ID and secret to configure the server. - // - // A HOSTED_ATTESTATION webhook server is hosted by Smallstep and must be used with an `ENRICHING` webhook type and an ACME Attestation provisioner. The webhook server will verify the attested permanent identifier exists as the ID of an instance in the configured collection. The data of the instance in the collection will be added to the template data. - ServerType ProvisionerWebhookServerType `json:"serverType"` - - // Url The URL of the webhook server. Required for `EXTERNAL` webhook servers; read-only for hosted webhook servers. - Url *string `json:"url,omitempty"` -} - -// ProvisionerWebhookCertType defines model for ProvisionerWebhook.CertType. -type ProvisionerWebhookCertType string - -// ProvisionerWebhookKind The webhook kind indicates how and when it is called. -// -// ENRICHING webhooks are called before rendering the certificate template. They have two functions. First, they must allow the certificate request or it will be aborted. Second, they can return additional data to be referenced in the certificate template. The payload sent to the webhook server varies based on whether an X509 or SSH certificate is to be signed and based on the type of provisioner. -type ProvisionerWebhookKind string - -// ProvisionerWebhookServerType An EXTERNAL webhook server is not operated by Smallstep. The caller must use the returned ID and secret to configure the server. -// -// A HOSTED_ATTESTATION webhook server is hosted by Smallstep and must be used with an `ENRICHING` webhook type and an ACME Attestation provisioner. The webhook server will verify the attested permanent identifier exists as the ID of an instance in the configured collection. The data of the instance in the collection will be added to the template data. -type ProvisionerWebhookServerType string - -// ScepProvisioner The [SCEP provisioner](https://smallstep.com/docs/step-ca/provisioners/#scep) grants certificates to clients using the SCEP protocol. This type is currently experimental and subject to change. -type ScepProvisioner struct { - // AutogenerateDecrypter Automatically generate a new RSA decrypter instead of providing one. - AutogenerateDecrypter *bool `json:"autogenerateDecrypter,omitempty"` - - // Challenge A static challenge secret. - Challenge *string `json:"challenge,omitempty"` - - // DecrypterCertificate A pem-encoded certificate for an RSA public key. - DecrypterCertificate *string `json:"decrypterCertificate,omitempty"` - - // DecrypterKey The pem-encoded RSA private key, corresponding to the certificate public key. - DecrypterKey *string `json:"decrypterKey,omitempty"` - - // DecrypterKeyPassword The password for the pem-encoded RSA private key, if any. - DecrypterKeyPassword *string `json:"decrypterKeyPassword,omitempty"` - - // EncryptionAlgorithmIdentifier The encryption algorithm used for encrypting responses to the SCEP client: - // * `DES_CBC` - [DES in CBC mode](https://www.rfc-editor.org/rfc/rfc8018.html#appendix-B.2.1) - `1.3.14.3.2.7` - // * `AES_128_CBC` - [AES-128 in CBC mode](https://www.rfc-editor.org/rfc/rfc8018.html#appendix-B.2.5) - `2.16.840.1.101.3.4.1.2` - // * `AES_128_GCM` - [AES-128 in GCM mode](https://www.rfc-editor.org/rfc/rfc5084.html#section-3.2) - `2.16.840.1.101.3.4.1.6` - // * `AES_256_CBC` - [AES-256 in CBC mode](https://www.rfc-editor.org/rfc/rfc3565.html#section-4.1) - `2.16.840.1.101.3.4.1.42` - // * `AES_256_GCM` - [AES-256 in GCM mode](https://www.rfc-editor.org/rfc/rfc5084.html#section-3.2) - `2.16.840.1.101.3.4.1.46` - EncryptionAlgorithmIdentifier *ScepProvisionerEncryptionAlgorithmIdentifier `json:"encryptionAlgorithmIdentifier,omitempty"` - - // ExcludeIntermediate Exclude the intermediate CA certificate in SCEP responses. - ExcludeIntermediate *bool `json:"excludeIntermediate,omitempty"` - - // ForceCN Force one of the SANs to become the Common Name, if a Common Name is not provided. - ForceCN *bool `json:"forceCN,omitempty"` - - // IncludeRoot Include the root CA certificate in SCEP responses. - IncludeRoot *bool `json:"includeRoot,omitempty"` - - // MinimumPublicKeyLength The minimum number of bits for RSA public keys accepted in SCEP requests. - MinimumPublicKeyLength *int `json:"minimumPublicKeyLength,omitempty"` -} - -// ScepProvisionerEncryptionAlgorithmIdentifier The encryption algorithm used for encrypting responses to the SCEP client: -// - `DES_CBC` - [DES in CBC mode](https://www.rfc-editor.org/rfc/rfc8018.html#appendix-B.2.1) - `1.3.14.3.2.7` -// - `AES_128_CBC` - [AES-128 in CBC mode](https://www.rfc-editor.org/rfc/rfc8018.html#appendix-B.2.5) - `2.16.840.1.101.3.4.1.2` -// - `AES_128_GCM` - [AES-128 in GCM mode](https://www.rfc-editor.org/rfc/rfc5084.html#section-3.2) - `2.16.840.1.101.3.4.1.6` -// - `AES_256_CBC` - [AES-256 in CBC mode](https://www.rfc-editor.org/rfc/rfc3565.html#section-4.1) - `2.16.840.1.101.3.4.1.42` -// - `AES_256_GCM` - [AES-256 in GCM mode](https://www.rfc-editor.org/rfc/rfc5084.html#section-3.2) - `2.16.840.1.101.3.4.1.46` -type ScepProvisionerEncryptionAlgorithmIdentifier string - -// SshOptions Options that apply when issuing SSH certificates -type SshOptions struct { - // Template A JSON representation of the SSH certificate to be created. [More info](https://smallstep.com/docs/step-ca/templates/#ssh-templates). - Template *string `json:"template,omitempty"` - - // TemplateData A map of data that can be used by the certificate template. - TemplateData *interface{} `json:"templateData,omitempty"` -} - -// Subject Name used in x509 certificates -type Subject struct { - CommonName *string `json:"commonName,omitempty"` - Country *[]string `json:"country,omitempty"` - EmailAddress *[]string `json:"emailAddress,omitempty"` - ExtraNames *[]ExtraName `json:"extraNames,omitempty"` - Locality *[]string `json:"locality,omitempty"` - Organization *[]string `json:"organization,omitempty"` - OrganizationalUnit *[]string `json:"organizationalUnit,omitempty"` - PostalCode *[]string `json:"postalCode,omitempty"` - Province *[]string `json:"province,omitempty"` - SerialNumber *string `json:"serialNumber,omitempty"` - StreetAddress *[]string `json:"streetAddress,omitempty"` -} - -// Tag A key-value pair attached to a host. -// Smallstep determines access by comparing host tags to group grants when a user attempts to SSH to a host. -type Tag struct { - // Id A UUID identifying this host tag. - Id *string `json:"id,omitempty"` - - // Name The key for the host tag. - Name *string `json:"name,omitempty"` - - // Value The value for the host tag. - Value *string `json:"value,omitempty"` -} - -// Tpm Configuration for a device collection of machines with TPMs. -type Tpm struct { - // AttestorIntermediates The pem-encoded list of intermediate certificates used to build a chain of trust to verify the attestation certificates submitted by agents. Ignored if the team already has an attestation authority. - AttestorIntermediates *string `json:"attestorIntermediates,omitempty"` - - // AttestorRoots The pem-encoded list of certificates used to verify the attestation certificates submitted by agents. Ignored if the team already has an attestation authority. Required if the team does not already have an attestation authority. - AttestorRoots *string `json:"attestorRoots,omitempty"` - - // ForceCN Force one of the SANs to become the Common Name, if a Common Name is not provided. - ForceCN *bool `json:"forceCN,omitempty"` - - // RequireEAB Only ACME clients that have been preconfigured with valid EAB credentials will be able to create an account with this provisioner. - RequireEAB *bool `json:"requireEAB,omitempty"` -} - -// User SSH Users are synced from the team's Identity Provider, or from the default Smallstep directory if no external Identity Provider has been configured. -type User struct { - // Active Whether the user has been deactivated in the team's Identity Provider. - Active *bool `json:"active,omitempty"` - - // DisplayName The user's display name. - DisplayName *string `json:"displayName,omitempty"` - Emails *[]Email `json:"emails,omitempty"` - - // FamilyName The user's family name. - FamilyName *string `json:"familyName,omitempty"` - - // GivenName The user's given name. - GivenName *string `json:"givenName,omitempty"` - Groups *[]Group `json:"groups,omitempty"` - - // Id A UUID identifying the user. - Id *string `json:"id,omitempty"` - PosixUsers *[]PosixUser `json:"posixUsers,omitempty"` -} - -// VpnAccount Configuration to connect a device to a VPN. -type VpnAccount struct { - Autojoin *bool `json:"autojoin,omitempty"` - ConnectionType VpnAccountConnectionType `json:"connectionType"` - Ike *IkeV2Config `json:"ike,omitempty"` - RemoteAddress string `json:"remoteAddress"` - Vendor *VpnAccountVendor `json:"vendor,omitempty"` -} - -// VpnAccountConnectionType defines model for VpnAccount.ConnectionType. -type VpnAccountConnectionType string - -// VpnAccountVendor defines model for VpnAccount.Vendor. -type VpnAccountVendor string - -// WifiAccount Configuration to connect a device to a protected WiFi network. -type WifiAccount struct { - Autojoin *bool `json:"autojoin,omitempty"` - CaChain *string `json:"caChain,omitempty"` - ExternalRadiusServer *bool `json:"externalRadiusServer,omitempty"` - Hidden *bool `json:"hidden,omitempty"` - NetworkAccessServerIP *string `json:"networkAccessServerIP,omitempty"` - Ssid string `json:"ssid"` -} - -// Workload defines model for workload. -type Workload struct { - // AuthorityID A UUID identifying the authority to issue certificates for the workload. - AuthorityID string `json:"authorityID"` - - // CertificateInfo Details on a managed certificate. - CertificateInfo *EndpointCertificateInfo `json:"certificateInfo,omitempty"` - - // DisplayName A friendly name for the workload. Also used as the Common Name, if no static SANs are provided. - DisplayName string `json:"displayName"` - - // Hooks The collection of commands to run when a certificate for a managed endpoint is signed or renewed. - Hooks *EndpointHooks `json:"hooks,omitempty"` - - // KeyInfo The attributes of the cryptographic key. - KeyInfo *EndpointKeyInfo `json:"keyInfo,omitempty"` - - // ReloadInfo The properties used to reload a service. - ReloadInfo *EndpointReloadInfo `json:"reloadInfo,omitempty"` - - // Slug Used as the identifier for the workload. - Slug string `json:"slug"` - - // WorkloadType The type of workload being deployed. - // Possible values are `etcd` `generic` `git` `grafana` `haproxy` `httpd` `kafka` `mysql` `nginx` `nodejs` `postgres` `redis` `tomcat` and `zookeeper`. - // Use `generic` for a basic certificate workload. - WorkloadType *string `json:"workloadType,omitempty"` - union json.RawMessage -} - -// X509Certificate defines model for x509Certificate. -type X509Certificate struct { - AuthorityKeyId string `json:"authorityKeyId"` - BasicConstraints BasicConstraints `json:"basicConstraints"` - CrlDistributionPoints *[]string `json:"crlDistributionPoints,omitempty"` - DnsNames *[]string `json:"dnsNames,omitempty"` - EmailAddresses *[]string `json:"emailAddresses,omitempty"` - ExtKeyUsage *[]string `json:"extKeyUsage,omitempty"` - IpAddresses *[]string `json:"ipAddresses,omitempty"` - - // Issuer Name used in x509 certificates - Issuer Subject `json:"issuer"` - IssuingCertificateURL *[]string `json:"issuingCertificateURL,omitempty"` - KeyUsage []string `json:"keyUsage"` - - // NameConstraints X509 certificate name constraints. - NameConstraints *NameConstraints `json:"nameConstraints,omitempty"` - OcspServer *[]string `json:"ocspServer,omitempty"` - Pem string `json:"pem"` - PolicyIdentifiers *[]string `json:"policyIdentifiers,omitempty"` - RevocationReason *X509CertificateRevocationReason `json:"revocationReason,omitempty"` - Revoked *bool `json:"revoked,omitempty"` - SerialNumber string `json:"serialNumber"` - SignatureAlgorithm string `json:"signatureAlgorithm"` - - // Subject Name used in x509 certificates - Subject Subject `json:"subject"` - SubjectKeyId string `json:"subjectKeyId"` - Uris *[]string `json:"uris,omitempty"` - Version int `json:"version"` -} - -// X509CertificateRevocationReason defines model for X509Certificate.RevocationReason. -type X509CertificateRevocationReason string - -// X509Fields defines model for x509Fields. -type X509Fields struct { - // CommonName A certificate field that takes a single string value, e.g. Common Name. - CommonName *CertificateField `json:"commonName,omitempty"` - - // Country A certificate field that accepts multiple string values, e.g. SANs. - Country *CertificateFieldList `json:"country,omitempty"` - - // Locality A certificate field that accepts multiple string values, e.g. SANs. - Locality *CertificateFieldList `json:"locality,omitempty"` - - // Organization A certificate field that accepts multiple string values, e.g. SANs. - Organization *CertificateFieldList `json:"organization,omitempty"` - - // OrganizationalUnit A certificate field that accepts multiple string values, e.g. SANs. - OrganizationalUnit *CertificateFieldList `json:"organizationalUnit,omitempty"` - - // PostalCode A certificate field that accepts multiple string values, e.g. SANs. - PostalCode *CertificateFieldList `json:"postalCode,omitempty"` - - // Province A certificate field that accepts multiple string values, e.g. SANs. - Province *CertificateFieldList `json:"province,omitempty"` - - // Sans A certificate field that accepts multiple string values, e.g. SANs. - Sans *CertificateFieldList `json:"sans,omitempty"` - - // StreetAddress A certificate field that accepts multiple string values, e.g. SANs. - StreetAddress *CertificateFieldList `json:"streetAddress,omitempty"` -} - -// X509Issuer A Customized X509 issuer for an authority. -type X509Issuer struct { - // Duration The certificate lifetime. Parsed as a [Golang duration](https://pkg.go.dev/time#ParseDuration). - Duration *string `json:"duration,omitempty"` - - // KeyVersion The signature algorithm. - KeyVersion X509IssuerKeyVersion `json:"keyVersion"` - MaxPathLength *int `json:"maxPathLength,omitempty"` - - // Name The name of the issuer. - Name string `json:"name"` - - // NameConstraints X509 certificate name constraints. - NameConstraints *NameConstraints `json:"nameConstraints,omitempty"` - - // Subject Name used in x509 certificates - Subject *DistinguishedName `json:"subject,omitempty"` -} - -// X509IssuerKeyVersion The signature algorithm. -type X509IssuerKeyVersion string - -// X509Options Options that apply when issuing x509 certificates. -type X509Options struct { - // Template A JSON representation of the x509 certificate to be created. [More info](https://smallstep.com/docs/step-ca/templates/#x509-templates). - Template *string `json:"template,omitempty"` - - // TemplateData A map of data that can be used by the certificate template. - TemplateData *interface{} `json:"templateData,omitempty"` -} - -// X5cProvisioner A [provisioner](https://smallstep.com/docs/step-ca/provisioners/#x5c---x509-certificate) that authenticates a certificate request with an existing x509 certificate. -type X5cProvisioner struct { - // Roots A list of pem-encoded x509 certificates. Any certificate bundle that chains up to any of these roots can be used in a certificate request. - Roots []string `json:"roots"` -} - -// Accept defines model for accept. -type Accept = string - -// AccountID defines model for accountID. -type AccountID = string - -// AccountSlug defines model for accountSlug. -type AccountSlug = string - -// AttestationAuthorityID defines model for attestationAuthorityID. -type AttestationAuthorityID = string - -// AuthorityDomainOrID defines model for authorityDomainOrID. -type AuthorityDomainOrID = string - -// AuthorityID defines model for authorityID. -type AuthorityID = string - -// CollectionSlug defines model for collectionSlug. -type CollectionSlug = string - -// GrantID defines model for grantID. -type GrantID = string - -// GroupID defines model for groupID. -type GroupID = string - -// HostID defines model for hostID. -type HostID = string - -// InstanceID defines model for instanceID. -type InstanceID = string - -// Pagination defines model for pagination. -type Pagination struct { - // After Fetch a page of results other than the first page. - // Must be copied from a previously returned X-Next-Cursor header. - After *string `json:"after"` - - // First Limits the number of results returned. - // Defaults to 100. - First *int `json:"first"` -} - -// PlatformSlug defines model for platformSlug. -type PlatformSlug = string - -// ProvisionerNameOrID defines model for provisionerNameOrID. -type ProvisionerNameOrID = string - -// RequestID defines model for requestID. -type RequestID = string - -// SerialNumber defines model for serialNumber. -type SerialNumber = string - -// WebhookNameOrID defines model for webhookNameOrID. -type WebhookNameOrID = string - -// WorkloadSlug defines model for workloadSlug. -type WorkloadSlug = string - -// N400 defines model for 400. -type N400 = Error - -// N401 defines model for 401. -type N401 = Error - -// N403 defines model for 403. -type N403 = Error - -// N404 defines model for 404. -type N404 = Error - -// N409 defines model for 409. -type N409 = Error - -// N412 defines model for 412. -type N412 = Error - -// N422 defines model for 422. -type N422 = Error - -// N500 defines model for 500. -type N500 = Error - -// ListAccountsParams defines parameters for ListAccounts. -type ListAccountsParams struct { - // Pagination Paginate over a list of objects. Example: `?pagination[first]=30&pagination[after]=MTIzNA==`, which after encoding would be `?pagination%5Bfirst%5D=30&pagination%5Bafter%5D=MTIzNA==` - Pagination *Pagination `json:"pagination,omitempty"` - - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// PostAccountsParams defines parameters for PostAccounts. -type PostAccountsParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// DeleteAccountParams defines parameters for DeleteAccount. -type DeleteAccountParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// GetAccountParams defines parameters for GetAccount. -type GetAccountParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// PutAccountParams defines parameters for PutAccount. -type PutAccountParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// GetAttestationAuthoritiesParams defines parameters for GetAttestationAuthorities. -type GetAttestationAuthoritiesParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// PostAttestationAuthoritiesParams defines parameters for PostAttestationAuthorities. -type PostAttestationAuthoritiesParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// DeleteAttestationAuthorityParams defines parameters for DeleteAttestationAuthority. -type DeleteAttestationAuthorityParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// GetAttestationAuthorityParams defines parameters for GetAttestationAuthority. -type GetAttestationAuthorityParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// PostAuthJSONBody defines parameters for PostAuth. -type PostAuthJSONBody struct { - Audience *PostAuthJSONBodyAudience `json:"audience,omitempty"` - Bundle *[]openapi_types.File `json:"bundle,omitempty"` - TeamID *string `json:"teamID,omitempty"` - TeamSlug *string `json:"teamSlug,omitempty"` -} - -// PostAuthJSONBodyAudience defines parameters for PostAuth. -type PostAuthJSONBodyAudience string - -// GetAuthoritiesParams defines parameters for GetAuthorities. -type GetAuthoritiesParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// PostAuthoritiesParams defines parameters for PostAuthorities. -type PostAuthoritiesParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// PostAuthoritiesCsrParams defines parameters for PostAuthoritiesCsr. -type PostAuthoritiesCsrParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// DeleteAuthorityParams defines parameters for DeleteAuthority. -type DeleteAuthorityParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// GetAuthorityParams defines parameters for GetAuthority. -type GetAuthorityParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// ListAuthorityProvisionersParams defines parameters for ListAuthorityProvisioners. -type ListAuthorityProvisionersParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// PostAuthorityProvisionersParams defines parameters for PostAuthorityProvisioners. -type PostAuthorityProvisionersParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// DeleteProvisionerParams defines parameters for DeleteProvisioner. -type DeleteProvisionerParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// GetProvisionerParams defines parameters for GetProvisioner. -type GetProvisionerParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// PostWebhooksParams defines parameters for PostWebhooks. -type PostWebhooksParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// DeleteWebhookParams defines parameters for DeleteWebhook. -type DeleteWebhookParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// GetWebhookParams defines parameters for GetWebhook. -type GetWebhookParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// PostAuthorityRootJSONBody defines parameters for PostAuthorityRoot. -type PostAuthorityRootJSONBody struct { - // AdminEmails Users that will have admin access to manage the authority - AdminEmails []string `json:"adminEmails"` - - // Id The `id` returned from a previous call to `/authorities/csr` - Id string `json:"id"` - - // IntermediatePEM The signed intermediate certificate - IntermediatePEM string `json:"intermediatePEM"` - - // RootName A name for the external root issuer - RootName string `json:"rootName"` - - // RootPEM The root certificate in pem format - RootPEM string `json:"rootPEM"` -} - -// PostAuthorityRootParams defines parameters for PostAuthorityRoot. -type PostAuthorityRootParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// ListCertificatesParams defines parameters for ListCertificates. -type ListCertificatesParams struct { - // Pagination Paginate over a list of objects. Example: `?pagination[first]=30&pagination[after]=MTIzNA==`, which after encoding would be `?pagination%5Bfirst%5D=30&pagination%5Bafter%5D=MTIzNA==` - Pagination *Pagination `json:"pagination,omitempty"` - - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// GetCertificateParams defines parameters for GetCertificate. -type GetCertificateParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// ListCollectionsParams defines parameters for ListCollections. -type ListCollectionsParams struct { - // Pagination Paginate over a list of objects. Example: `?pagination[first]=30&pagination[after]=MTIzNA==`, which after encoding would be `?pagination%5Bfirst%5D=30&pagination%5Bafter%5D=MTIzNA==` - Pagination *Pagination `json:"pagination,omitempty"` - - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// PostCollectionsParams defines parameters for PostCollections. -type PostCollectionsParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// DeleteCollectionParams defines parameters for DeleteCollection. -type DeleteCollectionParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// GetCollectionParams defines parameters for GetCollection. -type GetCollectionParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// PutCollectionParams defines parameters for PutCollection. -type PutCollectionParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// DeleteCollectionInstanceParams defines parameters for DeleteCollectionInstance. -type DeleteCollectionInstanceParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// GetCollectionInstanceParams defines parameters for GetCollectionInstance. -type GetCollectionInstanceParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// PutCollectionInstanceJSONBody defines parameters for PutCollectionInstance. -type PutCollectionInstanceJSONBody struct { - Data interface{} `json:"data"` -} - -// PutCollectionInstanceParams defines parameters for PutCollectionInstance. -type PutCollectionInstanceParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// GetCollectionInstanceDataParams defines parameters for GetCollectionInstanceData. -type GetCollectionInstanceDataParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// PutCollectionInstanceDataJSONBody defines parameters for PutCollectionInstanceData. -type PutCollectionInstanceDataJSONBody = interface{} - -// PutCollectionInstanceDataParams defines parameters for PutCollectionInstanceData. -type PutCollectionInstanceDataParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// ListCollectionInstancesParams defines parameters for ListCollectionInstances. -type ListCollectionInstancesParams struct { - // Pagination Paginate over a list of objects. Example: `?pagination[first]=30&pagination[after]=MTIzNA==`, which after encoding would be `?pagination%5Bfirst%5D=30&pagination%5Bafter%5D=MTIzNA==` - Pagination *Pagination `json:"pagination,omitempty"` - - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// DeleteDeviceCollectionParams defines parameters for DeleteDeviceCollection. -type DeleteDeviceCollectionParams struct { - // Purge Delete all workloads and devices in the collection. - // The API will return 422 if the device collection is not empty and the purge flag is not set. - Purge *bool `form:"purge,omitempty" json:"purge,omitempty"` - - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// GetDeviceCollectionParams defines parameters for GetDeviceCollection. -type GetDeviceCollectionParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// PutDeviceCollectionParams defines parameters for PutDeviceCollection. -type PutDeviceCollectionParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// DeleteDeviceCollectionAccountParams defines parameters for DeleteDeviceCollectionAccount. -type DeleteDeviceCollectionAccountParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// GetDeviceCollectionAccountParams defines parameters for GetDeviceCollectionAccount. -type GetDeviceCollectionAccountParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// PutDeviceCollectionAccountParams defines parameters for PutDeviceCollectionAccount. -type PutDeviceCollectionAccountParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// DeleteWorkloadParams defines parameters for DeleteWorkload. -type DeleteWorkloadParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// GetWorkloadParams defines parameters for GetWorkload. -type GetWorkloadParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// PutWorkloadParams defines parameters for PutWorkload. -type PutWorkloadParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// PostDeviceEnrollmentTokenParams defines parameters for PostDeviceEnrollmentToken. -type PostDeviceEnrollmentTokenParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// GetSshGrantsParams defines parameters for GetSshGrants. -type GetSshGrantsParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// PostSshGrantsParams defines parameters for PostSshGrants. -type PostSshGrantsParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// DeleteSshGrantParams defines parameters for DeleteSshGrant. -type DeleteSshGrantParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// GetSshGrantParams defines parameters for GetSshGrant. -type GetSshGrantParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// GetSshGroupsParams defines parameters for GetSshGroups. -type GetSshGroupsParams struct { - // Pagination Paginate over a list of objects. Example: `?pagination[first]=30&pagination[after]=MTIzNA==`, which after encoding would be `?pagination%5Bfirst%5D=30&pagination%5Bafter%5D=MTIzNA==` - Pagination *Pagination `json:"pagination,omitempty"` - - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// GetSshGroupParams defines parameters for GetSshGroup. -type GetSshGroupParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// GetSshHostsParams defines parameters for GetSshHosts. -type GetSshHostsParams struct { - // Pagination Paginate over a list of objects. Example: `?pagination[first]=30&pagination[after]=MTIzNA==`, which after encoding would be `?pagination%5Bfirst%5D=30&pagination%5Bafter%5D=MTIzNA==` - Pagination *Pagination `json:"pagination,omitempty"` - - // Active If unset or set to `true` the results will only include active hosts. If set to `false` the results will include both active and inactive hosts. - Active *bool `form:"active,omitempty" json:"active,omitempty"` - - // Bastion Filter (non-)bastion hosts. If unset the results will include both bastion and non-bastion hosts. If set to `true` the results will include only bastion hosts and if set to `false` the results will include only non-bastion hosts. - Bastion *bool `form:"bastion,omitempty" json:"bastion,omitempty"` - - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// GetSshHostParams defines parameters for GetSshHost. -type GetSshHostParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// PostHostsHostIDTagsParams defines parameters for PostHostsHostIDTags. -type PostHostsHostIDTagsParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// UnregisterSshHostParams defines parameters for UnregisterSshHost. -type UnregisterSshHostParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// GetPlatformsParams defines parameters for GetPlatforms. -type GetPlatformsParams struct { - // Pagination Paginate over a list of objects. Example: `?pagination[first]=30&pagination[after]=MTIzNA==`, which after encoding would be `?pagination%5Bfirst%5D=30&pagination%5Bafter%5D=MTIzNA==` - Pagination *Pagination `json:"pagination,omitempty"` - - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// PutPlatformParams defines parameters for PutPlatform. -type PutPlatformParams struct { - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// GetSshHostTagsParams defines parameters for GetSshHostTags. -type GetSshHostTagsParams struct { - // Pagination Paginate over a list of objects. Example: `?pagination[first]=30&pagination[after]=MTIzNA==`, which after encoding would be `?pagination%5Bfirst%5D=30&pagination%5Bafter%5D=MTIzNA==` - Pagination *Pagination `json:"pagination,omitempty"` - - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// GetSshUsersParams defines parameters for GetSshUsers. -type GetSshUsersParams struct { - // Pagination Paginate over a list of objects. Example: `?pagination[first]=30&pagination[after]=MTIzNA==`, which after encoding would be `?pagination%5Bfirst%5D=30&pagination%5Bafter%5D=MTIzNA==` - Pagination *Pagination `json:"pagination,omitempty"` - - // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. - XRequestId *RequestID `json:"X-Request-Id,omitempty"` - - // Accept The content type the client is willing to accept. Also includes API version. - Accept *Accept `json:"Accept,omitempty"` -} - -// PostAccountsJSONRequestBody defines body for PostAccounts for application/json ContentType. -type PostAccountsJSONRequestBody = Account - -// PutAccountJSONRequestBody defines body for PutAccount for application/json ContentType. -type PutAccountJSONRequestBody = Account - -// PostAttestationAuthoritiesJSONRequestBody defines body for PostAttestationAuthorities for application/json ContentType. -type PostAttestationAuthoritiesJSONRequestBody = AttestationAuthority - -// PostAuthJSONRequestBody defines body for PostAuth for application/json ContentType. -type PostAuthJSONRequestBody PostAuthJSONBody - -// PostAuthoritiesJSONRequestBody defines body for PostAuthorities for application/json ContentType. -type PostAuthoritiesJSONRequestBody = NewAuthority - -// PostAuthoritiesCsrJSONRequestBody defines body for PostAuthoritiesCsr for application/json ContentType. -type PostAuthoritiesCsrJSONRequestBody = NewAuthorityCsr - -// PostAuthorityProvisionersJSONRequestBody defines body for PostAuthorityProvisioners for application/json ContentType. -type PostAuthorityProvisionersJSONRequestBody = Provisioner - -// PostWebhooksJSONRequestBody defines body for PostWebhooks for application/json ContentType. -type PostWebhooksJSONRequestBody = ProvisionerWebhook - -// PostAuthorityRootJSONRequestBody defines body for PostAuthorityRoot for application/json ContentType. -type PostAuthorityRootJSONRequestBody PostAuthorityRootJSONBody - -// PostCollectionsJSONRequestBody defines body for PostCollections for application/json ContentType. -type PostCollectionsJSONRequestBody = NewCollection - -// PutCollectionJSONRequestBody defines body for PutCollection for application/json ContentType. -type PutCollectionJSONRequestBody = Collection - -// PutCollectionInstanceJSONRequestBody defines body for PutCollectionInstance for application/json ContentType. -type PutCollectionInstanceJSONRequestBody PutCollectionInstanceJSONBody - -// PutCollectionInstanceDataJSONRequestBody defines body for PutCollectionInstanceData for application/json ContentType. -type PutCollectionInstanceDataJSONRequestBody = PutCollectionInstanceDataJSONBody - -// PutDeviceCollectionJSONRequestBody defines body for PutDeviceCollection for application/json ContentType. -type PutDeviceCollectionJSONRequestBody = DeviceCollection - -// PutDeviceCollectionAccountJSONRequestBody defines body for PutDeviceCollectionAccount for application/json ContentType. -type PutDeviceCollectionAccountJSONRequestBody = DeviceCollectionAccount - -// PutWorkloadJSONRequestBody defines body for PutWorkload for application/json ContentType. -type PutWorkloadJSONRequestBody = Workload - -// PostDeviceEnrollmentTokenJSONRequestBody defines body for PostDeviceEnrollmentToken for application/json ContentType. -type PostDeviceEnrollmentTokenJSONRequestBody = NewEnrollmentToken - -// PostSshGrantsJSONRequestBody defines body for PostSshGrants for application/json ContentType. -type PostSshGrantsJSONRequestBody = NewGrant - -// PostHostsHostIDTagsJSONRequestBody defines body for PostHostsHostIDTags for application/json ContentType. -type PostHostsHostIDTagsJSONRequestBody = NewTag - -// PutPlatformJSONRequestBody defines body for PutPlatform for application/json ContentType. -type PutPlatformJSONRequestBody = NewPlatform - -// AsWifiAccount returns the union data inside the Account as a WifiAccount -func (t Account) AsWifiAccount() (WifiAccount, error) { - var body WifiAccount - err := json.Unmarshal(t.union, &body) - return body, err -} - -// FromWifiAccount overwrites any union data inside the Account as the provided WifiAccount -func (t *Account) FromWifiAccount(v WifiAccount) error { - b, err := json.Marshal(v) - t.union = b - return err -} - -// MergeWifiAccount performs a merge with any union data inside the Account, using the provided WifiAccount -func (t *Account) MergeWifiAccount(v WifiAccount) error { - b, err := json.Marshal(v) - if err != nil { - return err - } - - merged, err := runtime.JSONMerge(t.union, b) - t.union = merged - return err -} - -// AsEthernetAccount returns the union data inside the Account as a EthernetAccount -func (t Account) AsEthernetAccount() (EthernetAccount, error) { - var body EthernetAccount - err := json.Unmarshal(t.union, &body) - return body, err -} - -// FromEthernetAccount overwrites any union data inside the Account as the provided EthernetAccount -func (t *Account) FromEthernetAccount(v EthernetAccount) error { - b, err := json.Marshal(v) - t.union = b - return err -} - -// MergeEthernetAccount performs a merge with any union data inside the Account, using the provided EthernetAccount -func (t *Account) MergeEthernetAccount(v EthernetAccount) error { - b, err := json.Marshal(v) - if err != nil { - return err - } - - merged, err := runtime.JSONMerge(t.union, b) - t.union = merged - return err -} - -// AsVpnAccount returns the union data inside the Account as a VpnAccount -func (t Account) AsVpnAccount() (VpnAccount, error) { - var body VpnAccount - err := json.Unmarshal(t.union, &body) - return body, err -} - -// FromVpnAccount overwrites any union data inside the Account as the provided VpnAccount -func (t *Account) FromVpnAccount(v VpnAccount) error { - b, err := json.Marshal(v) - t.union = b - return err -} - -// MergeVpnAccount performs a merge with any union data inside the Account, using the provided VpnAccount -func (t *Account) MergeVpnAccount(v VpnAccount) error { - b, err := json.Marshal(v) - if err != nil { - return err - } - - merged, err := runtime.JSONMerge(t.union, b) - t.union = merged - return err -} - -// AsBrowserAccount returns the union data inside the Account as a BrowserAccount -func (t Account) AsBrowserAccount() (BrowserAccount, error) { - var body BrowserAccount - err := json.Unmarshal(t.union, &body) - return body, err -} - -// FromBrowserAccount overwrites any union data inside the Account as the provided BrowserAccount -func (t *Account) FromBrowserAccount(v BrowserAccount) error { - b, err := json.Marshal(v) - t.union = b - return err -} - -// MergeBrowserAccount performs a merge with any union data inside the Account, using the provided BrowserAccount -func (t *Account) MergeBrowserAccount(v BrowserAccount) error { - b, err := json.Marshal(v) - if err != nil { - return err - } - - merged, err := runtime.JSONMerge(t.union, b) - t.union = merged - return err -} - -func (t Account) MarshalJSON() ([]byte, error) { - b, err := t.union.MarshalJSON() - if err != nil { - return nil, err - } - object := make(map[string]json.RawMessage) - if t.union != nil { - err = json.Unmarshal(b, &object) - if err != nil { - return nil, err - } - } - - if t.Id != nil { - object["id"], err = json.Marshal(t.Id) - if err != nil { - return nil, fmt.Errorf("error marshaling 'id': %w", err) - } - } - - object["name"], err = json.Marshal(t.Name) - if err != nil { - return nil, fmt.Errorf("error marshaling 'name': %w", err) - } - - object["type"], err = json.Marshal(t.Type) - if err != nil { - return nil, fmt.Errorf("error marshaling 'type': %w", err) - } - - b, err = json.Marshal(object) - return b, err -} - -func (t *Account) UnmarshalJSON(b []byte) error { - err := t.union.UnmarshalJSON(b) - if err != nil { - return err - } - object := make(map[string]json.RawMessage) - err = json.Unmarshal(b, &object) - if err != nil { - return err - } - - if raw, found := object["id"]; found { - err = json.Unmarshal(raw, &t.Id) - if err != nil { - return fmt.Errorf("error reading 'id': %w", err) - } - } - - if raw, found := object["name"]; found { - err = json.Unmarshal(raw, &t.Name) - if err != nil { - return fmt.Errorf("error reading 'name': %w", err) - } - } - - if raw, found := object["type"]; found { - err = json.Unmarshal(raw, &t.Type) - if err != nil { - return fmt.Errorf("error reading 'type': %w", err) - } - } - - return err -} - -// AsCertificateFieldStatic returns the union data inside the CertificateField as a CertificateFieldStatic -func (t CertificateField) AsCertificateFieldStatic() (CertificateFieldStatic, error) { - var body CertificateFieldStatic - err := json.Unmarshal(t.union, &body) - return body, err -} - -// FromCertificateFieldStatic overwrites any union data inside the CertificateField as the provided CertificateFieldStatic -func (t *CertificateField) FromCertificateFieldStatic(v CertificateFieldStatic) error { - b, err := json.Marshal(v) - t.union = b - return err -} - -// MergeCertificateFieldStatic performs a merge with any union data inside the CertificateField, using the provided CertificateFieldStatic -func (t *CertificateField) MergeCertificateFieldStatic(v CertificateFieldStatic) error { - b, err := json.Marshal(v) - if err != nil { - return err - } - - merged, err := runtime.JSONMerge(t.union, b) - t.union = merged - return err -} - -// AsCertificateFieldDeviceMetadata returns the union data inside the CertificateField as a CertificateFieldDeviceMetadata -func (t CertificateField) AsCertificateFieldDeviceMetadata() (CertificateFieldDeviceMetadata, error) { - var body CertificateFieldDeviceMetadata - err := json.Unmarshal(t.union, &body) - return body, err -} - -// FromCertificateFieldDeviceMetadata overwrites any union data inside the CertificateField as the provided CertificateFieldDeviceMetadata -func (t *CertificateField) FromCertificateFieldDeviceMetadata(v CertificateFieldDeviceMetadata) error { - b, err := json.Marshal(v) - t.union = b - return err -} - -// MergeCertificateFieldDeviceMetadata performs a merge with any union data inside the CertificateField, using the provided CertificateFieldDeviceMetadata -func (t *CertificateField) MergeCertificateFieldDeviceMetadata(v CertificateFieldDeviceMetadata) error { - b, err := json.Marshal(v) - if err != nil { - return err - } - - merged, err := runtime.JSONMerge(t.union, b) - t.union = merged - return err -} - -func (t CertificateField) MarshalJSON() ([]byte, error) { - b, err := t.union.MarshalJSON() - return b, err -} - -func (t *CertificateField) UnmarshalJSON(b []byte) error { - err := t.union.UnmarshalJSON(b) - return err -} - -// AsAwsVM returns the union data inside the DeviceCollection_DeviceTypeConfiguration as a AwsVM -func (t DeviceCollection_DeviceTypeConfiguration) AsAwsVM() (AwsVM, error) { - var body AwsVM - err := json.Unmarshal(t.union, &body) - return body, err -} - -// FromAwsVM overwrites any union data inside the DeviceCollection_DeviceTypeConfiguration as the provided AwsVM -func (t *DeviceCollection_DeviceTypeConfiguration) FromAwsVM(v AwsVM) error { - b, err := json.Marshal(v) - t.union = b - return err -} - -// MergeAwsVM performs a merge with any union data inside the DeviceCollection_DeviceTypeConfiguration, using the provided AwsVM -func (t *DeviceCollection_DeviceTypeConfiguration) MergeAwsVM(v AwsVM) error { - b, err := json.Marshal(v) - if err != nil { - return err - } - - merged, err := runtime.JSONMerge(t.union, b) - t.union = merged - return err -} - -// AsAzureVM returns the union data inside the DeviceCollection_DeviceTypeConfiguration as a AzureVM -func (t DeviceCollection_DeviceTypeConfiguration) AsAzureVM() (AzureVM, error) { - var body AzureVM - err := json.Unmarshal(t.union, &body) - return body, err -} - -// FromAzureVM overwrites any union data inside the DeviceCollection_DeviceTypeConfiguration as the provided AzureVM -func (t *DeviceCollection_DeviceTypeConfiguration) FromAzureVM(v AzureVM) error { - b, err := json.Marshal(v) - t.union = b - return err -} - -// MergeAzureVM performs a merge with any union data inside the DeviceCollection_DeviceTypeConfiguration, using the provided AzureVM -func (t *DeviceCollection_DeviceTypeConfiguration) MergeAzureVM(v AzureVM) error { - b, err := json.Marshal(v) - if err != nil { - return err - } - - merged, err := runtime.JSONMerge(t.union, b) - t.union = merged - return err -} - -// AsGcpVM returns the union data inside the DeviceCollection_DeviceTypeConfiguration as a GcpVM -func (t DeviceCollection_DeviceTypeConfiguration) AsGcpVM() (GcpVM, error) { - var body GcpVM - err := json.Unmarshal(t.union, &body) - return body, err -} - -// FromGcpVM overwrites any union data inside the DeviceCollection_DeviceTypeConfiguration as the provided GcpVM -func (t *DeviceCollection_DeviceTypeConfiguration) FromGcpVM(v GcpVM) error { - b, err := json.Marshal(v) - t.union = b - return err -} - -// MergeGcpVM performs a merge with any union data inside the DeviceCollection_DeviceTypeConfiguration, using the provided GcpVM -func (t *DeviceCollection_DeviceTypeConfiguration) MergeGcpVM(v GcpVM) error { - b, err := json.Marshal(v) - if err != nil { - return err - } - - merged, err := runtime.JSONMerge(t.union, b) - t.union = merged - return err -} - -// AsTpm returns the union data inside the DeviceCollection_DeviceTypeConfiguration as a Tpm -func (t DeviceCollection_DeviceTypeConfiguration) AsTpm() (Tpm, error) { - var body Tpm - err := json.Unmarshal(t.union, &body) - return body, err -} - -// FromTpm overwrites any union data inside the DeviceCollection_DeviceTypeConfiguration as the provided Tpm -func (t *DeviceCollection_DeviceTypeConfiguration) FromTpm(v Tpm) error { - b, err := json.Marshal(v) - t.union = b - return err -} - -// MergeTpm performs a merge with any union data inside the DeviceCollection_DeviceTypeConfiguration, using the provided Tpm -func (t *DeviceCollection_DeviceTypeConfiguration) MergeTpm(v Tpm) error { - b, err := json.Marshal(v) - if err != nil { - return err - } - - merged, err := runtime.JSONMerge(t.union, b) - t.union = merged - return err -} - -func (t DeviceCollection_DeviceTypeConfiguration) MarshalJSON() ([]byte, error) { - b, err := t.union.MarshalJSON() - return b, err -} - -func (t *DeviceCollection_DeviceTypeConfiguration) UnmarshalJSON(b []byte) error { - err := t.union.UnmarshalJSON(b) - return err -} - -// AsX509Fields returns the union data inside the DeviceCollectionAccount as a X509Fields -func (t DeviceCollectionAccount) AsX509Fields() (X509Fields, error) { - var body X509Fields - err := json.Unmarshal(t.union, &body) - return body, err -} - -// FromX509Fields overwrites any union data inside the DeviceCollectionAccount as the provided X509Fields -func (t *DeviceCollectionAccount) FromX509Fields(v X509Fields) error { - b, err := json.Marshal(v) - t.union = b - return err -} - -// MergeX509Fields performs a merge with any union data inside the DeviceCollectionAccount, using the provided X509Fields -func (t *DeviceCollectionAccount) MergeX509Fields(v X509Fields) error { - b, err := json.Marshal(v) - if err != nil { - return err - } - - merged, err := runtime.JSONMerge(t.union, b) - t.union = merged - return err -} - -func (t DeviceCollectionAccount) MarshalJSON() ([]byte, error) { - b, err := t.union.MarshalJSON() - if err != nil { - return nil, err - } - object := make(map[string]json.RawMessage) - if t.union != nil { - err = json.Unmarshal(b, &object) - if err != nil { - return nil, err - } - } - - object["accountID"], err = json.Marshal(t.AccountID) - if err != nil { - return nil, fmt.Errorf("error marshaling 'accountID': %w", err) - } - - object["authorityID"], err = json.Marshal(t.AuthorityID) - if err != nil { - return nil, fmt.Errorf("error marshaling 'authorityID': %w", err) - } - - if t.CertificateInfo != nil { - object["certificateInfo"], err = json.Marshal(t.CertificateInfo) - if err != nil { - return nil, fmt.Errorf("error marshaling 'certificateInfo': %w", err) - } - } - - object["displayName"], err = json.Marshal(t.DisplayName) - if err != nil { - return nil, fmt.Errorf("error marshaling 'displayName': %w", err) - } - - if t.Hooks != nil { - object["hooks"], err = json.Marshal(t.Hooks) - if err != nil { - return nil, fmt.Errorf("error marshaling 'hooks': %w", err) - } - } - - if t.KeyInfo != nil { - object["keyInfo"], err = json.Marshal(t.KeyInfo) - if err != nil { - return nil, fmt.Errorf("error marshaling 'keyInfo': %w", err) - } - } - - if t.ReloadInfo != nil { - object["reloadInfo"], err = json.Marshal(t.ReloadInfo) - if err != nil { - return nil, fmt.Errorf("error marshaling 'reloadInfo': %w", err) - } - } - - object["slug"], err = json.Marshal(t.Slug) - if err != nil { - return nil, fmt.Errorf("error marshaling 'slug': %w", err) - } - - b, err = json.Marshal(object) - return b, err -} - -func (t *DeviceCollectionAccount) UnmarshalJSON(b []byte) error { - err := t.union.UnmarshalJSON(b) - if err != nil { - return err - } - object := make(map[string]json.RawMessage) - err = json.Unmarshal(b, &object) - if err != nil { - return err - } - - if raw, found := object["accountID"]; found { - err = json.Unmarshal(raw, &t.AccountID) - if err != nil { - return fmt.Errorf("error reading 'accountID': %w", err) - } - } - - if raw, found := object["authorityID"]; found { - err = json.Unmarshal(raw, &t.AuthorityID) - if err != nil { - return fmt.Errorf("error reading 'authorityID': %w", err) - } - } - - if raw, found := object["certificateInfo"]; found { - err = json.Unmarshal(raw, &t.CertificateInfo) - if err != nil { - return fmt.Errorf("error reading 'certificateInfo': %w", err) - } - } - - if raw, found := object["displayName"]; found { - err = json.Unmarshal(raw, &t.DisplayName) - if err != nil { - return fmt.Errorf("error reading 'displayName': %w", err) - } - } - - if raw, found := object["hooks"]; found { - err = json.Unmarshal(raw, &t.Hooks) - if err != nil { - return fmt.Errorf("error reading 'hooks': %w", err) - } - } - - if raw, found := object["keyInfo"]; found { - err = json.Unmarshal(raw, &t.KeyInfo) - if err != nil { - return fmt.Errorf("error reading 'keyInfo': %w", err) - } - } - - if raw, found := object["reloadInfo"]; found { - err = json.Unmarshal(raw, &t.ReloadInfo) - if err != nil { - return fmt.Errorf("error reading 'reloadInfo': %w", err) - } - } - - if raw, found := object["slug"]; found { - err = json.Unmarshal(raw, &t.Slug) - if err != nil { - return fmt.Errorf("error reading 'slug': %w", err) - } - } - - return err -} - -// AsAwsPlatform returns the union data inside the NewPlatform_PlatformConfiguration as a AwsPlatform -func (t NewPlatform_PlatformConfiguration) AsAwsPlatform() (AwsPlatform, error) { - var body AwsPlatform - err := json.Unmarshal(t.union, &body) - return body, err -} - -// FromAwsPlatform overwrites any union data inside the NewPlatform_PlatformConfiguration as the provided AwsPlatform -func (t *NewPlatform_PlatformConfiguration) FromAwsPlatform(v AwsPlatform) error { - b, err := json.Marshal(v) - t.union = b - return err -} - -// MergeAwsPlatform performs a merge with any union data inside the NewPlatform_PlatformConfiguration, using the provided AwsPlatform -func (t *NewPlatform_PlatformConfiguration) MergeAwsPlatform(v AwsPlatform) error { - b, err := json.Marshal(v) - if err != nil { - return err - } - - merged, err := runtime.JSONMerge(t.union, b) - t.union = merged - return err -} - -// AsAzurePlatform returns the union data inside the NewPlatform_PlatformConfiguration as a AzurePlatform -func (t NewPlatform_PlatformConfiguration) AsAzurePlatform() (AzurePlatform, error) { - var body AzurePlatform - err := json.Unmarshal(t.union, &body) - return body, err -} - -// FromAzurePlatform overwrites any union data inside the NewPlatform_PlatformConfiguration as the provided AzurePlatform -func (t *NewPlatform_PlatformConfiguration) FromAzurePlatform(v AzurePlatform) error { - b, err := json.Marshal(v) - t.union = b - return err -} - -// MergeAzurePlatform performs a merge with any union data inside the NewPlatform_PlatformConfiguration, using the provided AzurePlatform -func (t *NewPlatform_PlatformConfiguration) MergeAzurePlatform(v AzurePlatform) error { - b, err := json.Marshal(v) - if err != nil { - return err - } - - merged, err := runtime.JSONMerge(t.union, b) - t.union = merged - return err -} - -// AsGcpPlatform returns the union data inside the NewPlatform_PlatformConfiguration as a GcpPlatform -func (t NewPlatform_PlatformConfiguration) AsGcpPlatform() (GcpPlatform, error) { - var body GcpPlatform - err := json.Unmarshal(t.union, &body) - return body, err -} - -// FromGcpPlatform overwrites any union data inside the NewPlatform_PlatformConfiguration as the provided GcpPlatform -func (t *NewPlatform_PlatformConfiguration) FromGcpPlatform(v GcpPlatform) error { - b, err := json.Marshal(v) - t.union = b - return err -} - -// MergeGcpPlatform performs a merge with any union data inside the NewPlatform_PlatformConfiguration, using the provided GcpPlatform -func (t *NewPlatform_PlatformConfiguration) MergeGcpPlatform(v GcpPlatform) error { - b, err := json.Marshal(v) - if err != nil { - return err - } - - merged, err := runtime.JSONMerge(t.union, b) - t.union = merged - return err -} - -func (t NewPlatform_PlatformConfiguration) MarshalJSON() ([]byte, error) { - b, err := t.union.MarshalJSON() - return b, err -} - -func (t *NewPlatform_PlatformConfiguration) UnmarshalJSON(b []byte) error { - err := t.union.UnmarshalJSON(b) - return err -} - -// AsAwsPlatform returns the union data inside the Platform_PlatformConfigurations_Item as a AwsPlatform -func (t Platform_PlatformConfigurations_Item) AsAwsPlatform() (AwsPlatform, error) { - var body AwsPlatform - err := json.Unmarshal(t.union, &body) - return body, err -} - -// FromAwsPlatform overwrites any union data inside the Platform_PlatformConfigurations_Item as the provided AwsPlatform -func (t *Platform_PlatformConfigurations_Item) FromAwsPlatform(v AwsPlatform) error { - b, err := json.Marshal(v) - t.union = b - return err -} - -// MergeAwsPlatform performs a merge with any union data inside the Platform_PlatformConfigurations_Item, using the provided AwsPlatform -func (t *Platform_PlatformConfigurations_Item) MergeAwsPlatform(v AwsPlatform) error { - b, err := json.Marshal(v) - if err != nil { - return err - } - - merged, err := runtime.JSONMerge(t.union, b) - t.union = merged - return err -} - -// AsAzurePlatform returns the union data inside the Platform_PlatformConfigurations_Item as a AzurePlatform -func (t Platform_PlatformConfigurations_Item) AsAzurePlatform() (AzurePlatform, error) { - var body AzurePlatform - err := json.Unmarshal(t.union, &body) - return body, err -} - -// FromAzurePlatform overwrites any union data inside the Platform_PlatformConfigurations_Item as the provided AzurePlatform -func (t *Platform_PlatformConfigurations_Item) FromAzurePlatform(v AzurePlatform) error { - b, err := json.Marshal(v) - t.union = b - return err -} - -// MergeAzurePlatform performs a merge with any union data inside the Platform_PlatformConfigurations_Item, using the provided AzurePlatform -func (t *Platform_PlatformConfigurations_Item) MergeAzurePlatform(v AzurePlatform) error { - b, err := json.Marshal(v) - if err != nil { - return err - } - - merged, err := runtime.JSONMerge(t.union, b) - t.union = merged - return err -} - -// AsGcpPlatform returns the union data inside the Platform_PlatformConfigurations_Item as a GcpPlatform -func (t Platform_PlatformConfigurations_Item) AsGcpPlatform() (GcpPlatform, error) { - var body GcpPlatform - err := json.Unmarshal(t.union, &body) - return body, err -} - -// FromGcpPlatform overwrites any union data inside the Platform_PlatformConfigurations_Item as the provided GcpPlatform -func (t *Platform_PlatformConfigurations_Item) FromGcpPlatform(v GcpPlatform) error { - b, err := json.Marshal(v) - t.union = b - return err -} - -// MergeGcpPlatform performs a merge with any union data inside the Platform_PlatformConfigurations_Item, using the provided GcpPlatform -func (t *Platform_PlatformConfigurations_Item) MergeGcpPlatform(v GcpPlatform) error { - b, err := json.Marshal(v) - if err != nil { - return err - } - - merged, err := runtime.JSONMerge(t.union, b) - t.union = merged - return err -} - -func (t Platform_PlatformConfigurations_Item) MarshalJSON() ([]byte, error) { - b, err := t.union.MarshalJSON() - return b, err -} - -func (t *Platform_PlatformConfigurations_Item) UnmarshalJSON(b []byte) error { - err := t.union.UnmarshalJSON(b) - return err -} - -// AsOidcProvisioner returns the union data inside the Provisioner as a OidcProvisioner -func (t Provisioner) AsOidcProvisioner() (OidcProvisioner, error) { - var body OidcProvisioner - err := json.Unmarshal(t.union, &body) - return body, err -} - -// FromOidcProvisioner overwrites any union data inside the Provisioner as the provided OidcProvisioner -func (t *Provisioner) FromOidcProvisioner(v OidcProvisioner) error { - b, err := json.Marshal(v) - t.union = b - return err -} - -// MergeOidcProvisioner performs a merge with any union data inside the Provisioner, using the provided OidcProvisioner -func (t *Provisioner) MergeOidcProvisioner(v OidcProvisioner) error { - b, err := json.Marshal(v) - if err != nil { - return err - } - - merged, err := runtime.JSONMerge(t.union, b) - t.union = merged - return err -} - -// AsJwkProvisioner returns the union data inside the Provisioner as a JwkProvisioner -func (t Provisioner) AsJwkProvisioner() (JwkProvisioner, error) { - var body JwkProvisioner - err := json.Unmarshal(t.union, &body) - return body, err -} - -// FromJwkProvisioner overwrites any union data inside the Provisioner as the provided JwkProvisioner -func (t *Provisioner) FromJwkProvisioner(v JwkProvisioner) error { - b, err := json.Marshal(v) - t.union = b - return err -} - -// MergeJwkProvisioner performs a merge with any union data inside the Provisioner, using the provided JwkProvisioner -func (t *Provisioner) MergeJwkProvisioner(v JwkProvisioner) error { - b, err := json.Marshal(v) - if err != nil { - return err - } - - merged, err := runtime.JSONMerge(t.union, b) - t.union = merged - return err -} - -// AsAcmeProvisioner returns the union data inside the Provisioner as a AcmeProvisioner -func (t Provisioner) AsAcmeProvisioner() (AcmeProvisioner, error) { - var body AcmeProvisioner - err := json.Unmarshal(t.union, &body) - return body, err -} - -// FromAcmeProvisioner overwrites any union data inside the Provisioner as the provided AcmeProvisioner -func (t *Provisioner) FromAcmeProvisioner(v AcmeProvisioner) error { - b, err := json.Marshal(v) - t.union = b - return err -} - -// MergeAcmeProvisioner performs a merge with any union data inside the Provisioner, using the provided AcmeProvisioner -func (t *Provisioner) MergeAcmeProvisioner(v AcmeProvisioner) error { - b, err := json.Marshal(v) - if err != nil { - return err - } - - merged, err := runtime.JSONMerge(t.union, b) - t.union = merged - return err -} - -// AsAcmeAttestationProvisioner returns the union data inside the Provisioner as a AcmeAttestationProvisioner -func (t Provisioner) AsAcmeAttestationProvisioner() (AcmeAttestationProvisioner, error) { - var body AcmeAttestationProvisioner - err := json.Unmarshal(t.union, &body) - return body, err -} - -// FromAcmeAttestationProvisioner overwrites any union data inside the Provisioner as the provided AcmeAttestationProvisioner -func (t *Provisioner) FromAcmeAttestationProvisioner(v AcmeAttestationProvisioner) error { - b, err := json.Marshal(v) - t.union = b - return err -} - -// MergeAcmeAttestationProvisioner performs a merge with any union data inside the Provisioner, using the provided AcmeAttestationProvisioner -func (t *Provisioner) MergeAcmeAttestationProvisioner(v AcmeAttestationProvisioner) error { - b, err := json.Marshal(v) - if err != nil { - return err - } - - merged, err := runtime.JSONMerge(t.union, b) - t.union = merged - return err -} - -// AsX5cProvisioner returns the union data inside the Provisioner as a X5cProvisioner -func (t Provisioner) AsX5cProvisioner() (X5cProvisioner, error) { - var body X5cProvisioner - err := json.Unmarshal(t.union, &body) - return body, err -} - -// FromX5cProvisioner overwrites any union data inside the Provisioner as the provided X5cProvisioner -func (t *Provisioner) FromX5cProvisioner(v X5cProvisioner) error { - b, err := json.Marshal(v) - t.union = b - return err -} - -// MergeX5cProvisioner performs a merge with any union data inside the Provisioner, using the provided X5cProvisioner -func (t *Provisioner) MergeX5cProvisioner(v X5cProvisioner) error { - b, err := json.Marshal(v) - if err != nil { - return err - } - - merged, err := runtime.JSONMerge(t.union, b) - t.union = merged - return err -} - -// AsAwsProvisioner returns the union data inside the Provisioner as a AwsProvisioner -func (t Provisioner) AsAwsProvisioner() (AwsProvisioner, error) { - var body AwsProvisioner - err := json.Unmarshal(t.union, &body) - return body, err -} - -// FromAwsProvisioner overwrites any union data inside the Provisioner as the provided AwsProvisioner -func (t *Provisioner) FromAwsProvisioner(v AwsProvisioner) error { - b, err := json.Marshal(v) - t.union = b - return err -} - -// MergeAwsProvisioner performs a merge with any union data inside the Provisioner, using the provided AwsProvisioner -func (t *Provisioner) MergeAwsProvisioner(v AwsProvisioner) error { - b, err := json.Marshal(v) - if err != nil { - return err - } - - merged, err := runtime.JSONMerge(t.union, b) - t.union = merged - return err -} - -// AsGcpProvisioner returns the union data inside the Provisioner as a GcpProvisioner -func (t Provisioner) AsGcpProvisioner() (GcpProvisioner, error) { - var body GcpProvisioner - err := json.Unmarshal(t.union, &body) - return body, err -} - -// FromGcpProvisioner overwrites any union data inside the Provisioner as the provided GcpProvisioner -func (t *Provisioner) FromGcpProvisioner(v GcpProvisioner) error { - b, err := json.Marshal(v) - t.union = b - return err -} - -// MergeGcpProvisioner performs a merge with any union data inside the Provisioner, using the provided GcpProvisioner -func (t *Provisioner) MergeGcpProvisioner(v GcpProvisioner) error { - b, err := json.Marshal(v) - if err != nil { - return err - } - - merged, err := runtime.JSONMerge(t.union, b) - t.union = merged - return err -} - -// AsAzureProvisioner returns the union data inside the Provisioner as a AzureProvisioner -func (t Provisioner) AsAzureProvisioner() (AzureProvisioner, error) { - var body AzureProvisioner - err := json.Unmarshal(t.union, &body) - return body, err -} - -// FromAzureProvisioner overwrites any union data inside the Provisioner as the provided AzureProvisioner -func (t *Provisioner) FromAzureProvisioner(v AzureProvisioner) error { - b, err := json.Marshal(v) - t.union = b - return err -} - -// MergeAzureProvisioner performs a merge with any union data inside the Provisioner, using the provided AzureProvisioner -func (t *Provisioner) MergeAzureProvisioner(v AzureProvisioner) error { - b, err := json.Marshal(v) - if err != nil { - return err - } - - merged, err := runtime.JSONMerge(t.union, b) - t.union = merged - return err -} - -// AsScepProvisioner returns the union data inside the Provisioner as a ScepProvisioner -func (t Provisioner) AsScepProvisioner() (ScepProvisioner, error) { - var body ScepProvisioner - err := json.Unmarshal(t.union, &body) - return body, err -} - -// FromScepProvisioner overwrites any union data inside the Provisioner as the provided ScepProvisioner -func (t *Provisioner) FromScepProvisioner(v ScepProvisioner) error { - b, err := json.Marshal(v) - t.union = b - return err -} - -// MergeScepProvisioner performs a merge with any union data inside the Provisioner, using the provided ScepProvisioner -func (t *Provisioner) MergeScepProvisioner(v ScepProvisioner) error { - b, err := json.Marshal(v) - if err != nil { - return err - } - - merged, err := runtime.JSONMerge(t.union, b) - t.union = merged - return err -} - -func (t Provisioner) MarshalJSON() ([]byte, error) { - b, err := t.union.MarshalJSON() - if err != nil { - return nil, err - } - object := make(map[string]json.RawMessage) - if t.union != nil { - err = json.Unmarshal(b, &object) - if err != nil { - return nil, err - } - } - - if t.Claims != nil { - object["claims"], err = json.Marshal(t.Claims) - if err != nil { - return nil, fmt.Errorf("error marshaling 'claims': %w", err) - } - } - - if t.CreatedAt != nil { - object["createdAt"], err = json.Marshal(t.CreatedAt) - if err != nil { - return nil, fmt.Errorf("error marshaling 'createdAt': %w", err) - } - } - - if t.Id != nil { - object["id"], err = json.Marshal(t.Id) - if err != nil { - return nil, fmt.Errorf("error marshaling 'id': %w", err) - } - } - - object["name"], err = json.Marshal(t.Name) - if err != nil { - return nil, fmt.Errorf("error marshaling 'name': %w", err) - } - - if t.Options != nil { - object["options"], err = json.Marshal(t.Options) - if err != nil { - return nil, fmt.Errorf("error marshaling 'options': %w", err) - } - } - - object["type"], err = json.Marshal(t.Type) - if err != nil { - return nil, fmt.Errorf("error marshaling 'type': %w", err) - } - - b, err = json.Marshal(object) - return b, err -} - -func (t *Provisioner) UnmarshalJSON(b []byte) error { - err := t.union.UnmarshalJSON(b) - if err != nil { - return err - } - object := make(map[string]json.RawMessage) - err = json.Unmarshal(b, &object) - if err != nil { - return err - } - - if raw, found := object["claims"]; found { - err = json.Unmarshal(raw, &t.Claims) - if err != nil { - return fmt.Errorf("error reading 'claims': %w", err) - } - } - - if raw, found := object["createdAt"]; found { - err = json.Unmarshal(raw, &t.CreatedAt) - if err != nil { - return fmt.Errorf("error reading 'createdAt': %w", err) - } - } - - if raw, found := object["id"]; found { - err = json.Unmarshal(raw, &t.Id) - if err != nil { - return fmt.Errorf("error reading 'id': %w", err) - } - } - - if raw, found := object["name"]; found { - err = json.Unmarshal(raw, &t.Name) - if err != nil { - return fmt.Errorf("error reading 'name': %w", err) - } - } - - if raw, found := object["options"]; found { - err = json.Unmarshal(raw, &t.Options) - if err != nil { - return fmt.Errorf("error reading 'options': %w", err) - } - } - - if raw, found := object["type"]; found { - err = json.Unmarshal(raw, &t.Type) - if err != nil { - return fmt.Errorf("error reading 'type': %w", err) - } - } - - return err -} - -// AsX509Fields returns the union data inside the Workload as a X509Fields -func (t Workload) AsX509Fields() (X509Fields, error) { - var body X509Fields - err := json.Unmarshal(t.union, &body) - return body, err -} - -// FromX509Fields overwrites any union data inside the Workload as the provided X509Fields -func (t *Workload) FromX509Fields(v X509Fields) error { - b, err := json.Marshal(v) - t.union = b - return err -} - -// MergeX509Fields performs a merge with any union data inside the Workload, using the provided X509Fields -func (t *Workload) MergeX509Fields(v X509Fields) error { - b, err := json.Marshal(v) - if err != nil { - return err - } - - merged, err := runtime.JSONMerge(t.union, b) - t.union = merged - return err -} - -func (t Workload) MarshalJSON() ([]byte, error) { - b, err := t.union.MarshalJSON() - if err != nil { - return nil, err - } - object := make(map[string]json.RawMessage) - if t.union != nil { - err = json.Unmarshal(b, &object) - if err != nil { - return nil, err - } - } - - object["authorityID"], err = json.Marshal(t.AuthorityID) - if err != nil { - return nil, fmt.Errorf("error marshaling 'authorityID': %w", err) - } - - if t.CertificateInfo != nil { - object["certificateInfo"], err = json.Marshal(t.CertificateInfo) - if err != nil { - return nil, fmt.Errorf("error marshaling 'certificateInfo': %w", err) - } - } - - object["displayName"], err = json.Marshal(t.DisplayName) - if err != nil { - return nil, fmt.Errorf("error marshaling 'displayName': %w", err) - } - - if t.Hooks != nil { - object["hooks"], err = json.Marshal(t.Hooks) - if err != nil { - return nil, fmt.Errorf("error marshaling 'hooks': %w", err) - } - } - - if t.KeyInfo != nil { - object["keyInfo"], err = json.Marshal(t.KeyInfo) - if err != nil { - return nil, fmt.Errorf("error marshaling 'keyInfo': %w", err) - } - } - - if t.ReloadInfo != nil { - object["reloadInfo"], err = json.Marshal(t.ReloadInfo) - if err != nil { - return nil, fmt.Errorf("error marshaling 'reloadInfo': %w", err) - } - } - - object["slug"], err = json.Marshal(t.Slug) - if err != nil { - return nil, fmt.Errorf("error marshaling 'slug': %w", err) - } - - if t.WorkloadType != nil { - object["workloadType"], err = json.Marshal(t.WorkloadType) - if err != nil { - return nil, fmt.Errorf("error marshaling 'workloadType': %w", err) - } - } - b, err = json.Marshal(object) - return b, err -} - -func (t *Workload) UnmarshalJSON(b []byte) error { - err := t.union.UnmarshalJSON(b) - if err != nil { - return err - } - object := make(map[string]json.RawMessage) - err = json.Unmarshal(b, &object) - if err != nil { - return err - } - - if raw, found := object["authorityID"]; found { - err = json.Unmarshal(raw, &t.AuthorityID) - if err != nil { - return fmt.Errorf("error reading 'authorityID': %w", err) - } - } - - if raw, found := object["certificateInfo"]; found { - err = json.Unmarshal(raw, &t.CertificateInfo) - if err != nil { - return fmt.Errorf("error reading 'certificateInfo': %w", err) - } - } - - if raw, found := object["displayName"]; found { - err = json.Unmarshal(raw, &t.DisplayName) - if err != nil { - return fmt.Errorf("error reading 'displayName': %w", err) - } - } - - if raw, found := object["hooks"]; found { - err = json.Unmarshal(raw, &t.Hooks) - if err != nil { - return fmt.Errorf("error reading 'hooks': %w", err) - } - } - - if raw, found := object["keyInfo"]; found { - err = json.Unmarshal(raw, &t.KeyInfo) - if err != nil { - return fmt.Errorf("error reading 'keyInfo': %w", err) - } - } - - if raw, found := object["reloadInfo"]; found { - err = json.Unmarshal(raw, &t.ReloadInfo) - if err != nil { - return fmt.Errorf("error reading 'reloadInfo': %w", err) - } - } - - if raw, found := object["slug"]; found { - err = json.Unmarshal(raw, &t.Slug) - if err != nil { - return fmt.Errorf("error reading 'slug': %w", err) - } - } - - if raw, found := object["workloadType"]; found { - err = json.Unmarshal(raw, &t.WorkloadType) - if err != nil { - return fmt.Errorf("error reading 'workloadType': %w", err) - } - } - - return err -} - -// RequestEditorFn is the function signature for the RequestEditor callback function -type RequestEditorFn func(ctx context.Context, req *http.Request) error - -// Doer performs HTTP requests. -// -// The standard http.Client implements this interface. -type HttpRequestDoer interface { - Do(req *http.Request) (*http.Response, error) -} - -// Client which conforms to the OpenAPI3 specification for this service. -type Client struct { - // The endpoint of the server conforming to this interface, with scheme, - // https://api.deepmap.com for example. This can contain a path relative - // to the server, such as https://api.deepmap.com/dev-test, and all the - // paths in the swagger spec will be appended to the server. - Server string - - // Doer for performing requests, typically a *http.Client with any - // customized settings, such as certificate chains. - Client HttpRequestDoer - - // A list of callbacks for modifying requests which are generated before sending over - // the network. - RequestEditors []RequestEditorFn -} - -// ClientOption allows setting custom parameters during construction -type ClientOption func(*Client) error - -// Creates a new Client, with reasonable defaults -func NewClient(server string, opts ...ClientOption) (*Client, error) { - // create a client with sane default values - client := Client{ - Server: server, - } - // mutate client and add all optional params - for _, o := range opts { - if err := o(&client); err != nil { - return nil, err - } - } - // ensure the server URL always has a trailing slash - if !strings.HasSuffix(client.Server, "/") { - client.Server += "/" - } - // create httpClient, if not already present - if client.Client == nil { - client.Client = &http.Client{} - } - return &client, nil -} - -// WithHTTPClient allows overriding the default Doer, which is -// automatically created using http.Client. This is useful for tests. -func WithHTTPClient(doer HttpRequestDoer) ClientOption { - return func(c *Client) error { - c.Client = doer - return nil - } -} - -// WithRequestEditorFn allows setting up a callback function, which will be -// called right before sending the request. This can be used to mutate the request. -func WithRequestEditorFn(fn RequestEditorFn) ClientOption { - return func(c *Client) error { - c.RequestEditors = append(c.RequestEditors, fn) - return nil - } -} - -// The interface specification for the client above. -type ClientInterface interface { - // ListAccounts request - ListAccounts(ctx context.Context, params *ListAccountsParams, reqEditors ...RequestEditorFn) (*http.Response, error) - - // PostAccountsWithBody request with any body - PostAccountsWithBody(ctx context.Context, params *PostAccountsParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - - PostAccounts(ctx context.Context, params *PostAccountsParams, body PostAccountsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - - // DeleteAccount request - DeleteAccount(ctx context.Context, accountID AccountID, params *DeleteAccountParams, reqEditors ...RequestEditorFn) (*http.Response, error) - - // GetAccount request - GetAccount(ctx context.Context, accountID AccountID, params *GetAccountParams, reqEditors ...RequestEditorFn) (*http.Response, error) - - // PutAccountWithBody request with any body - PutAccountWithBody(ctx context.Context, accountID AccountID, params *PutAccountParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - - PutAccount(ctx context.Context, accountID AccountID, params *PutAccountParams, body PutAccountJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - - // GetAttestationAuthorities request - GetAttestationAuthorities(ctx context.Context, params *GetAttestationAuthoritiesParams, reqEditors ...RequestEditorFn) (*http.Response, error) - - // PostAttestationAuthoritiesWithBody request with any body - PostAttestationAuthoritiesWithBody(ctx context.Context, params *PostAttestationAuthoritiesParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - - PostAttestationAuthorities(ctx context.Context, params *PostAttestationAuthoritiesParams, body PostAttestationAuthoritiesJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - - // DeleteAttestationAuthority request - DeleteAttestationAuthority(ctx context.Context, attestationAuthorityID AttestationAuthorityID, params *DeleteAttestationAuthorityParams, reqEditors ...RequestEditorFn) (*http.Response, error) - - // GetAttestationAuthority request - GetAttestationAuthority(ctx context.Context, attestationAuthorityID AttestationAuthorityID, params *GetAttestationAuthorityParams, reqEditors ...RequestEditorFn) (*http.Response, error) - - // PostAuthWithBody request with any body - PostAuthWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - - PostAuth(ctx context.Context, body PostAuthJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - - // GetAuthorities request - GetAuthorities(ctx context.Context, params *GetAuthoritiesParams, reqEditors ...RequestEditorFn) (*http.Response, error) - - // PostAuthoritiesWithBody request with any body - PostAuthoritiesWithBody(ctx context.Context, params *PostAuthoritiesParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - - PostAuthorities(ctx context.Context, params *PostAuthoritiesParams, body PostAuthoritiesJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - - // PostAuthoritiesCsrWithBody request with any body - PostAuthoritiesCsrWithBody(ctx context.Context, params *PostAuthoritiesCsrParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - - PostAuthoritiesCsr(ctx context.Context, params *PostAuthoritiesCsrParams, body PostAuthoritiesCsrJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - - // DeleteAuthority request - DeleteAuthority(ctx context.Context, authorityDomainOrID AuthorityDomainOrID, params *DeleteAuthorityParams, reqEditors ...RequestEditorFn) (*http.Response, error) - - // GetAuthority request - GetAuthority(ctx context.Context, authorityDomainOrID AuthorityDomainOrID, params *GetAuthorityParams, reqEditors ...RequestEditorFn) (*http.Response, error) - - // ListAuthorityProvisioners request - ListAuthorityProvisioners(ctx context.Context, authorityID AuthorityID, params *ListAuthorityProvisionersParams, reqEditors ...RequestEditorFn) (*http.Response, error) - - // PostAuthorityProvisionersWithBody request with any body - PostAuthorityProvisionersWithBody(ctx context.Context, authorityID AuthorityID, params *PostAuthorityProvisionersParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - - PostAuthorityProvisioners(ctx context.Context, authorityID AuthorityID, params *PostAuthorityProvisionersParams, body PostAuthorityProvisionersJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - - // DeleteProvisioner request - DeleteProvisioner(ctx context.Context, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, params *DeleteProvisionerParams, reqEditors ...RequestEditorFn) (*http.Response, error) - - // GetProvisioner request - GetProvisioner(ctx context.Context, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, params *GetProvisionerParams, reqEditors ...RequestEditorFn) (*http.Response, error) - - // PostWebhooksWithBody request with any body - PostWebhooksWithBody(ctx context.Context, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, params *PostWebhooksParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - - PostWebhooks(ctx context.Context, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, params *PostWebhooksParams, body PostWebhooksJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - - // DeleteWebhook request - DeleteWebhook(ctx context.Context, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, webhookNameOrID WebhookNameOrID, params *DeleteWebhookParams, reqEditors ...RequestEditorFn) (*http.Response, error) - - // GetWebhook request - GetWebhook(ctx context.Context, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, webhookNameOrID WebhookNameOrID, params *GetWebhookParams, reqEditors ...RequestEditorFn) (*http.Response, error) - - // PostAuthorityRootWithBody request with any body - PostAuthorityRootWithBody(ctx context.Context, authorityID AuthorityID, params *PostAuthorityRootParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - - PostAuthorityRoot(ctx context.Context, authorityID AuthorityID, params *PostAuthorityRootParams, body PostAuthorityRootJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - - // ListCertificates request - ListCertificates(ctx context.Context, params *ListCertificatesParams, reqEditors ...RequestEditorFn) (*http.Response, error) - - // GetCertificate request - GetCertificate(ctx context.Context, serialNumber SerialNumber, params *GetCertificateParams, reqEditors ...RequestEditorFn) (*http.Response, error) - - // ListCollections request - ListCollections(ctx context.Context, params *ListCollectionsParams, reqEditors ...RequestEditorFn) (*http.Response, error) - - // PostCollectionsWithBody request with any body - PostCollectionsWithBody(ctx context.Context, params *PostCollectionsParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - - PostCollections(ctx context.Context, params *PostCollectionsParams, body PostCollectionsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - - // DeleteCollection request - DeleteCollection(ctx context.Context, collectionSlug CollectionSlug, params *DeleteCollectionParams, reqEditors ...RequestEditorFn) (*http.Response, error) - - // GetCollection request - GetCollection(ctx context.Context, collectionSlug CollectionSlug, params *GetCollectionParams, reqEditors ...RequestEditorFn) (*http.Response, error) - - // PutCollectionWithBody request with any body - PutCollectionWithBody(ctx context.Context, collectionSlug CollectionSlug, params *PutCollectionParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - - PutCollection(ctx context.Context, collectionSlug CollectionSlug, params *PutCollectionParams, body PutCollectionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - - // DeleteCollectionInstance request - DeleteCollectionInstance(ctx context.Context, collectionSlug CollectionSlug, instanceID InstanceID, params *DeleteCollectionInstanceParams, reqEditors ...RequestEditorFn) (*http.Response, error) - - // GetCollectionInstance request - GetCollectionInstance(ctx context.Context, collectionSlug CollectionSlug, instanceID InstanceID, params *GetCollectionInstanceParams, reqEditors ...RequestEditorFn) (*http.Response, error) - - // PutCollectionInstanceWithBody request with any body - PutCollectionInstanceWithBody(ctx context.Context, collectionSlug CollectionSlug, instanceID InstanceID, params *PutCollectionInstanceParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - - PutCollectionInstance(ctx context.Context, collectionSlug CollectionSlug, instanceID InstanceID, params *PutCollectionInstanceParams, body PutCollectionInstanceJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - - // GetCollectionInstanceData request - GetCollectionInstanceData(ctx context.Context, collectionSlug CollectionSlug, instanceID InstanceID, params *GetCollectionInstanceDataParams, reqEditors ...RequestEditorFn) (*http.Response, error) - - // PutCollectionInstanceDataWithBody request with any body - PutCollectionInstanceDataWithBody(ctx context.Context, collectionSlug CollectionSlug, instanceID InstanceID, params *PutCollectionInstanceDataParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - - PutCollectionInstanceData(ctx context.Context, collectionSlug CollectionSlug, instanceID InstanceID, params *PutCollectionInstanceDataParams, body PutCollectionInstanceDataJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - - // ListCollectionInstances request - ListCollectionInstances(ctx context.Context, collectionSlug CollectionSlug, params *ListCollectionInstancesParams, reqEditors ...RequestEditorFn) (*http.Response, error) - - // DeleteDeviceCollection request - DeleteDeviceCollection(ctx context.Context, collectionSlug CollectionSlug, params *DeleteDeviceCollectionParams, reqEditors ...RequestEditorFn) (*http.Response, error) - - // GetDeviceCollection request - GetDeviceCollection(ctx context.Context, collectionSlug CollectionSlug, params *GetDeviceCollectionParams, reqEditors ...RequestEditorFn) (*http.Response, error) - - // PutDeviceCollectionWithBody request with any body - PutDeviceCollectionWithBody(ctx context.Context, collectionSlug CollectionSlug, params *PutDeviceCollectionParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - - PutDeviceCollection(ctx context.Context, collectionSlug CollectionSlug, params *PutDeviceCollectionParams, body PutDeviceCollectionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - - // DeleteDeviceCollectionAccount request - DeleteDeviceCollectionAccount(ctx context.Context, collectionSlug CollectionSlug, accountSlug AccountSlug, params *DeleteDeviceCollectionAccountParams, reqEditors ...RequestEditorFn) (*http.Response, error) - - // GetDeviceCollectionAccount request - GetDeviceCollectionAccount(ctx context.Context, collectionSlug CollectionSlug, accountSlug AccountSlug, params *GetDeviceCollectionAccountParams, reqEditors ...RequestEditorFn) (*http.Response, error) - - // PutDeviceCollectionAccountWithBody request with any body - PutDeviceCollectionAccountWithBody(ctx context.Context, collectionSlug CollectionSlug, accountSlug AccountSlug, params *PutDeviceCollectionAccountParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - - PutDeviceCollectionAccount(ctx context.Context, collectionSlug CollectionSlug, accountSlug AccountSlug, params *PutDeviceCollectionAccountParams, body PutDeviceCollectionAccountJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - - // DeleteWorkload request - DeleteWorkload(ctx context.Context, collectionSlug CollectionSlug, workloadSlug WorkloadSlug, params *DeleteWorkloadParams, reqEditors ...RequestEditorFn) (*http.Response, error) - - // GetWorkload request - GetWorkload(ctx context.Context, collectionSlug CollectionSlug, workloadSlug WorkloadSlug, params *GetWorkloadParams, reqEditors ...RequestEditorFn) (*http.Response, error) - - // PutWorkloadWithBody request with any body - PutWorkloadWithBody(ctx context.Context, collectionSlug CollectionSlug, workloadSlug WorkloadSlug, params *PutWorkloadParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - - PutWorkload(ctx context.Context, collectionSlug CollectionSlug, workloadSlug WorkloadSlug, params *PutWorkloadParams, body PutWorkloadJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - - // PostDeviceEnrollmentTokenWithBody request with any body - PostDeviceEnrollmentTokenWithBody(ctx context.Context, collectionSlug CollectionSlug, instanceID InstanceID, params *PostDeviceEnrollmentTokenParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - - PostDeviceEnrollmentToken(ctx context.Context, collectionSlug CollectionSlug, instanceID InstanceID, params *PostDeviceEnrollmentTokenParams, body PostDeviceEnrollmentTokenJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - - // GetSshGrants request - GetSshGrants(ctx context.Context, params *GetSshGrantsParams, reqEditors ...RequestEditorFn) (*http.Response, error) - - // PostSshGrantsWithBody request with any body - PostSshGrantsWithBody(ctx context.Context, params *PostSshGrantsParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - - PostSshGrants(ctx context.Context, params *PostSshGrantsParams, body PostSshGrantsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - - // DeleteSshGrant request - DeleteSshGrant(ctx context.Context, grantID GrantID, params *DeleteSshGrantParams, reqEditors ...RequestEditorFn) (*http.Response, error) - - // GetSshGrant request - GetSshGrant(ctx context.Context, grantID GrantID, params *GetSshGrantParams, reqEditors ...RequestEditorFn) (*http.Response, error) - - // GetSshGroups request - GetSshGroups(ctx context.Context, params *GetSshGroupsParams, reqEditors ...RequestEditorFn) (*http.Response, error) - - // GetSshGroup request - GetSshGroup(ctx context.Context, groupID GroupID, params *GetSshGroupParams, reqEditors ...RequestEditorFn) (*http.Response, error) - - // GetSshHosts request - GetSshHosts(ctx context.Context, params *GetSshHostsParams, reqEditors ...RequestEditorFn) (*http.Response, error) - - // GetSshHost request - GetSshHost(ctx context.Context, hostID HostID, params *GetSshHostParams, reqEditors ...RequestEditorFn) (*http.Response, error) - - // PostHostsHostIDTagsWithBody request with any body - PostHostsHostIDTagsWithBody(ctx context.Context, hostID HostID, params *PostHostsHostIDTagsParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - - PostHostsHostIDTags(ctx context.Context, hostID HostID, params *PostHostsHostIDTagsParams, body PostHostsHostIDTagsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - - // UnregisterSshHost request - UnregisterSshHost(ctx context.Context, hostID HostID, params *UnregisterSshHostParams, reqEditors ...RequestEditorFn) (*http.Response, error) - - // GetPlatforms request - GetPlatforms(ctx context.Context, params *GetPlatformsParams, reqEditors ...RequestEditorFn) (*http.Response, error) - - // PutPlatformWithBody request with any body - PutPlatformWithBody(ctx context.Context, platformSlug PlatformSlug, params *PutPlatformParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - - PutPlatform(ctx context.Context, platformSlug PlatformSlug, params *PutPlatformParams, body PutPlatformJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - - // GetSshHostTags request - GetSshHostTags(ctx context.Context, params *GetSshHostTagsParams, reqEditors ...RequestEditorFn) (*http.Response, error) - - // GetSshUsers request - GetSshUsers(ctx context.Context, params *GetSshUsersParams, reqEditors ...RequestEditorFn) (*http.Response, error) -} - -func (c *Client) ListAccounts(ctx context.Context, params *ListAccountsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewListAccountsRequest(c.Server, params) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) PostAccountsWithBody(ctx context.Context, params *PostAccountsParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPostAccountsRequestWithBody(c.Server, params, contentType, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) PostAccounts(ctx context.Context, params *PostAccountsParams, body PostAccountsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPostAccountsRequest(c.Server, params, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) DeleteAccount(ctx context.Context, accountID AccountID, params *DeleteAccountParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewDeleteAccountRequest(c.Server, accountID, params) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) GetAccount(ctx context.Context, accountID AccountID, params *GetAccountParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewGetAccountRequest(c.Server, accountID, params) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) PutAccountWithBody(ctx context.Context, accountID AccountID, params *PutAccountParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPutAccountRequestWithBody(c.Server, accountID, params, contentType, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) PutAccount(ctx context.Context, accountID AccountID, params *PutAccountParams, body PutAccountJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPutAccountRequest(c.Server, accountID, params, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) GetAttestationAuthorities(ctx context.Context, params *GetAttestationAuthoritiesParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewGetAttestationAuthoritiesRequest(c.Server, params) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) PostAttestationAuthoritiesWithBody(ctx context.Context, params *PostAttestationAuthoritiesParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPostAttestationAuthoritiesRequestWithBody(c.Server, params, contentType, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) PostAttestationAuthorities(ctx context.Context, params *PostAttestationAuthoritiesParams, body PostAttestationAuthoritiesJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPostAttestationAuthoritiesRequest(c.Server, params, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) DeleteAttestationAuthority(ctx context.Context, attestationAuthorityID AttestationAuthorityID, params *DeleteAttestationAuthorityParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewDeleteAttestationAuthorityRequest(c.Server, attestationAuthorityID, params) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) GetAttestationAuthority(ctx context.Context, attestationAuthorityID AttestationAuthorityID, params *GetAttestationAuthorityParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewGetAttestationAuthorityRequest(c.Server, attestationAuthorityID, params) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) PostAuthWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPostAuthRequestWithBody(c.Server, contentType, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) PostAuth(ctx context.Context, body PostAuthJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPostAuthRequest(c.Server, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) GetAuthorities(ctx context.Context, params *GetAuthoritiesParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewGetAuthoritiesRequest(c.Server, params) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) PostAuthoritiesWithBody(ctx context.Context, params *PostAuthoritiesParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPostAuthoritiesRequestWithBody(c.Server, params, contentType, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) PostAuthorities(ctx context.Context, params *PostAuthoritiesParams, body PostAuthoritiesJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPostAuthoritiesRequest(c.Server, params, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) PostAuthoritiesCsrWithBody(ctx context.Context, params *PostAuthoritiesCsrParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPostAuthoritiesCsrRequestWithBody(c.Server, params, contentType, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) PostAuthoritiesCsr(ctx context.Context, params *PostAuthoritiesCsrParams, body PostAuthoritiesCsrJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPostAuthoritiesCsrRequest(c.Server, params, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) DeleteAuthority(ctx context.Context, authorityDomainOrID AuthorityDomainOrID, params *DeleteAuthorityParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewDeleteAuthorityRequest(c.Server, authorityDomainOrID, params) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) GetAuthority(ctx context.Context, authorityDomainOrID AuthorityDomainOrID, params *GetAuthorityParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewGetAuthorityRequest(c.Server, authorityDomainOrID, params) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) ListAuthorityProvisioners(ctx context.Context, authorityID AuthorityID, params *ListAuthorityProvisionersParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewListAuthorityProvisionersRequest(c.Server, authorityID, params) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) PostAuthorityProvisionersWithBody(ctx context.Context, authorityID AuthorityID, params *PostAuthorityProvisionersParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPostAuthorityProvisionersRequestWithBody(c.Server, authorityID, params, contentType, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) PostAuthorityProvisioners(ctx context.Context, authorityID AuthorityID, params *PostAuthorityProvisionersParams, body PostAuthorityProvisionersJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPostAuthorityProvisionersRequest(c.Server, authorityID, params, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) DeleteProvisioner(ctx context.Context, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, params *DeleteProvisionerParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewDeleteProvisionerRequest(c.Server, authorityID, provisionerNameOrID, params) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) GetProvisioner(ctx context.Context, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, params *GetProvisionerParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewGetProvisionerRequest(c.Server, authorityID, provisionerNameOrID, params) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) PostWebhooksWithBody(ctx context.Context, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, params *PostWebhooksParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPostWebhooksRequestWithBody(c.Server, authorityID, provisionerNameOrID, params, contentType, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) PostWebhooks(ctx context.Context, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, params *PostWebhooksParams, body PostWebhooksJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPostWebhooksRequest(c.Server, authorityID, provisionerNameOrID, params, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) DeleteWebhook(ctx context.Context, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, webhookNameOrID WebhookNameOrID, params *DeleteWebhookParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewDeleteWebhookRequest(c.Server, authorityID, provisionerNameOrID, webhookNameOrID, params) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) GetWebhook(ctx context.Context, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, webhookNameOrID WebhookNameOrID, params *GetWebhookParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewGetWebhookRequest(c.Server, authorityID, provisionerNameOrID, webhookNameOrID, params) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) PostAuthorityRootWithBody(ctx context.Context, authorityID AuthorityID, params *PostAuthorityRootParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPostAuthorityRootRequestWithBody(c.Server, authorityID, params, contentType, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) PostAuthorityRoot(ctx context.Context, authorityID AuthorityID, params *PostAuthorityRootParams, body PostAuthorityRootJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPostAuthorityRootRequest(c.Server, authorityID, params, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) ListCertificates(ctx context.Context, params *ListCertificatesParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewListCertificatesRequest(c.Server, params) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) GetCertificate(ctx context.Context, serialNumber SerialNumber, params *GetCertificateParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewGetCertificateRequest(c.Server, serialNumber, params) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) ListCollections(ctx context.Context, params *ListCollectionsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewListCollectionsRequest(c.Server, params) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) PostCollectionsWithBody(ctx context.Context, params *PostCollectionsParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPostCollectionsRequestWithBody(c.Server, params, contentType, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) PostCollections(ctx context.Context, params *PostCollectionsParams, body PostCollectionsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPostCollectionsRequest(c.Server, params, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) DeleteCollection(ctx context.Context, collectionSlug CollectionSlug, params *DeleteCollectionParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewDeleteCollectionRequest(c.Server, collectionSlug, params) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) GetCollection(ctx context.Context, collectionSlug CollectionSlug, params *GetCollectionParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewGetCollectionRequest(c.Server, collectionSlug, params) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) PutCollectionWithBody(ctx context.Context, collectionSlug CollectionSlug, params *PutCollectionParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPutCollectionRequestWithBody(c.Server, collectionSlug, params, contentType, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) PutCollection(ctx context.Context, collectionSlug CollectionSlug, params *PutCollectionParams, body PutCollectionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPutCollectionRequest(c.Server, collectionSlug, params, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) DeleteCollectionInstance(ctx context.Context, collectionSlug CollectionSlug, instanceID InstanceID, params *DeleteCollectionInstanceParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewDeleteCollectionInstanceRequest(c.Server, collectionSlug, instanceID, params) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) GetCollectionInstance(ctx context.Context, collectionSlug CollectionSlug, instanceID InstanceID, params *GetCollectionInstanceParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewGetCollectionInstanceRequest(c.Server, collectionSlug, instanceID, params) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) PutCollectionInstanceWithBody(ctx context.Context, collectionSlug CollectionSlug, instanceID InstanceID, params *PutCollectionInstanceParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPutCollectionInstanceRequestWithBody(c.Server, collectionSlug, instanceID, params, contentType, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) PutCollectionInstance(ctx context.Context, collectionSlug CollectionSlug, instanceID InstanceID, params *PutCollectionInstanceParams, body PutCollectionInstanceJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPutCollectionInstanceRequest(c.Server, collectionSlug, instanceID, params, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) GetCollectionInstanceData(ctx context.Context, collectionSlug CollectionSlug, instanceID InstanceID, params *GetCollectionInstanceDataParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewGetCollectionInstanceDataRequest(c.Server, collectionSlug, instanceID, params) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) PutCollectionInstanceDataWithBody(ctx context.Context, collectionSlug CollectionSlug, instanceID InstanceID, params *PutCollectionInstanceDataParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPutCollectionInstanceDataRequestWithBody(c.Server, collectionSlug, instanceID, params, contentType, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) PutCollectionInstanceData(ctx context.Context, collectionSlug CollectionSlug, instanceID InstanceID, params *PutCollectionInstanceDataParams, body PutCollectionInstanceDataJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPutCollectionInstanceDataRequest(c.Server, collectionSlug, instanceID, params, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) ListCollectionInstances(ctx context.Context, collectionSlug CollectionSlug, params *ListCollectionInstancesParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewListCollectionInstancesRequest(c.Server, collectionSlug, params) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) DeleteDeviceCollection(ctx context.Context, collectionSlug CollectionSlug, params *DeleteDeviceCollectionParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewDeleteDeviceCollectionRequest(c.Server, collectionSlug, params) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) GetDeviceCollection(ctx context.Context, collectionSlug CollectionSlug, params *GetDeviceCollectionParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewGetDeviceCollectionRequest(c.Server, collectionSlug, params) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) PutDeviceCollectionWithBody(ctx context.Context, collectionSlug CollectionSlug, params *PutDeviceCollectionParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPutDeviceCollectionRequestWithBody(c.Server, collectionSlug, params, contentType, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) PutDeviceCollection(ctx context.Context, collectionSlug CollectionSlug, params *PutDeviceCollectionParams, body PutDeviceCollectionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPutDeviceCollectionRequest(c.Server, collectionSlug, params, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) DeleteDeviceCollectionAccount(ctx context.Context, collectionSlug CollectionSlug, accountSlug AccountSlug, params *DeleteDeviceCollectionAccountParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewDeleteDeviceCollectionAccountRequest(c.Server, collectionSlug, accountSlug, params) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) GetDeviceCollectionAccount(ctx context.Context, collectionSlug CollectionSlug, accountSlug AccountSlug, params *GetDeviceCollectionAccountParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewGetDeviceCollectionAccountRequest(c.Server, collectionSlug, accountSlug, params) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) PutDeviceCollectionAccountWithBody(ctx context.Context, collectionSlug CollectionSlug, accountSlug AccountSlug, params *PutDeviceCollectionAccountParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPutDeviceCollectionAccountRequestWithBody(c.Server, collectionSlug, accountSlug, params, contentType, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) PutDeviceCollectionAccount(ctx context.Context, collectionSlug CollectionSlug, accountSlug AccountSlug, params *PutDeviceCollectionAccountParams, body PutDeviceCollectionAccountJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPutDeviceCollectionAccountRequest(c.Server, collectionSlug, accountSlug, params, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) DeleteWorkload(ctx context.Context, collectionSlug CollectionSlug, workloadSlug WorkloadSlug, params *DeleteWorkloadParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewDeleteWorkloadRequest(c.Server, collectionSlug, workloadSlug, params) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) GetWorkload(ctx context.Context, collectionSlug CollectionSlug, workloadSlug WorkloadSlug, params *GetWorkloadParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewGetWorkloadRequest(c.Server, collectionSlug, workloadSlug, params) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) PutWorkloadWithBody(ctx context.Context, collectionSlug CollectionSlug, workloadSlug WorkloadSlug, params *PutWorkloadParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPutWorkloadRequestWithBody(c.Server, collectionSlug, workloadSlug, params, contentType, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) PutWorkload(ctx context.Context, collectionSlug CollectionSlug, workloadSlug WorkloadSlug, params *PutWorkloadParams, body PutWorkloadJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPutWorkloadRequest(c.Server, collectionSlug, workloadSlug, params, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) PostDeviceEnrollmentTokenWithBody(ctx context.Context, collectionSlug CollectionSlug, instanceID InstanceID, params *PostDeviceEnrollmentTokenParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPostDeviceEnrollmentTokenRequestWithBody(c.Server, collectionSlug, instanceID, params, contentType, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) PostDeviceEnrollmentToken(ctx context.Context, collectionSlug CollectionSlug, instanceID InstanceID, params *PostDeviceEnrollmentTokenParams, body PostDeviceEnrollmentTokenJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPostDeviceEnrollmentTokenRequest(c.Server, collectionSlug, instanceID, params, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) GetSshGrants(ctx context.Context, params *GetSshGrantsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewGetSshGrantsRequest(c.Server, params) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) PostSshGrantsWithBody(ctx context.Context, params *PostSshGrantsParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPostSshGrantsRequestWithBody(c.Server, params, contentType, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) PostSshGrants(ctx context.Context, params *PostSshGrantsParams, body PostSshGrantsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPostSshGrantsRequest(c.Server, params, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) DeleteSshGrant(ctx context.Context, grantID GrantID, params *DeleteSshGrantParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewDeleteSshGrantRequest(c.Server, grantID, params) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) GetSshGrant(ctx context.Context, grantID GrantID, params *GetSshGrantParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewGetSshGrantRequest(c.Server, grantID, params) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) GetSshGroups(ctx context.Context, params *GetSshGroupsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewGetSshGroupsRequest(c.Server, params) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) GetSshGroup(ctx context.Context, groupID GroupID, params *GetSshGroupParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewGetSshGroupRequest(c.Server, groupID, params) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) GetSshHosts(ctx context.Context, params *GetSshHostsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewGetSshHostsRequest(c.Server, params) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) GetSshHost(ctx context.Context, hostID HostID, params *GetSshHostParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewGetSshHostRequest(c.Server, hostID, params) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) PostHostsHostIDTagsWithBody(ctx context.Context, hostID HostID, params *PostHostsHostIDTagsParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPostHostsHostIDTagsRequestWithBody(c.Server, hostID, params, contentType, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) PostHostsHostIDTags(ctx context.Context, hostID HostID, params *PostHostsHostIDTagsParams, body PostHostsHostIDTagsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPostHostsHostIDTagsRequest(c.Server, hostID, params, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) UnregisterSshHost(ctx context.Context, hostID HostID, params *UnregisterSshHostParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewUnregisterSshHostRequest(c.Server, hostID, params) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) GetPlatforms(ctx context.Context, params *GetPlatformsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewGetPlatformsRequest(c.Server, params) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) PutPlatformWithBody(ctx context.Context, platformSlug PlatformSlug, params *PutPlatformParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPutPlatformRequestWithBody(c.Server, platformSlug, params, contentType, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) PutPlatform(ctx context.Context, platformSlug PlatformSlug, params *PutPlatformParams, body PutPlatformJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPutPlatformRequest(c.Server, platformSlug, params, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) GetSshHostTags(ctx context.Context, params *GetSshHostTagsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewGetSshHostTagsRequest(c.Server, params) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) GetSshUsers(ctx context.Context, params *GetSshUsersParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewGetSshUsersRequest(c.Server, params) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -// NewListAccountsRequest generates requests for ListAccounts -func NewListAccountsRequest(server string, params *ListAccountsParams) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/accounts") - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - if params != nil { - queryValues := queryURL.Query() - - if params.Pagination != nil { - - if queryFrag, err := runtime.StyleParamWithLocation("deepObject", true, "pagination", runtime.ParamLocationQuery, *params.Pagination); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - - } - - queryURL.RawQuery = queryValues.Encode() - } - - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { - return nil, err - } - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewPostAccountsRequest calls the generic PostAccounts builder with application/json body -func NewPostAccountsRequest(server string, params *PostAccountsParams, body PostAccountsJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - return NewPostAccountsRequestWithBody(server, params, "application/json", bodyReader) -} - -// NewPostAccountsRequestWithBody generates requests for PostAccounts with any type of body -func NewPostAccountsRequestWithBody(server string, params *PostAccountsParams, contentType string, body io.Reader) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/accounts") - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("POST", queryURL.String(), body) - if err != nil { - return nil, err - } - - req.Header.Add("Content-Type", contentType) - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewDeleteAccountRequest generates requests for DeleteAccount -func NewDeleteAccountRequest(server string, accountID AccountID, params *DeleteAccountParams) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "accountID", runtime.ParamLocationPath, accountID) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/accounts/%s", pathParam0) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("DELETE", queryURL.String(), nil) - if err != nil { - return nil, err - } - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewGetAccountRequest generates requests for GetAccount -func NewGetAccountRequest(server string, accountID AccountID, params *GetAccountParams) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "accountID", runtime.ParamLocationPath, accountID) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/accounts/%s", pathParam0) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { - return nil, err - } - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewPutAccountRequest calls the generic PutAccount builder with application/json body -func NewPutAccountRequest(server string, accountID AccountID, params *PutAccountParams, body PutAccountJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - return NewPutAccountRequestWithBody(server, accountID, params, "application/json", bodyReader) -} - -// NewPutAccountRequestWithBody generates requests for PutAccount with any type of body -func NewPutAccountRequestWithBody(server string, accountID AccountID, params *PutAccountParams, contentType string, body io.Reader) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "accountID", runtime.ParamLocationPath, accountID) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/accounts/%s", pathParam0) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("PUT", queryURL.String(), body) - if err != nil { - return nil, err - } - - req.Header.Add("Content-Type", contentType) - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewGetAttestationAuthoritiesRequest generates requests for GetAttestationAuthorities -func NewGetAttestationAuthoritiesRequest(server string, params *GetAttestationAuthoritiesParams) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/attestation-authorities") - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { - return nil, err - } - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewPostAttestationAuthoritiesRequest calls the generic PostAttestationAuthorities builder with application/json body -func NewPostAttestationAuthoritiesRequest(server string, params *PostAttestationAuthoritiesParams, body PostAttestationAuthoritiesJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - return NewPostAttestationAuthoritiesRequestWithBody(server, params, "application/json", bodyReader) -} - -// NewPostAttestationAuthoritiesRequestWithBody generates requests for PostAttestationAuthorities with any type of body -func NewPostAttestationAuthoritiesRequestWithBody(server string, params *PostAttestationAuthoritiesParams, contentType string, body io.Reader) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/attestation-authorities") - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("POST", queryURL.String(), body) - if err != nil { - return nil, err - } - - req.Header.Add("Content-Type", contentType) - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewDeleteAttestationAuthorityRequest generates requests for DeleteAttestationAuthority -func NewDeleteAttestationAuthorityRequest(server string, attestationAuthorityID AttestationAuthorityID, params *DeleteAttestationAuthorityParams) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "attestationAuthorityID", runtime.ParamLocationPath, attestationAuthorityID) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/attestation-authorities/%s", pathParam0) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("DELETE", queryURL.String(), nil) - if err != nil { - return nil, err - } - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewGetAttestationAuthorityRequest generates requests for GetAttestationAuthority -func NewGetAttestationAuthorityRequest(server string, attestationAuthorityID AttestationAuthorityID, params *GetAttestationAuthorityParams) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "attestationAuthorityID", runtime.ParamLocationPath, attestationAuthorityID) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/attestation-authorities/%s", pathParam0) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { - return nil, err - } - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewPostAuthRequest calls the generic PostAuth builder with application/json body -func NewPostAuthRequest(server string, body PostAuthJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - return NewPostAuthRequestWithBody(server, "application/json", bodyReader) -} - -// NewPostAuthRequestWithBody generates requests for PostAuth with any type of body -func NewPostAuthRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/auth") - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("POST", queryURL.String(), body) - if err != nil { - return nil, err - } - - req.Header.Add("Content-Type", contentType) - - return req, nil -} - -// NewGetAuthoritiesRequest generates requests for GetAuthorities -func NewGetAuthoritiesRequest(server string, params *GetAuthoritiesParams) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/authorities") - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { - return nil, err - } - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewPostAuthoritiesRequest calls the generic PostAuthorities builder with application/json body -func NewPostAuthoritiesRequest(server string, params *PostAuthoritiesParams, body PostAuthoritiesJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - return NewPostAuthoritiesRequestWithBody(server, params, "application/json", bodyReader) -} - -// NewPostAuthoritiesRequestWithBody generates requests for PostAuthorities with any type of body -func NewPostAuthoritiesRequestWithBody(server string, params *PostAuthoritiesParams, contentType string, body io.Reader) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/authorities") - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("POST", queryURL.String(), body) - if err != nil { - return nil, err - } - - req.Header.Add("Content-Type", contentType) - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewPostAuthoritiesCsrRequest calls the generic PostAuthoritiesCsr builder with application/json body -func NewPostAuthoritiesCsrRequest(server string, params *PostAuthoritiesCsrParams, body PostAuthoritiesCsrJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - return NewPostAuthoritiesCsrRequestWithBody(server, params, "application/json", bodyReader) -} - -// NewPostAuthoritiesCsrRequestWithBody generates requests for PostAuthoritiesCsr with any type of body -func NewPostAuthoritiesCsrRequestWithBody(server string, params *PostAuthoritiesCsrParams, contentType string, body io.Reader) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/authorities/csr") - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("POST", queryURL.String(), body) - if err != nil { - return nil, err - } - - req.Header.Add("Content-Type", contentType) - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewDeleteAuthorityRequest generates requests for DeleteAuthority -func NewDeleteAuthorityRequest(server string, authorityDomainOrID AuthorityDomainOrID, params *DeleteAuthorityParams) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "authorityDomainOrID", runtime.ParamLocationPath, authorityDomainOrID) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/authorities/%s", pathParam0) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("DELETE", queryURL.String(), nil) - if err != nil { - return nil, err - } - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewGetAuthorityRequest generates requests for GetAuthority -func NewGetAuthorityRequest(server string, authorityDomainOrID AuthorityDomainOrID, params *GetAuthorityParams) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "authorityDomainOrID", runtime.ParamLocationPath, authorityDomainOrID) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/authorities/%s", pathParam0) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { - return nil, err - } - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewListAuthorityProvisionersRequest generates requests for ListAuthorityProvisioners -func NewListAuthorityProvisionersRequest(server string, authorityID AuthorityID, params *ListAuthorityProvisionersParams) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "authorityID", runtime.ParamLocationPath, authorityID) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/authorities/%s/provisioners", pathParam0) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { - return nil, err - } - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewPostAuthorityProvisionersRequest calls the generic PostAuthorityProvisioners builder with application/json body -func NewPostAuthorityProvisionersRequest(server string, authorityID AuthorityID, params *PostAuthorityProvisionersParams, body PostAuthorityProvisionersJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - return NewPostAuthorityProvisionersRequestWithBody(server, authorityID, params, "application/json", bodyReader) -} - -// NewPostAuthorityProvisionersRequestWithBody generates requests for PostAuthorityProvisioners with any type of body -func NewPostAuthorityProvisionersRequestWithBody(server string, authorityID AuthorityID, params *PostAuthorityProvisionersParams, contentType string, body io.Reader) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "authorityID", runtime.ParamLocationPath, authorityID) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/authorities/%s/provisioners", pathParam0) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("POST", queryURL.String(), body) - if err != nil { - return nil, err - } - - req.Header.Add("Content-Type", contentType) - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewDeleteProvisionerRequest generates requests for DeleteProvisioner -func NewDeleteProvisionerRequest(server string, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, params *DeleteProvisionerParams) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "authorityID", runtime.ParamLocationPath, authorityID) - if err != nil { - return nil, err - } - - var pathParam1 string - - pathParam1, err = runtime.StyleParamWithLocation("simple", false, "provisionerNameOrID", runtime.ParamLocationPath, provisionerNameOrID) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/authorities/%s/provisioners/%s", pathParam0, pathParam1) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("DELETE", queryURL.String(), nil) - if err != nil { - return nil, err - } - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewGetProvisionerRequest generates requests for GetProvisioner -func NewGetProvisionerRequest(server string, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, params *GetProvisionerParams) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "authorityID", runtime.ParamLocationPath, authorityID) - if err != nil { - return nil, err - } - - var pathParam1 string - - pathParam1, err = runtime.StyleParamWithLocation("simple", false, "provisionerNameOrID", runtime.ParamLocationPath, provisionerNameOrID) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/authorities/%s/provisioners/%s", pathParam0, pathParam1) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { - return nil, err - } - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewPostWebhooksRequest calls the generic PostWebhooks builder with application/json body -func NewPostWebhooksRequest(server string, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, params *PostWebhooksParams, body PostWebhooksJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - return NewPostWebhooksRequestWithBody(server, authorityID, provisionerNameOrID, params, "application/json", bodyReader) -} - -// NewPostWebhooksRequestWithBody generates requests for PostWebhooks with any type of body -func NewPostWebhooksRequestWithBody(server string, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, params *PostWebhooksParams, contentType string, body io.Reader) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "authorityID", runtime.ParamLocationPath, authorityID) - if err != nil { - return nil, err - } - - var pathParam1 string - - pathParam1, err = runtime.StyleParamWithLocation("simple", false, "provisionerNameOrID", runtime.ParamLocationPath, provisionerNameOrID) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/authorities/%s/provisioners/%s/webhooks", pathParam0, pathParam1) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("POST", queryURL.String(), body) - if err != nil { - return nil, err - } - - req.Header.Add("Content-Type", contentType) - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewDeleteWebhookRequest generates requests for DeleteWebhook -func NewDeleteWebhookRequest(server string, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, webhookNameOrID WebhookNameOrID, params *DeleteWebhookParams) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "authorityID", runtime.ParamLocationPath, authorityID) - if err != nil { - return nil, err - } - - var pathParam1 string - - pathParam1, err = runtime.StyleParamWithLocation("simple", false, "provisionerNameOrID", runtime.ParamLocationPath, provisionerNameOrID) - if err != nil { - return nil, err - } - - var pathParam2 string - - pathParam2, err = runtime.StyleParamWithLocation("simple", false, "webhookNameOrID", runtime.ParamLocationPath, webhookNameOrID) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/authorities/%s/provisioners/%s/webhooks/%s", pathParam0, pathParam1, pathParam2) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("DELETE", queryURL.String(), nil) - if err != nil { - return nil, err - } - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewGetWebhookRequest generates requests for GetWebhook -func NewGetWebhookRequest(server string, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, webhookNameOrID WebhookNameOrID, params *GetWebhookParams) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "authorityID", runtime.ParamLocationPath, authorityID) - if err != nil { - return nil, err - } - - var pathParam1 string - - pathParam1, err = runtime.StyleParamWithLocation("simple", false, "provisionerNameOrID", runtime.ParamLocationPath, provisionerNameOrID) - if err != nil { - return nil, err - } - - var pathParam2 string - - pathParam2, err = runtime.StyleParamWithLocation("simple", false, "webhookNameOrID", runtime.ParamLocationPath, webhookNameOrID) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/authorities/%s/provisioners/%s/webhooks/%s", pathParam0, pathParam1, pathParam2) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { - return nil, err - } - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewPostAuthorityRootRequest calls the generic PostAuthorityRoot builder with application/json body -func NewPostAuthorityRootRequest(server string, authorityID AuthorityID, params *PostAuthorityRootParams, body PostAuthorityRootJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - return NewPostAuthorityRootRequestWithBody(server, authorityID, params, "application/json", bodyReader) -} - -// NewPostAuthorityRootRequestWithBody generates requests for PostAuthorityRoot with any type of body -func NewPostAuthorityRootRequestWithBody(server string, authorityID AuthorityID, params *PostAuthorityRootParams, contentType string, body io.Reader) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "authorityID", runtime.ParamLocationPath, authorityID) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/authorities/%s/root", pathParam0) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("POST", queryURL.String(), body) - if err != nil { - return nil, err - } - - req.Header.Add("Content-Type", contentType) - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewListCertificatesRequest generates requests for ListCertificates -func NewListCertificatesRequest(server string, params *ListCertificatesParams) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/certificates") - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - if params != nil { - queryValues := queryURL.Query() - - if params.Pagination != nil { - - if queryFrag, err := runtime.StyleParamWithLocation("deepObject", true, "pagination", runtime.ParamLocationQuery, *params.Pagination); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - - } - - queryURL.RawQuery = queryValues.Encode() - } - - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { - return nil, err - } - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewGetCertificateRequest generates requests for GetCertificate -func NewGetCertificateRequest(server string, serialNumber SerialNumber, params *GetCertificateParams) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "serialNumber", runtime.ParamLocationPath, serialNumber) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/certificates/%s", pathParam0) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { - return nil, err - } - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewListCollectionsRequest generates requests for ListCollections -func NewListCollectionsRequest(server string, params *ListCollectionsParams) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/collections") - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - if params != nil { - queryValues := queryURL.Query() - - if params.Pagination != nil { - - if queryFrag, err := runtime.StyleParamWithLocation("deepObject", true, "pagination", runtime.ParamLocationQuery, *params.Pagination); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - - } - - queryURL.RawQuery = queryValues.Encode() - } - - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { - return nil, err - } - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewPostCollectionsRequest calls the generic PostCollections builder with application/json body -func NewPostCollectionsRequest(server string, params *PostCollectionsParams, body PostCollectionsJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - return NewPostCollectionsRequestWithBody(server, params, "application/json", bodyReader) -} - -// NewPostCollectionsRequestWithBody generates requests for PostCollections with any type of body -func NewPostCollectionsRequestWithBody(server string, params *PostCollectionsParams, contentType string, body io.Reader) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/collections") - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("POST", queryURL.String(), body) - if err != nil { - return nil, err - } - - req.Header.Add("Content-Type", contentType) - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewDeleteCollectionRequest generates requests for DeleteCollection -func NewDeleteCollectionRequest(server string, collectionSlug CollectionSlug, params *DeleteCollectionParams) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "collectionSlug", runtime.ParamLocationPath, collectionSlug) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/collections/%s", pathParam0) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("DELETE", queryURL.String(), nil) - if err != nil { - return nil, err - } - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewGetCollectionRequest generates requests for GetCollection -func NewGetCollectionRequest(server string, collectionSlug CollectionSlug, params *GetCollectionParams) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "collectionSlug", runtime.ParamLocationPath, collectionSlug) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/collections/%s", pathParam0) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { - return nil, err - } - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewPutCollectionRequest calls the generic PutCollection builder with application/json body -func NewPutCollectionRequest(server string, collectionSlug CollectionSlug, params *PutCollectionParams, body PutCollectionJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - return NewPutCollectionRequestWithBody(server, collectionSlug, params, "application/json", bodyReader) -} - -// NewPutCollectionRequestWithBody generates requests for PutCollection with any type of body -func NewPutCollectionRequestWithBody(server string, collectionSlug CollectionSlug, params *PutCollectionParams, contentType string, body io.Reader) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "collectionSlug", runtime.ParamLocationPath, collectionSlug) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/collections/%s", pathParam0) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("PUT", queryURL.String(), body) - if err != nil { - return nil, err - } - - req.Header.Add("Content-Type", contentType) - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewDeleteCollectionInstanceRequest generates requests for DeleteCollectionInstance -func NewDeleteCollectionInstanceRequest(server string, collectionSlug CollectionSlug, instanceID InstanceID, params *DeleteCollectionInstanceParams) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "collectionSlug", runtime.ParamLocationPath, collectionSlug) - if err != nil { - return nil, err - } - - var pathParam1 string - - pathParam1, err = runtime.StyleParamWithLocation("simple", false, "instanceID", runtime.ParamLocationPath, instanceID) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/collections/%s/instances/%s", pathParam0, pathParam1) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("DELETE", queryURL.String(), nil) - if err != nil { - return nil, err - } - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewGetCollectionInstanceRequest generates requests for GetCollectionInstance -func NewGetCollectionInstanceRequest(server string, collectionSlug CollectionSlug, instanceID InstanceID, params *GetCollectionInstanceParams) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "collectionSlug", runtime.ParamLocationPath, collectionSlug) - if err != nil { - return nil, err - } - - var pathParam1 string - - pathParam1, err = runtime.StyleParamWithLocation("simple", false, "instanceID", runtime.ParamLocationPath, instanceID) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/collections/%s/instances/%s", pathParam0, pathParam1) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { - return nil, err - } - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewPutCollectionInstanceRequest calls the generic PutCollectionInstance builder with application/json body -func NewPutCollectionInstanceRequest(server string, collectionSlug CollectionSlug, instanceID InstanceID, params *PutCollectionInstanceParams, body PutCollectionInstanceJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - return NewPutCollectionInstanceRequestWithBody(server, collectionSlug, instanceID, params, "application/json", bodyReader) -} - -// NewPutCollectionInstanceRequestWithBody generates requests for PutCollectionInstance with any type of body -func NewPutCollectionInstanceRequestWithBody(server string, collectionSlug CollectionSlug, instanceID InstanceID, params *PutCollectionInstanceParams, contentType string, body io.Reader) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "collectionSlug", runtime.ParamLocationPath, collectionSlug) - if err != nil { - return nil, err - } - - var pathParam1 string - - pathParam1, err = runtime.StyleParamWithLocation("simple", false, "instanceID", runtime.ParamLocationPath, instanceID) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/collections/%s/instances/%s", pathParam0, pathParam1) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("PUT", queryURL.String(), body) - if err != nil { - return nil, err - } - - req.Header.Add("Content-Type", contentType) - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewGetCollectionInstanceDataRequest generates requests for GetCollectionInstanceData -func NewGetCollectionInstanceDataRequest(server string, collectionSlug CollectionSlug, instanceID InstanceID, params *GetCollectionInstanceDataParams) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "collectionSlug", runtime.ParamLocationPath, collectionSlug) - if err != nil { - return nil, err - } - - var pathParam1 string - - pathParam1, err = runtime.StyleParamWithLocation("simple", false, "instanceID", runtime.ParamLocationPath, instanceID) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/collections/%s/instances/%s/data", pathParam0, pathParam1) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { - return nil, err - } - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewPutCollectionInstanceDataRequest calls the generic PutCollectionInstanceData builder with application/json body -func NewPutCollectionInstanceDataRequest(server string, collectionSlug CollectionSlug, instanceID InstanceID, params *PutCollectionInstanceDataParams, body PutCollectionInstanceDataJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - return NewPutCollectionInstanceDataRequestWithBody(server, collectionSlug, instanceID, params, "application/json", bodyReader) -} - -// NewPutCollectionInstanceDataRequestWithBody generates requests for PutCollectionInstanceData with any type of body -func NewPutCollectionInstanceDataRequestWithBody(server string, collectionSlug CollectionSlug, instanceID InstanceID, params *PutCollectionInstanceDataParams, contentType string, body io.Reader) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "collectionSlug", runtime.ParamLocationPath, collectionSlug) - if err != nil { - return nil, err - } - - var pathParam1 string - - pathParam1, err = runtime.StyleParamWithLocation("simple", false, "instanceID", runtime.ParamLocationPath, instanceID) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/collections/%s/instances/%s/data", pathParam0, pathParam1) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("PUT", queryURL.String(), body) - if err != nil { - return nil, err - } - - req.Header.Add("Content-Type", contentType) - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewListCollectionInstancesRequest generates requests for ListCollectionInstances -func NewListCollectionInstancesRequest(server string, collectionSlug CollectionSlug, params *ListCollectionInstancesParams) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "collectionSlug", runtime.ParamLocationPath, collectionSlug) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/collections/%s/items", pathParam0) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - if params != nil { - queryValues := queryURL.Query() - - if params.Pagination != nil { - - if queryFrag, err := runtime.StyleParamWithLocation("deepObject", true, "pagination", runtime.ParamLocationQuery, *params.Pagination); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - - } - - queryURL.RawQuery = queryValues.Encode() - } - - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { - return nil, err - } - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewDeleteDeviceCollectionRequest generates requests for DeleteDeviceCollection -func NewDeleteDeviceCollectionRequest(server string, collectionSlug CollectionSlug, params *DeleteDeviceCollectionParams) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "collectionSlug", runtime.ParamLocationPath, collectionSlug) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/device-collections/%s", pathParam0) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - if params != nil { - queryValues := queryURL.Query() - - if params.Purge != nil { - - if queryFrag, err := runtime.StyleParamWithLocation("form", true, "purge", runtime.ParamLocationQuery, *params.Purge); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - - } - - queryURL.RawQuery = queryValues.Encode() - } - - req, err := http.NewRequest("DELETE", queryURL.String(), nil) - if err != nil { - return nil, err - } - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewGetDeviceCollectionRequest generates requests for GetDeviceCollection -func NewGetDeviceCollectionRequest(server string, collectionSlug CollectionSlug, params *GetDeviceCollectionParams) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "collectionSlug", runtime.ParamLocationPath, collectionSlug) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/device-collections/%s", pathParam0) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { - return nil, err - } - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewPutDeviceCollectionRequest calls the generic PutDeviceCollection builder with application/json body -func NewPutDeviceCollectionRequest(server string, collectionSlug CollectionSlug, params *PutDeviceCollectionParams, body PutDeviceCollectionJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - return NewPutDeviceCollectionRequestWithBody(server, collectionSlug, params, "application/json", bodyReader) -} - -// NewPutDeviceCollectionRequestWithBody generates requests for PutDeviceCollection with any type of body -func NewPutDeviceCollectionRequestWithBody(server string, collectionSlug CollectionSlug, params *PutDeviceCollectionParams, contentType string, body io.Reader) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "collectionSlug", runtime.ParamLocationPath, collectionSlug) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/device-collections/%s", pathParam0) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("PUT", queryURL.String(), body) - if err != nil { - return nil, err - } - - req.Header.Add("Content-Type", contentType) - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewDeleteDeviceCollectionAccountRequest generates requests for DeleteDeviceCollectionAccount -func NewDeleteDeviceCollectionAccountRequest(server string, collectionSlug CollectionSlug, accountSlug AccountSlug, params *DeleteDeviceCollectionAccountParams) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "collectionSlug", runtime.ParamLocationPath, collectionSlug) - if err != nil { - return nil, err - } - - var pathParam1 string - - pathParam1, err = runtime.StyleParamWithLocation("simple", false, "accountSlug", runtime.ParamLocationPath, accountSlug) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/device-collections/%s/accounts/%s", pathParam0, pathParam1) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("DELETE", queryURL.String(), nil) - if err != nil { - return nil, err - } - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewGetDeviceCollectionAccountRequest generates requests for GetDeviceCollectionAccount -func NewGetDeviceCollectionAccountRequest(server string, collectionSlug CollectionSlug, accountSlug AccountSlug, params *GetDeviceCollectionAccountParams) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "collectionSlug", runtime.ParamLocationPath, collectionSlug) - if err != nil { - return nil, err - } - - var pathParam1 string - - pathParam1, err = runtime.StyleParamWithLocation("simple", false, "accountSlug", runtime.ParamLocationPath, accountSlug) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/device-collections/%s/accounts/%s", pathParam0, pathParam1) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { - return nil, err - } - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewPutDeviceCollectionAccountRequest calls the generic PutDeviceCollectionAccount builder with application/json body -func NewPutDeviceCollectionAccountRequest(server string, collectionSlug CollectionSlug, accountSlug AccountSlug, params *PutDeviceCollectionAccountParams, body PutDeviceCollectionAccountJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - return NewPutDeviceCollectionAccountRequestWithBody(server, collectionSlug, accountSlug, params, "application/json", bodyReader) -} - -// NewPutDeviceCollectionAccountRequestWithBody generates requests for PutDeviceCollectionAccount with any type of body -func NewPutDeviceCollectionAccountRequestWithBody(server string, collectionSlug CollectionSlug, accountSlug AccountSlug, params *PutDeviceCollectionAccountParams, contentType string, body io.Reader) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "collectionSlug", runtime.ParamLocationPath, collectionSlug) - if err != nil { - return nil, err - } - - var pathParam1 string - - pathParam1, err = runtime.StyleParamWithLocation("simple", false, "accountSlug", runtime.ParamLocationPath, accountSlug) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/device-collections/%s/accounts/%s", pathParam0, pathParam1) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("PUT", queryURL.String(), body) - if err != nil { - return nil, err - } - - req.Header.Add("Content-Type", contentType) - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewDeleteWorkloadRequest generates requests for DeleteWorkload -func NewDeleteWorkloadRequest(server string, collectionSlug CollectionSlug, workloadSlug WorkloadSlug, params *DeleteWorkloadParams) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "collectionSlug", runtime.ParamLocationPath, collectionSlug) - if err != nil { - return nil, err - } - - var pathParam1 string - - pathParam1, err = runtime.StyleParamWithLocation("simple", false, "workloadSlug", runtime.ParamLocationPath, workloadSlug) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/device-collections/%s/workloads/%s", pathParam0, pathParam1) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("DELETE", queryURL.String(), nil) - if err != nil { - return nil, err - } - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewGetWorkloadRequest generates requests for GetWorkload -func NewGetWorkloadRequest(server string, collectionSlug CollectionSlug, workloadSlug WorkloadSlug, params *GetWorkloadParams) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "collectionSlug", runtime.ParamLocationPath, collectionSlug) - if err != nil { - return nil, err - } - - var pathParam1 string - - pathParam1, err = runtime.StyleParamWithLocation("simple", false, "workloadSlug", runtime.ParamLocationPath, workloadSlug) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/device-collections/%s/workloads/%s", pathParam0, pathParam1) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { - return nil, err - } - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewPutWorkloadRequest calls the generic PutWorkload builder with application/json body -func NewPutWorkloadRequest(server string, collectionSlug CollectionSlug, workloadSlug WorkloadSlug, params *PutWorkloadParams, body PutWorkloadJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - return NewPutWorkloadRequestWithBody(server, collectionSlug, workloadSlug, params, "application/json", bodyReader) -} - -// NewPutWorkloadRequestWithBody generates requests for PutWorkload with any type of body -func NewPutWorkloadRequestWithBody(server string, collectionSlug CollectionSlug, workloadSlug WorkloadSlug, params *PutWorkloadParams, contentType string, body io.Reader) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "collectionSlug", runtime.ParamLocationPath, collectionSlug) - if err != nil { - return nil, err - } - - var pathParam1 string - - pathParam1, err = runtime.StyleParamWithLocation("simple", false, "workloadSlug", runtime.ParamLocationPath, workloadSlug) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/device-collections/%s/workloads/%s", pathParam0, pathParam1) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("PUT", queryURL.String(), body) - if err != nil { - return nil, err - } - - req.Header.Add("Content-Type", contentType) - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewPostDeviceEnrollmentTokenRequest calls the generic PostDeviceEnrollmentToken builder with application/json body -func NewPostDeviceEnrollmentTokenRequest(server string, collectionSlug CollectionSlug, instanceID InstanceID, params *PostDeviceEnrollmentTokenParams, body PostDeviceEnrollmentTokenJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - return NewPostDeviceEnrollmentTokenRequestWithBody(server, collectionSlug, instanceID, params, "application/json", bodyReader) -} - -// NewPostDeviceEnrollmentTokenRequestWithBody generates requests for PostDeviceEnrollmentToken with any type of body -func NewPostDeviceEnrollmentTokenRequestWithBody(server string, collectionSlug CollectionSlug, instanceID InstanceID, params *PostDeviceEnrollmentTokenParams, contentType string, body io.Reader) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "collectionSlug", runtime.ParamLocationPath, collectionSlug) - if err != nil { - return nil, err - } - - var pathParam1 string - - pathParam1, err = runtime.StyleParamWithLocation("simple", false, "instanceID", runtime.ParamLocationPath, instanceID) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/device-collections/%s/%s/enrollment-token", pathParam0, pathParam1) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("POST", queryURL.String(), body) - if err != nil { - return nil, err - } - - req.Header.Add("Content-Type", contentType) - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewGetSshGrantsRequest generates requests for GetSshGrants -func NewGetSshGrantsRequest(server string, params *GetSshGrantsParams) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/grants") - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { - return nil, err - } - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewPostSshGrantsRequest calls the generic PostSshGrants builder with application/json body -func NewPostSshGrantsRequest(server string, params *PostSshGrantsParams, body PostSshGrantsJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - return NewPostSshGrantsRequestWithBody(server, params, "application/json", bodyReader) -} - -// NewPostSshGrantsRequestWithBody generates requests for PostSshGrants with any type of body -func NewPostSshGrantsRequestWithBody(server string, params *PostSshGrantsParams, contentType string, body io.Reader) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/grants") - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("POST", queryURL.String(), body) - if err != nil { - return nil, err - } - - req.Header.Add("Content-Type", contentType) - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewDeleteSshGrantRequest generates requests for DeleteSshGrant -func NewDeleteSshGrantRequest(server string, grantID GrantID, params *DeleteSshGrantParams) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "grantID", runtime.ParamLocationPath, grantID) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/grants/%s", pathParam0) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("DELETE", queryURL.String(), nil) - if err != nil { - return nil, err - } - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewGetSshGrantRequest generates requests for GetSshGrant -func NewGetSshGrantRequest(server string, grantID GrantID, params *GetSshGrantParams) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "grantID", runtime.ParamLocationPath, grantID) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/grants/%s", pathParam0) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { - return nil, err - } - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewGetSshGroupsRequest generates requests for GetSshGroups -func NewGetSshGroupsRequest(server string, params *GetSshGroupsParams) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/groups") - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - if params != nil { - queryValues := queryURL.Query() - - if params.Pagination != nil { - - if queryFrag, err := runtime.StyleParamWithLocation("deepObject", true, "pagination", runtime.ParamLocationQuery, *params.Pagination); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - - } - - queryURL.RawQuery = queryValues.Encode() - } - - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { - return nil, err - } - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewGetSshGroupRequest generates requests for GetSshGroup -func NewGetSshGroupRequest(server string, groupID GroupID, params *GetSshGroupParams) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "groupID", runtime.ParamLocationPath, groupID) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/groups/%s", pathParam0) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { - return nil, err - } - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewGetSshHostsRequest generates requests for GetSshHosts -func NewGetSshHostsRequest(server string, params *GetSshHostsParams) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/hosts") - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - if params != nil { - queryValues := queryURL.Query() - - if params.Pagination != nil { - - if queryFrag, err := runtime.StyleParamWithLocation("deepObject", true, "pagination", runtime.ParamLocationQuery, *params.Pagination); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - - } - - if params.Active != nil { - - if queryFrag, err := runtime.StyleParamWithLocation("form", true, "active", runtime.ParamLocationQuery, *params.Active); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - - } - - if params.Bastion != nil { - - if queryFrag, err := runtime.StyleParamWithLocation("form", true, "bastion", runtime.ParamLocationQuery, *params.Bastion); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - - } - - queryURL.RawQuery = queryValues.Encode() - } - - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { - return nil, err - } - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewGetSshHostRequest generates requests for GetSshHost -func NewGetSshHostRequest(server string, hostID HostID, params *GetSshHostParams) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "hostID", runtime.ParamLocationPath, hostID) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/hosts/%s", pathParam0) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { - return nil, err - } - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewPostHostsHostIDTagsRequest calls the generic PostHostsHostIDTags builder with application/json body -func NewPostHostsHostIDTagsRequest(server string, hostID HostID, params *PostHostsHostIDTagsParams, body PostHostsHostIDTagsJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - return NewPostHostsHostIDTagsRequestWithBody(server, hostID, params, "application/json", bodyReader) -} - -// NewPostHostsHostIDTagsRequestWithBody generates requests for PostHostsHostIDTags with any type of body -func NewPostHostsHostIDTagsRequestWithBody(server string, hostID HostID, params *PostHostsHostIDTagsParams, contentType string, body io.Reader) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "hostID", runtime.ParamLocationPath, hostID) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/hosts/%s/tags", pathParam0) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("POST", queryURL.String(), body) - if err != nil { - return nil, err - } - - req.Header.Add("Content-Type", contentType) - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewUnregisterSshHostRequest generates requests for UnregisterSshHost -func NewUnregisterSshHostRequest(server string, hostID HostID, params *UnregisterSshHostParams) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "hostID", runtime.ParamLocationPath, hostID) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/hosts/%s/unregister", pathParam0) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("POST", queryURL.String(), nil) - if err != nil { - return nil, err - } - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewGetPlatformsRequest generates requests for GetPlatforms -func NewGetPlatformsRequest(server string, params *GetPlatformsParams) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/platforms") - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - if params != nil { - queryValues := queryURL.Query() - - if params.Pagination != nil { - - if queryFrag, err := runtime.StyleParamWithLocation("deepObject", true, "pagination", runtime.ParamLocationQuery, *params.Pagination); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - - } - - queryURL.RawQuery = queryValues.Encode() - } - - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { - return nil, err - } - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewPutPlatformRequest calls the generic PutPlatform builder with application/json body -func NewPutPlatformRequest(server string, platformSlug PlatformSlug, params *PutPlatformParams, body PutPlatformJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - return NewPutPlatformRequestWithBody(server, platformSlug, params, "application/json", bodyReader) -} - -// NewPutPlatformRequestWithBody generates requests for PutPlatform with any type of body -func NewPutPlatformRequestWithBody(server string, platformSlug PlatformSlug, params *PutPlatformParams, contentType string, body io.Reader) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "platformSlug", runtime.ParamLocationPath, platformSlug) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/platforms/%s", pathParam0) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("PUT", queryURL.String(), body) - if err != nil { - return nil, err - } - - req.Header.Add("Content-Type", contentType) - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewGetSshHostTagsRequest generates requests for GetSshHostTags -func NewGetSshHostTagsRequest(server string, params *GetSshHostTagsParams) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/tags") - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - if params != nil { - queryValues := queryURL.Query() - - if params.Pagination != nil { - - if queryFrag, err := runtime.StyleParamWithLocation("deepObject", true, "pagination", runtime.ParamLocationQuery, *params.Pagination); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - - } - - queryURL.RawQuery = queryValues.Encode() - } - - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { - return nil, err - } - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -// NewGetSshUsersRequest generates requests for GetSshUsers -func NewGetSshUsersRequest(server string, params *GetSshUsersParams) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/users") - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - if params != nil { - queryValues := queryURL.Query() - - if params.Pagination != nil { - - if queryFrag, err := runtime.StyleParamWithLocation("deepObject", true, "pagination", runtime.ParamLocationQuery, *params.Pagination); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - - } - - queryURL.RawQuery = queryValues.Encode() - } - - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { - return nil, err - } - - if params != nil { - - if params.XRequestId != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) - if err != nil { - return nil, err - } - - req.Header.Set("X-Request-Id", headerParam0) - } - - if params.Accept != nil { - var headerParam1 string - - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", headerParam1) - } - - } - - return req, nil -} - -func (c *Client) applyEditors(ctx context.Context, req *http.Request, additionalEditors []RequestEditorFn) error { - for _, r := range c.RequestEditors { - if err := r(ctx, req); err != nil { - return err - } - } - for _, r := range additionalEditors { - if err := r(ctx, req); err != nil { - return err - } - } - return nil -} - -// ClientWithResponses builds on ClientInterface to offer response payloads -type ClientWithResponses struct { - ClientInterface -} - -// NewClientWithResponses creates a new ClientWithResponses, which wraps -// Client with return type handling -func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error) { - client, err := NewClient(server, opts...) - if err != nil { - return nil, err - } - return &ClientWithResponses{client}, nil -} - -// WithBaseURL overrides the baseURL. -func WithBaseURL(baseURL string) ClientOption { - return func(c *Client) error { - newBaseURL, err := url.Parse(baseURL) - if err != nil { - return err - } - c.Server = newBaseURL.String() - return nil - } -} - -// ClientWithResponsesInterface is the interface specification for the client with responses above. -type ClientWithResponsesInterface interface { - // ListAccountsWithResponse request - ListAccountsWithResponse(ctx context.Context, params *ListAccountsParams, reqEditors ...RequestEditorFn) (*ListAccountsResponse, error) - - // PostAccountsWithBodyWithResponse request with any body - PostAccountsWithBodyWithResponse(ctx context.Context, params *PostAccountsParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostAccountsResponse, error) - - PostAccountsWithResponse(ctx context.Context, params *PostAccountsParams, body PostAccountsJSONRequestBody, reqEditors ...RequestEditorFn) (*PostAccountsResponse, error) - - // DeleteAccountWithResponse request - DeleteAccountWithResponse(ctx context.Context, accountID AccountID, params *DeleteAccountParams, reqEditors ...RequestEditorFn) (*DeleteAccountResponse, error) - - // GetAccountWithResponse request - GetAccountWithResponse(ctx context.Context, accountID AccountID, params *GetAccountParams, reqEditors ...RequestEditorFn) (*GetAccountResponse, error) - - // PutAccountWithBodyWithResponse request with any body - PutAccountWithBodyWithResponse(ctx context.Context, accountID AccountID, params *PutAccountParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutAccountResponse, error) - - PutAccountWithResponse(ctx context.Context, accountID AccountID, params *PutAccountParams, body PutAccountJSONRequestBody, reqEditors ...RequestEditorFn) (*PutAccountResponse, error) - - // GetAttestationAuthoritiesWithResponse request - GetAttestationAuthoritiesWithResponse(ctx context.Context, params *GetAttestationAuthoritiesParams, reqEditors ...RequestEditorFn) (*GetAttestationAuthoritiesResponse, error) - - // PostAttestationAuthoritiesWithBodyWithResponse request with any body - PostAttestationAuthoritiesWithBodyWithResponse(ctx context.Context, params *PostAttestationAuthoritiesParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostAttestationAuthoritiesResponse, error) - - PostAttestationAuthoritiesWithResponse(ctx context.Context, params *PostAttestationAuthoritiesParams, body PostAttestationAuthoritiesJSONRequestBody, reqEditors ...RequestEditorFn) (*PostAttestationAuthoritiesResponse, error) - - // DeleteAttestationAuthorityWithResponse request - DeleteAttestationAuthorityWithResponse(ctx context.Context, attestationAuthorityID AttestationAuthorityID, params *DeleteAttestationAuthorityParams, reqEditors ...RequestEditorFn) (*DeleteAttestationAuthorityResponse, error) - - // GetAttestationAuthorityWithResponse request - GetAttestationAuthorityWithResponse(ctx context.Context, attestationAuthorityID AttestationAuthorityID, params *GetAttestationAuthorityParams, reqEditors ...RequestEditorFn) (*GetAttestationAuthorityResponse, error) - - // PostAuthWithBodyWithResponse request with any body - PostAuthWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostAuthResponse, error) - - PostAuthWithResponse(ctx context.Context, body PostAuthJSONRequestBody, reqEditors ...RequestEditorFn) (*PostAuthResponse, error) - - // GetAuthoritiesWithResponse request - GetAuthoritiesWithResponse(ctx context.Context, params *GetAuthoritiesParams, reqEditors ...RequestEditorFn) (*GetAuthoritiesResponse, error) - - // PostAuthoritiesWithBodyWithResponse request with any body - PostAuthoritiesWithBodyWithResponse(ctx context.Context, params *PostAuthoritiesParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostAuthoritiesResponse, error) - - PostAuthoritiesWithResponse(ctx context.Context, params *PostAuthoritiesParams, body PostAuthoritiesJSONRequestBody, reqEditors ...RequestEditorFn) (*PostAuthoritiesResponse, error) - - // PostAuthoritiesCsrWithBodyWithResponse request with any body - PostAuthoritiesCsrWithBodyWithResponse(ctx context.Context, params *PostAuthoritiesCsrParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostAuthoritiesCsrResponse, error) - - PostAuthoritiesCsrWithResponse(ctx context.Context, params *PostAuthoritiesCsrParams, body PostAuthoritiesCsrJSONRequestBody, reqEditors ...RequestEditorFn) (*PostAuthoritiesCsrResponse, error) - - // DeleteAuthorityWithResponse request - DeleteAuthorityWithResponse(ctx context.Context, authorityDomainOrID AuthorityDomainOrID, params *DeleteAuthorityParams, reqEditors ...RequestEditorFn) (*DeleteAuthorityResponse, error) - - // GetAuthorityWithResponse request - GetAuthorityWithResponse(ctx context.Context, authorityDomainOrID AuthorityDomainOrID, params *GetAuthorityParams, reqEditors ...RequestEditorFn) (*GetAuthorityResponse, error) - - // ListAuthorityProvisionersWithResponse request - ListAuthorityProvisionersWithResponse(ctx context.Context, authorityID AuthorityID, params *ListAuthorityProvisionersParams, reqEditors ...RequestEditorFn) (*ListAuthorityProvisionersResponse, error) - - // PostAuthorityProvisionersWithBodyWithResponse request with any body - PostAuthorityProvisionersWithBodyWithResponse(ctx context.Context, authorityID AuthorityID, params *PostAuthorityProvisionersParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostAuthorityProvisionersResponse, error) - - PostAuthorityProvisionersWithResponse(ctx context.Context, authorityID AuthorityID, params *PostAuthorityProvisionersParams, body PostAuthorityProvisionersJSONRequestBody, reqEditors ...RequestEditorFn) (*PostAuthorityProvisionersResponse, error) - - // DeleteProvisionerWithResponse request - DeleteProvisionerWithResponse(ctx context.Context, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, params *DeleteProvisionerParams, reqEditors ...RequestEditorFn) (*DeleteProvisionerResponse, error) - - // GetProvisionerWithResponse request - GetProvisionerWithResponse(ctx context.Context, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, params *GetProvisionerParams, reqEditors ...RequestEditorFn) (*GetProvisionerResponse, error) - - // PostWebhooksWithBodyWithResponse request with any body - PostWebhooksWithBodyWithResponse(ctx context.Context, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, params *PostWebhooksParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostWebhooksResponse, error) - - PostWebhooksWithResponse(ctx context.Context, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, params *PostWebhooksParams, body PostWebhooksJSONRequestBody, reqEditors ...RequestEditorFn) (*PostWebhooksResponse, error) - - // DeleteWebhookWithResponse request - DeleteWebhookWithResponse(ctx context.Context, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, webhookNameOrID WebhookNameOrID, params *DeleteWebhookParams, reqEditors ...RequestEditorFn) (*DeleteWebhookResponse, error) - - // GetWebhookWithResponse request - GetWebhookWithResponse(ctx context.Context, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, webhookNameOrID WebhookNameOrID, params *GetWebhookParams, reqEditors ...RequestEditorFn) (*GetWebhookResponse, error) - - // PostAuthorityRootWithBodyWithResponse request with any body - PostAuthorityRootWithBodyWithResponse(ctx context.Context, authorityID AuthorityID, params *PostAuthorityRootParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostAuthorityRootResponse, error) - - PostAuthorityRootWithResponse(ctx context.Context, authorityID AuthorityID, params *PostAuthorityRootParams, body PostAuthorityRootJSONRequestBody, reqEditors ...RequestEditorFn) (*PostAuthorityRootResponse, error) - - // ListCertificatesWithResponse request - ListCertificatesWithResponse(ctx context.Context, params *ListCertificatesParams, reqEditors ...RequestEditorFn) (*ListCertificatesResponse, error) - - // GetCertificateWithResponse request - GetCertificateWithResponse(ctx context.Context, serialNumber SerialNumber, params *GetCertificateParams, reqEditors ...RequestEditorFn) (*GetCertificateResponse, error) - - // ListCollectionsWithResponse request - ListCollectionsWithResponse(ctx context.Context, params *ListCollectionsParams, reqEditors ...RequestEditorFn) (*ListCollectionsResponse, error) - - // PostCollectionsWithBodyWithResponse request with any body - PostCollectionsWithBodyWithResponse(ctx context.Context, params *PostCollectionsParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostCollectionsResponse, error) - - PostCollectionsWithResponse(ctx context.Context, params *PostCollectionsParams, body PostCollectionsJSONRequestBody, reqEditors ...RequestEditorFn) (*PostCollectionsResponse, error) - - // DeleteCollectionWithResponse request - DeleteCollectionWithResponse(ctx context.Context, collectionSlug CollectionSlug, params *DeleteCollectionParams, reqEditors ...RequestEditorFn) (*DeleteCollectionResponse, error) - - // GetCollectionWithResponse request - GetCollectionWithResponse(ctx context.Context, collectionSlug CollectionSlug, params *GetCollectionParams, reqEditors ...RequestEditorFn) (*GetCollectionResponse, error) - - // PutCollectionWithBodyWithResponse request with any body - PutCollectionWithBodyWithResponse(ctx context.Context, collectionSlug CollectionSlug, params *PutCollectionParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutCollectionResponse, error) - - PutCollectionWithResponse(ctx context.Context, collectionSlug CollectionSlug, params *PutCollectionParams, body PutCollectionJSONRequestBody, reqEditors ...RequestEditorFn) (*PutCollectionResponse, error) - - // DeleteCollectionInstanceWithResponse request - DeleteCollectionInstanceWithResponse(ctx context.Context, collectionSlug CollectionSlug, instanceID InstanceID, params *DeleteCollectionInstanceParams, reqEditors ...RequestEditorFn) (*DeleteCollectionInstanceResponse, error) - - // GetCollectionInstanceWithResponse request - GetCollectionInstanceWithResponse(ctx context.Context, collectionSlug CollectionSlug, instanceID InstanceID, params *GetCollectionInstanceParams, reqEditors ...RequestEditorFn) (*GetCollectionInstanceResponse, error) - - // PutCollectionInstanceWithBodyWithResponse request with any body - PutCollectionInstanceWithBodyWithResponse(ctx context.Context, collectionSlug CollectionSlug, instanceID InstanceID, params *PutCollectionInstanceParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutCollectionInstanceResponse, error) - - PutCollectionInstanceWithResponse(ctx context.Context, collectionSlug CollectionSlug, instanceID InstanceID, params *PutCollectionInstanceParams, body PutCollectionInstanceJSONRequestBody, reqEditors ...RequestEditorFn) (*PutCollectionInstanceResponse, error) - - // GetCollectionInstanceDataWithResponse request - GetCollectionInstanceDataWithResponse(ctx context.Context, collectionSlug CollectionSlug, instanceID InstanceID, params *GetCollectionInstanceDataParams, reqEditors ...RequestEditorFn) (*GetCollectionInstanceDataResponse, error) - - // PutCollectionInstanceDataWithBodyWithResponse request with any body - PutCollectionInstanceDataWithBodyWithResponse(ctx context.Context, collectionSlug CollectionSlug, instanceID InstanceID, params *PutCollectionInstanceDataParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutCollectionInstanceDataResponse, error) - - PutCollectionInstanceDataWithResponse(ctx context.Context, collectionSlug CollectionSlug, instanceID InstanceID, params *PutCollectionInstanceDataParams, body PutCollectionInstanceDataJSONRequestBody, reqEditors ...RequestEditorFn) (*PutCollectionInstanceDataResponse, error) - - // ListCollectionInstancesWithResponse request - ListCollectionInstancesWithResponse(ctx context.Context, collectionSlug CollectionSlug, params *ListCollectionInstancesParams, reqEditors ...RequestEditorFn) (*ListCollectionInstancesResponse, error) - - // DeleteDeviceCollectionWithResponse request - DeleteDeviceCollectionWithResponse(ctx context.Context, collectionSlug CollectionSlug, params *DeleteDeviceCollectionParams, reqEditors ...RequestEditorFn) (*DeleteDeviceCollectionResponse, error) - - // GetDeviceCollectionWithResponse request - GetDeviceCollectionWithResponse(ctx context.Context, collectionSlug CollectionSlug, params *GetDeviceCollectionParams, reqEditors ...RequestEditorFn) (*GetDeviceCollectionResponse, error) - - // PutDeviceCollectionWithBodyWithResponse request with any body - PutDeviceCollectionWithBodyWithResponse(ctx context.Context, collectionSlug CollectionSlug, params *PutDeviceCollectionParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutDeviceCollectionResponse, error) - - PutDeviceCollectionWithResponse(ctx context.Context, collectionSlug CollectionSlug, params *PutDeviceCollectionParams, body PutDeviceCollectionJSONRequestBody, reqEditors ...RequestEditorFn) (*PutDeviceCollectionResponse, error) - - // DeleteDeviceCollectionAccountWithResponse request - DeleteDeviceCollectionAccountWithResponse(ctx context.Context, collectionSlug CollectionSlug, accountSlug AccountSlug, params *DeleteDeviceCollectionAccountParams, reqEditors ...RequestEditorFn) (*DeleteDeviceCollectionAccountResponse, error) - - // GetDeviceCollectionAccountWithResponse request - GetDeviceCollectionAccountWithResponse(ctx context.Context, collectionSlug CollectionSlug, accountSlug AccountSlug, params *GetDeviceCollectionAccountParams, reqEditors ...RequestEditorFn) (*GetDeviceCollectionAccountResponse, error) - - // PutDeviceCollectionAccountWithBodyWithResponse request with any body - PutDeviceCollectionAccountWithBodyWithResponse(ctx context.Context, collectionSlug CollectionSlug, accountSlug AccountSlug, params *PutDeviceCollectionAccountParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutDeviceCollectionAccountResponse, error) - - PutDeviceCollectionAccountWithResponse(ctx context.Context, collectionSlug CollectionSlug, accountSlug AccountSlug, params *PutDeviceCollectionAccountParams, body PutDeviceCollectionAccountJSONRequestBody, reqEditors ...RequestEditorFn) (*PutDeviceCollectionAccountResponse, error) - - // DeleteWorkloadWithResponse request - DeleteWorkloadWithResponse(ctx context.Context, collectionSlug CollectionSlug, workloadSlug WorkloadSlug, params *DeleteWorkloadParams, reqEditors ...RequestEditorFn) (*DeleteWorkloadResponse, error) - - // GetWorkloadWithResponse request - GetWorkloadWithResponse(ctx context.Context, collectionSlug CollectionSlug, workloadSlug WorkloadSlug, params *GetWorkloadParams, reqEditors ...RequestEditorFn) (*GetWorkloadResponse, error) - - // PutWorkloadWithBodyWithResponse request with any body - PutWorkloadWithBodyWithResponse(ctx context.Context, collectionSlug CollectionSlug, workloadSlug WorkloadSlug, params *PutWorkloadParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutWorkloadResponse, error) - - PutWorkloadWithResponse(ctx context.Context, collectionSlug CollectionSlug, workloadSlug WorkloadSlug, params *PutWorkloadParams, body PutWorkloadJSONRequestBody, reqEditors ...RequestEditorFn) (*PutWorkloadResponse, error) - - // PostDeviceEnrollmentTokenWithBodyWithResponse request with any body - PostDeviceEnrollmentTokenWithBodyWithResponse(ctx context.Context, collectionSlug CollectionSlug, instanceID InstanceID, params *PostDeviceEnrollmentTokenParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostDeviceEnrollmentTokenResponse, error) - - PostDeviceEnrollmentTokenWithResponse(ctx context.Context, collectionSlug CollectionSlug, instanceID InstanceID, params *PostDeviceEnrollmentTokenParams, body PostDeviceEnrollmentTokenJSONRequestBody, reqEditors ...RequestEditorFn) (*PostDeviceEnrollmentTokenResponse, error) - - // GetSshGrantsWithResponse request - GetSshGrantsWithResponse(ctx context.Context, params *GetSshGrantsParams, reqEditors ...RequestEditorFn) (*GetSshGrantsResponse, error) - - // PostSshGrantsWithBodyWithResponse request with any body - PostSshGrantsWithBodyWithResponse(ctx context.Context, params *PostSshGrantsParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSshGrantsResponse, error) - - PostSshGrantsWithResponse(ctx context.Context, params *PostSshGrantsParams, body PostSshGrantsJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSshGrantsResponse, error) - - // DeleteSshGrantWithResponse request - DeleteSshGrantWithResponse(ctx context.Context, grantID GrantID, params *DeleteSshGrantParams, reqEditors ...RequestEditorFn) (*DeleteSshGrantResponse, error) - - // GetSshGrantWithResponse request - GetSshGrantWithResponse(ctx context.Context, grantID GrantID, params *GetSshGrantParams, reqEditors ...RequestEditorFn) (*GetSshGrantResponse, error) - - // GetSshGroupsWithResponse request - GetSshGroupsWithResponse(ctx context.Context, params *GetSshGroupsParams, reqEditors ...RequestEditorFn) (*GetSshGroupsResponse, error) - - // GetSshGroupWithResponse request - GetSshGroupWithResponse(ctx context.Context, groupID GroupID, params *GetSshGroupParams, reqEditors ...RequestEditorFn) (*GetSshGroupResponse, error) - - // GetSshHostsWithResponse request - GetSshHostsWithResponse(ctx context.Context, params *GetSshHostsParams, reqEditors ...RequestEditorFn) (*GetSshHostsResponse, error) - - // GetSshHostWithResponse request - GetSshHostWithResponse(ctx context.Context, hostID HostID, params *GetSshHostParams, reqEditors ...RequestEditorFn) (*GetSshHostResponse, error) - - // PostHostsHostIDTagsWithBodyWithResponse request with any body - PostHostsHostIDTagsWithBodyWithResponse(ctx context.Context, hostID HostID, params *PostHostsHostIDTagsParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostHostsHostIDTagsResponse, error) - - PostHostsHostIDTagsWithResponse(ctx context.Context, hostID HostID, params *PostHostsHostIDTagsParams, body PostHostsHostIDTagsJSONRequestBody, reqEditors ...RequestEditorFn) (*PostHostsHostIDTagsResponse, error) - - // UnregisterSshHostWithResponse request - UnregisterSshHostWithResponse(ctx context.Context, hostID HostID, params *UnregisterSshHostParams, reqEditors ...RequestEditorFn) (*UnregisterSshHostResponse, error) - - // GetPlatformsWithResponse request - GetPlatformsWithResponse(ctx context.Context, params *GetPlatformsParams, reqEditors ...RequestEditorFn) (*GetPlatformsResponse, error) - - // PutPlatformWithBodyWithResponse request with any body - PutPlatformWithBodyWithResponse(ctx context.Context, platformSlug PlatformSlug, params *PutPlatformParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutPlatformResponse, error) - - PutPlatformWithResponse(ctx context.Context, platformSlug PlatformSlug, params *PutPlatformParams, body PutPlatformJSONRequestBody, reqEditors ...RequestEditorFn) (*PutPlatformResponse, error) - - // GetSshHostTagsWithResponse request - GetSshHostTagsWithResponse(ctx context.Context, params *GetSshHostTagsParams, reqEditors ...RequestEditorFn) (*GetSshHostTagsResponse, error) - - // GetSshUsersWithResponse request - GetSshUsersWithResponse(ctx context.Context, params *GetSshUsersParams, reqEditors ...RequestEditorFn) (*GetSshUsersResponse, error) -} - -type ListAccountsResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *[]Account - JSON400 *N400 - JSON401 *N401 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r ListAccountsResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r ListAccountsResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type PostAccountsResponse struct { - Body []byte - HTTPResponse *http.Response - JSON201 *Account - JSON400 *N400 - JSON401 *N401 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r PostAccountsResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r PostAccountsResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type DeleteAccountResponse struct { - Body []byte - HTTPResponse *http.Response - JSON400 *N400 - JSON401 *N401 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r DeleteAccountResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r DeleteAccountResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type GetAccountResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *Account - JSON400 *N400 - JSON401 *N401 - JSON404 *N404 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r GetAccountResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r GetAccountResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type PutAccountResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *Account - JSON400 *N400 - JSON401 *N401 - JSON404 *N401 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r PutAccountResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r PutAccountResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type GetAttestationAuthoritiesResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *[]AttestationAuthority - JSON400 *N400 - JSON401 *N401 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r GetAttestationAuthoritiesResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r GetAttestationAuthoritiesResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type PostAttestationAuthoritiesResponse struct { - Body []byte - HTTPResponse *http.Response - JSON201 *AttestationAuthority - JSON400 *N400 - JSON401 *N401 - JSON409 *N409 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r PostAttestationAuthoritiesResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r PostAttestationAuthoritiesResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type DeleteAttestationAuthorityResponse struct { - Body []byte - HTTPResponse *http.Response - JSON400 *N400 - JSON401 *N401 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r DeleteAttestationAuthorityResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r DeleteAttestationAuthorityResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type GetAttestationAuthorityResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *AttestationAuthority - JSON400 *N400 - JSON401 *N401 - JSON404 *N404 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r GetAttestationAuthorityResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r GetAttestationAuthorityResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type PostAuthResponse struct { - Body []byte - HTTPResponse *http.Response - JSON201 *struct { - Token *string `json:"token,omitempty"` - } - JSON400 *N400 - JSON401 *N401 - JSON403 *N403 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r PostAuthResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r PostAuthResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type GetAuthoritiesResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *[]Authority - JSON400 *N400 - JSON401 *N401 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r GetAuthoritiesResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r GetAuthoritiesResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type PostAuthoritiesResponse struct { - Body []byte - HTTPResponse *http.Response - JSON201 *Authority - JSON400 *N400 - JSON401 *N401 - JSON409 *N409 - JSON412 *N412 - JSON422 *N422 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r PostAuthoritiesResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r PostAuthoritiesResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type PostAuthoritiesCsrResponse struct { - Body []byte - HTTPResponse *http.Response - JSON201 *AuthorityCsr - JSON400 *N400 - JSON401 *N401 - JSON409 *N409 - JSON412 *N412 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r PostAuthoritiesCsrResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r PostAuthoritiesCsrResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type DeleteAuthorityResponse struct { - Body []byte - HTTPResponse *http.Response - JSON400 *N400 - JSON401 *N401 - JSON422 *N422 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r DeleteAuthorityResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r DeleteAuthorityResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type GetAuthorityResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *Authority - JSON400 *N400 - JSON401 *N401 - JSON404 *N404 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r GetAuthorityResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r GetAuthorityResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type ListAuthorityProvisionersResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *[]Provisioner - JSON400 *N400 - JSON401 *N401 - JSON404 *N404 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r ListAuthorityProvisionersResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r ListAuthorityProvisionersResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type PostAuthorityProvisionersResponse struct { - Body []byte - HTTPResponse *http.Response - JSON201 *Provisioner - JSON400 *N400 - JSON401 *N401 - JSON404 *N404 - JSON409 *N409 - JSON422 *N422 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r PostAuthorityProvisionersResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r PostAuthorityProvisionersResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type DeleteProvisionerResponse struct { - Body []byte - HTTPResponse *http.Response - JSON400 *N400 - JSON401 *N401 - JSON422 *N422 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r DeleteProvisionerResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r DeleteProvisionerResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type GetProvisionerResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *Provisioner - JSON400 *N400 - JSON401 *N401 - JSON404 *N404 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r GetProvisionerResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r GetProvisionerResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type PostWebhooksResponse struct { - Body []byte - HTTPResponse *http.Response - JSON201 *ProvisionerWebhook - JSON400 *N400 - JSON401 *N401 - JSON404 *N404 - JSON409 *N409 - JSON412 *N412 - JSON422 *N422 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r PostWebhooksResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r PostWebhooksResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type DeleteWebhookResponse struct { - Body []byte - HTTPResponse *http.Response - JSON400 *N400 - JSON401 *N401 - JSON422 *N422 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r DeleteWebhookResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r DeleteWebhookResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type GetWebhookResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *ProvisionerWebhook - JSON400 *N400 - JSON401 *N401 - JSON404 *N404 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r GetWebhookResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r GetWebhookResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type PostAuthorityRootResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *Authority - JSON400 *N400 - JSON401 *N401 - JSON404 *N404 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r PostAuthorityRootResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r PostAuthorityRootResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type ListCertificatesResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *[]X509Certificate - JSON400 *N400 - JSON401 *N401 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r ListCertificatesResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r ListCertificatesResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type GetCertificateResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *X509Certificate - JSON400 *N400 - JSON401 *N401 - JSON404 *N404 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r GetCertificateResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r GetCertificateResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type ListCollectionsResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *[]Collection - JSON400 *N400 - JSON401 *N401 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r ListCollectionsResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r ListCollectionsResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type PostCollectionsResponse struct { - Body []byte - HTTPResponse *http.Response - JSON201 *Collection - JSON400 *N400 - JSON401 *N401 - JSON409 *N409 - JSON412 *N412 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r PostCollectionsResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r PostCollectionsResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type DeleteCollectionResponse struct { - Body []byte - HTTPResponse *http.Response - JSON400 *N400 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r DeleteCollectionResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r DeleteCollectionResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type GetCollectionResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *Collection - JSON400 *N400 - JSON401 *N401 - JSON404 *N401 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r GetCollectionResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r GetCollectionResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type PutCollectionResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *Collection - JSON400 *N400 - JSON401 *N401 - JSON404 *N404 - JSON412 *N412 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r PutCollectionResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r PutCollectionResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type DeleteCollectionInstanceResponse struct { - Body []byte - HTTPResponse *http.Response - JSON400 *N400 - JSON401 *N401 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r DeleteCollectionInstanceResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r DeleteCollectionInstanceResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type GetCollectionInstanceResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *CollectionInstance - JSON400 *N400 - JSON401 *N401 - JSON404 *N404 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r GetCollectionInstanceResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r GetCollectionInstanceResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type PutCollectionInstanceResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *CollectionInstance - JSON400 *N400 - JSON401 *N401 - JSON409 *N409 - JSON412 *N412 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r PutCollectionInstanceResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r PutCollectionInstanceResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type GetCollectionInstanceDataResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *interface{} - JSON400 *N400 - JSON401 *N401 - JSON404 *N404 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r GetCollectionInstanceDataResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r GetCollectionInstanceDataResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type PutCollectionInstanceDataResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *interface{} - JSON400 *N400 - JSON401 *N401 - JSON409 *N409 - JSON412 *N412 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r PutCollectionInstanceDataResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r PutCollectionInstanceDataResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type ListCollectionInstancesResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *[]CollectionInstance - JSON400 *N400 - JSON401 *N401 - JSON404 *N401 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r ListCollectionInstancesResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r ListCollectionInstancesResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type DeleteDeviceCollectionResponse struct { - Body []byte - HTTPResponse *http.Response - JSON400 *N400 - JSON401 *N401 - JSON422 *N422 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r DeleteDeviceCollectionResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r DeleteDeviceCollectionResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type GetDeviceCollectionResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *DeviceCollection - JSON400 *N400 - JSON401 *N401 - JSON404 *N404 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r GetDeviceCollectionResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r GetDeviceCollectionResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type PutDeviceCollectionResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *DeviceCollection - JSON400 *N400 - JSON401 *N401 - JSON409 *N409 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r PutDeviceCollectionResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r PutDeviceCollectionResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type DeleteDeviceCollectionAccountResponse struct { - Body []byte - HTTPResponse *http.Response - JSON400 *N400 - JSON401 *N401 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r DeleteDeviceCollectionAccountResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r DeleteDeviceCollectionAccountResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type GetDeviceCollectionAccountResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *DeviceCollectionAccount - JSON400 *N400 - JSON401 *N401 - JSON404 *N404 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r GetDeviceCollectionAccountResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r GetDeviceCollectionAccountResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type PutDeviceCollectionAccountResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *DeviceCollectionAccount - JSON400 *N400 - JSON401 *N401 - JSON404 *N404 - JSON422 *N422 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r PutDeviceCollectionAccountResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r PutDeviceCollectionAccountResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type DeleteWorkloadResponse struct { - Body []byte - HTTPResponse *http.Response - JSON400 *N400 - JSON401 *N401 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r DeleteWorkloadResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r DeleteWorkloadResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type GetWorkloadResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *Workload - JSON400 *N400 - JSON401 *N401 - JSON404 *N404 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r GetWorkloadResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r GetWorkloadResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type PutWorkloadResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *Workload - JSON400 *N400 - JSON401 *N401 - JSON404 *N404 - JSON412 *N412 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r PutWorkloadResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r PutWorkloadResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type PostDeviceEnrollmentTokenResponse struct { - Body []byte - HTTPResponse *http.Response - JSON201 *EnrollmentToken - JSON400 *N400 - JSON401 *N401 - JSON404 *N404 - JSON412 *N412 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r PostDeviceEnrollmentTokenResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r PostDeviceEnrollmentTokenResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type GetSshGrantsResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *[]Grant - JSON401 *N401 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r GetSshGrantsResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r GetSshGrantsResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type PostSshGrantsResponse struct { - Body []byte - HTTPResponse *http.Response - JSON201 *Grant - JSON400 *N400 - JSON401 *N401 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r PostSshGrantsResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r PostSshGrantsResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type DeleteSshGrantResponse struct { - Body []byte - HTTPResponse *http.Response - JSON400 *N400 - JSON401 *N401 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r DeleteSshGrantResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r DeleteSshGrantResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type GetSshGrantResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *Grant - JSON400 *N400 - JSON401 *N401 - JSON404 *N404 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r GetSshGrantResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r GetSshGrantResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type GetSshGroupsResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *[]Group - JSON400 *N400 - JSON401 *N401 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r GetSshGroupsResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r GetSshGroupsResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type GetSshGroupResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *Group - JSON400 *N400 - JSON401 *N401 - JSON404 *N404 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r GetSshGroupResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r GetSshGroupResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type GetSshHostsResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *[]Host - JSON400 *N400 - JSON401 *N401 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r GetSshHostsResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r GetSshHostsResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type GetSshHostResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *Host - JSON400 *N400 - JSON401 *N401 - JSON404 *N404 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r GetSshHostResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r GetSshHostResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type PostHostsHostIDTagsResponse struct { - Body []byte - HTTPResponse *http.Response - JSON201 *Tag - JSON400 *N400 - JSON401 *N401 - JSON404 *N404 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r PostHostsHostIDTagsResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r PostHostsHostIDTagsResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type UnregisterSshHostResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *Host - JSON400 *N400 - JSON401 *N401 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r UnregisterSshHostResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r UnregisterSshHostResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type GetPlatformsResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *[]Platform - JSON400 *N400 - JSON401 *N401 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r GetPlatformsResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r GetPlatformsResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type PutPlatformResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *Platform - JSON400 *N400 - JSON401 *N401 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r PutPlatformResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r PutPlatformResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type GetSshHostTagsResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *[]Tag - JSON400 *N400 - JSON401 *N401 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r GetSshHostTagsResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r GetSshHostTagsResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type GetSshUsersResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *[]User - JSON400 *N400 - JSON401 *N401 - JSON500 *N500 -} - -// Status returns HTTPResponse.Status -func (r GetSshUsersResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r GetSshUsersResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -// ListAccountsWithResponse request returning *ListAccountsResponse -func (c *ClientWithResponses) ListAccountsWithResponse(ctx context.Context, params *ListAccountsParams, reqEditors ...RequestEditorFn) (*ListAccountsResponse, error) { - rsp, err := c.ListAccounts(ctx, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseListAccountsResponse(rsp) -} - -// PostAccountsWithBodyWithResponse request with arbitrary body returning *PostAccountsResponse -func (c *ClientWithResponses) PostAccountsWithBodyWithResponse(ctx context.Context, params *PostAccountsParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostAccountsResponse, error) { - rsp, err := c.PostAccountsWithBody(ctx, params, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParsePostAccountsResponse(rsp) -} - -func (c *ClientWithResponses) PostAccountsWithResponse(ctx context.Context, params *PostAccountsParams, body PostAccountsJSONRequestBody, reqEditors ...RequestEditorFn) (*PostAccountsResponse, error) { - rsp, err := c.PostAccounts(ctx, params, body, reqEditors...) - if err != nil { - return nil, err - } - return ParsePostAccountsResponse(rsp) -} - -// DeleteAccountWithResponse request returning *DeleteAccountResponse -func (c *ClientWithResponses) DeleteAccountWithResponse(ctx context.Context, accountID AccountID, params *DeleteAccountParams, reqEditors ...RequestEditorFn) (*DeleteAccountResponse, error) { - rsp, err := c.DeleteAccount(ctx, accountID, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseDeleteAccountResponse(rsp) -} - -// GetAccountWithResponse request returning *GetAccountResponse -func (c *ClientWithResponses) GetAccountWithResponse(ctx context.Context, accountID AccountID, params *GetAccountParams, reqEditors ...RequestEditorFn) (*GetAccountResponse, error) { - rsp, err := c.GetAccount(ctx, accountID, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseGetAccountResponse(rsp) -} - -// PutAccountWithBodyWithResponse request with arbitrary body returning *PutAccountResponse -func (c *ClientWithResponses) PutAccountWithBodyWithResponse(ctx context.Context, accountID AccountID, params *PutAccountParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutAccountResponse, error) { - rsp, err := c.PutAccountWithBody(ctx, accountID, params, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParsePutAccountResponse(rsp) -} - -func (c *ClientWithResponses) PutAccountWithResponse(ctx context.Context, accountID AccountID, params *PutAccountParams, body PutAccountJSONRequestBody, reqEditors ...RequestEditorFn) (*PutAccountResponse, error) { - rsp, err := c.PutAccount(ctx, accountID, params, body, reqEditors...) - if err != nil { - return nil, err - } - return ParsePutAccountResponse(rsp) -} - -// GetAttestationAuthoritiesWithResponse request returning *GetAttestationAuthoritiesResponse -func (c *ClientWithResponses) GetAttestationAuthoritiesWithResponse(ctx context.Context, params *GetAttestationAuthoritiesParams, reqEditors ...RequestEditorFn) (*GetAttestationAuthoritiesResponse, error) { - rsp, err := c.GetAttestationAuthorities(ctx, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseGetAttestationAuthoritiesResponse(rsp) -} - -// PostAttestationAuthoritiesWithBodyWithResponse request with arbitrary body returning *PostAttestationAuthoritiesResponse -func (c *ClientWithResponses) PostAttestationAuthoritiesWithBodyWithResponse(ctx context.Context, params *PostAttestationAuthoritiesParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostAttestationAuthoritiesResponse, error) { - rsp, err := c.PostAttestationAuthoritiesWithBody(ctx, params, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParsePostAttestationAuthoritiesResponse(rsp) -} - -func (c *ClientWithResponses) PostAttestationAuthoritiesWithResponse(ctx context.Context, params *PostAttestationAuthoritiesParams, body PostAttestationAuthoritiesJSONRequestBody, reqEditors ...RequestEditorFn) (*PostAttestationAuthoritiesResponse, error) { - rsp, err := c.PostAttestationAuthorities(ctx, params, body, reqEditors...) - if err != nil { - return nil, err - } - return ParsePostAttestationAuthoritiesResponse(rsp) -} - -// DeleteAttestationAuthorityWithResponse request returning *DeleteAttestationAuthorityResponse -func (c *ClientWithResponses) DeleteAttestationAuthorityWithResponse(ctx context.Context, attestationAuthorityID AttestationAuthorityID, params *DeleteAttestationAuthorityParams, reqEditors ...RequestEditorFn) (*DeleteAttestationAuthorityResponse, error) { - rsp, err := c.DeleteAttestationAuthority(ctx, attestationAuthorityID, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseDeleteAttestationAuthorityResponse(rsp) -} - -// GetAttestationAuthorityWithResponse request returning *GetAttestationAuthorityResponse -func (c *ClientWithResponses) GetAttestationAuthorityWithResponse(ctx context.Context, attestationAuthorityID AttestationAuthorityID, params *GetAttestationAuthorityParams, reqEditors ...RequestEditorFn) (*GetAttestationAuthorityResponse, error) { - rsp, err := c.GetAttestationAuthority(ctx, attestationAuthorityID, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseGetAttestationAuthorityResponse(rsp) -} - -// PostAuthWithBodyWithResponse request with arbitrary body returning *PostAuthResponse -func (c *ClientWithResponses) PostAuthWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostAuthResponse, error) { - rsp, err := c.PostAuthWithBody(ctx, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParsePostAuthResponse(rsp) -} - -func (c *ClientWithResponses) PostAuthWithResponse(ctx context.Context, body PostAuthJSONRequestBody, reqEditors ...RequestEditorFn) (*PostAuthResponse, error) { - rsp, err := c.PostAuth(ctx, body, reqEditors...) - if err != nil { - return nil, err - } - return ParsePostAuthResponse(rsp) -} - -// GetAuthoritiesWithResponse request returning *GetAuthoritiesResponse -func (c *ClientWithResponses) GetAuthoritiesWithResponse(ctx context.Context, params *GetAuthoritiesParams, reqEditors ...RequestEditorFn) (*GetAuthoritiesResponse, error) { - rsp, err := c.GetAuthorities(ctx, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseGetAuthoritiesResponse(rsp) -} - -// PostAuthoritiesWithBodyWithResponse request with arbitrary body returning *PostAuthoritiesResponse -func (c *ClientWithResponses) PostAuthoritiesWithBodyWithResponse(ctx context.Context, params *PostAuthoritiesParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostAuthoritiesResponse, error) { - rsp, err := c.PostAuthoritiesWithBody(ctx, params, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParsePostAuthoritiesResponse(rsp) -} - -func (c *ClientWithResponses) PostAuthoritiesWithResponse(ctx context.Context, params *PostAuthoritiesParams, body PostAuthoritiesJSONRequestBody, reqEditors ...RequestEditorFn) (*PostAuthoritiesResponse, error) { - rsp, err := c.PostAuthorities(ctx, params, body, reqEditors...) - if err != nil { - return nil, err - } - return ParsePostAuthoritiesResponse(rsp) -} - -// PostAuthoritiesCsrWithBodyWithResponse request with arbitrary body returning *PostAuthoritiesCsrResponse -func (c *ClientWithResponses) PostAuthoritiesCsrWithBodyWithResponse(ctx context.Context, params *PostAuthoritiesCsrParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostAuthoritiesCsrResponse, error) { - rsp, err := c.PostAuthoritiesCsrWithBody(ctx, params, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParsePostAuthoritiesCsrResponse(rsp) -} - -func (c *ClientWithResponses) PostAuthoritiesCsrWithResponse(ctx context.Context, params *PostAuthoritiesCsrParams, body PostAuthoritiesCsrJSONRequestBody, reqEditors ...RequestEditorFn) (*PostAuthoritiesCsrResponse, error) { - rsp, err := c.PostAuthoritiesCsr(ctx, params, body, reqEditors...) - if err != nil { - return nil, err - } - return ParsePostAuthoritiesCsrResponse(rsp) -} - -// DeleteAuthorityWithResponse request returning *DeleteAuthorityResponse -func (c *ClientWithResponses) DeleteAuthorityWithResponse(ctx context.Context, authorityDomainOrID AuthorityDomainOrID, params *DeleteAuthorityParams, reqEditors ...RequestEditorFn) (*DeleteAuthorityResponse, error) { - rsp, err := c.DeleteAuthority(ctx, authorityDomainOrID, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseDeleteAuthorityResponse(rsp) -} - -// GetAuthorityWithResponse request returning *GetAuthorityResponse -func (c *ClientWithResponses) GetAuthorityWithResponse(ctx context.Context, authorityDomainOrID AuthorityDomainOrID, params *GetAuthorityParams, reqEditors ...RequestEditorFn) (*GetAuthorityResponse, error) { - rsp, err := c.GetAuthority(ctx, authorityDomainOrID, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseGetAuthorityResponse(rsp) -} - -// ListAuthorityProvisionersWithResponse request returning *ListAuthorityProvisionersResponse -func (c *ClientWithResponses) ListAuthorityProvisionersWithResponse(ctx context.Context, authorityID AuthorityID, params *ListAuthorityProvisionersParams, reqEditors ...RequestEditorFn) (*ListAuthorityProvisionersResponse, error) { - rsp, err := c.ListAuthorityProvisioners(ctx, authorityID, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseListAuthorityProvisionersResponse(rsp) -} - -// PostAuthorityProvisionersWithBodyWithResponse request with arbitrary body returning *PostAuthorityProvisionersResponse -func (c *ClientWithResponses) PostAuthorityProvisionersWithBodyWithResponse(ctx context.Context, authorityID AuthorityID, params *PostAuthorityProvisionersParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostAuthorityProvisionersResponse, error) { - rsp, err := c.PostAuthorityProvisionersWithBody(ctx, authorityID, params, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParsePostAuthorityProvisionersResponse(rsp) -} - -func (c *ClientWithResponses) PostAuthorityProvisionersWithResponse(ctx context.Context, authorityID AuthorityID, params *PostAuthorityProvisionersParams, body PostAuthorityProvisionersJSONRequestBody, reqEditors ...RequestEditorFn) (*PostAuthorityProvisionersResponse, error) { - rsp, err := c.PostAuthorityProvisioners(ctx, authorityID, params, body, reqEditors...) - if err != nil { - return nil, err - } - return ParsePostAuthorityProvisionersResponse(rsp) -} - -// DeleteProvisionerWithResponse request returning *DeleteProvisionerResponse -func (c *ClientWithResponses) DeleteProvisionerWithResponse(ctx context.Context, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, params *DeleteProvisionerParams, reqEditors ...RequestEditorFn) (*DeleteProvisionerResponse, error) { - rsp, err := c.DeleteProvisioner(ctx, authorityID, provisionerNameOrID, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseDeleteProvisionerResponse(rsp) -} - -// GetProvisionerWithResponse request returning *GetProvisionerResponse -func (c *ClientWithResponses) GetProvisionerWithResponse(ctx context.Context, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, params *GetProvisionerParams, reqEditors ...RequestEditorFn) (*GetProvisionerResponse, error) { - rsp, err := c.GetProvisioner(ctx, authorityID, provisionerNameOrID, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseGetProvisionerResponse(rsp) -} - -// PostWebhooksWithBodyWithResponse request with arbitrary body returning *PostWebhooksResponse -func (c *ClientWithResponses) PostWebhooksWithBodyWithResponse(ctx context.Context, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, params *PostWebhooksParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostWebhooksResponse, error) { - rsp, err := c.PostWebhooksWithBody(ctx, authorityID, provisionerNameOrID, params, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParsePostWebhooksResponse(rsp) -} - -func (c *ClientWithResponses) PostWebhooksWithResponse(ctx context.Context, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, params *PostWebhooksParams, body PostWebhooksJSONRequestBody, reqEditors ...RequestEditorFn) (*PostWebhooksResponse, error) { - rsp, err := c.PostWebhooks(ctx, authorityID, provisionerNameOrID, params, body, reqEditors...) - if err != nil { - return nil, err - } - return ParsePostWebhooksResponse(rsp) -} - -// DeleteWebhookWithResponse request returning *DeleteWebhookResponse -func (c *ClientWithResponses) DeleteWebhookWithResponse(ctx context.Context, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, webhookNameOrID WebhookNameOrID, params *DeleteWebhookParams, reqEditors ...RequestEditorFn) (*DeleteWebhookResponse, error) { - rsp, err := c.DeleteWebhook(ctx, authorityID, provisionerNameOrID, webhookNameOrID, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseDeleteWebhookResponse(rsp) -} - -// GetWebhookWithResponse request returning *GetWebhookResponse -func (c *ClientWithResponses) GetWebhookWithResponse(ctx context.Context, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, webhookNameOrID WebhookNameOrID, params *GetWebhookParams, reqEditors ...RequestEditorFn) (*GetWebhookResponse, error) { - rsp, err := c.GetWebhook(ctx, authorityID, provisionerNameOrID, webhookNameOrID, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseGetWebhookResponse(rsp) -} - -// PostAuthorityRootWithBodyWithResponse request with arbitrary body returning *PostAuthorityRootResponse -func (c *ClientWithResponses) PostAuthorityRootWithBodyWithResponse(ctx context.Context, authorityID AuthorityID, params *PostAuthorityRootParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostAuthorityRootResponse, error) { - rsp, err := c.PostAuthorityRootWithBody(ctx, authorityID, params, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParsePostAuthorityRootResponse(rsp) -} - -func (c *ClientWithResponses) PostAuthorityRootWithResponse(ctx context.Context, authorityID AuthorityID, params *PostAuthorityRootParams, body PostAuthorityRootJSONRequestBody, reqEditors ...RequestEditorFn) (*PostAuthorityRootResponse, error) { - rsp, err := c.PostAuthorityRoot(ctx, authorityID, params, body, reqEditors...) - if err != nil { - return nil, err - } - return ParsePostAuthorityRootResponse(rsp) -} - -// ListCertificatesWithResponse request returning *ListCertificatesResponse -func (c *ClientWithResponses) ListCertificatesWithResponse(ctx context.Context, params *ListCertificatesParams, reqEditors ...RequestEditorFn) (*ListCertificatesResponse, error) { - rsp, err := c.ListCertificates(ctx, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseListCertificatesResponse(rsp) -} - -// GetCertificateWithResponse request returning *GetCertificateResponse -func (c *ClientWithResponses) GetCertificateWithResponse(ctx context.Context, serialNumber SerialNumber, params *GetCertificateParams, reqEditors ...RequestEditorFn) (*GetCertificateResponse, error) { - rsp, err := c.GetCertificate(ctx, serialNumber, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseGetCertificateResponse(rsp) -} - -// ListCollectionsWithResponse request returning *ListCollectionsResponse -func (c *ClientWithResponses) ListCollectionsWithResponse(ctx context.Context, params *ListCollectionsParams, reqEditors ...RequestEditorFn) (*ListCollectionsResponse, error) { - rsp, err := c.ListCollections(ctx, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseListCollectionsResponse(rsp) -} - -// PostCollectionsWithBodyWithResponse request with arbitrary body returning *PostCollectionsResponse -func (c *ClientWithResponses) PostCollectionsWithBodyWithResponse(ctx context.Context, params *PostCollectionsParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostCollectionsResponse, error) { - rsp, err := c.PostCollectionsWithBody(ctx, params, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParsePostCollectionsResponse(rsp) -} - -func (c *ClientWithResponses) PostCollectionsWithResponse(ctx context.Context, params *PostCollectionsParams, body PostCollectionsJSONRequestBody, reqEditors ...RequestEditorFn) (*PostCollectionsResponse, error) { - rsp, err := c.PostCollections(ctx, params, body, reqEditors...) - if err != nil { - return nil, err - } - return ParsePostCollectionsResponse(rsp) -} - -// DeleteCollectionWithResponse request returning *DeleteCollectionResponse -func (c *ClientWithResponses) DeleteCollectionWithResponse(ctx context.Context, collectionSlug CollectionSlug, params *DeleteCollectionParams, reqEditors ...RequestEditorFn) (*DeleteCollectionResponse, error) { - rsp, err := c.DeleteCollection(ctx, collectionSlug, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseDeleteCollectionResponse(rsp) -} - -// GetCollectionWithResponse request returning *GetCollectionResponse -func (c *ClientWithResponses) GetCollectionWithResponse(ctx context.Context, collectionSlug CollectionSlug, params *GetCollectionParams, reqEditors ...RequestEditorFn) (*GetCollectionResponse, error) { - rsp, err := c.GetCollection(ctx, collectionSlug, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseGetCollectionResponse(rsp) -} - -// PutCollectionWithBodyWithResponse request with arbitrary body returning *PutCollectionResponse -func (c *ClientWithResponses) PutCollectionWithBodyWithResponse(ctx context.Context, collectionSlug CollectionSlug, params *PutCollectionParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutCollectionResponse, error) { - rsp, err := c.PutCollectionWithBody(ctx, collectionSlug, params, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParsePutCollectionResponse(rsp) -} - -func (c *ClientWithResponses) PutCollectionWithResponse(ctx context.Context, collectionSlug CollectionSlug, params *PutCollectionParams, body PutCollectionJSONRequestBody, reqEditors ...RequestEditorFn) (*PutCollectionResponse, error) { - rsp, err := c.PutCollection(ctx, collectionSlug, params, body, reqEditors...) - if err != nil { - return nil, err - } - return ParsePutCollectionResponse(rsp) -} - -// DeleteCollectionInstanceWithResponse request returning *DeleteCollectionInstanceResponse -func (c *ClientWithResponses) DeleteCollectionInstanceWithResponse(ctx context.Context, collectionSlug CollectionSlug, instanceID InstanceID, params *DeleteCollectionInstanceParams, reqEditors ...RequestEditorFn) (*DeleteCollectionInstanceResponse, error) { - rsp, err := c.DeleteCollectionInstance(ctx, collectionSlug, instanceID, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseDeleteCollectionInstanceResponse(rsp) -} - -// GetCollectionInstanceWithResponse request returning *GetCollectionInstanceResponse -func (c *ClientWithResponses) GetCollectionInstanceWithResponse(ctx context.Context, collectionSlug CollectionSlug, instanceID InstanceID, params *GetCollectionInstanceParams, reqEditors ...RequestEditorFn) (*GetCollectionInstanceResponse, error) { - rsp, err := c.GetCollectionInstance(ctx, collectionSlug, instanceID, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseGetCollectionInstanceResponse(rsp) -} - -// PutCollectionInstanceWithBodyWithResponse request with arbitrary body returning *PutCollectionInstanceResponse -func (c *ClientWithResponses) PutCollectionInstanceWithBodyWithResponse(ctx context.Context, collectionSlug CollectionSlug, instanceID InstanceID, params *PutCollectionInstanceParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutCollectionInstanceResponse, error) { - rsp, err := c.PutCollectionInstanceWithBody(ctx, collectionSlug, instanceID, params, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParsePutCollectionInstanceResponse(rsp) -} - -func (c *ClientWithResponses) PutCollectionInstanceWithResponse(ctx context.Context, collectionSlug CollectionSlug, instanceID InstanceID, params *PutCollectionInstanceParams, body PutCollectionInstanceJSONRequestBody, reqEditors ...RequestEditorFn) (*PutCollectionInstanceResponse, error) { - rsp, err := c.PutCollectionInstance(ctx, collectionSlug, instanceID, params, body, reqEditors...) - if err != nil { - return nil, err - } - return ParsePutCollectionInstanceResponse(rsp) -} - -// GetCollectionInstanceDataWithResponse request returning *GetCollectionInstanceDataResponse -func (c *ClientWithResponses) GetCollectionInstanceDataWithResponse(ctx context.Context, collectionSlug CollectionSlug, instanceID InstanceID, params *GetCollectionInstanceDataParams, reqEditors ...RequestEditorFn) (*GetCollectionInstanceDataResponse, error) { - rsp, err := c.GetCollectionInstanceData(ctx, collectionSlug, instanceID, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseGetCollectionInstanceDataResponse(rsp) -} - -// PutCollectionInstanceDataWithBodyWithResponse request with arbitrary body returning *PutCollectionInstanceDataResponse -func (c *ClientWithResponses) PutCollectionInstanceDataWithBodyWithResponse(ctx context.Context, collectionSlug CollectionSlug, instanceID InstanceID, params *PutCollectionInstanceDataParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutCollectionInstanceDataResponse, error) { - rsp, err := c.PutCollectionInstanceDataWithBody(ctx, collectionSlug, instanceID, params, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParsePutCollectionInstanceDataResponse(rsp) -} - -func (c *ClientWithResponses) PutCollectionInstanceDataWithResponse(ctx context.Context, collectionSlug CollectionSlug, instanceID InstanceID, params *PutCollectionInstanceDataParams, body PutCollectionInstanceDataJSONRequestBody, reqEditors ...RequestEditorFn) (*PutCollectionInstanceDataResponse, error) { - rsp, err := c.PutCollectionInstanceData(ctx, collectionSlug, instanceID, params, body, reqEditors...) - if err != nil { - return nil, err - } - return ParsePutCollectionInstanceDataResponse(rsp) -} - -// ListCollectionInstancesWithResponse request returning *ListCollectionInstancesResponse -func (c *ClientWithResponses) ListCollectionInstancesWithResponse(ctx context.Context, collectionSlug CollectionSlug, params *ListCollectionInstancesParams, reqEditors ...RequestEditorFn) (*ListCollectionInstancesResponse, error) { - rsp, err := c.ListCollectionInstances(ctx, collectionSlug, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseListCollectionInstancesResponse(rsp) -} - -// DeleteDeviceCollectionWithResponse request returning *DeleteDeviceCollectionResponse -func (c *ClientWithResponses) DeleteDeviceCollectionWithResponse(ctx context.Context, collectionSlug CollectionSlug, params *DeleteDeviceCollectionParams, reqEditors ...RequestEditorFn) (*DeleteDeviceCollectionResponse, error) { - rsp, err := c.DeleteDeviceCollection(ctx, collectionSlug, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseDeleteDeviceCollectionResponse(rsp) -} - -// GetDeviceCollectionWithResponse request returning *GetDeviceCollectionResponse -func (c *ClientWithResponses) GetDeviceCollectionWithResponse(ctx context.Context, collectionSlug CollectionSlug, params *GetDeviceCollectionParams, reqEditors ...RequestEditorFn) (*GetDeviceCollectionResponse, error) { - rsp, err := c.GetDeviceCollection(ctx, collectionSlug, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseGetDeviceCollectionResponse(rsp) -} - -// PutDeviceCollectionWithBodyWithResponse request with arbitrary body returning *PutDeviceCollectionResponse -func (c *ClientWithResponses) PutDeviceCollectionWithBodyWithResponse(ctx context.Context, collectionSlug CollectionSlug, params *PutDeviceCollectionParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutDeviceCollectionResponse, error) { - rsp, err := c.PutDeviceCollectionWithBody(ctx, collectionSlug, params, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParsePutDeviceCollectionResponse(rsp) -} - -func (c *ClientWithResponses) PutDeviceCollectionWithResponse(ctx context.Context, collectionSlug CollectionSlug, params *PutDeviceCollectionParams, body PutDeviceCollectionJSONRequestBody, reqEditors ...RequestEditorFn) (*PutDeviceCollectionResponse, error) { - rsp, err := c.PutDeviceCollection(ctx, collectionSlug, params, body, reqEditors...) - if err != nil { - return nil, err - } - return ParsePutDeviceCollectionResponse(rsp) -} - -// DeleteDeviceCollectionAccountWithResponse request returning *DeleteDeviceCollectionAccountResponse -func (c *ClientWithResponses) DeleteDeviceCollectionAccountWithResponse(ctx context.Context, collectionSlug CollectionSlug, accountSlug AccountSlug, params *DeleteDeviceCollectionAccountParams, reqEditors ...RequestEditorFn) (*DeleteDeviceCollectionAccountResponse, error) { - rsp, err := c.DeleteDeviceCollectionAccount(ctx, collectionSlug, accountSlug, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseDeleteDeviceCollectionAccountResponse(rsp) -} - -// GetDeviceCollectionAccountWithResponse request returning *GetDeviceCollectionAccountResponse -func (c *ClientWithResponses) GetDeviceCollectionAccountWithResponse(ctx context.Context, collectionSlug CollectionSlug, accountSlug AccountSlug, params *GetDeviceCollectionAccountParams, reqEditors ...RequestEditorFn) (*GetDeviceCollectionAccountResponse, error) { - rsp, err := c.GetDeviceCollectionAccount(ctx, collectionSlug, accountSlug, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseGetDeviceCollectionAccountResponse(rsp) -} - -// PutDeviceCollectionAccountWithBodyWithResponse request with arbitrary body returning *PutDeviceCollectionAccountResponse -func (c *ClientWithResponses) PutDeviceCollectionAccountWithBodyWithResponse(ctx context.Context, collectionSlug CollectionSlug, accountSlug AccountSlug, params *PutDeviceCollectionAccountParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutDeviceCollectionAccountResponse, error) { - rsp, err := c.PutDeviceCollectionAccountWithBody(ctx, collectionSlug, accountSlug, params, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParsePutDeviceCollectionAccountResponse(rsp) -} - -func (c *ClientWithResponses) PutDeviceCollectionAccountWithResponse(ctx context.Context, collectionSlug CollectionSlug, accountSlug AccountSlug, params *PutDeviceCollectionAccountParams, body PutDeviceCollectionAccountJSONRequestBody, reqEditors ...RequestEditorFn) (*PutDeviceCollectionAccountResponse, error) { - rsp, err := c.PutDeviceCollectionAccount(ctx, collectionSlug, accountSlug, params, body, reqEditors...) - if err != nil { - return nil, err - } - return ParsePutDeviceCollectionAccountResponse(rsp) -} - -// DeleteWorkloadWithResponse request returning *DeleteWorkloadResponse -func (c *ClientWithResponses) DeleteWorkloadWithResponse(ctx context.Context, collectionSlug CollectionSlug, workloadSlug WorkloadSlug, params *DeleteWorkloadParams, reqEditors ...RequestEditorFn) (*DeleteWorkloadResponse, error) { - rsp, err := c.DeleteWorkload(ctx, collectionSlug, workloadSlug, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseDeleteWorkloadResponse(rsp) -} - -// GetWorkloadWithResponse request returning *GetWorkloadResponse -func (c *ClientWithResponses) GetWorkloadWithResponse(ctx context.Context, collectionSlug CollectionSlug, workloadSlug WorkloadSlug, params *GetWorkloadParams, reqEditors ...RequestEditorFn) (*GetWorkloadResponse, error) { - rsp, err := c.GetWorkload(ctx, collectionSlug, workloadSlug, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseGetWorkloadResponse(rsp) -} - -// PutWorkloadWithBodyWithResponse request with arbitrary body returning *PutWorkloadResponse -func (c *ClientWithResponses) PutWorkloadWithBodyWithResponse(ctx context.Context, collectionSlug CollectionSlug, workloadSlug WorkloadSlug, params *PutWorkloadParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutWorkloadResponse, error) { - rsp, err := c.PutWorkloadWithBody(ctx, collectionSlug, workloadSlug, params, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParsePutWorkloadResponse(rsp) -} - -func (c *ClientWithResponses) PutWorkloadWithResponse(ctx context.Context, collectionSlug CollectionSlug, workloadSlug WorkloadSlug, params *PutWorkloadParams, body PutWorkloadJSONRequestBody, reqEditors ...RequestEditorFn) (*PutWorkloadResponse, error) { - rsp, err := c.PutWorkload(ctx, collectionSlug, workloadSlug, params, body, reqEditors...) - if err != nil { - return nil, err - } - return ParsePutWorkloadResponse(rsp) -} - -// PostDeviceEnrollmentTokenWithBodyWithResponse request with arbitrary body returning *PostDeviceEnrollmentTokenResponse -func (c *ClientWithResponses) PostDeviceEnrollmentTokenWithBodyWithResponse(ctx context.Context, collectionSlug CollectionSlug, instanceID InstanceID, params *PostDeviceEnrollmentTokenParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostDeviceEnrollmentTokenResponse, error) { - rsp, err := c.PostDeviceEnrollmentTokenWithBody(ctx, collectionSlug, instanceID, params, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParsePostDeviceEnrollmentTokenResponse(rsp) -} - -func (c *ClientWithResponses) PostDeviceEnrollmentTokenWithResponse(ctx context.Context, collectionSlug CollectionSlug, instanceID InstanceID, params *PostDeviceEnrollmentTokenParams, body PostDeviceEnrollmentTokenJSONRequestBody, reqEditors ...RequestEditorFn) (*PostDeviceEnrollmentTokenResponse, error) { - rsp, err := c.PostDeviceEnrollmentToken(ctx, collectionSlug, instanceID, params, body, reqEditors...) - if err != nil { - return nil, err - } - return ParsePostDeviceEnrollmentTokenResponse(rsp) -} - -// GetSshGrantsWithResponse request returning *GetSshGrantsResponse -func (c *ClientWithResponses) GetSshGrantsWithResponse(ctx context.Context, params *GetSshGrantsParams, reqEditors ...RequestEditorFn) (*GetSshGrantsResponse, error) { - rsp, err := c.GetSshGrants(ctx, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseGetSshGrantsResponse(rsp) -} - -// PostSshGrantsWithBodyWithResponse request with arbitrary body returning *PostSshGrantsResponse -func (c *ClientWithResponses) PostSshGrantsWithBodyWithResponse(ctx context.Context, params *PostSshGrantsParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSshGrantsResponse, error) { - rsp, err := c.PostSshGrantsWithBody(ctx, params, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParsePostSshGrantsResponse(rsp) -} - -func (c *ClientWithResponses) PostSshGrantsWithResponse(ctx context.Context, params *PostSshGrantsParams, body PostSshGrantsJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSshGrantsResponse, error) { - rsp, err := c.PostSshGrants(ctx, params, body, reqEditors...) - if err != nil { - return nil, err - } - return ParsePostSshGrantsResponse(rsp) -} - -// DeleteSshGrantWithResponse request returning *DeleteSshGrantResponse -func (c *ClientWithResponses) DeleteSshGrantWithResponse(ctx context.Context, grantID GrantID, params *DeleteSshGrantParams, reqEditors ...RequestEditorFn) (*DeleteSshGrantResponse, error) { - rsp, err := c.DeleteSshGrant(ctx, grantID, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseDeleteSshGrantResponse(rsp) -} - -// GetSshGrantWithResponse request returning *GetSshGrantResponse -func (c *ClientWithResponses) GetSshGrantWithResponse(ctx context.Context, grantID GrantID, params *GetSshGrantParams, reqEditors ...RequestEditorFn) (*GetSshGrantResponse, error) { - rsp, err := c.GetSshGrant(ctx, grantID, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseGetSshGrantResponse(rsp) -} - -// GetSshGroupsWithResponse request returning *GetSshGroupsResponse -func (c *ClientWithResponses) GetSshGroupsWithResponse(ctx context.Context, params *GetSshGroupsParams, reqEditors ...RequestEditorFn) (*GetSshGroupsResponse, error) { - rsp, err := c.GetSshGroups(ctx, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseGetSshGroupsResponse(rsp) -} - -// GetSshGroupWithResponse request returning *GetSshGroupResponse -func (c *ClientWithResponses) GetSshGroupWithResponse(ctx context.Context, groupID GroupID, params *GetSshGroupParams, reqEditors ...RequestEditorFn) (*GetSshGroupResponse, error) { - rsp, err := c.GetSshGroup(ctx, groupID, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseGetSshGroupResponse(rsp) -} - -// GetSshHostsWithResponse request returning *GetSshHostsResponse -func (c *ClientWithResponses) GetSshHostsWithResponse(ctx context.Context, params *GetSshHostsParams, reqEditors ...RequestEditorFn) (*GetSshHostsResponse, error) { - rsp, err := c.GetSshHosts(ctx, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseGetSshHostsResponse(rsp) -} - -// GetSshHostWithResponse request returning *GetSshHostResponse -func (c *ClientWithResponses) GetSshHostWithResponse(ctx context.Context, hostID HostID, params *GetSshHostParams, reqEditors ...RequestEditorFn) (*GetSshHostResponse, error) { - rsp, err := c.GetSshHost(ctx, hostID, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseGetSshHostResponse(rsp) -} - -// PostHostsHostIDTagsWithBodyWithResponse request with arbitrary body returning *PostHostsHostIDTagsResponse -func (c *ClientWithResponses) PostHostsHostIDTagsWithBodyWithResponse(ctx context.Context, hostID HostID, params *PostHostsHostIDTagsParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostHostsHostIDTagsResponse, error) { - rsp, err := c.PostHostsHostIDTagsWithBody(ctx, hostID, params, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParsePostHostsHostIDTagsResponse(rsp) -} - -func (c *ClientWithResponses) PostHostsHostIDTagsWithResponse(ctx context.Context, hostID HostID, params *PostHostsHostIDTagsParams, body PostHostsHostIDTagsJSONRequestBody, reqEditors ...RequestEditorFn) (*PostHostsHostIDTagsResponse, error) { - rsp, err := c.PostHostsHostIDTags(ctx, hostID, params, body, reqEditors...) - if err != nil { - return nil, err - } - return ParsePostHostsHostIDTagsResponse(rsp) -} - -// UnregisterSshHostWithResponse request returning *UnregisterSshHostResponse -func (c *ClientWithResponses) UnregisterSshHostWithResponse(ctx context.Context, hostID HostID, params *UnregisterSshHostParams, reqEditors ...RequestEditorFn) (*UnregisterSshHostResponse, error) { - rsp, err := c.UnregisterSshHost(ctx, hostID, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseUnregisterSshHostResponse(rsp) -} - -// GetPlatformsWithResponse request returning *GetPlatformsResponse -func (c *ClientWithResponses) GetPlatformsWithResponse(ctx context.Context, params *GetPlatformsParams, reqEditors ...RequestEditorFn) (*GetPlatformsResponse, error) { - rsp, err := c.GetPlatforms(ctx, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseGetPlatformsResponse(rsp) -} - -// PutPlatformWithBodyWithResponse request with arbitrary body returning *PutPlatformResponse -func (c *ClientWithResponses) PutPlatformWithBodyWithResponse(ctx context.Context, platformSlug PlatformSlug, params *PutPlatformParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutPlatformResponse, error) { - rsp, err := c.PutPlatformWithBody(ctx, platformSlug, params, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParsePutPlatformResponse(rsp) -} - -func (c *ClientWithResponses) PutPlatformWithResponse(ctx context.Context, platformSlug PlatformSlug, params *PutPlatformParams, body PutPlatformJSONRequestBody, reqEditors ...RequestEditorFn) (*PutPlatformResponse, error) { - rsp, err := c.PutPlatform(ctx, platformSlug, params, body, reqEditors...) - if err != nil { - return nil, err - } - return ParsePutPlatformResponse(rsp) -} - -// GetSshHostTagsWithResponse request returning *GetSshHostTagsResponse -func (c *ClientWithResponses) GetSshHostTagsWithResponse(ctx context.Context, params *GetSshHostTagsParams, reqEditors ...RequestEditorFn) (*GetSshHostTagsResponse, error) { - rsp, err := c.GetSshHostTags(ctx, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseGetSshHostTagsResponse(rsp) -} - -// GetSshUsersWithResponse request returning *GetSshUsersResponse -func (c *ClientWithResponses) GetSshUsersWithResponse(ctx context.Context, params *GetSshUsersParams, reqEditors ...RequestEditorFn) (*GetSshUsersResponse, error) { - rsp, err := c.GetSshUsers(ctx, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseGetSshUsersResponse(rsp) -} - -// ParseListAccountsResponse parses an HTTP response from a ListAccountsWithResponse call -func ParseListAccountsResponse(rsp *http.Response) (*ListAccountsResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &ListAccountsResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest []Account - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParsePostAccountsResponse parses an HTTP response from a PostAccountsWithResponse call -func ParsePostAccountsResponse(rsp *http.Response) (*PostAccountsResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &PostAccountsResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: - var dest Account - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON201 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParseDeleteAccountResponse parses an HTTP response from a DeleteAccountWithResponse call -func ParseDeleteAccountResponse(rsp *http.Response) (*DeleteAccountResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &DeleteAccountResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParseGetAccountResponse parses an HTTP response from a GetAccountWithResponse call -func ParseGetAccountResponse(rsp *http.Response) (*GetAccountResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &GetAccountResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Account - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: - var dest N404 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON404 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParsePutAccountResponse parses an HTTP response from a PutAccountWithResponse call -func ParsePutAccountResponse(rsp *http.Response) (*PutAccountResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &PutAccountResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Account - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON404 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParseGetAttestationAuthoritiesResponse parses an HTTP response from a GetAttestationAuthoritiesWithResponse call -func ParseGetAttestationAuthoritiesResponse(rsp *http.Response) (*GetAttestationAuthoritiesResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &GetAttestationAuthoritiesResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest []AttestationAuthority - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParsePostAttestationAuthoritiesResponse parses an HTTP response from a PostAttestationAuthoritiesWithResponse call -func ParsePostAttestationAuthoritiesResponse(rsp *http.Response) (*PostAttestationAuthoritiesResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &PostAttestationAuthoritiesResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: - var dest AttestationAuthority - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON201 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: - var dest N409 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON409 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParseDeleteAttestationAuthorityResponse parses an HTTP response from a DeleteAttestationAuthorityWithResponse call -func ParseDeleteAttestationAuthorityResponse(rsp *http.Response) (*DeleteAttestationAuthorityResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &DeleteAttestationAuthorityResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParseGetAttestationAuthorityResponse parses an HTTP response from a GetAttestationAuthorityWithResponse call -func ParseGetAttestationAuthorityResponse(rsp *http.Response) (*GetAttestationAuthorityResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &GetAttestationAuthorityResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest AttestationAuthority - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: - var dest N404 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON404 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParsePostAuthResponse parses an HTTP response from a PostAuthWithResponse call -func ParsePostAuthResponse(rsp *http.Response) (*PostAuthResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &PostAuthResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: - var dest struct { - Token *string `json:"token,omitempty"` - } - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON201 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: - var dest N403 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON403 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParseGetAuthoritiesResponse parses an HTTP response from a GetAuthoritiesWithResponse call -func ParseGetAuthoritiesResponse(rsp *http.Response) (*GetAuthoritiesResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &GetAuthoritiesResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest []Authority - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParsePostAuthoritiesResponse parses an HTTP response from a PostAuthoritiesWithResponse call -func ParsePostAuthoritiesResponse(rsp *http.Response) (*PostAuthoritiesResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &PostAuthoritiesResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: - var dest Authority - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON201 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: - var dest N409 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON409 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 412: - var dest N412 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON412 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 422: - var dest N422 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON422 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParsePostAuthoritiesCsrResponse parses an HTTP response from a PostAuthoritiesCsrWithResponse call -func ParsePostAuthoritiesCsrResponse(rsp *http.Response) (*PostAuthoritiesCsrResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &PostAuthoritiesCsrResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: - var dest AuthorityCsr - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON201 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: - var dest N409 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON409 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 412: - var dest N412 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON412 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParseDeleteAuthorityResponse parses an HTTP response from a DeleteAuthorityWithResponse call -func ParseDeleteAuthorityResponse(rsp *http.Response) (*DeleteAuthorityResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &DeleteAuthorityResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 422: - var dest N422 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON422 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParseGetAuthorityResponse parses an HTTP response from a GetAuthorityWithResponse call -func ParseGetAuthorityResponse(rsp *http.Response) (*GetAuthorityResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &GetAuthorityResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Authority - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: - var dest N404 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON404 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParseListAuthorityProvisionersResponse parses an HTTP response from a ListAuthorityProvisionersWithResponse call -func ParseListAuthorityProvisionersResponse(rsp *http.Response) (*ListAuthorityProvisionersResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &ListAuthorityProvisionersResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest []Provisioner - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: - var dest N404 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON404 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParsePostAuthorityProvisionersResponse parses an HTTP response from a PostAuthorityProvisionersWithResponse call -func ParsePostAuthorityProvisionersResponse(rsp *http.Response) (*PostAuthorityProvisionersResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &PostAuthorityProvisionersResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: - var dest Provisioner - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON201 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: - var dest N404 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON404 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: - var dest N409 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON409 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 422: - var dest N422 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON422 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParseDeleteProvisionerResponse parses an HTTP response from a DeleteProvisionerWithResponse call -func ParseDeleteProvisionerResponse(rsp *http.Response) (*DeleteProvisionerResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &DeleteProvisionerResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 422: - var dest N422 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON422 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParseGetProvisionerResponse parses an HTTP response from a GetProvisionerWithResponse call -func ParseGetProvisionerResponse(rsp *http.Response) (*GetProvisionerResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &GetProvisionerResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Provisioner - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: - var dest N404 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON404 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParsePostWebhooksResponse parses an HTTP response from a PostWebhooksWithResponse call -func ParsePostWebhooksResponse(rsp *http.Response) (*PostWebhooksResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &PostWebhooksResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: - var dest ProvisionerWebhook - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON201 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: - var dest N404 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON404 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: - var dest N409 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON409 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 412: - var dest N412 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON412 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 422: - var dest N422 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON422 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParseDeleteWebhookResponse parses an HTTP response from a DeleteWebhookWithResponse call -func ParseDeleteWebhookResponse(rsp *http.Response) (*DeleteWebhookResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &DeleteWebhookResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 422: - var dest N422 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON422 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParseGetWebhookResponse parses an HTTP response from a GetWebhookWithResponse call -func ParseGetWebhookResponse(rsp *http.Response) (*GetWebhookResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &GetWebhookResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest ProvisionerWebhook - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: - var dest N404 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON404 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParsePostAuthorityRootResponse parses an HTTP response from a PostAuthorityRootWithResponse call -func ParsePostAuthorityRootResponse(rsp *http.Response) (*PostAuthorityRootResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &PostAuthorityRootResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Authority - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: - var dest N404 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON404 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParseListCertificatesResponse parses an HTTP response from a ListCertificatesWithResponse call -func ParseListCertificatesResponse(rsp *http.Response) (*ListCertificatesResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &ListCertificatesResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest []X509Certificate - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParseGetCertificateResponse parses an HTTP response from a GetCertificateWithResponse call -func ParseGetCertificateResponse(rsp *http.Response) (*GetCertificateResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &GetCertificateResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest X509Certificate - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: - var dest N404 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON404 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParseListCollectionsResponse parses an HTTP response from a ListCollectionsWithResponse call -func ParseListCollectionsResponse(rsp *http.Response) (*ListCollectionsResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &ListCollectionsResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest []Collection - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParsePostCollectionsResponse parses an HTTP response from a PostCollectionsWithResponse call -func ParsePostCollectionsResponse(rsp *http.Response) (*PostCollectionsResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &PostCollectionsResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: - var dest Collection - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON201 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: - var dest N409 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON409 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 412: - var dest N412 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON412 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParseDeleteCollectionResponse parses an HTTP response from a DeleteCollectionWithResponse call -func ParseDeleteCollectionResponse(rsp *http.Response) (*DeleteCollectionResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &DeleteCollectionResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParseGetCollectionResponse parses an HTTP response from a GetCollectionWithResponse call -func ParseGetCollectionResponse(rsp *http.Response) (*GetCollectionResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &GetCollectionResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Collection - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON404 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParsePutCollectionResponse parses an HTTP response from a PutCollectionWithResponse call -func ParsePutCollectionResponse(rsp *http.Response) (*PutCollectionResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &PutCollectionResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Collection - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: - var dest N404 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON404 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 412: - var dest N412 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON412 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParseDeleteCollectionInstanceResponse parses an HTTP response from a DeleteCollectionInstanceWithResponse call -func ParseDeleteCollectionInstanceResponse(rsp *http.Response) (*DeleteCollectionInstanceResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &DeleteCollectionInstanceResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParseGetCollectionInstanceResponse parses an HTTP response from a GetCollectionInstanceWithResponse call -func ParseGetCollectionInstanceResponse(rsp *http.Response) (*GetCollectionInstanceResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &GetCollectionInstanceResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest CollectionInstance - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: - var dest N404 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON404 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParsePutCollectionInstanceResponse parses an HTTP response from a PutCollectionInstanceWithResponse call -func ParsePutCollectionInstanceResponse(rsp *http.Response) (*PutCollectionInstanceResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &PutCollectionInstanceResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest CollectionInstance - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: - var dest N409 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON409 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 412: - var dest N412 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON412 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParseGetCollectionInstanceDataResponse parses an HTTP response from a GetCollectionInstanceDataWithResponse call -func ParseGetCollectionInstanceDataResponse(rsp *http.Response) (*GetCollectionInstanceDataResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &GetCollectionInstanceDataResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest interface{} - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: - var dest N404 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON404 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParsePutCollectionInstanceDataResponse parses an HTTP response from a PutCollectionInstanceDataWithResponse call -func ParsePutCollectionInstanceDataResponse(rsp *http.Response) (*PutCollectionInstanceDataResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &PutCollectionInstanceDataResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest interface{} - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: - var dest N409 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON409 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 412: - var dest N412 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON412 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParseListCollectionInstancesResponse parses an HTTP response from a ListCollectionInstancesWithResponse call -func ParseListCollectionInstancesResponse(rsp *http.Response) (*ListCollectionInstancesResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &ListCollectionInstancesResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest []CollectionInstance - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON404 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParseDeleteDeviceCollectionResponse parses an HTTP response from a DeleteDeviceCollectionWithResponse call -func ParseDeleteDeviceCollectionResponse(rsp *http.Response) (*DeleteDeviceCollectionResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &DeleteDeviceCollectionResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 422: - var dest N422 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON422 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParseGetDeviceCollectionResponse parses an HTTP response from a GetDeviceCollectionWithResponse call -func ParseGetDeviceCollectionResponse(rsp *http.Response) (*GetDeviceCollectionResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &GetDeviceCollectionResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest DeviceCollection - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: - var dest N404 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON404 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParsePutDeviceCollectionResponse parses an HTTP response from a PutDeviceCollectionWithResponse call -func ParsePutDeviceCollectionResponse(rsp *http.Response) (*PutDeviceCollectionResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &PutDeviceCollectionResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest DeviceCollection - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: - var dest N409 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON409 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParseDeleteDeviceCollectionAccountResponse parses an HTTP response from a DeleteDeviceCollectionAccountWithResponse call -func ParseDeleteDeviceCollectionAccountResponse(rsp *http.Response) (*DeleteDeviceCollectionAccountResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &DeleteDeviceCollectionAccountResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParseGetDeviceCollectionAccountResponse parses an HTTP response from a GetDeviceCollectionAccountWithResponse call -func ParseGetDeviceCollectionAccountResponse(rsp *http.Response) (*GetDeviceCollectionAccountResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &GetDeviceCollectionAccountResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest DeviceCollectionAccount - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: - var dest N404 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON404 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParsePutDeviceCollectionAccountResponse parses an HTTP response from a PutDeviceCollectionAccountWithResponse call -func ParsePutDeviceCollectionAccountResponse(rsp *http.Response) (*PutDeviceCollectionAccountResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &PutDeviceCollectionAccountResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest DeviceCollectionAccount - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: - var dest N404 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON404 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 422: - var dest N422 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON422 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParseDeleteWorkloadResponse parses an HTTP response from a DeleteWorkloadWithResponse call -func ParseDeleteWorkloadResponse(rsp *http.Response) (*DeleteWorkloadResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &DeleteWorkloadResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParseGetWorkloadResponse parses an HTTP response from a GetWorkloadWithResponse call -func ParseGetWorkloadResponse(rsp *http.Response) (*GetWorkloadResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &GetWorkloadResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Workload - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: - var dest N404 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON404 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParsePutWorkloadResponse parses an HTTP response from a PutWorkloadWithResponse call -func ParsePutWorkloadResponse(rsp *http.Response) (*PutWorkloadResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &PutWorkloadResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Workload - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: - var dest N404 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON404 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 412: - var dest N412 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON412 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParsePostDeviceEnrollmentTokenResponse parses an HTTP response from a PostDeviceEnrollmentTokenWithResponse call -func ParsePostDeviceEnrollmentTokenResponse(rsp *http.Response) (*PostDeviceEnrollmentTokenResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &PostDeviceEnrollmentTokenResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: - var dest EnrollmentToken - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON201 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: - var dest N404 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON404 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 412: - var dest N412 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON412 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParseGetSshGrantsResponse parses an HTTP response from a GetSshGrantsWithResponse call -func ParseGetSshGrantsResponse(rsp *http.Response) (*GetSshGrantsResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &GetSshGrantsResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest []Grant - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParsePostSshGrantsResponse parses an HTTP response from a PostSshGrantsWithResponse call -func ParsePostSshGrantsResponse(rsp *http.Response) (*PostSshGrantsResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &PostSshGrantsResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: - var dest Grant - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON201 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParseDeleteSshGrantResponse parses an HTTP response from a DeleteSshGrantWithResponse call -func ParseDeleteSshGrantResponse(rsp *http.Response) (*DeleteSshGrantResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &DeleteSshGrantResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParseGetSshGrantResponse parses an HTTP response from a GetSshGrantWithResponse call -func ParseGetSshGrantResponse(rsp *http.Response) (*GetSshGrantResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &GetSshGrantResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Grant - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: - var dest N404 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON404 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParseGetSshGroupsResponse parses an HTTP response from a GetSshGroupsWithResponse call -func ParseGetSshGroupsResponse(rsp *http.Response) (*GetSshGroupsResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &GetSshGroupsResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest []Group - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParseGetSshGroupResponse parses an HTTP response from a GetSshGroupWithResponse call -func ParseGetSshGroupResponse(rsp *http.Response) (*GetSshGroupResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &GetSshGroupResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Group - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: - var dest N404 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON404 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParseGetSshHostsResponse parses an HTTP response from a GetSshHostsWithResponse call -func ParseGetSshHostsResponse(rsp *http.Response) (*GetSshHostsResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &GetSshHostsResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest []Host - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParseGetSshHostResponse parses an HTTP response from a GetSshHostWithResponse call -func ParseGetSshHostResponse(rsp *http.Response) (*GetSshHostResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &GetSshHostResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Host - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: - var dest N404 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON404 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParsePostHostsHostIDTagsResponse parses an HTTP response from a PostHostsHostIDTagsWithResponse call -func ParsePostHostsHostIDTagsResponse(rsp *http.Response) (*PostHostsHostIDTagsResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &PostHostsHostIDTagsResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: - var dest Tag - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON201 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: - var dest N404 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON404 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParseUnregisterSshHostResponse parses an HTTP response from a UnregisterSshHostWithResponse call -func ParseUnregisterSshHostResponse(rsp *http.Response) (*UnregisterSshHostResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &UnregisterSshHostResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Host - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParseGetPlatformsResponse parses an HTTP response from a GetPlatformsWithResponse call -func ParseGetPlatformsResponse(rsp *http.Response) (*GetPlatformsResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &GetPlatformsResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest []Platform - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParsePutPlatformResponse parses an HTTP response from a PutPlatformWithResponse call -func ParsePutPlatformResponse(rsp *http.Response) (*PutPlatformResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &PutPlatformResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Platform - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParseGetSshHostTagsResponse parses an HTTP response from a GetSshHostTagsWithResponse call -func ParseGetSshHostTagsResponse(rsp *http.Response) (*GetSshHostTagsResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &GetSshHostTagsResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest []Tag - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParseGetSshUsersResponse parses an HTTP response from a GetSshUsersWithResponse call -func ParseGetSshUsersResponse(rsp *http.Response) (*GetSshUsersResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &GetSshUsersResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest []User - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest N400 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest N401 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest N500 - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// Base64 encoded, gzipped, json marshaled Swagger object -var swaggerSpec = []string{ - - "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", - "YBgiEgqlpPZukgYUov7/AAAA//+rTsveFtkBAA==", -} - -// GetSwagger returns the content of the embedded swagger specification file -// or error if failed to decode -func decodeSpec() ([]byte, error) { - zipped, err := base64.StdEncoding.DecodeString(strings.Join(swaggerSpec, "")) - if err != nil { - return nil, fmt.Errorf("error base64 decoding spec: %w", err) - } - zr, err := gzip.NewReader(bytes.NewReader(zipped)) - if err != nil { - return nil, fmt.Errorf("error decompressing spec: %w", err) - } - var buf bytes.Buffer - _, err = buf.ReadFrom(zr) - if err != nil { - return nil, fmt.Errorf("error decompressing spec: %w", err) - } - - return buf.Bytes(), nil -} - -var rawSpec = decodeSpecCached() - -// a naive cached of a decoded swagger spec -func decodeSpecCached() func() ([]byte, error) { - data, err := decodeSpec() - return func() ([]byte, error) { - return data, err - } -} - -// Constructs a synthetic filesystem for resolving external references when loading openapi specifications. -func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error) { - res := make(map[string]func() ([]byte, error)) - if len(pathToFile) > 0 { - res[pathToFile] = rawSpec - } - - return res -} - -// GetSwagger returns the Swagger specification corresponding to the generated code -// in this file. The external references of Swagger specification are resolved. -// The logic of resolving external references is tightly connected to "import-mapping" feature. -// Externally referenced files must be embedded in the corresponding golang packages. -// Urls can be supported but this task was out of the scope. -func GetSwagger() (swagger *openapi3.T, err error) { - resolvePath := PathToRawSpec("") - - loader := openapi3.NewLoader() - loader.IsExternalRefsAllowed = true - loader.ReadFromURIFunc = func(loader *openapi3.Loader, url *url.URL) ([]byte, error) { - pathToFile := url.String() - pathToFile = path.Clean(pathToFile) - getSpec, ok := resolvePath[pathToFile] - if !ok { - err1 := fmt.Errorf("path not found: %s", pathToFile) - return nil, err1 - } - return getSpec() - } - var specData []byte - specData, err = rawSpec() - if err != nil { - return - } - swagger, err = loader.LoadFromData(specData) - if err != nil { - return - } - return -} diff --git a/internal/apiclient/v20250101/api.gen.go b/internal/apiclient/v20250101/api.gen.go new file mode 100644 index 0000000000000000000000000000000000000000..af489adf8c62979e902f3ed60023e29c2bab9d30 --- /dev/null +++ b/internal/apiclient/v20250101/api.gen.go @@ -0,0 +1,5621 @@ +// Package v20250101 provides primitives to interact with the openapi HTTP API. +// +// Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.4.1 DO NOT EDIT. +package v20250101 + +import ( + "bytes" + "compress/gzip" + "context" + "encoding/base64" + "encoding/json" + "fmt" + "io" + "net/http" + "net/url" + "path" + "strings" + "time" + + "github.com/getkin/kin-openapi/openapi3" + "github.com/oapi-codegen/runtime" + openapi_types "github.com/oapi-codegen/runtime/types" +) + +const ( + JWTScopes = "JWT.Scopes" + MtlsScopes = "mtls.Scopes" +) + +// Defines values for AcmeAttestationProvisionerAttestationFormats. +const ( + Apple AcmeAttestationProvisionerAttestationFormats = "apple" + Step AcmeAttestationProvisionerAttestationFormats = "step" + Tpm AcmeAttestationProvisionerAttestationFormats = "tpm" +) + +// Defines values for AcmeProvisionerChallenges. +const ( + Dns01 AcmeProvisionerChallenges = "dns-01" + Http01 AcmeProvisionerChallenges = "http-01" + TlsAlpn01 AcmeProvisionerChallenges = "tls-alpn-01" +) + +// Defines values for AuthorityType. +const ( + AuthorityTypeAdvanced AuthorityType = "advanced" + AuthorityTypeDevops AuthorityType = "devops" + AuthorityTypeManaged AuthorityType = "managed" +) + +// Defines values for DeviceOs. +const ( + DeviceOsIOS DeviceOs = "iOS" + DeviceOsLinux DeviceOs = "Linux" + DeviceOsMacOS DeviceOs = "macOS" + DeviceOsTvOS DeviceOs = "tvOS" + DeviceOsVisionOS DeviceOs = "visionOS" + DeviceOsWatchOS DeviceOs = "watchOS" + DeviceOsWindows DeviceOs = "Windows" +) + +// Defines values for DeviceOwnership. +const ( + DeviceOwnershipCompany DeviceOwnership = "company" + DeviceOwnershipUser DeviceOwnership = "user" +) + +// Defines values for DeviceRequestOs. +const ( + DeviceRequestOsIOS DeviceRequestOs = "iOS" + DeviceRequestOsLinux DeviceRequestOs = "Linux" + DeviceRequestOsMacOS DeviceRequestOs = "macOS" + DeviceRequestOsTvOS DeviceRequestOs = "tvOS" + DeviceRequestOsVisionOS DeviceRequestOs = "visionOS" + DeviceRequestOsWatchOS DeviceRequestOs = "watchOS" + DeviceRequestOsWindows DeviceRequestOs = "Windows" +) + +// Defines values for DeviceRequestOwnership. +const ( + DeviceRequestOwnershipCompany DeviceRequestOwnership = "company" + DeviceRequestOwnershipUser DeviceRequestOwnership = "user" +) + +// Defines values for NewAuthorityType. +const ( + NewAuthorityTypeAdvanced NewAuthorityType = "advanced" + NewAuthorityTypeDevops NewAuthorityType = "devops" +) + +// Defines values for NewPlatformPlatformType. +const ( + NewPlatformPlatformTypeAws NewPlatformPlatformType = "aws" + NewPlatformPlatformTypeAzure NewPlatformPlatformType = "azure" + NewPlatformPlatformTypeGcp NewPlatformPlatformType = "gcp" +) + +// Defines values for PlatformPlatformType. +const ( + PlatformPlatformTypeAws PlatformPlatformType = "aws" + PlatformPlatformTypeAzure PlatformPlatformType = "azure" + PlatformPlatformTypeGcp PlatformPlatformType = "gcp" +) + +// Defines values for ProvisionerType. +const ( + ACME ProvisionerType = "ACME" + ACMEATTESTATION ProvisionerType = "ACME_ATTESTATION" + AWS ProvisionerType = "AWS" + AZURE ProvisionerType = "AZURE" + GCP ProvisionerType = "GCP" + JWK ProvisionerType = "JWK" + OIDC ProvisionerType = "OIDC" + SCEP ProvisionerType = "SCEP" + X5C ProvisionerType = "X5C" +) + +// Defines values for ProvisionerWebhookCertType. +const ( + ALL ProvisionerWebhookCertType = "ALL" + SSH ProvisionerWebhookCertType = "SSH" + X509 ProvisionerWebhookCertType = "X509" +) + +// Defines values for ProvisionerWebhookKind. +const ( + ENRICHING ProvisionerWebhookKind = "ENRICHING" +) + +// Defines values for ProvisionerWebhookServerType. +const ( + EXTERNAL ProvisionerWebhookServerType = "EXTERNAL" + HOSTEDATTESTATION ProvisionerWebhookServerType = "HOSTED_ATTESTATION" +) + +// Defines values for ScepProvisionerEncryptionAlgorithmIdentifier. +const ( + AES128CBC ScepProvisionerEncryptionAlgorithmIdentifier = "AES_128_CBC" + AES128GCM ScepProvisionerEncryptionAlgorithmIdentifier = "AES_128_GCM" + AES256CBC ScepProvisionerEncryptionAlgorithmIdentifier = "AES_256_CBC" + AES256GCM ScepProvisionerEncryptionAlgorithmIdentifier = "AES_256_GCM" + DESCBC ScepProvisionerEncryptionAlgorithmIdentifier = "DES_CBC" +) + +// Defines values for X509CertificateRevocationReason. +const ( + AACOMPROMISE X509CertificateRevocationReason = "AA_COMPROMISE" + AFFILIATIONCHANGED X509CertificateRevocationReason = "AFFILIATION_CHANGED" + CACOMPROMISE X509CertificateRevocationReason = "CA_COMPROMISE" + CERTIFICATEHOLD X509CertificateRevocationReason = "CERTIFICATE_HOLD" + CESSATIONOFOPERATION X509CertificateRevocationReason = "CESSATION_OF_OPERATION" + KEYCOMPROMISE X509CertificateRevocationReason = "KEY_COMPROMISE" + PRIVILEGEWITHDRAWN X509CertificateRevocationReason = "PRIVILEGE_WITHDRAWN" + SUPERSEDED X509CertificateRevocationReason = "SUPERSEDED" + UNSPECIFIED X509CertificateRevocationReason = "UNSPECIFIED" +) + +// Defines values for X509IssuerKeyVersion. +const ( + ECSIGNP256SHA256 X509IssuerKeyVersion = "EC_SIGN_P256_SHA256" + ECSIGNP384SHA384 X509IssuerKeyVersion = "EC_SIGN_P384_SHA384" + RSASIGNPKCS12048SHA256 X509IssuerKeyVersion = "RSA_SIGN_PKCS1_2048_SHA256" + RSASIGNPKCS13072SHA256 X509IssuerKeyVersion = "RSA_SIGN_PKCS1_3072_SHA256" + RSASIGNPKCS14096SHA256 X509IssuerKeyVersion = "RSA_SIGN_PKCS1_4096_SHA256" + RSASIGNPKCS14096SHA512 X509IssuerKeyVersion = "RSA_SIGN_PKCS1_4096_SHA512" + RSASIGNPSS2048SHA256 X509IssuerKeyVersion = "RSA_SIGN_PSS_2048_SHA256" + RSASIGNPSS3072SHA256 X509IssuerKeyVersion = "RSA_SIGN_PSS_3072_SHA256" + RSASIGNPSS4096SHA256 X509IssuerKeyVersion = "RSA_SIGN_PSS_4096_SHA256" + RSASIGNPSS4096SHA512 X509IssuerKeyVersion = "RSA_SIGN_PSS_4096_SHA512" +) + +// Defines values for PostAuthJSONBodyAudience. +const ( + StepAgent PostAuthJSONBodyAudience = "step-agent" +) + +// AcmeAttestationProvisioner A [provisioner](https://smallstep.com/docs/step-ca/provisioners/#acme) that enables automation with the [device-attest-01 challenge of the ACME protocol](https://smallstep.com/blog/acme-managed-device-attestation-explained/). +type AcmeAttestationProvisioner struct { + // AttestationFormats The allowed attestation formats for the device-attest-01 challenge. Valid values are `apple`, `step`, and `tpm`. The apple format is for Apple devices, and adds trust for Apple's CAs. The step format is for non-TPM devices that can issue attestation certificates, such as YubiKey PIV. It adds trust for Yubico's root CA. The tpm format is for TPMs and does not trust any CAs by default. + AttestationFormats []AcmeAttestationProvisionerAttestationFormats `json:"attestationFormats"` + + // AttestationRoots A trust bundle of root certificates in PEM format that will be used to verify attestation certificates. The default value depends on the value of attestationFormats. If provided, this PEM bundle will override the CA trust established by setting attestationFormats to apple or step. At least one root certificate is required when using the tpm attestationFormat. + AttestationRoots *[]string `json:"attestationRoots,omitempty"` + + // ForceCN Force one of the SANs to become the Common Name, if a Common Name is not provided. + ForceCN *bool `json:"forceCN,omitempty"` + + // RequireEAB Only ACME clients that have been preconfigured with valid EAB credentials will be able to create an account with this provisioner. + RequireEAB *bool `json:"requireEAB,omitempty"` +} + +// AcmeAttestationProvisionerAttestationFormats defines model for AcmeAttestationProvisioner.AttestationFormats. +type AcmeAttestationProvisionerAttestationFormats string + +// AcmeProvisioner A [provisioner](https://smallstep.com/docs/step-ca/provisioners/#acme) that enables automation with the [ACME protocol](https://smallstep.com/docs/step-ca/acme-basics/#acme-challenges). +type AcmeProvisioner struct { + // Challenges Which ACME challenge types are allowed. + Challenges []AcmeProvisionerChallenges `json:"challenges"` + + // ForceCN Force one of the SANs to become the Common Name, if a Common Name is not provided. + ForceCN *bool `json:"forceCN,omitempty"` + + // RequireEAB Only ACME clients that have been preconfigured with valid EAB credentials will be able to create an account with this provisioner. Must be `true` for all new provisioners. + RequireEAB bool `json:"requireEAB"` +} + +// AcmeProvisionerChallenges defines model for AcmeProvisioner.Challenges. +type AcmeProvisionerChallenges string + +// Authority An X509 authority hosted by Smallstep. +type Authority struct { + // ActiveRevocation Whether CRL and OCSP are enabled (advanced authorities only). + ActiveRevocation *bool `json:"activeRevocation,omitempty"` + + // AdminEmails Users that have admin access to manage the authority. + AdminEmails *[]string `json:"adminEmails,omitempty"` + + // CreatedAt Timestamp when the authority was created. + CreatedAt time.Time `json:"createdAt"` + + // Domain The domain where the authority can be reached. + Domain string `json:"domain"` + + // Fingerprint The SHA-256 digest of the authority's root certificate in hex format. + Fingerprint *string `json:"fingerprint,omitempty"` + + // Id A UUID identifying this authority. + Id string `json:"id"` + + // Name The name of the authority. + Name string `json:"name"` + + // Root The root certificate in pem format. + Root *string `json:"root,omitempty"` + + // Type One of the available authority types + Type AuthorityType `json:"type"` +} + +// AuthorityCsr A certificate signing request for an X509 advanced authority with an external root. +type AuthorityCsr struct { + // AuthorityID A UUID identifying the authority. + AuthorityID string `json:"authorityID"` + + // Csr A certificate sigining request for the authority's intermediate issuer in pem format. + Csr string `json:"csr"` + + // Id A UUID identifying this CSR. + Id string `json:"id"` +} + +// AuthorityType One of the available authority types +type AuthorityType string + +// AwsAccounts The list of AWS account IDs that are allowed to use an AWS cloud provisioner. +type AwsAccounts = []string + +// AwsDisableCustomSANs By default custom SANs are valid, but if this option is set to `true` only the SANs available in the instance identity document will be valid. These are the private IP and the DNS ip-<private-ip>.<region>.compute.internal. +type AwsDisableCustomSANs = bool + +// AwsPlatform Configuration for an AWS platform. +type AwsPlatform struct { + AccountId string `json:"accountId"` + + // Name A friendly name for this AWS account. + Name string `json:"name"` + + // RoleArn A role ARN that allows the Smallstep Platform to manage resources on your behalf. + RoleArn *string `json:"roleArn,omitempty"` +} + +// AwsProvisioner The [AWS provisioner](https://smallstep.com/docs/step-ca/provisioners/#aws) grants a certificate to an Amazon EC2 instance using the Instance Identity Document. +type AwsProvisioner struct { + // Accounts The list of AWS account IDs that are allowed to use an AWS cloud provisioner. + Accounts AwsAccounts `json:"accounts"` + + // DisableCustomSANs By default custom SANs are valid, but if this option is set to `true` only the SANs available in the instance identity document will be valid. These are the private IP and the DNS ip-<private-ip>.<region>.compute.internal. + DisableCustomSANs *AwsDisableCustomSANs `json:"disableCustomSANs,omitempty"` + + // DisableTrustOnFirstUse By default only one certificate will be granted per instance, but if the option is set to `true` this limit is not set and different tokens can be used to get different certificates. + DisableTrustOnFirstUse *bool `json:"disableTrustOnFirstUse,omitempty"` + + // InstanceAge The maximum age of an instance that should be allowed to obtain a certificate. Limits certificate issuance to new instances to mitigate the risk of credential-misuse from instances that don't need a certificate. Parsed as a [Golang duration](https://pkg.go.dev/time#ParseDuration). + InstanceAge *InstanceAge `json:"instanceAge,omitempty"` +} + +// AzureAudience Defaults to https://management.azure.com/ but it can be changed if necessary. +type AzureAudience = string + +// AzureDisableCustomSANs By default custom SANs are valid, but if this option is set to `true` only the SANs available in the token will be valid, in Azure only the virtual machine name is available. +type AzureDisableCustomSANs = bool + +// AzurePlatform Microsoft Azure +type AzurePlatform struct { + // ClientId The client ID of an Azure Service Principal that allows the Smallstep Platform to manage resources on your behalf. + ClientId *string `json:"clientId,omitempty"` + + // ClientSecret The client secret of an Azure Service Principal that allows the Smallstep Platform to manage resources on your behalf. + ClientSecret *string `json:"clientSecret,omitempty"` + + // Name A friendly name for this Azure connection + Name string `json:"name"` + + // ResourceGroups A list of resource groups that are allowed to enroll with the Smallstep Platform. + ResourceGroups []string `json:"resourceGroups"` + + // TenantId The Azure Entra tenant ID + TenantId string `json:"tenantId"` +} + +// AzureProvisioner The [Azure provisioner](https://smallstep.com/docs/step-ca/provisioners/#azure) grants certificates to Microsoft Azure instances using the managed identities tokens. +type AzureProvisioner struct { + // Audience Defaults to https://management.azure.com/ but it can be changed if necessary. + Audience *AzureAudience `json:"audience,omitempty"` + + // DisableCustomSANs By default custom SANs are valid, but if this option is set to `true` only the SANs available in the token will be valid, in Azure only the virtual machine name is available. + DisableCustomSANs *AzureDisableCustomSANs `json:"disableCustomSANs,omitempty"` + + // DisableTrustOnFirstUse By default only one certificate will be granted per instance, but if the option is set to true this limit is not set and different tokens can be used to get different certificates. + DisableTrustOnFirstUse *bool `json:"disableTrustOnFirstUse,omitempty"` + + // ResourceGroups The list of resource group names that are allowed to use this provisioner. + ResourceGroups AzureResourceGroups `json:"resourceGroups"` + + // TenantID The Azure account tenant ID for this provisioner. This ID is the Directory ID available in the Azure Active Directory properties. + TenantID AzureTenantID `json:"tenantID"` +} + +// AzureResourceGroups The list of resource group names that are allowed to use this provisioner. +type AzureResourceGroups = []string + +// AzureTenantID The Azure account tenant ID for this provisioner. This ID is the Directory ID available in the Azure Active Directory properties. +type AzureTenantID = string + +// BasicAuth Configures provisioner webhook requests to include an Authorization header with these credentials. Optional for `EXTERNAL` webhook servers; not allowed with hosted webhook servers. At most one of `bearerToken` and `basicAuth` may be set. +type BasicAuth struct { + Password string `json:"password"` + Username string `json:"username"` +} + +// BasicConstraints defines model for basicConstraints. +type BasicConstraints struct { + IsCA bool `json:"isCA"` + MaxPathLen int `json:"maxPathLen"` +} + +// Device defines model for device. +type Device struct { + // ApprovedAt Timestamp in RFC3339 format when the device was approved to connect to company resources. Read only. + ApprovedAt *time.Time `json:"approvedAt,omitempty"` + + // Connected The device is currently connected to Smallstep. Read only. + Connected bool `json:"connected"` + + // DisplayId An opaque identifier that may be used to link this device to an external inventory. + DisplayId *string `json:"displayId,omitempty"` + + // DisplayName A friendly name for the device. + DisplayName *string `json:"displayName,omitempty"` + + // EnrolledAt Timestamp in RFC3339 format when the device first connected to Smallstep. Read only. + EnrolledAt *time.Time `json:"enrolledAt,omitempty"` + + // HighAssurance The device has been issued certificates using high assurance device attestation. Read only. + HighAssurance bool `json:"highAssurance"` + + // Id A UUID identifying this device. Read only. + Id string `json:"id"` + + // LastSeen Timestamp in RFC3339 format when the device last connected to Smallstep. Read only. + LastSeen *time.Time `json:"lastSeen,omitempty"` + + // Metadata A set of key-value pairs available as template data when a provisioner with a webhook is used to issue a certificate to a device. + Metadata *[]DeviceMetadata `json:"metadata,omitempty"` + + // Os The device operating system. + Os *DeviceOs `json:"os,omitempty"` + + // Ownership Whether the device is owned by the user or the company. + Ownership *DeviceOwnership `json:"ownership,omitempty"` + + // PermanentIdentifier The cryptographic identity of the device. High-assurance devices are only issued certificates when this identifier is attested by a trusted source. All devices with the same permanent identifier appear as a single device in the Smallstep API. For Windows and Linux devices this is the hash of the TPM endorsement key and for Apple devices it is the serial number. + PermanentIdentifier string `json:"permanentIdentifier"` + + // Serial The serial number of the device. + Serial *string `json:"serial,omitempty"` + + // Tags A set of tags that can be used to group devices. + Tags *[]string `json:"tags,omitempty"` + User *DeviceUser `json:"user,omitempty"` +} + +// DeviceOs The device operating system. +type DeviceOs string + +// DeviceOwnership Whether the device is owned by the user or the company. +type DeviceOwnership string + +// DeviceMetadata defines model for deviceMetadata. +type DeviceMetadata struct { + Key string `json:"key"` + Value string `json:"value"` +} + +// DeviceRequest Data that can be added to a device record. +type DeviceRequest struct { + // DisplayId An opaque identifier that may be used to link this device to an external inventory. + DisplayId *string `json:"displayId,omitempty"` + + // DisplayName A friendly name for the device. + DisplayName *string `json:"displayName,omitempty"` + + // Metadata A set of key-value pairs available as template data when a provisioner with a webhook is used to issue a certificate to a device. + Metadata *[]DeviceMetadata `json:"metadata,omitempty"` + + // Os The device operating system. + Os *DeviceRequestOs `json:"os,omitempty"` + + // Ownership Whether the device is owned by the user or the company. + Ownership *DeviceRequestOwnership `json:"ownership,omitempty"` + + // PermanentIdentifier The cryptographic identity of the device. High-assurance devices are only issued certificates when this identifier is attested by a trusted source. All devices with the same permanent identifier appear as a single device in the Smallstep API. For Windows and Linux devices this is the hash of the TPM endorsement key and for Apple devices it is the serial number. + PermanentIdentifier string `json:"permanentIdentifier"` + + // Serial The serial number of the device. + Serial *string `json:"serial,omitempty"` + + // Tags A set of tags that can be used to group devices. + Tags *[]string `json:"tags,omitempty"` + User *DeviceUser `json:"user,omitempty"` +} + +// DeviceRequestOs The device operating system. +type DeviceRequestOs string + +// DeviceRequestOwnership Whether the device is owned by the user or the company. +type DeviceRequestOwnership string + +// DeviceUser defines model for deviceUser. +type DeviceUser struct { + // DisplayName Full name of the user the device is assigned to. Synced from team's identity provider. Read only. + DisplayName *string `json:"displayName,omitempty"` + + // Email Email of the user the device is assigned to. + Email string `json:"email"` +} + +// DistinguishedName Name used in x509 certificates +type DistinguishedName struct { + CommonName *string `json:"commonName,omitempty"` + Country *string `json:"country,omitempty"` + EmailAddress *string `json:"emailAddress,omitempty"` + Locality *string `json:"locality,omitempty"` + Organization *string `json:"organization,omitempty"` + OrganizationalUnit *string `json:"organizationalUnit,omitempty"` + PostalCode *string `json:"postalCode,omitempty"` + Province *string `json:"province,omitempty"` + SerialNumber *string `json:"serialNumber,omitempty"` + StreetAddress *string `json:"streetAddress,omitempty"` +} + +// Error defines model for error. +type Error struct { + // Message A description of the error. + Message string `json:"message"` +} + +// ExtraName defines model for extraName. +type ExtraName struct { + Type string `json:"type"` + Value interface{} `json:"value"` +} + +// GcpDisableCustomSANs By default custom SANs are valid, but if this option is set to `true` only the SANs available in the instance identity document will be valid, these are the DNS `<instance-name>.c.<project-id>.internal` and `<instance-name>.<zone>.c.<project-id>.internal`. +type GcpDisableCustomSANs = bool + +// GcpPlatform Google Cloud Platform +type GcpPlatform struct { + // Name A friendly name for this GCP connection + Name string `json:"name"` + + // ProjectIds The project IDs where the resources are located. + ProjectIds []string `json:"projectIds"` + + // ServiceAccountKey A JSON-formatted service account key that allows the Smallstep Platform to manage resources on your behalf. + ServiceAccountKey *string `json:"serviceAccountKey,omitempty"` + + // ServiceAccounts GCE service accounts that are allowed to enroll with the Smallstep Platform. + ServiceAccounts *[]string `json:"serviceAccounts,omitempty"` +} + +// GcpProjectIDs The list of project identifiers that are allowed to use a GCP cloud provisioner. +type GcpProjectIDs = []string + +// GcpProvisioner The [GCP provisioner](https://smallstep.com/docs/step-ca/provisioners/#gcp) grants a certificate to a Google Compute Engine instance using its identity token. At least one service account or project ID must be set. +type GcpProvisioner struct { + // DisableCustomSANs By default custom SANs are valid, but if this option is set to `true` only the SANs available in the instance identity document will be valid, these are the DNS `<instance-name>.c.<project-id>.internal` and `<instance-name>.<zone>.c.<project-id>.internal`. + DisableCustomSANs *GcpDisableCustomSANs `json:"disableCustomSANs,omitempty"` + + // DisableTrustOnFirstUse By default only one certificate will be granted per instance, but if the option is set to `true` this limit is not set and different tokens can be used to get different certificates. + DisableTrustOnFirstUse *bool `json:"disableTrustOnFirstUse,omitempty"` + + // InstanceAge The maximum age of an instance that should be allowed to obtain a certificate. Limits certificate issuance to new instances to mitigate the risk of credential-misuse from instances that don't need a certificate. Parsed as a [Golang duration](https://pkg.go.dev/time#ParseDuration). + InstanceAge *InstanceAge `json:"instanceAge,omitempty"` + + // ProjectIDs The list of project identifiers that are allowed to use a GCP cloud provisioner. + ProjectIDs *GcpProjectIDs `json:"projectIDs,omitempty"` + + // ServiceAccounts The list of service accounts that are allowed to use a GCP cloud provisioner. + ServiceAccounts *GcpServiceAccounts `json:"serviceAccounts,omitempty"` +} + +// GcpServiceAccounts The list of service accounts that are allowed to use a GCP cloud provisioner. +type GcpServiceAccounts = []string + +// InstanceAge The maximum age of an instance that should be allowed to obtain a certificate. Limits certificate issuance to new instances to mitigate the risk of credential-misuse from instances that don't need a certificate. Parsed as a [Golang duration](https://pkg.go.dev/time#ParseDuration). +type InstanceAge = string + +// JwkProvisioner A [provisioner](https://smallstep.com/docs/step-ca/provisioners/#jwk) that uses public-key cryptography to sign and validate a JSON Web Token (JWT). +type JwkProvisioner struct { + // EncryptedKey The JWE encrypted private key. + EncryptedKey *string `json:"encryptedKey,omitempty"` + + // Key The public JSON web key. + Key interface{} `json:"key"` +} + +// NameConstraints X509 certificate name constratins. +type NameConstraints struct { + // Critical Whether or not name constraints are marked critical. + Critical *bool `json:"critical,omitempty"` + ExcludedDNSDomains *[]string `json:"excludedDNSDomains,omitempty"` + ExcludedEmailAddresses *[]string `json:"excludedEmailAddresses,omitempty"` + ExcludedIPRanges *[]string `json:"excludedIPRanges,omitempty"` + ExcludedURIDomains *[]string `json:"excludedURIDomains,omitempty"` + PermittedDNSDomains *[]string `json:"permittedDNSDomains,omitempty"` + PermittedEmailAddresses *[]string `json:"permittedEmailAddresses,omitempty"` + PermittedIPRanges *[]string `json:"permittedIPRanges,omitempty"` + PermittedURIDomains *[]string `json:"permittedURIDomains,omitempty"` +} + +// NewAuthority The body of a request to create a new authority. +type NewAuthority struct { + // ActiveRevocation Whether to enable CRL and OCSP on an advanced authority. + ActiveRevocation *bool `json:"activeRevocation,omitempty"` + + // AdminEmails Users that will have admin access to manage the authority. + AdminEmails []string `json:"adminEmails"` + + // IntermediateIssuer A Customized X509 issuer for an authority. + IntermediateIssuer *X509Issuer `json:"intermediateIssuer,omitempty"` + + // Name The name of the authority. + Name string `json:"name"` + + // RootIssuer A Customized X509 issuer for an authority. + RootIssuer *X509Issuer `json:"rootIssuer,omitempty"` + + // Subdomain The new authority will be available at <subdomain>.<team slug>.ca.smallstep.com. + Subdomain string `json:"subdomain"` + + // Type Create either a devops or advanced authority. + Type NewAuthorityType `json:"type"` +} + +// NewAuthorityType Create either a devops or advanced authority. +type NewAuthorityType string + +// NewAuthorityCsr Body of a request to create a new X509 advanced authority with an external root. +type NewAuthorityCsr struct { + // ActiveRevocation Whether to enable CRL and OCSP on the authority. + ActiveRevocation *bool `json:"activeRevocation,omitempty"` + + // IntermediateIssuer A Customized X509 issuer for an authority. + IntermediateIssuer X509Issuer `json:"intermediateIssuer"` + + // Name The name of the authority. + Name string `json:"name"` + + // Subdomain The new authority will be available at <subdomain>.<team slug>.ca.smallstep.com. + Subdomain string `json:"subdomain"` +} + +// NewPlatform Configuration to create a new platform. +type NewPlatform struct { + DisplayName string `json:"displayName"` + PlatformConfiguration NewPlatform_PlatformConfiguration `json:"platformConfiguration"` + + // PlatformType Determines which set of fields to use in platformConfiguration. Cannot be changed. + PlatformType NewPlatformPlatformType `json:"platformType"` + Slug string `json:"slug"` +} + +// NewPlatform_PlatformConfiguration defines model for NewPlatform.PlatformConfiguration. +type NewPlatform_PlatformConfiguration struct { + union json.RawMessage +} + +// NewPlatformPlatformType Determines which set of fields to use in platformConfiguration. Cannot be changed. +type NewPlatformPlatformType string + +// OidcProvisioner A [provisioner](https://smallstep.com/docs/step-ca/provisioners/#oauthoidc-single-sign-on) that is configured to trust and accept an OAuth provider's ID tokens for authentication. By default, the issued certificate will use the subject (sub) claim from the identity token as its subject. The value of the token's email claim is also included as an email SAN in the certificate. +type OidcProvisioner struct { + // Admins The emails of admin users in an OpenID Connect provisioner. These users will not have restrictions in the certificates to sign. + Admins *[]string `json:"admins,omitempty"` + + // ClientID The id used to validate the audience in an OpenID Connect token. + ClientID string `json:"clientID"` + + // ClientSecret The secret used to obtain the OpenID Connect tokens. + ClientSecret string `json:"clientSecret"` + + // ConfigurationEndpoint OpenID Connect configuration URL. + ConfigurationEndpoint string `json:"configurationEndpoint"` + + // Domains The domains used to validate the email claim in an OpenID Connect provisioner. + Domains *[]string `json:"domains,omitempty"` + + // Groups The group list used to validate the groups extension in an OpenID Connect token. + Groups *[]string `json:"groups,omitempty"` + + // ListenAddress The callback address used in the OpenID Connect flow. + ListenAddress *string `json:"listenAddress,omitempty"` + + // TenantID The tenant-id used to replace the templatized tenantid value in the OpenID Configuration. + TenantID *string `json:"tenantID,omitempty"` +} + +// Platform A platform with a list of configurations. +type Platform struct { + DisplayName string `json:"displayName"` + PlatformConfigurations []Platform_PlatformConfigurations_Item `json:"platformConfigurations"` + + // PlatformType The type used in platformConfiguration. + PlatformType PlatformPlatformType `json:"platformType"` + Slug string `json:"slug"` +} + +// Platform_PlatformConfigurations_Item defines model for platform.platformConfigurations.Item. +type Platform_PlatformConfigurations_Item struct { + union json.RawMessage +} + +// PlatformPlatformType The type used in platformConfiguration. +type PlatformPlatformType string + +// Provisioner defines model for provisioner. +type Provisioner struct { + // Claims A set of constraints configuring how this provisioner can be used to issue certificates. + Claims *ProvisionerClaims `json:"claims,omitempty"` + + // CreatedAt Timestamp of when the provisioner was created in RFC 3339 format. Generated server-side. + CreatedAt *time.Time `json:"createdAt,omitempty"` + + // Id A UUID identifying this provisioner. Generated server-side when the provisioner is created. + Id *string `json:"id,omitempty"` + + // Name The name of the provisioner. + Name string `json:"name"` + + // Options Options that apply when issuing certificates with this provisioner. + Options *ProvisionerOptions `json:"options,omitempty"` + + // Type The type of provisioner. + Type ProvisionerType `json:"type"` + union json.RawMessage +} + +// ProvisionerType The type of provisioner. +type ProvisionerType string + +// ProvisionerClaims A set of constraints configuring how this provisioner can be used to issue certificates. +type ProvisionerClaims struct { + // AllowRenewalAfterExpiry Allow renewals for expired certificates generated by this provisioner. + AllowRenewalAfterExpiry *bool `json:"allowRenewalAfterExpiry,omitempty"` + + // DefaultHostSSHCertDuration The default duration for an SSH host certificate generated by this provisioner. Parsed as a [Golang duration](https://pkg.go.dev/time#ParseDuration). + DefaultHostSSHCertDuration *string `json:"defaultHostSSHCertDuration,omitempty"` + + // DefaultTLSCertDuration The default duration for an x509 certificate generated by this provisioner. Parsed as a [Golang duration](https://pkg.go.dev/time#ParseDuration). + DefaultTLSCertDuration *string `json:"defaultTLSCertDuration,omitempty"` + + // DefaultUserSSHCertDuration The default duration for an SSH user certificate generated by this provisioner. Parsed as a [Golang duration](https://pkg.go.dev/time#ParseDuration). + DefaultUserSSHCertDuration *string `json:"defaultUserSSHCertDuration,omitempty"` + + // DisableRenewal Disable renewal for all certificates generated by this provisioner. + DisableRenewal *bool `json:"disableRenewal,omitempty"` + + // EnableSSHCA Allow this provisioner to be used to generate SSH certificates. + EnableSSHCA *bool `json:"enableSSHCA,omitempty"` + + // MaxHostSSHCertDuration The maximum duration for an SSH host certificate generated by this provisioner. Parsed as a [Golang duration](https://pkg.go.dev/time#ParseDuration). + MaxHostSSHCertDuration *string `json:"maxHostSSHCertDuration,omitempty"` + + // MaxTLSCertDuration The maximum duration for an x509 certificate generated by this provisioner. Parsed as a [Golang duration](https://pkg.go.dev/time#ParseDuration). + MaxTLSCertDuration *string `json:"maxTLSCertDuration,omitempty"` + + // MaxUserSSHCertDuration The maximum duration for an SSH user certificate generated by this provisioner. Parsed as a [Golang duration](https://pkg.go.dev/time#ParseDuration). + MaxUserSSHCertDuration *string `json:"maxUserSSHCertDuration,omitempty"` + + // MinHostSSHCertDuration The minimum duration for an SSH host certificate generated by this provisioner. Parsed as a [Golang duration](https://pkg.go.dev/time#ParseDuration). + MinHostSSHCertDuration *string `json:"minHostSSHCertDuration,omitempty"` + + // MinTLSCertDuration The minimum duration for an x509 certificate generated by this provisioner. Parsed as a [Golang duration](https://pkg.go.dev/time#ParseDuration). + MinTLSCertDuration *string `json:"minTLSCertDuration,omitempty"` + + // MinUserSSHCertDuration The minimum duration for an SSH user certificate generated by this provisioner. Parsed as a [Golang duration](https://pkg.go.dev/time#ParseDuration). + MinUserSSHCertDuration *string `json:"minUserSSHCertDuration,omitempty"` +} + +// ProvisionerOptions Options that apply when issuing certificates with this provisioner. +type ProvisionerOptions struct { + // Ssh Options that apply when issuing SSH certificates + Ssh *SshOptions `json:"ssh,omitempty"` + Webhooks *[]ProvisionerWebhook `json:"webhooks,omitempty"` + + // X509 Options that apply when issuing x509 certificates. + X509 *X509Options `json:"x509,omitempty"` +} + +// ProvisionerWebhook A [webhook](https://smallstep.com/docs/step-ca/webhooks/) to call when a certificate request is being processed. +type ProvisionerWebhook struct { + // BasicAuth Configures provisioner webhook requests to include an Authorization header with these credentials. Optional for `EXTERNAL` webhook servers; not allowed with hosted webhook servers. At most one of `bearerToken` and `basicAuth` may be set. + BasicAuth *BasicAuth `json:"basicAuth,omitempty"` + + // BearerToken Webhook requests will include an Authorization header with the token. Optional for `EXTERNAL` webhook servers; not allowed with hosted webhook servers. At most one of `bearerToken` and `basicAuth` may be set. + BearerToken *string `json:"bearerToken,omitempty"` + CertType ProvisionerWebhookCertType `json:"certType"` + + // CollectionSlug For HOSTED_ATTESTATION webhooks, the collectionSlug is a reference to the collection that holds the devices that may be issued certificates. This collection must already exist. Required for `HOSTED_ATTESTATION` webhook servers; not allowed for `EXTERNAL`. + CollectionSlug *string `json:"collectionSlug,omitempty"` + + // DisableTLSClientAuth The CA will not send a client certificate when requested by the webhook server. Optional for `EXTERNAL` webhook servers; not allowed with hosted webhook servers. + DisableTLSClientAuth *bool `json:"disableTLSClientAuth,omitempty"` + + // Id UUID identifying this webhook. Generated server-side when the webhook is created. Will be sent to the webhook server in every request in the `X-Smallstep-Webhook-ID` header. + Id *string `json:"id,omitempty"` + + // Kind The webhook kind indicates how and when it is called. + // + // ENRICHING webhooks are called before rendering the certificate template. They have two functions. First, they must allow the certificate request or it will be aborted. Second, they can return additional data to be referenced in the certificate template. The payload sent to the webhook server varies based on whether an X509 or SSH certificate is to be signed and based on the type of provisioner. + Kind ProvisionerWebhookKind `json:"kind"` + + // Name The name of the webhook. For `ENRICHING` webhooks, the returned data can be referenced in the certificate under the path `.Webhooks.<name>`. Must be unique to the provisioner. + Name string `json:"name"` + + // Secret The shared secret used to authenticate the payload sent to the webhook server. Generated server-side. This is returned only for `EXTERNAL` webhook servers and only once, at the time of creation. + Secret *string `json:"secret,omitempty"` + + // ServerType An EXTERNAL webhook server is not operated by Smallstep. The caller must use the returned ID and secret to configure the server. + // + // A HOSTED_ATTESTATION webhook server is hosted by Smallstep and must be used with an `ENRICHING` webhook type and an ACME Attestation provisioner. The webhook server will verify the attested permanent identifier exists as the ID of an instance in the configured collection. The data of the instance in the collection will be added to the template data. + ServerType ProvisionerWebhookServerType `json:"serverType"` + + // Url The URL of the webhook server. Required for `EXTERNAL` webhook servers; read-only for hosted webhook servers. + Url *string `json:"url,omitempty"` +} + +// ProvisionerWebhookCertType defines model for ProvisionerWebhook.CertType. +type ProvisionerWebhookCertType string + +// ProvisionerWebhookKind The webhook kind indicates how and when it is called. +// +// ENRICHING webhooks are called before rendering the certificate template. They have two functions. First, they must allow the certificate request or it will be aborted. Second, they can return additional data to be referenced in the certificate template. The payload sent to the webhook server varies based on whether an X509 or SSH certificate is to be signed and based on the type of provisioner. +type ProvisionerWebhookKind string + +// ProvisionerWebhookServerType An EXTERNAL webhook server is not operated by Smallstep. The caller must use the returned ID and secret to configure the server. +// +// A HOSTED_ATTESTATION webhook server is hosted by Smallstep and must be used with an `ENRICHING` webhook type and an ACME Attestation provisioner. The webhook server will verify the attested permanent identifier exists as the ID of an instance in the configured collection. The data of the instance in the collection will be added to the template data. +type ProvisionerWebhookServerType string + +// ScepProvisioner The [SCEP provisioner](https://smallstep.com/docs/step-ca/provisioners/#scep) grants certificates to clients using the SCEP protocol. This type is currently experimental and subject to change. +type ScepProvisioner struct { + // AutogenerateDecrypter Automatically generate a new RSA decrypter instead of providing one. + AutogenerateDecrypter *bool `json:"autogenerateDecrypter,omitempty"` + + // Challenge A static challenge secret. + Challenge *string `json:"challenge,omitempty"` + + // DecrypterCertificate A pem-encoded certificate for an RSA public key. + DecrypterCertificate *string `json:"decrypterCertificate,omitempty"` + + // DecrypterKey The pem-encoded RSA private key, corresponding to the certificate public key. + DecrypterKey *string `json:"decrypterKey,omitempty"` + + // DecrypterKeyPassword The password for the pem-encoded RSA private key, if any. + DecrypterKeyPassword *string `json:"decrypterKeyPassword,omitempty"` + + // EncryptionAlgorithmIdentifier The encryption algorithm used for encrypting responses to the SCEP client: + // * `DES_CBC` - [DES in CBC mode](https://www.rfc-editor.org/rfc/rfc8018.html#appendix-B.2.1) - `1.3.14.3.2.7` + // * `AES_128_CBC` - [AES-128 in CBC mode](https://www.rfc-editor.org/rfc/rfc8018.html#appendix-B.2.5) - `2.16.840.1.101.3.4.1.2` + // * `AES_128_GCM` - [AES-128 in GCM mode](https://www.rfc-editor.org/rfc/rfc5084.html#section-3.2) - `2.16.840.1.101.3.4.1.6` + // * `AES_256_CBC` - [AES-256 in CBC mode](https://www.rfc-editor.org/rfc/rfc3565.html#section-4.1) - `2.16.840.1.101.3.4.1.42` + // * `AES_256_GCM` - [AES-256 in GCM mode](https://www.rfc-editor.org/rfc/rfc5084.html#section-3.2) - `2.16.840.1.101.3.4.1.46` + EncryptionAlgorithmIdentifier *ScepProvisionerEncryptionAlgorithmIdentifier `json:"encryptionAlgorithmIdentifier,omitempty"` + + // ExcludeIntermediate Exclude the intermediate CA certificate in SCEP responses. + ExcludeIntermediate *bool `json:"excludeIntermediate,omitempty"` + + // ForceCN Force one of the SANs to become the Common Name, if a Common Name is not provided. + ForceCN *bool `json:"forceCN,omitempty"` + + // IncludeRoot Include the root CA certificate in SCEP responses. + IncludeRoot *bool `json:"includeRoot,omitempty"` + + // MinimumPublicKeyLength The minimum number of bits for RSA public keys accepted in SCEP requests. + MinimumPublicKeyLength *int `json:"minimumPublicKeyLength,omitempty"` +} + +// ScepProvisionerEncryptionAlgorithmIdentifier The encryption algorithm used for encrypting responses to the SCEP client: +// - `DES_CBC` - [DES in CBC mode](https://www.rfc-editor.org/rfc/rfc8018.html#appendix-B.2.1) - `1.3.14.3.2.7` +// - `AES_128_CBC` - [AES-128 in CBC mode](https://www.rfc-editor.org/rfc/rfc8018.html#appendix-B.2.5) - `2.16.840.1.101.3.4.1.2` +// - `AES_128_GCM` - [AES-128 in GCM mode](https://www.rfc-editor.org/rfc/rfc5084.html#section-3.2) - `2.16.840.1.101.3.4.1.6` +// - `AES_256_CBC` - [AES-256 in CBC mode](https://www.rfc-editor.org/rfc/rfc3565.html#section-4.1) - `2.16.840.1.101.3.4.1.42` +// - `AES_256_GCM` - [AES-256 in GCM mode](https://www.rfc-editor.org/rfc/rfc5084.html#section-3.2) - `2.16.840.1.101.3.4.1.46` +type ScepProvisionerEncryptionAlgorithmIdentifier string + +// SshOptions Options that apply when issuing SSH certificates +type SshOptions struct { + // Template A JSON representation of the SSH certificate to be created. [More info](https://smallstep.com/docs/step-ca/templates/#ssh-templates). + Template *string `json:"template,omitempty"` + + // TemplateData A map of data that can be used by the certificate template. + TemplateData *interface{} `json:"templateData,omitempty"` +} + +// Subject Name used in x509 certificates +type Subject struct { + CommonName *string `json:"commonName,omitempty"` + Country *[]string `json:"country,omitempty"` + EmailAddress *[]string `json:"emailAddress,omitempty"` + ExtraNames *[]ExtraName `json:"extraNames,omitempty"` + Locality *[]string `json:"locality,omitempty"` + Organization *[]string `json:"organization,omitempty"` + OrganizationalUnit *[]string `json:"organizationalUnit,omitempty"` + PostalCode *[]string `json:"postalCode,omitempty"` + Province *[]string `json:"province,omitempty"` + SerialNumber *string `json:"serialNumber,omitempty"` + StreetAddress *[]string `json:"streetAddress,omitempty"` +} + +// X509Certificate defines model for x509Certificate. +type X509Certificate struct { + AuthorityKeyId string `json:"authorityKeyId"` + BasicConstraints BasicConstraints `json:"basicConstraints"` + CrlDistributionPoints *[]string `json:"crlDistributionPoints,omitempty"` + DnsNames *[]string `json:"dnsNames,omitempty"` + EmailAddresses *[]string `json:"emailAddresses,omitempty"` + ExtKeyUsage *[]string `json:"extKeyUsage,omitempty"` + IpAddresses *[]string `json:"ipAddresses,omitempty"` + + // Issuer Name used in x509 certificates + Issuer Subject `json:"issuer"` + IssuingCertificateURL *[]string `json:"issuingCertificateURL,omitempty"` + KeyUsage []string `json:"keyUsage"` + + // NameConstraints X509 certificate name constratins. + NameConstraints *NameConstraints `json:"nameConstraints,omitempty"` + OcspServer *[]string `json:"ocspServer,omitempty"` + Pem string `json:"pem"` + PolicyIdentifiers *[]string `json:"policyIdentifiers,omitempty"` + RevocationReason *X509CertificateRevocationReason `json:"revocationReason,omitempty"` + Revoked *bool `json:"revoked,omitempty"` + SerialNumber string `json:"serialNumber"` + SignatureAlgorithm string `json:"signatureAlgorithm"` + + // Subject Name used in x509 certificates + Subject Subject `json:"subject"` + SubjectKeyId string `json:"subjectKeyId"` + Uris *[]string `json:"uris,omitempty"` + Version int `json:"version"` +} + +// X509CertificateRevocationReason defines model for X509Certificate.RevocationReason. +type X509CertificateRevocationReason string + +// X509Issuer A Customized X509 issuer for an authority. +type X509Issuer struct { + // Duration The certificate lifetime. Parsed as a [Golang duration](https://pkg.go.dev/time#ParseDuration). + Duration *string `json:"duration,omitempty"` + + // KeyVersion The signature algorithm. + KeyVersion X509IssuerKeyVersion `json:"keyVersion"` + MaxPathLength *int `json:"maxPathLength,omitempty"` + + // Name The name of the issuer. + Name string `json:"name"` + + // NameConstraints X509 certificate name constratins. + NameConstraints *NameConstraints `json:"nameConstraints,omitempty"` + + // Subject Name used in x509 certificates + Subject *DistinguishedName `json:"subject,omitempty"` +} + +// X509IssuerKeyVersion The signature algorithm. +type X509IssuerKeyVersion string + +// X509Options Options that apply when issuing x509 certificates. +type X509Options struct { + // Template A JSON representation of the x509 certificate to be created. [More info](https://smallstep.com/docs/step-ca/templates/#x509-templates). + Template *string `json:"template,omitempty"` + + // TemplateData A map of data that can be used by the certificate template. + TemplateData *interface{} `json:"templateData,omitempty"` +} + +// X5cProvisioner A [provisioner](https://smallstep.com/docs/step-ca/provisioners/#x5c---x509-certificate) that authenticates a certificate request with an existing x509 certificate. +type X5cProvisioner struct { + // Roots A list of pem-encoded x509 certificates. Any certificate bundle that chains up to any of these roots can be used in a certificate request. + Roots []string `json:"roots"` +} + +// Accept defines model for accept. +type Accept = string + +// AuthorityDomainOrID defines model for authorityDomainOrID. +type AuthorityDomainOrID = string + +// AuthorityID defines model for authorityID. +type AuthorityID = string + +// Pagination defines model for pagination. +type Pagination struct { + // After Fetch a page of results other than the first page. + // Must be copied from a previously returned X-Next-Cursor header. + After *string `json:"after"` + + // First Limits the number of results returned. + // Defaults to 100. + First *int `json:"first"` +} + +// PlatformSlug defines model for platformSlug. +type PlatformSlug = string + +// ProvisionerNameOrID defines model for provisionerNameOrID. +type ProvisionerNameOrID = string + +// RequestID defines model for requestID. +type RequestID = string + +// SerialNumber defines model for serialNumber. +type SerialNumber = string + +// WebhookNameOrID defines model for webhookNameOrID. +type WebhookNameOrID = string + +// N400 defines model for 400. +type N400 = Error + +// N401 defines model for 401. +type N401 = Error + +// N403 defines model for 403. +type N403 = Error + +// N404 defines model for 404. +type N404 = Error + +// N409 defines model for 409. +type N409 = Error + +// N412 defines model for 412. +type N412 = Error + +// N422 defines model for 422. +type N422 = Error + +// N500 defines model for 500. +type N500 = Error + +// PostAuthJSONBody defines parameters for PostAuth. +type PostAuthJSONBody struct { + Audience *PostAuthJSONBodyAudience `json:"audience,omitempty"` + Bundle *[]openapi_types.File `json:"bundle,omitempty"` + TeamID *string `json:"teamID,omitempty"` + TeamSlug *string `json:"teamSlug,omitempty"` +} + +// PostAuthJSONBodyAudience defines parameters for PostAuth. +type PostAuthJSONBodyAudience string + +// GetAuthoritiesParams defines parameters for GetAuthorities. +type GetAuthoritiesParams struct { + // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. + XRequestId *RequestID `json:"X-Request-Id,omitempty"` + + // Accept The content type the client is willing to accept. Also includes API version. + Accept *Accept `json:"Accept,omitempty"` +} + +// PostAuthoritiesParams defines parameters for PostAuthorities. +type PostAuthoritiesParams struct { + // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. + XRequestId *RequestID `json:"X-Request-Id,omitempty"` + + // Accept The content type the client is willing to accept. Also includes API version. + Accept *Accept `json:"Accept,omitempty"` +} + +// PostAuthoritiesCsrParams defines parameters for PostAuthoritiesCsr. +type PostAuthoritiesCsrParams struct { + // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. + XRequestId *RequestID `json:"X-Request-Id,omitempty"` + + // Accept The content type the client is willing to accept. Also includes API version. + Accept *Accept `json:"Accept,omitempty"` +} + +// DeleteAuthorityParams defines parameters for DeleteAuthority. +type DeleteAuthorityParams struct { + // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. + XRequestId *RequestID `json:"X-Request-Id,omitempty"` + + // Accept The content type the client is willing to accept. Also includes API version. + Accept *Accept `json:"Accept,omitempty"` +} + +// GetAuthorityParams defines parameters for GetAuthority. +type GetAuthorityParams struct { + // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. + XRequestId *RequestID `json:"X-Request-Id,omitempty"` + + // Accept The content type the client is willing to accept. Also includes API version. + Accept *Accept `json:"Accept,omitempty"` +} + +// ListAuthorityProvisionersParams defines parameters for ListAuthorityProvisioners. +type ListAuthorityProvisionersParams struct { + // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. + XRequestId *RequestID `json:"X-Request-Id,omitempty"` + + // Accept The content type the client is willing to accept. Also includes API version. + Accept *Accept `json:"Accept,omitempty"` +} + +// PostAuthorityProvisionersParams defines parameters for PostAuthorityProvisioners. +type PostAuthorityProvisionersParams struct { + // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. + XRequestId *RequestID `json:"X-Request-Id,omitempty"` + + // Accept The content type the client is willing to accept. Also includes API version. + Accept *Accept `json:"Accept,omitempty"` +} + +// DeleteProvisionerParams defines parameters for DeleteProvisioner. +type DeleteProvisionerParams struct { + // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. + XRequestId *RequestID `json:"X-Request-Id,omitempty"` + + // Accept The content type the client is willing to accept. Also includes API version. + Accept *Accept `json:"Accept,omitempty"` +} + +// GetProvisionerParams defines parameters for GetProvisioner. +type GetProvisionerParams struct { + // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. + XRequestId *RequestID `json:"X-Request-Id,omitempty"` + + // Accept The content type the client is willing to accept. Also includes API version. + Accept *Accept `json:"Accept,omitempty"` +} + +// PostWebhooksParams defines parameters for PostWebhooks. +type PostWebhooksParams struct { + // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. + XRequestId *RequestID `json:"X-Request-Id,omitempty"` + + // Accept The content type the client is willing to accept. Also includes API version. + Accept *Accept `json:"Accept,omitempty"` +} + +// DeleteWebhookParams defines parameters for DeleteWebhook. +type DeleteWebhookParams struct { + // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. + XRequestId *RequestID `json:"X-Request-Id,omitempty"` + + // Accept The content type the client is willing to accept. Also includes API version. + Accept *Accept `json:"Accept,omitempty"` +} + +// GetWebhookParams defines parameters for GetWebhook. +type GetWebhookParams struct { + // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. + XRequestId *RequestID `json:"X-Request-Id,omitempty"` + + // Accept The content type the client is willing to accept. Also includes API version. + Accept *Accept `json:"Accept,omitempty"` +} + +// PostAuthorityRootJSONBody defines parameters for PostAuthorityRoot. +type PostAuthorityRootJSONBody struct { + // AdminEmails Users that will have admin access to manage the authority + AdminEmails []string `json:"adminEmails"` + + // Id The `id` returned from a previous call to `/authorities/csr` + Id string `json:"id"` + + // IntermediatePEM The signed intermediate certificate + IntermediatePEM string `json:"intermediatePEM"` + + // RootName A name for the external root issuer + RootName string `json:"rootName"` + + // RootPEM The root certificate in pem format + RootPEM string `json:"rootPEM"` +} + +// PostAuthorityRootParams defines parameters for PostAuthorityRoot. +type PostAuthorityRootParams struct { + // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. + XRequestId *RequestID `json:"X-Request-Id,omitempty"` + + // Accept The content type the client is willing to accept. Also includes API version. + Accept *Accept `json:"Accept,omitempty"` +} + +// ListCertificatesParams defines parameters for ListCertificates. +type ListCertificatesParams struct { + // Pagination Paginate over a list of objects. Example: `?pagination[first]=30&pagination[after]=MTIzNA==`, which after encoding would be `?pagination%5Bfirst%5D=30&pagination%5Bafter%5D=MTIzNA==` + Pagination *Pagination `json:"pagination,omitempty"` + + // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. + XRequestId *RequestID `json:"X-Request-Id,omitempty"` + + // Accept The content type the client is willing to accept. Also includes API version. + Accept *Accept `json:"Accept,omitempty"` +} + +// GetCertificateParams defines parameters for GetCertificate. +type GetCertificateParams struct { + // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. + XRequestId *RequestID `json:"X-Request-Id,omitempty"` + + // Accept The content type the client is willing to accept. Also includes API version. + Accept *Accept `json:"Accept,omitempty"` +} + +// PostDevicesParams defines parameters for PostDevices. +type PostDevicesParams struct { + // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. + XRequestId *RequestID `json:"X-Request-Id,omitempty"` + + // Accept The content type the client is willing to accept. Also includes API version. + Accept *Accept `json:"Accept,omitempty"` +} + +// GetPlatformsParams defines parameters for GetPlatforms. +type GetPlatformsParams struct { + // Pagination Paginate over a list of objects. Example: `?pagination[first]=30&pagination[after]=MTIzNA==`, which after encoding would be `?pagination%5Bfirst%5D=30&pagination%5Bafter%5D=MTIzNA==` + Pagination *Pagination `json:"pagination,omitempty"` + + // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. + XRequestId *RequestID `json:"X-Request-Id,omitempty"` + + // Accept The content type the client is willing to accept. Also includes API version. + Accept *Accept `json:"Accept,omitempty"` +} + +// PutPlatformParams defines parameters for PutPlatform. +type PutPlatformParams struct { + // XRequestId A request ID provided by the client. If not provided, the server will generate one. Will be reflected in responses. + XRequestId *RequestID `json:"X-Request-Id,omitempty"` + + // Accept The content type the client is willing to accept. Also includes API version. + Accept *Accept `json:"Accept,omitempty"` +} + +// PostAuthJSONRequestBody defines body for PostAuth for application/json ContentType. +type PostAuthJSONRequestBody PostAuthJSONBody + +// PostAuthoritiesJSONRequestBody defines body for PostAuthorities for application/json ContentType. +type PostAuthoritiesJSONRequestBody = NewAuthority + +// PostAuthoritiesCsrJSONRequestBody defines body for PostAuthoritiesCsr for application/json ContentType. +type PostAuthoritiesCsrJSONRequestBody = NewAuthorityCsr + +// PostAuthorityProvisionersJSONRequestBody defines body for PostAuthorityProvisioners for application/json ContentType. +type PostAuthorityProvisionersJSONRequestBody = Provisioner + +// PostWebhooksJSONRequestBody defines body for PostWebhooks for application/json ContentType. +type PostWebhooksJSONRequestBody = ProvisionerWebhook + +// PostAuthorityRootJSONRequestBody defines body for PostAuthorityRoot for application/json ContentType. +type PostAuthorityRootJSONRequestBody PostAuthorityRootJSONBody + +// PostDevicesJSONRequestBody defines body for PostDevices for application/json ContentType. +type PostDevicesJSONRequestBody = DeviceRequest + +// PutPlatformJSONRequestBody defines body for PutPlatform for application/json ContentType. +type PutPlatformJSONRequestBody = NewPlatform + +// AsAwsPlatform returns the union data inside the NewPlatform_PlatformConfiguration as a AwsPlatform +func (t NewPlatform_PlatformConfiguration) AsAwsPlatform() (AwsPlatform, error) { + var body AwsPlatform + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromAwsPlatform overwrites any union data inside the NewPlatform_PlatformConfiguration as the provided AwsPlatform +func (t *NewPlatform_PlatformConfiguration) FromAwsPlatform(v AwsPlatform) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeAwsPlatform performs a merge with any union data inside the NewPlatform_PlatformConfiguration, using the provided AwsPlatform +func (t *NewPlatform_PlatformConfiguration) MergeAwsPlatform(v AwsPlatform) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +// AsAzurePlatform returns the union data inside the NewPlatform_PlatformConfiguration as a AzurePlatform +func (t NewPlatform_PlatformConfiguration) AsAzurePlatform() (AzurePlatform, error) { + var body AzurePlatform + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromAzurePlatform overwrites any union data inside the NewPlatform_PlatformConfiguration as the provided AzurePlatform +func (t *NewPlatform_PlatformConfiguration) FromAzurePlatform(v AzurePlatform) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeAzurePlatform performs a merge with any union data inside the NewPlatform_PlatformConfiguration, using the provided AzurePlatform +func (t *NewPlatform_PlatformConfiguration) MergeAzurePlatform(v AzurePlatform) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +// AsGcpPlatform returns the union data inside the NewPlatform_PlatformConfiguration as a GcpPlatform +func (t NewPlatform_PlatformConfiguration) AsGcpPlatform() (GcpPlatform, error) { + var body GcpPlatform + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromGcpPlatform overwrites any union data inside the NewPlatform_PlatformConfiguration as the provided GcpPlatform +func (t *NewPlatform_PlatformConfiguration) FromGcpPlatform(v GcpPlatform) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeGcpPlatform performs a merge with any union data inside the NewPlatform_PlatformConfiguration, using the provided GcpPlatform +func (t *NewPlatform_PlatformConfiguration) MergeGcpPlatform(v GcpPlatform) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +func (t NewPlatform_PlatformConfiguration) MarshalJSON() ([]byte, error) { + b, err := t.union.MarshalJSON() + return b, err +} + +func (t *NewPlatform_PlatformConfiguration) UnmarshalJSON(b []byte) error { + err := t.union.UnmarshalJSON(b) + return err +} + +// AsAwsPlatform returns the union data inside the Platform_PlatformConfigurations_Item as a AwsPlatform +func (t Platform_PlatformConfigurations_Item) AsAwsPlatform() (AwsPlatform, error) { + var body AwsPlatform + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromAwsPlatform overwrites any union data inside the Platform_PlatformConfigurations_Item as the provided AwsPlatform +func (t *Platform_PlatformConfigurations_Item) FromAwsPlatform(v AwsPlatform) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeAwsPlatform performs a merge with any union data inside the Platform_PlatformConfigurations_Item, using the provided AwsPlatform +func (t *Platform_PlatformConfigurations_Item) MergeAwsPlatform(v AwsPlatform) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +// AsAzurePlatform returns the union data inside the Platform_PlatformConfigurations_Item as a AzurePlatform +func (t Platform_PlatformConfigurations_Item) AsAzurePlatform() (AzurePlatform, error) { + var body AzurePlatform + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromAzurePlatform overwrites any union data inside the Platform_PlatformConfigurations_Item as the provided AzurePlatform +func (t *Platform_PlatformConfigurations_Item) FromAzurePlatform(v AzurePlatform) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeAzurePlatform performs a merge with any union data inside the Platform_PlatformConfigurations_Item, using the provided AzurePlatform +func (t *Platform_PlatformConfigurations_Item) MergeAzurePlatform(v AzurePlatform) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +// AsGcpPlatform returns the union data inside the Platform_PlatformConfigurations_Item as a GcpPlatform +func (t Platform_PlatformConfigurations_Item) AsGcpPlatform() (GcpPlatform, error) { + var body GcpPlatform + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromGcpPlatform overwrites any union data inside the Platform_PlatformConfigurations_Item as the provided GcpPlatform +func (t *Platform_PlatformConfigurations_Item) FromGcpPlatform(v GcpPlatform) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeGcpPlatform performs a merge with any union data inside the Platform_PlatformConfigurations_Item, using the provided GcpPlatform +func (t *Platform_PlatformConfigurations_Item) MergeGcpPlatform(v GcpPlatform) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +func (t Platform_PlatformConfigurations_Item) MarshalJSON() ([]byte, error) { + b, err := t.union.MarshalJSON() + return b, err +} + +func (t *Platform_PlatformConfigurations_Item) UnmarshalJSON(b []byte) error { + err := t.union.UnmarshalJSON(b) + return err +} + +// AsOidcProvisioner returns the union data inside the Provisioner as a OidcProvisioner +func (t Provisioner) AsOidcProvisioner() (OidcProvisioner, error) { + var body OidcProvisioner + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromOidcProvisioner overwrites any union data inside the Provisioner as the provided OidcProvisioner +func (t *Provisioner) FromOidcProvisioner(v OidcProvisioner) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeOidcProvisioner performs a merge with any union data inside the Provisioner, using the provided OidcProvisioner +func (t *Provisioner) MergeOidcProvisioner(v OidcProvisioner) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +// AsJwkProvisioner returns the union data inside the Provisioner as a JwkProvisioner +func (t Provisioner) AsJwkProvisioner() (JwkProvisioner, error) { + var body JwkProvisioner + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromJwkProvisioner overwrites any union data inside the Provisioner as the provided JwkProvisioner +func (t *Provisioner) FromJwkProvisioner(v JwkProvisioner) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeJwkProvisioner performs a merge with any union data inside the Provisioner, using the provided JwkProvisioner +func (t *Provisioner) MergeJwkProvisioner(v JwkProvisioner) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +// AsAcmeProvisioner returns the union data inside the Provisioner as a AcmeProvisioner +func (t Provisioner) AsAcmeProvisioner() (AcmeProvisioner, error) { + var body AcmeProvisioner + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromAcmeProvisioner overwrites any union data inside the Provisioner as the provided AcmeProvisioner +func (t *Provisioner) FromAcmeProvisioner(v AcmeProvisioner) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeAcmeProvisioner performs a merge with any union data inside the Provisioner, using the provided AcmeProvisioner +func (t *Provisioner) MergeAcmeProvisioner(v AcmeProvisioner) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +// AsAcmeAttestationProvisioner returns the union data inside the Provisioner as a AcmeAttestationProvisioner +func (t Provisioner) AsAcmeAttestationProvisioner() (AcmeAttestationProvisioner, error) { + var body AcmeAttestationProvisioner + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromAcmeAttestationProvisioner overwrites any union data inside the Provisioner as the provided AcmeAttestationProvisioner +func (t *Provisioner) FromAcmeAttestationProvisioner(v AcmeAttestationProvisioner) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeAcmeAttestationProvisioner performs a merge with any union data inside the Provisioner, using the provided AcmeAttestationProvisioner +func (t *Provisioner) MergeAcmeAttestationProvisioner(v AcmeAttestationProvisioner) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +// AsX5cProvisioner returns the union data inside the Provisioner as a X5cProvisioner +func (t Provisioner) AsX5cProvisioner() (X5cProvisioner, error) { + var body X5cProvisioner + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromX5cProvisioner overwrites any union data inside the Provisioner as the provided X5cProvisioner +func (t *Provisioner) FromX5cProvisioner(v X5cProvisioner) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeX5cProvisioner performs a merge with any union data inside the Provisioner, using the provided X5cProvisioner +func (t *Provisioner) MergeX5cProvisioner(v X5cProvisioner) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +// AsAwsProvisioner returns the union data inside the Provisioner as a AwsProvisioner +func (t Provisioner) AsAwsProvisioner() (AwsProvisioner, error) { + var body AwsProvisioner + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromAwsProvisioner overwrites any union data inside the Provisioner as the provided AwsProvisioner +func (t *Provisioner) FromAwsProvisioner(v AwsProvisioner) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeAwsProvisioner performs a merge with any union data inside the Provisioner, using the provided AwsProvisioner +func (t *Provisioner) MergeAwsProvisioner(v AwsProvisioner) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +// AsGcpProvisioner returns the union data inside the Provisioner as a GcpProvisioner +func (t Provisioner) AsGcpProvisioner() (GcpProvisioner, error) { + var body GcpProvisioner + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromGcpProvisioner overwrites any union data inside the Provisioner as the provided GcpProvisioner +func (t *Provisioner) FromGcpProvisioner(v GcpProvisioner) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeGcpProvisioner performs a merge with any union data inside the Provisioner, using the provided GcpProvisioner +func (t *Provisioner) MergeGcpProvisioner(v GcpProvisioner) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +// AsAzureProvisioner returns the union data inside the Provisioner as a AzureProvisioner +func (t Provisioner) AsAzureProvisioner() (AzureProvisioner, error) { + var body AzureProvisioner + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromAzureProvisioner overwrites any union data inside the Provisioner as the provided AzureProvisioner +func (t *Provisioner) FromAzureProvisioner(v AzureProvisioner) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeAzureProvisioner performs a merge with any union data inside the Provisioner, using the provided AzureProvisioner +func (t *Provisioner) MergeAzureProvisioner(v AzureProvisioner) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +// AsScepProvisioner returns the union data inside the Provisioner as a ScepProvisioner +func (t Provisioner) AsScepProvisioner() (ScepProvisioner, error) { + var body ScepProvisioner + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromScepProvisioner overwrites any union data inside the Provisioner as the provided ScepProvisioner +func (t *Provisioner) FromScepProvisioner(v ScepProvisioner) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeScepProvisioner performs a merge with any union data inside the Provisioner, using the provided ScepProvisioner +func (t *Provisioner) MergeScepProvisioner(v ScepProvisioner) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +func (t Provisioner) MarshalJSON() ([]byte, error) { + b, err := t.union.MarshalJSON() + if err != nil { + return nil, err + } + object := make(map[string]json.RawMessage) + if t.union != nil { + err = json.Unmarshal(b, &object) + if err != nil { + return nil, err + } + } + + if t.Claims != nil { + object["claims"], err = json.Marshal(t.Claims) + if err != nil { + return nil, fmt.Errorf("error marshaling 'claims': %w", err) + } + } + + if t.CreatedAt != nil { + object["createdAt"], err = json.Marshal(t.CreatedAt) + if err != nil { + return nil, fmt.Errorf("error marshaling 'createdAt': %w", err) + } + } + + if t.Id != nil { + object["id"], err = json.Marshal(t.Id) + if err != nil { + return nil, fmt.Errorf("error marshaling 'id': %w", err) + } + } + + object["name"], err = json.Marshal(t.Name) + if err != nil { + return nil, fmt.Errorf("error marshaling 'name': %w", err) + } + + if t.Options != nil { + object["options"], err = json.Marshal(t.Options) + if err != nil { + return nil, fmt.Errorf("error marshaling 'options': %w", err) + } + } + + object["type"], err = json.Marshal(t.Type) + if err != nil { + return nil, fmt.Errorf("error marshaling 'type': %w", err) + } + + b, err = json.Marshal(object) + return b, err +} + +func (t *Provisioner) UnmarshalJSON(b []byte) error { + err := t.union.UnmarshalJSON(b) + if err != nil { + return err + } + object := make(map[string]json.RawMessage) + err = json.Unmarshal(b, &object) + if err != nil { + return err + } + + if raw, found := object["claims"]; found { + err = json.Unmarshal(raw, &t.Claims) + if err != nil { + return fmt.Errorf("error reading 'claims': %w", err) + } + } + + if raw, found := object["createdAt"]; found { + err = json.Unmarshal(raw, &t.CreatedAt) + if err != nil { + return fmt.Errorf("error reading 'createdAt': %w", err) + } + } + + if raw, found := object["id"]; found { + err = json.Unmarshal(raw, &t.Id) + if err != nil { + return fmt.Errorf("error reading 'id': %w", err) + } + } + + if raw, found := object["name"]; found { + err = json.Unmarshal(raw, &t.Name) + if err != nil { + return fmt.Errorf("error reading 'name': %w", err) + } + } + + if raw, found := object["options"]; found { + err = json.Unmarshal(raw, &t.Options) + if err != nil { + return fmt.Errorf("error reading 'options': %w", err) + } + } + + if raw, found := object["type"]; found { + err = json.Unmarshal(raw, &t.Type) + if err != nil { + return fmt.Errorf("error reading 'type': %w", err) + } + } + + return err +} + +// RequestEditorFn is the function signature for the RequestEditor callback function +type RequestEditorFn func(ctx context.Context, req *http.Request) error + +// Doer performs HTTP requests. +// +// The standard http.Client implements this interface. +type HttpRequestDoer interface { + Do(req *http.Request) (*http.Response, error) +} + +// Client which conforms to the OpenAPI3 specification for this service. +type Client struct { + // The endpoint of the server conforming to this interface, with scheme, + // https://api.deepmap.com for example. This can contain a path relative + // to the server, such as https://api.deepmap.com/dev-test, and all the + // paths in the swagger spec will be appended to the server. + Server string + + // Doer for performing requests, typically a *http.Client with any + // customized settings, such as certificate chains. + Client HttpRequestDoer + + // A list of callbacks for modifying requests which are generated before sending over + // the network. + RequestEditors []RequestEditorFn +} + +// ClientOption allows setting custom parameters during construction +type ClientOption func(*Client) error + +// Creates a new Client, with reasonable defaults +func NewClient(server string, opts ...ClientOption) (*Client, error) { + // create a client with sane default values + client := Client{ + Server: server, + } + // mutate client and add all optional params + for _, o := range opts { + if err := o(&client); err != nil { + return nil, err + } + } + // ensure the server URL always has a trailing slash + if !strings.HasSuffix(client.Server, "/") { + client.Server += "/" + } + // create httpClient, if not already present + if client.Client == nil { + client.Client = &http.Client{} + } + return &client, nil +} + +// WithHTTPClient allows overriding the default Doer, which is +// automatically created using http.Client. This is useful for tests. +func WithHTTPClient(doer HttpRequestDoer) ClientOption { + return func(c *Client) error { + c.Client = doer + return nil + } +} + +// WithRequestEditorFn allows setting up a callback function, which will be +// called right before sending the request. This can be used to mutate the request. +func WithRequestEditorFn(fn RequestEditorFn) ClientOption { + return func(c *Client) error { + c.RequestEditors = append(c.RequestEditors, fn) + return nil + } +} + +// The interface specification for the client above. +type ClientInterface interface { + // PostAuthWithBody request with any body + PostAuthWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PostAuth(ctx context.Context, body PostAuthJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetAuthorities request + GetAuthorities(ctx context.Context, params *GetAuthoritiesParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PostAuthoritiesWithBody request with any body + PostAuthoritiesWithBody(ctx context.Context, params *PostAuthoritiesParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PostAuthorities(ctx context.Context, params *PostAuthoritiesParams, body PostAuthoritiesJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PostAuthoritiesCsrWithBody request with any body + PostAuthoritiesCsrWithBody(ctx context.Context, params *PostAuthoritiesCsrParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PostAuthoritiesCsr(ctx context.Context, params *PostAuthoritiesCsrParams, body PostAuthoritiesCsrJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DeleteAuthority request + DeleteAuthority(ctx context.Context, authorityDomainOrID AuthorityDomainOrID, params *DeleteAuthorityParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetAuthority request + GetAuthority(ctx context.Context, authorityDomainOrID AuthorityDomainOrID, params *GetAuthorityParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ListAuthorityProvisioners request + ListAuthorityProvisioners(ctx context.Context, authorityID AuthorityID, params *ListAuthorityProvisionersParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PostAuthorityProvisionersWithBody request with any body + PostAuthorityProvisionersWithBody(ctx context.Context, authorityID AuthorityID, params *PostAuthorityProvisionersParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PostAuthorityProvisioners(ctx context.Context, authorityID AuthorityID, params *PostAuthorityProvisionersParams, body PostAuthorityProvisionersJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DeleteProvisioner request + DeleteProvisioner(ctx context.Context, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, params *DeleteProvisionerParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetProvisioner request + GetProvisioner(ctx context.Context, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, params *GetProvisionerParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PostWebhooksWithBody request with any body + PostWebhooksWithBody(ctx context.Context, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, params *PostWebhooksParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PostWebhooks(ctx context.Context, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, params *PostWebhooksParams, body PostWebhooksJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DeleteWebhook request + DeleteWebhook(ctx context.Context, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, webhookNameOrID WebhookNameOrID, params *DeleteWebhookParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetWebhook request + GetWebhook(ctx context.Context, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, webhookNameOrID WebhookNameOrID, params *GetWebhookParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PostAuthorityRootWithBody request with any body + PostAuthorityRootWithBody(ctx context.Context, authorityID AuthorityID, params *PostAuthorityRootParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PostAuthorityRoot(ctx context.Context, authorityID AuthorityID, params *PostAuthorityRootParams, body PostAuthorityRootJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ListCertificates request + ListCertificates(ctx context.Context, params *ListCertificatesParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetCertificate request + GetCertificate(ctx context.Context, serialNumber SerialNumber, params *GetCertificateParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PostDevicesWithBody request with any body + PostDevicesWithBody(ctx context.Context, params *PostDevicesParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PostDevices(ctx context.Context, params *PostDevicesParams, body PostDevicesJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetPlatforms request + GetPlatforms(ctx context.Context, params *GetPlatformsParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PutPlatformWithBody request with any body + PutPlatformWithBody(ctx context.Context, platformSlug PlatformSlug, params *PutPlatformParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PutPlatform(ctx context.Context, platformSlug PlatformSlug, params *PutPlatformParams, body PutPlatformJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) +} + +func (c *Client) PostAuthWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostAuthRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostAuth(ctx context.Context, body PostAuthJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostAuthRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetAuthorities(ctx context.Context, params *GetAuthoritiesParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetAuthoritiesRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostAuthoritiesWithBody(ctx context.Context, params *PostAuthoritiesParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostAuthoritiesRequestWithBody(c.Server, params, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostAuthorities(ctx context.Context, params *PostAuthoritiesParams, body PostAuthoritiesJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostAuthoritiesRequest(c.Server, params, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostAuthoritiesCsrWithBody(ctx context.Context, params *PostAuthoritiesCsrParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostAuthoritiesCsrRequestWithBody(c.Server, params, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostAuthoritiesCsr(ctx context.Context, params *PostAuthoritiesCsrParams, body PostAuthoritiesCsrJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostAuthoritiesCsrRequest(c.Server, params, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) DeleteAuthority(ctx context.Context, authorityDomainOrID AuthorityDomainOrID, params *DeleteAuthorityParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteAuthorityRequest(c.Server, authorityDomainOrID, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetAuthority(ctx context.Context, authorityDomainOrID AuthorityDomainOrID, params *GetAuthorityParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetAuthorityRequest(c.Server, authorityDomainOrID, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) ListAuthorityProvisioners(ctx context.Context, authorityID AuthorityID, params *ListAuthorityProvisionersParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListAuthorityProvisionersRequest(c.Server, authorityID, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostAuthorityProvisionersWithBody(ctx context.Context, authorityID AuthorityID, params *PostAuthorityProvisionersParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostAuthorityProvisionersRequestWithBody(c.Server, authorityID, params, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostAuthorityProvisioners(ctx context.Context, authorityID AuthorityID, params *PostAuthorityProvisionersParams, body PostAuthorityProvisionersJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostAuthorityProvisionersRequest(c.Server, authorityID, params, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) DeleteProvisioner(ctx context.Context, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, params *DeleteProvisionerParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteProvisionerRequest(c.Server, authorityID, provisionerNameOrID, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetProvisioner(ctx context.Context, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, params *GetProvisionerParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetProvisionerRequest(c.Server, authorityID, provisionerNameOrID, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostWebhooksWithBody(ctx context.Context, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, params *PostWebhooksParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostWebhooksRequestWithBody(c.Server, authorityID, provisionerNameOrID, params, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostWebhooks(ctx context.Context, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, params *PostWebhooksParams, body PostWebhooksJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostWebhooksRequest(c.Server, authorityID, provisionerNameOrID, params, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) DeleteWebhook(ctx context.Context, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, webhookNameOrID WebhookNameOrID, params *DeleteWebhookParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteWebhookRequest(c.Server, authorityID, provisionerNameOrID, webhookNameOrID, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetWebhook(ctx context.Context, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, webhookNameOrID WebhookNameOrID, params *GetWebhookParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetWebhookRequest(c.Server, authorityID, provisionerNameOrID, webhookNameOrID, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostAuthorityRootWithBody(ctx context.Context, authorityID AuthorityID, params *PostAuthorityRootParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostAuthorityRootRequestWithBody(c.Server, authorityID, params, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostAuthorityRoot(ctx context.Context, authorityID AuthorityID, params *PostAuthorityRootParams, body PostAuthorityRootJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostAuthorityRootRequest(c.Server, authorityID, params, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) ListCertificates(ctx context.Context, params *ListCertificatesParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListCertificatesRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetCertificate(ctx context.Context, serialNumber SerialNumber, params *GetCertificateParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetCertificateRequest(c.Server, serialNumber, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostDevicesWithBody(ctx context.Context, params *PostDevicesParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostDevicesRequestWithBody(c.Server, params, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostDevices(ctx context.Context, params *PostDevicesParams, body PostDevicesJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostDevicesRequest(c.Server, params, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetPlatforms(ctx context.Context, params *GetPlatformsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetPlatformsRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PutPlatformWithBody(ctx context.Context, platformSlug PlatformSlug, params *PutPlatformParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPutPlatformRequestWithBody(c.Server, platformSlug, params, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PutPlatform(ctx context.Context, platformSlug PlatformSlug, params *PutPlatformParams, body PutPlatformJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPutPlatformRequest(c.Server, platformSlug, params, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +// NewPostAuthRequest calls the generic PostAuth builder with application/json body +func NewPostAuthRequest(server string, body PostAuthJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPostAuthRequestWithBody(server, "application/json", bodyReader) +} + +// NewPostAuthRequestWithBody generates requests for PostAuth with any type of body +func NewPostAuthRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/auth") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewGetAuthoritiesRequest generates requests for GetAuthorities +func NewGetAuthoritiesRequest(server string, params *GetAuthoritiesParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/authorities") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + if params != nil { + + if params.XRequestId != nil { + var headerParam0 string + + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) + if err != nil { + return nil, err + } + + req.Header.Set("X-Request-Id", headerParam0) + } + + if params.Accept != nil { + var headerParam1 string + + headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) + if err != nil { + return nil, err + } + + req.Header.Set("Accept", headerParam1) + } + + } + + return req, nil +} + +// NewPostAuthoritiesRequest calls the generic PostAuthorities builder with application/json body +func NewPostAuthoritiesRequest(server string, params *PostAuthoritiesParams, body PostAuthoritiesJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPostAuthoritiesRequestWithBody(server, params, "application/json", bodyReader) +} + +// NewPostAuthoritiesRequestWithBody generates requests for PostAuthorities with any type of body +func NewPostAuthoritiesRequestWithBody(server string, params *PostAuthoritiesParams, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/authorities") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + if params != nil { + + if params.XRequestId != nil { + var headerParam0 string + + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) + if err != nil { + return nil, err + } + + req.Header.Set("X-Request-Id", headerParam0) + } + + if params.Accept != nil { + var headerParam1 string + + headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) + if err != nil { + return nil, err + } + + req.Header.Set("Accept", headerParam1) + } + + } + + return req, nil +} + +// NewPostAuthoritiesCsrRequest calls the generic PostAuthoritiesCsr builder with application/json body +func NewPostAuthoritiesCsrRequest(server string, params *PostAuthoritiesCsrParams, body PostAuthoritiesCsrJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPostAuthoritiesCsrRequestWithBody(server, params, "application/json", bodyReader) +} + +// NewPostAuthoritiesCsrRequestWithBody generates requests for PostAuthoritiesCsr with any type of body +func NewPostAuthoritiesCsrRequestWithBody(server string, params *PostAuthoritiesCsrParams, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/authorities/csr") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + if params != nil { + + if params.XRequestId != nil { + var headerParam0 string + + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) + if err != nil { + return nil, err + } + + req.Header.Set("X-Request-Id", headerParam0) + } + + if params.Accept != nil { + var headerParam1 string + + headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) + if err != nil { + return nil, err + } + + req.Header.Set("Accept", headerParam1) + } + + } + + return req, nil +} + +// NewDeleteAuthorityRequest generates requests for DeleteAuthority +func NewDeleteAuthorityRequest(server string, authorityDomainOrID AuthorityDomainOrID, params *DeleteAuthorityParams) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "authorityDomainOrID", runtime.ParamLocationPath, authorityDomainOrID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/authorities/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("DELETE", queryURL.String(), nil) + if err != nil { + return nil, err + } + + if params != nil { + + if params.XRequestId != nil { + var headerParam0 string + + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) + if err != nil { + return nil, err + } + + req.Header.Set("X-Request-Id", headerParam0) + } + + if params.Accept != nil { + var headerParam1 string + + headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) + if err != nil { + return nil, err + } + + req.Header.Set("Accept", headerParam1) + } + + } + + return req, nil +} + +// NewGetAuthorityRequest generates requests for GetAuthority +func NewGetAuthorityRequest(server string, authorityDomainOrID AuthorityDomainOrID, params *GetAuthorityParams) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "authorityDomainOrID", runtime.ParamLocationPath, authorityDomainOrID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/authorities/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + if params != nil { + + if params.XRequestId != nil { + var headerParam0 string + + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) + if err != nil { + return nil, err + } + + req.Header.Set("X-Request-Id", headerParam0) + } + + if params.Accept != nil { + var headerParam1 string + + headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) + if err != nil { + return nil, err + } + + req.Header.Set("Accept", headerParam1) + } + + } + + return req, nil +} + +// NewListAuthorityProvisionersRequest generates requests for ListAuthorityProvisioners +func NewListAuthorityProvisionersRequest(server string, authorityID AuthorityID, params *ListAuthorityProvisionersParams) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "authorityID", runtime.ParamLocationPath, authorityID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/authorities/%s/provisioners", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + if params != nil { + + if params.XRequestId != nil { + var headerParam0 string + + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) + if err != nil { + return nil, err + } + + req.Header.Set("X-Request-Id", headerParam0) + } + + if params.Accept != nil { + var headerParam1 string + + headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) + if err != nil { + return nil, err + } + + req.Header.Set("Accept", headerParam1) + } + + } + + return req, nil +} + +// NewPostAuthorityProvisionersRequest calls the generic PostAuthorityProvisioners builder with application/json body +func NewPostAuthorityProvisionersRequest(server string, authorityID AuthorityID, params *PostAuthorityProvisionersParams, body PostAuthorityProvisionersJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPostAuthorityProvisionersRequestWithBody(server, authorityID, params, "application/json", bodyReader) +} + +// NewPostAuthorityProvisionersRequestWithBody generates requests for PostAuthorityProvisioners with any type of body +func NewPostAuthorityProvisionersRequestWithBody(server string, authorityID AuthorityID, params *PostAuthorityProvisionersParams, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "authorityID", runtime.ParamLocationPath, authorityID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/authorities/%s/provisioners", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + if params != nil { + + if params.XRequestId != nil { + var headerParam0 string + + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) + if err != nil { + return nil, err + } + + req.Header.Set("X-Request-Id", headerParam0) + } + + if params.Accept != nil { + var headerParam1 string + + headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) + if err != nil { + return nil, err + } + + req.Header.Set("Accept", headerParam1) + } + + } + + return req, nil +} + +// NewDeleteProvisionerRequest generates requests for DeleteProvisioner +func NewDeleteProvisionerRequest(server string, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, params *DeleteProvisionerParams) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "authorityID", runtime.ParamLocationPath, authorityID) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "provisionerNameOrID", runtime.ParamLocationPath, provisionerNameOrID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/authorities/%s/provisioners/%s", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("DELETE", queryURL.String(), nil) + if err != nil { + return nil, err + } + + if params != nil { + + if params.XRequestId != nil { + var headerParam0 string + + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) + if err != nil { + return nil, err + } + + req.Header.Set("X-Request-Id", headerParam0) + } + + if params.Accept != nil { + var headerParam1 string + + headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) + if err != nil { + return nil, err + } + + req.Header.Set("Accept", headerParam1) + } + + } + + return req, nil +} + +// NewGetProvisionerRequest generates requests for GetProvisioner +func NewGetProvisionerRequest(server string, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, params *GetProvisionerParams) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "authorityID", runtime.ParamLocationPath, authorityID) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "provisionerNameOrID", runtime.ParamLocationPath, provisionerNameOrID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/authorities/%s/provisioners/%s", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + if params != nil { + + if params.XRequestId != nil { + var headerParam0 string + + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) + if err != nil { + return nil, err + } + + req.Header.Set("X-Request-Id", headerParam0) + } + + if params.Accept != nil { + var headerParam1 string + + headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) + if err != nil { + return nil, err + } + + req.Header.Set("Accept", headerParam1) + } + + } + + return req, nil +} + +// NewPostWebhooksRequest calls the generic PostWebhooks builder with application/json body +func NewPostWebhooksRequest(server string, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, params *PostWebhooksParams, body PostWebhooksJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPostWebhooksRequestWithBody(server, authorityID, provisionerNameOrID, params, "application/json", bodyReader) +} + +// NewPostWebhooksRequestWithBody generates requests for PostWebhooks with any type of body +func NewPostWebhooksRequestWithBody(server string, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, params *PostWebhooksParams, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "authorityID", runtime.ParamLocationPath, authorityID) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "provisionerNameOrID", runtime.ParamLocationPath, provisionerNameOrID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/authorities/%s/provisioners/%s/webhooks", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + if params != nil { + + if params.XRequestId != nil { + var headerParam0 string + + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) + if err != nil { + return nil, err + } + + req.Header.Set("X-Request-Id", headerParam0) + } + + if params.Accept != nil { + var headerParam1 string + + headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) + if err != nil { + return nil, err + } + + req.Header.Set("Accept", headerParam1) + } + + } + + return req, nil +} + +// NewDeleteWebhookRequest generates requests for DeleteWebhook +func NewDeleteWebhookRequest(server string, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, webhookNameOrID WebhookNameOrID, params *DeleteWebhookParams) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "authorityID", runtime.ParamLocationPath, authorityID) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "provisionerNameOrID", runtime.ParamLocationPath, provisionerNameOrID) + if err != nil { + return nil, err + } + + var pathParam2 string + + pathParam2, err = runtime.StyleParamWithLocation("simple", false, "webhookNameOrID", runtime.ParamLocationPath, webhookNameOrID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/authorities/%s/provisioners/%s/webhooks/%s", pathParam0, pathParam1, pathParam2) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("DELETE", queryURL.String(), nil) + if err != nil { + return nil, err + } + + if params != nil { + + if params.XRequestId != nil { + var headerParam0 string + + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) + if err != nil { + return nil, err + } + + req.Header.Set("X-Request-Id", headerParam0) + } + + if params.Accept != nil { + var headerParam1 string + + headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) + if err != nil { + return nil, err + } + + req.Header.Set("Accept", headerParam1) + } + + } + + return req, nil +} + +// NewGetWebhookRequest generates requests for GetWebhook +func NewGetWebhookRequest(server string, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, webhookNameOrID WebhookNameOrID, params *GetWebhookParams) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "authorityID", runtime.ParamLocationPath, authorityID) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "provisionerNameOrID", runtime.ParamLocationPath, provisionerNameOrID) + if err != nil { + return nil, err + } + + var pathParam2 string + + pathParam2, err = runtime.StyleParamWithLocation("simple", false, "webhookNameOrID", runtime.ParamLocationPath, webhookNameOrID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/authorities/%s/provisioners/%s/webhooks/%s", pathParam0, pathParam1, pathParam2) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + if params != nil { + + if params.XRequestId != nil { + var headerParam0 string + + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) + if err != nil { + return nil, err + } + + req.Header.Set("X-Request-Id", headerParam0) + } + + if params.Accept != nil { + var headerParam1 string + + headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) + if err != nil { + return nil, err + } + + req.Header.Set("Accept", headerParam1) + } + + } + + return req, nil +} + +// NewPostAuthorityRootRequest calls the generic PostAuthorityRoot builder with application/json body +func NewPostAuthorityRootRequest(server string, authorityID AuthorityID, params *PostAuthorityRootParams, body PostAuthorityRootJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPostAuthorityRootRequestWithBody(server, authorityID, params, "application/json", bodyReader) +} + +// NewPostAuthorityRootRequestWithBody generates requests for PostAuthorityRoot with any type of body +func NewPostAuthorityRootRequestWithBody(server string, authorityID AuthorityID, params *PostAuthorityRootParams, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "authorityID", runtime.ParamLocationPath, authorityID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/authorities/%s/root", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + if params != nil { + + if params.XRequestId != nil { + var headerParam0 string + + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) + if err != nil { + return nil, err + } + + req.Header.Set("X-Request-Id", headerParam0) + } + + if params.Accept != nil { + var headerParam1 string + + headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) + if err != nil { + return nil, err + } + + req.Header.Set("Accept", headerParam1) + } + + } + + return req, nil +} + +// NewListCertificatesRequest generates requests for ListCertificates +func NewListCertificatesRequest(server string, params *ListCertificatesParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/certificates") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + queryValues := queryURL.Query() + + if params.Pagination != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("deepObject", true, "pagination", runtime.ParamLocationQuery, *params.Pagination); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + if params != nil { + + if params.XRequestId != nil { + var headerParam0 string + + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) + if err != nil { + return nil, err + } + + req.Header.Set("X-Request-Id", headerParam0) + } + + if params.Accept != nil { + var headerParam1 string + + headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) + if err != nil { + return nil, err + } + + req.Header.Set("Accept", headerParam1) + } + + } + + return req, nil +} + +// NewGetCertificateRequest generates requests for GetCertificate +func NewGetCertificateRequest(server string, serialNumber SerialNumber, params *GetCertificateParams) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "serialNumber", runtime.ParamLocationPath, serialNumber) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/certificates/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + if params != nil { + + if params.XRequestId != nil { + var headerParam0 string + + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) + if err != nil { + return nil, err + } + + req.Header.Set("X-Request-Id", headerParam0) + } + + if params.Accept != nil { + var headerParam1 string + + headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) + if err != nil { + return nil, err + } + + req.Header.Set("Accept", headerParam1) + } + + } + + return req, nil +} + +// NewPostDevicesRequest calls the generic PostDevices builder with application/json body +func NewPostDevicesRequest(server string, params *PostDevicesParams, body PostDevicesJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPostDevicesRequestWithBody(server, params, "application/json", bodyReader) +} + +// NewPostDevicesRequestWithBody generates requests for PostDevices with any type of body +func NewPostDevicesRequestWithBody(server string, params *PostDevicesParams, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/devices") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + if params != nil { + + if params.XRequestId != nil { + var headerParam0 string + + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) + if err != nil { + return nil, err + } + + req.Header.Set("X-Request-Id", headerParam0) + } + + if params.Accept != nil { + var headerParam1 string + + headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) + if err != nil { + return nil, err + } + + req.Header.Set("Accept", headerParam1) + } + + } + + return req, nil +} + +// NewGetPlatformsRequest generates requests for GetPlatforms +func NewGetPlatformsRequest(server string, params *GetPlatformsParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/platforms") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + queryValues := queryURL.Query() + + if params.Pagination != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("deepObject", true, "pagination", runtime.ParamLocationQuery, *params.Pagination); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + if params != nil { + + if params.XRequestId != nil { + var headerParam0 string + + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) + if err != nil { + return nil, err + } + + req.Header.Set("X-Request-Id", headerParam0) + } + + if params.Accept != nil { + var headerParam1 string + + headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) + if err != nil { + return nil, err + } + + req.Header.Set("Accept", headerParam1) + } + + } + + return req, nil +} + +// NewPutPlatformRequest calls the generic PutPlatform builder with application/json body +func NewPutPlatformRequest(server string, platformSlug PlatformSlug, params *PutPlatformParams, body PutPlatformJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPutPlatformRequestWithBody(server, platformSlug, params, "application/json", bodyReader) +} + +// NewPutPlatformRequestWithBody generates requests for PutPlatform with any type of body +func NewPutPlatformRequestWithBody(server string, platformSlug PlatformSlug, params *PutPlatformParams, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "platformSlug", runtime.ParamLocationPath, platformSlug) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/platforms/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PUT", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + if params != nil { + + if params.XRequestId != nil { + var headerParam0 string + + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) + if err != nil { + return nil, err + } + + req.Header.Set("X-Request-Id", headerParam0) + } + + if params.Accept != nil { + var headerParam1 string + + headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) + if err != nil { + return nil, err + } + + req.Header.Set("Accept", headerParam1) + } + + } + + return req, nil +} + +func (c *Client) applyEditors(ctx context.Context, req *http.Request, additionalEditors []RequestEditorFn) error { + for _, r := range c.RequestEditors { + if err := r(ctx, req); err != nil { + return err + } + } + for _, r := range additionalEditors { + if err := r(ctx, req); err != nil { + return err + } + } + return nil +} + +// ClientWithResponses builds on ClientInterface to offer response payloads +type ClientWithResponses struct { + ClientInterface +} + +// NewClientWithResponses creates a new ClientWithResponses, which wraps +// Client with return type handling +func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error) { + client, err := NewClient(server, opts...) + if err != nil { + return nil, err + } + return &ClientWithResponses{client}, nil +} + +// WithBaseURL overrides the baseURL. +func WithBaseURL(baseURL string) ClientOption { + return func(c *Client) error { + newBaseURL, err := url.Parse(baseURL) + if err != nil { + return err + } + c.Server = newBaseURL.String() + return nil + } +} + +// ClientWithResponsesInterface is the interface specification for the client with responses above. +type ClientWithResponsesInterface interface { + // PostAuthWithBodyWithResponse request with any body + PostAuthWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostAuthResponse, error) + + PostAuthWithResponse(ctx context.Context, body PostAuthJSONRequestBody, reqEditors ...RequestEditorFn) (*PostAuthResponse, error) + + // GetAuthoritiesWithResponse request + GetAuthoritiesWithResponse(ctx context.Context, params *GetAuthoritiesParams, reqEditors ...RequestEditorFn) (*GetAuthoritiesResponse, error) + + // PostAuthoritiesWithBodyWithResponse request with any body + PostAuthoritiesWithBodyWithResponse(ctx context.Context, params *PostAuthoritiesParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostAuthoritiesResponse, error) + + PostAuthoritiesWithResponse(ctx context.Context, params *PostAuthoritiesParams, body PostAuthoritiesJSONRequestBody, reqEditors ...RequestEditorFn) (*PostAuthoritiesResponse, error) + + // PostAuthoritiesCsrWithBodyWithResponse request with any body + PostAuthoritiesCsrWithBodyWithResponse(ctx context.Context, params *PostAuthoritiesCsrParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostAuthoritiesCsrResponse, error) + + PostAuthoritiesCsrWithResponse(ctx context.Context, params *PostAuthoritiesCsrParams, body PostAuthoritiesCsrJSONRequestBody, reqEditors ...RequestEditorFn) (*PostAuthoritiesCsrResponse, error) + + // DeleteAuthorityWithResponse request + DeleteAuthorityWithResponse(ctx context.Context, authorityDomainOrID AuthorityDomainOrID, params *DeleteAuthorityParams, reqEditors ...RequestEditorFn) (*DeleteAuthorityResponse, error) + + // GetAuthorityWithResponse request + GetAuthorityWithResponse(ctx context.Context, authorityDomainOrID AuthorityDomainOrID, params *GetAuthorityParams, reqEditors ...RequestEditorFn) (*GetAuthorityResponse, error) + + // ListAuthorityProvisionersWithResponse request + ListAuthorityProvisionersWithResponse(ctx context.Context, authorityID AuthorityID, params *ListAuthorityProvisionersParams, reqEditors ...RequestEditorFn) (*ListAuthorityProvisionersResponse, error) + + // PostAuthorityProvisionersWithBodyWithResponse request with any body + PostAuthorityProvisionersWithBodyWithResponse(ctx context.Context, authorityID AuthorityID, params *PostAuthorityProvisionersParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostAuthorityProvisionersResponse, error) + + PostAuthorityProvisionersWithResponse(ctx context.Context, authorityID AuthorityID, params *PostAuthorityProvisionersParams, body PostAuthorityProvisionersJSONRequestBody, reqEditors ...RequestEditorFn) (*PostAuthorityProvisionersResponse, error) + + // DeleteProvisionerWithResponse request + DeleteProvisionerWithResponse(ctx context.Context, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, params *DeleteProvisionerParams, reqEditors ...RequestEditorFn) (*DeleteProvisionerResponse, error) + + // GetProvisionerWithResponse request + GetProvisionerWithResponse(ctx context.Context, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, params *GetProvisionerParams, reqEditors ...RequestEditorFn) (*GetProvisionerResponse, error) + + // PostWebhooksWithBodyWithResponse request with any body + PostWebhooksWithBodyWithResponse(ctx context.Context, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, params *PostWebhooksParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostWebhooksResponse, error) + + PostWebhooksWithResponse(ctx context.Context, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, params *PostWebhooksParams, body PostWebhooksJSONRequestBody, reqEditors ...RequestEditorFn) (*PostWebhooksResponse, error) + + // DeleteWebhookWithResponse request + DeleteWebhookWithResponse(ctx context.Context, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, webhookNameOrID WebhookNameOrID, params *DeleteWebhookParams, reqEditors ...RequestEditorFn) (*DeleteWebhookResponse, error) + + // GetWebhookWithResponse request + GetWebhookWithResponse(ctx context.Context, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, webhookNameOrID WebhookNameOrID, params *GetWebhookParams, reqEditors ...RequestEditorFn) (*GetWebhookResponse, error) + + // PostAuthorityRootWithBodyWithResponse request with any body + PostAuthorityRootWithBodyWithResponse(ctx context.Context, authorityID AuthorityID, params *PostAuthorityRootParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostAuthorityRootResponse, error) + + PostAuthorityRootWithResponse(ctx context.Context, authorityID AuthorityID, params *PostAuthorityRootParams, body PostAuthorityRootJSONRequestBody, reqEditors ...RequestEditorFn) (*PostAuthorityRootResponse, error) + + // ListCertificatesWithResponse request + ListCertificatesWithResponse(ctx context.Context, params *ListCertificatesParams, reqEditors ...RequestEditorFn) (*ListCertificatesResponse, error) + + // GetCertificateWithResponse request + GetCertificateWithResponse(ctx context.Context, serialNumber SerialNumber, params *GetCertificateParams, reqEditors ...RequestEditorFn) (*GetCertificateResponse, error) + + // PostDevicesWithBodyWithResponse request with any body + PostDevicesWithBodyWithResponse(ctx context.Context, params *PostDevicesParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostDevicesResponse, error) + + PostDevicesWithResponse(ctx context.Context, params *PostDevicesParams, body PostDevicesJSONRequestBody, reqEditors ...RequestEditorFn) (*PostDevicesResponse, error) + + // GetPlatformsWithResponse request + GetPlatformsWithResponse(ctx context.Context, params *GetPlatformsParams, reqEditors ...RequestEditorFn) (*GetPlatformsResponse, error) + + // PutPlatformWithBodyWithResponse request with any body + PutPlatformWithBodyWithResponse(ctx context.Context, platformSlug PlatformSlug, params *PutPlatformParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutPlatformResponse, error) + + PutPlatformWithResponse(ctx context.Context, platformSlug PlatformSlug, params *PutPlatformParams, body PutPlatformJSONRequestBody, reqEditors ...RequestEditorFn) (*PutPlatformResponse, error) +} + +type PostAuthResponse struct { + Body []byte + HTTPResponse *http.Response + JSON201 *struct { + Token *string `json:"token,omitempty"` + } + JSON400 *N400 + JSON401 *N401 + JSON403 *N403 + JSON500 *N500 +} + +// Status returns HTTPResponse.Status +func (r PostAuthResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PostAuthResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetAuthoritiesResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *[]Authority + JSON400 *N400 + JSON401 *N401 + JSON500 *N500 +} + +// Status returns HTTPResponse.Status +func (r GetAuthoritiesResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetAuthoritiesResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PostAuthoritiesResponse struct { + Body []byte + HTTPResponse *http.Response + JSON201 *Authority + JSON400 *N400 + JSON401 *N401 + JSON409 *N409 + JSON412 *N412 + JSON422 *N422 + JSON500 *N500 +} + +// Status returns HTTPResponse.Status +func (r PostAuthoritiesResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PostAuthoritiesResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PostAuthoritiesCsrResponse struct { + Body []byte + HTTPResponse *http.Response + JSON201 *AuthorityCsr + JSON400 *N400 + JSON401 *N401 + JSON409 *N409 + JSON412 *N412 + JSON500 *N500 +} + +// Status returns HTTPResponse.Status +func (r PostAuthoritiesCsrResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PostAuthoritiesCsrResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type DeleteAuthorityResponse struct { + Body []byte + HTTPResponse *http.Response + JSON400 *N400 + JSON401 *N401 + JSON422 *N422 + JSON500 *N500 +} + +// Status returns HTTPResponse.Status +func (r DeleteAuthorityResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteAuthorityResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetAuthorityResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *Authority + JSON400 *N400 + JSON401 *N401 + JSON404 *N404 + JSON500 *N500 +} + +// Status returns HTTPResponse.Status +func (r GetAuthorityResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetAuthorityResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type ListAuthorityProvisionersResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *[]Provisioner + JSON400 *N400 + JSON401 *N401 + JSON404 *N404 + JSON500 *N500 +} + +// Status returns HTTPResponse.Status +func (r ListAuthorityProvisionersResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListAuthorityProvisionersResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PostAuthorityProvisionersResponse struct { + Body []byte + HTTPResponse *http.Response + JSON201 *Provisioner + JSON400 *N400 + JSON401 *N401 + JSON404 *N404 + JSON409 *N409 + JSON422 *N422 + JSON500 *N500 +} + +// Status returns HTTPResponse.Status +func (r PostAuthorityProvisionersResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PostAuthorityProvisionersResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type DeleteProvisionerResponse struct { + Body []byte + HTTPResponse *http.Response + JSON400 *N400 + JSON401 *N401 + JSON422 *N422 + JSON500 *N500 +} + +// Status returns HTTPResponse.Status +func (r DeleteProvisionerResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteProvisionerResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetProvisionerResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *Provisioner + JSON400 *N400 + JSON401 *N401 + JSON404 *N404 + JSON500 *N500 +} + +// Status returns HTTPResponse.Status +func (r GetProvisionerResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetProvisionerResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PostWebhooksResponse struct { + Body []byte + HTTPResponse *http.Response + JSON201 *ProvisionerWebhook + JSON400 *N400 + JSON401 *N401 + JSON404 *N404 + JSON409 *N409 + JSON412 *N412 + JSON422 *N422 + JSON500 *N500 +} + +// Status returns HTTPResponse.Status +func (r PostWebhooksResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PostWebhooksResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type DeleteWebhookResponse struct { + Body []byte + HTTPResponse *http.Response + JSON400 *N400 + JSON401 *N401 + JSON422 *N422 + JSON500 *N500 +} + +// Status returns HTTPResponse.Status +func (r DeleteWebhookResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteWebhookResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetWebhookResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *ProvisionerWebhook + JSON400 *N400 + JSON401 *N401 + JSON404 *N404 + JSON500 *N500 +} + +// Status returns HTTPResponse.Status +func (r GetWebhookResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetWebhookResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PostAuthorityRootResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *Authority + JSON400 *N400 + JSON401 *N401 + JSON404 *N404 + JSON500 *N500 +} + +// Status returns HTTPResponse.Status +func (r PostAuthorityRootResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PostAuthorityRootResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type ListCertificatesResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *[]X509Certificate + JSON400 *N400 + JSON401 *N401 + JSON500 *N500 +} + +// Status returns HTTPResponse.Status +func (r ListCertificatesResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListCertificatesResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetCertificateResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *X509Certificate + JSON400 *N400 + JSON401 *N401 + JSON404 *N404 + JSON500 *N500 +} + +// Status returns HTTPResponse.Status +func (r GetCertificateResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetCertificateResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PostDevicesResponse struct { + Body []byte + HTTPResponse *http.Response + JSON201 *Device + JSON400 *N400 + JSON401 *N401 + JSON500 *N500 +} + +// Status returns HTTPResponse.Status +func (r PostDevicesResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PostDevicesResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetPlatformsResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *[]Platform + JSON400 *N400 + JSON401 *N401 + JSON500 *N500 +} + +// Status returns HTTPResponse.Status +func (r GetPlatformsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetPlatformsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PutPlatformResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *Platform + JSON400 *N400 + JSON401 *N401 + JSON500 *N500 +} + +// Status returns HTTPResponse.Status +func (r PutPlatformResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PutPlatformResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// PostAuthWithBodyWithResponse request with arbitrary body returning *PostAuthResponse +func (c *ClientWithResponses) PostAuthWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostAuthResponse, error) { + rsp, err := c.PostAuthWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostAuthResponse(rsp) +} + +func (c *ClientWithResponses) PostAuthWithResponse(ctx context.Context, body PostAuthJSONRequestBody, reqEditors ...RequestEditorFn) (*PostAuthResponse, error) { + rsp, err := c.PostAuth(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostAuthResponse(rsp) +} + +// GetAuthoritiesWithResponse request returning *GetAuthoritiesResponse +func (c *ClientWithResponses) GetAuthoritiesWithResponse(ctx context.Context, params *GetAuthoritiesParams, reqEditors ...RequestEditorFn) (*GetAuthoritiesResponse, error) { + rsp, err := c.GetAuthorities(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetAuthoritiesResponse(rsp) +} + +// PostAuthoritiesWithBodyWithResponse request with arbitrary body returning *PostAuthoritiesResponse +func (c *ClientWithResponses) PostAuthoritiesWithBodyWithResponse(ctx context.Context, params *PostAuthoritiesParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostAuthoritiesResponse, error) { + rsp, err := c.PostAuthoritiesWithBody(ctx, params, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostAuthoritiesResponse(rsp) +} + +func (c *ClientWithResponses) PostAuthoritiesWithResponse(ctx context.Context, params *PostAuthoritiesParams, body PostAuthoritiesJSONRequestBody, reqEditors ...RequestEditorFn) (*PostAuthoritiesResponse, error) { + rsp, err := c.PostAuthorities(ctx, params, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostAuthoritiesResponse(rsp) +} + +// PostAuthoritiesCsrWithBodyWithResponse request with arbitrary body returning *PostAuthoritiesCsrResponse +func (c *ClientWithResponses) PostAuthoritiesCsrWithBodyWithResponse(ctx context.Context, params *PostAuthoritiesCsrParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostAuthoritiesCsrResponse, error) { + rsp, err := c.PostAuthoritiesCsrWithBody(ctx, params, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostAuthoritiesCsrResponse(rsp) +} + +func (c *ClientWithResponses) PostAuthoritiesCsrWithResponse(ctx context.Context, params *PostAuthoritiesCsrParams, body PostAuthoritiesCsrJSONRequestBody, reqEditors ...RequestEditorFn) (*PostAuthoritiesCsrResponse, error) { + rsp, err := c.PostAuthoritiesCsr(ctx, params, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostAuthoritiesCsrResponse(rsp) +} + +// DeleteAuthorityWithResponse request returning *DeleteAuthorityResponse +func (c *ClientWithResponses) DeleteAuthorityWithResponse(ctx context.Context, authorityDomainOrID AuthorityDomainOrID, params *DeleteAuthorityParams, reqEditors ...RequestEditorFn) (*DeleteAuthorityResponse, error) { + rsp, err := c.DeleteAuthority(ctx, authorityDomainOrID, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteAuthorityResponse(rsp) +} + +// GetAuthorityWithResponse request returning *GetAuthorityResponse +func (c *ClientWithResponses) GetAuthorityWithResponse(ctx context.Context, authorityDomainOrID AuthorityDomainOrID, params *GetAuthorityParams, reqEditors ...RequestEditorFn) (*GetAuthorityResponse, error) { + rsp, err := c.GetAuthority(ctx, authorityDomainOrID, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetAuthorityResponse(rsp) +} + +// ListAuthorityProvisionersWithResponse request returning *ListAuthorityProvisionersResponse +func (c *ClientWithResponses) ListAuthorityProvisionersWithResponse(ctx context.Context, authorityID AuthorityID, params *ListAuthorityProvisionersParams, reqEditors ...RequestEditorFn) (*ListAuthorityProvisionersResponse, error) { + rsp, err := c.ListAuthorityProvisioners(ctx, authorityID, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseListAuthorityProvisionersResponse(rsp) +} + +// PostAuthorityProvisionersWithBodyWithResponse request with arbitrary body returning *PostAuthorityProvisionersResponse +func (c *ClientWithResponses) PostAuthorityProvisionersWithBodyWithResponse(ctx context.Context, authorityID AuthorityID, params *PostAuthorityProvisionersParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostAuthorityProvisionersResponse, error) { + rsp, err := c.PostAuthorityProvisionersWithBody(ctx, authorityID, params, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostAuthorityProvisionersResponse(rsp) +} + +func (c *ClientWithResponses) PostAuthorityProvisionersWithResponse(ctx context.Context, authorityID AuthorityID, params *PostAuthorityProvisionersParams, body PostAuthorityProvisionersJSONRequestBody, reqEditors ...RequestEditorFn) (*PostAuthorityProvisionersResponse, error) { + rsp, err := c.PostAuthorityProvisioners(ctx, authorityID, params, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostAuthorityProvisionersResponse(rsp) +} + +// DeleteProvisionerWithResponse request returning *DeleteProvisionerResponse +func (c *ClientWithResponses) DeleteProvisionerWithResponse(ctx context.Context, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, params *DeleteProvisionerParams, reqEditors ...RequestEditorFn) (*DeleteProvisionerResponse, error) { + rsp, err := c.DeleteProvisioner(ctx, authorityID, provisionerNameOrID, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteProvisionerResponse(rsp) +} + +// GetProvisionerWithResponse request returning *GetProvisionerResponse +func (c *ClientWithResponses) GetProvisionerWithResponse(ctx context.Context, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, params *GetProvisionerParams, reqEditors ...RequestEditorFn) (*GetProvisionerResponse, error) { + rsp, err := c.GetProvisioner(ctx, authorityID, provisionerNameOrID, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetProvisionerResponse(rsp) +} + +// PostWebhooksWithBodyWithResponse request with arbitrary body returning *PostWebhooksResponse +func (c *ClientWithResponses) PostWebhooksWithBodyWithResponse(ctx context.Context, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, params *PostWebhooksParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostWebhooksResponse, error) { + rsp, err := c.PostWebhooksWithBody(ctx, authorityID, provisionerNameOrID, params, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostWebhooksResponse(rsp) +} + +func (c *ClientWithResponses) PostWebhooksWithResponse(ctx context.Context, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, params *PostWebhooksParams, body PostWebhooksJSONRequestBody, reqEditors ...RequestEditorFn) (*PostWebhooksResponse, error) { + rsp, err := c.PostWebhooks(ctx, authorityID, provisionerNameOrID, params, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostWebhooksResponse(rsp) +} + +// DeleteWebhookWithResponse request returning *DeleteWebhookResponse +func (c *ClientWithResponses) DeleteWebhookWithResponse(ctx context.Context, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, webhookNameOrID WebhookNameOrID, params *DeleteWebhookParams, reqEditors ...RequestEditorFn) (*DeleteWebhookResponse, error) { + rsp, err := c.DeleteWebhook(ctx, authorityID, provisionerNameOrID, webhookNameOrID, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteWebhookResponse(rsp) +} + +// GetWebhookWithResponse request returning *GetWebhookResponse +func (c *ClientWithResponses) GetWebhookWithResponse(ctx context.Context, authorityID AuthorityID, provisionerNameOrID ProvisionerNameOrID, webhookNameOrID WebhookNameOrID, params *GetWebhookParams, reqEditors ...RequestEditorFn) (*GetWebhookResponse, error) { + rsp, err := c.GetWebhook(ctx, authorityID, provisionerNameOrID, webhookNameOrID, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetWebhookResponse(rsp) +} + +// PostAuthorityRootWithBodyWithResponse request with arbitrary body returning *PostAuthorityRootResponse +func (c *ClientWithResponses) PostAuthorityRootWithBodyWithResponse(ctx context.Context, authorityID AuthorityID, params *PostAuthorityRootParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostAuthorityRootResponse, error) { + rsp, err := c.PostAuthorityRootWithBody(ctx, authorityID, params, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostAuthorityRootResponse(rsp) +} + +func (c *ClientWithResponses) PostAuthorityRootWithResponse(ctx context.Context, authorityID AuthorityID, params *PostAuthorityRootParams, body PostAuthorityRootJSONRequestBody, reqEditors ...RequestEditorFn) (*PostAuthorityRootResponse, error) { + rsp, err := c.PostAuthorityRoot(ctx, authorityID, params, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostAuthorityRootResponse(rsp) +} + +// ListCertificatesWithResponse request returning *ListCertificatesResponse +func (c *ClientWithResponses) ListCertificatesWithResponse(ctx context.Context, params *ListCertificatesParams, reqEditors ...RequestEditorFn) (*ListCertificatesResponse, error) { + rsp, err := c.ListCertificates(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseListCertificatesResponse(rsp) +} + +// GetCertificateWithResponse request returning *GetCertificateResponse +func (c *ClientWithResponses) GetCertificateWithResponse(ctx context.Context, serialNumber SerialNumber, params *GetCertificateParams, reqEditors ...RequestEditorFn) (*GetCertificateResponse, error) { + rsp, err := c.GetCertificate(ctx, serialNumber, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetCertificateResponse(rsp) +} + +// PostDevicesWithBodyWithResponse request with arbitrary body returning *PostDevicesResponse +func (c *ClientWithResponses) PostDevicesWithBodyWithResponse(ctx context.Context, params *PostDevicesParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostDevicesResponse, error) { + rsp, err := c.PostDevicesWithBody(ctx, params, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostDevicesResponse(rsp) +} + +func (c *ClientWithResponses) PostDevicesWithResponse(ctx context.Context, params *PostDevicesParams, body PostDevicesJSONRequestBody, reqEditors ...RequestEditorFn) (*PostDevicesResponse, error) { + rsp, err := c.PostDevices(ctx, params, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostDevicesResponse(rsp) +} + +// GetPlatformsWithResponse request returning *GetPlatformsResponse +func (c *ClientWithResponses) GetPlatformsWithResponse(ctx context.Context, params *GetPlatformsParams, reqEditors ...RequestEditorFn) (*GetPlatformsResponse, error) { + rsp, err := c.GetPlatforms(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetPlatformsResponse(rsp) +} + +// PutPlatformWithBodyWithResponse request with arbitrary body returning *PutPlatformResponse +func (c *ClientWithResponses) PutPlatformWithBodyWithResponse(ctx context.Context, platformSlug PlatformSlug, params *PutPlatformParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutPlatformResponse, error) { + rsp, err := c.PutPlatformWithBody(ctx, platformSlug, params, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePutPlatformResponse(rsp) +} + +func (c *ClientWithResponses) PutPlatformWithResponse(ctx context.Context, platformSlug PlatformSlug, params *PutPlatformParams, body PutPlatformJSONRequestBody, reqEditors ...RequestEditorFn) (*PutPlatformResponse, error) { + rsp, err := c.PutPlatform(ctx, platformSlug, params, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePutPlatformResponse(rsp) +} + +// ParsePostAuthResponse parses an HTTP response from a PostAuthWithResponse call +func ParsePostAuthResponse(rsp *http.Response) (*PostAuthResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PostAuthResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest struct { + Token *string `json:"token,omitempty"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON201 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest N400 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest N401 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest N403 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest N500 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseGetAuthoritiesResponse parses an HTTP response from a GetAuthoritiesWithResponse call +func ParseGetAuthoritiesResponse(rsp *http.Response) (*GetAuthoritiesResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetAuthoritiesResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest []Authority + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest N400 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest N401 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest N500 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParsePostAuthoritiesResponse parses an HTTP response from a PostAuthoritiesWithResponse call +func ParsePostAuthoritiesResponse(rsp *http.Response) (*PostAuthoritiesResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PostAuthoritiesResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest Authority + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON201 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest N400 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest N401 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest N409 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 412: + var dest N412 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON412 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 422: + var dest N422 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON422 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest N500 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParsePostAuthoritiesCsrResponse parses an HTTP response from a PostAuthoritiesCsrWithResponse call +func ParsePostAuthoritiesCsrResponse(rsp *http.Response) (*PostAuthoritiesCsrResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PostAuthoritiesCsrResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest AuthorityCsr + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON201 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest N400 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest N401 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest N409 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 412: + var dest N412 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON412 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest N500 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseDeleteAuthorityResponse parses an HTTP response from a DeleteAuthorityWithResponse call +func ParseDeleteAuthorityResponse(rsp *http.Response) (*DeleteAuthorityResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteAuthorityResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest N400 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest N401 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 422: + var dest N422 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON422 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest N500 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseGetAuthorityResponse parses an HTTP response from a GetAuthorityWithResponse call +func ParseGetAuthorityResponse(rsp *http.Response) (*GetAuthorityResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetAuthorityResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Authority + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest N400 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest N401 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest N404 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest N500 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseListAuthorityProvisionersResponse parses an HTTP response from a ListAuthorityProvisionersWithResponse call +func ParseListAuthorityProvisionersResponse(rsp *http.Response) (*ListAuthorityProvisionersResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListAuthorityProvisionersResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest []Provisioner + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest N400 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest N401 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest N404 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest N500 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParsePostAuthorityProvisionersResponse parses an HTTP response from a PostAuthorityProvisionersWithResponse call +func ParsePostAuthorityProvisionersResponse(rsp *http.Response) (*PostAuthorityProvisionersResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PostAuthorityProvisionersResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest Provisioner + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON201 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest N400 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest N401 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest N404 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest N409 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 422: + var dest N422 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON422 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest N500 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseDeleteProvisionerResponse parses an HTTP response from a DeleteProvisionerWithResponse call +func ParseDeleteProvisionerResponse(rsp *http.Response) (*DeleteProvisionerResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteProvisionerResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest N400 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest N401 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 422: + var dest N422 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON422 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest N500 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseGetProvisionerResponse parses an HTTP response from a GetProvisionerWithResponse call +func ParseGetProvisionerResponse(rsp *http.Response) (*GetProvisionerResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetProvisionerResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Provisioner + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest N400 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest N401 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest N404 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest N500 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParsePostWebhooksResponse parses an HTTP response from a PostWebhooksWithResponse call +func ParsePostWebhooksResponse(rsp *http.Response) (*PostWebhooksResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PostWebhooksResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest ProvisionerWebhook + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON201 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest N400 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest N401 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest N404 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest N409 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 412: + var dest N412 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON412 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 422: + var dest N422 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON422 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest N500 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseDeleteWebhookResponse parses an HTTP response from a DeleteWebhookWithResponse call +func ParseDeleteWebhookResponse(rsp *http.Response) (*DeleteWebhookResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteWebhookResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest N400 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest N401 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 422: + var dest N422 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON422 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest N500 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseGetWebhookResponse parses an HTTP response from a GetWebhookWithResponse call +func ParseGetWebhookResponse(rsp *http.Response) (*GetWebhookResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetWebhookResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ProvisionerWebhook + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest N400 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest N401 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest N404 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest N500 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParsePostAuthorityRootResponse parses an HTTP response from a PostAuthorityRootWithResponse call +func ParsePostAuthorityRootResponse(rsp *http.Response) (*PostAuthorityRootResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PostAuthorityRootResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Authority + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest N400 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest N401 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest N404 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest N500 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseListCertificatesResponse parses an HTTP response from a ListCertificatesWithResponse call +func ParseListCertificatesResponse(rsp *http.Response) (*ListCertificatesResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListCertificatesResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest []X509Certificate + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest N400 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest N401 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest N500 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseGetCertificateResponse parses an HTTP response from a GetCertificateWithResponse call +func ParseGetCertificateResponse(rsp *http.Response) (*GetCertificateResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetCertificateResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest X509Certificate + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest N400 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest N401 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest N404 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest N500 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParsePostDevicesResponse parses an HTTP response from a PostDevicesWithResponse call +func ParsePostDevicesResponse(rsp *http.Response) (*PostDevicesResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PostDevicesResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest Device + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON201 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest N400 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest N401 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest N500 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseGetPlatformsResponse parses an HTTP response from a GetPlatformsWithResponse call +func ParseGetPlatformsResponse(rsp *http.Response) (*GetPlatformsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetPlatformsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest []Platform + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest N400 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest N401 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest N500 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParsePutPlatformResponse parses an HTTP response from a PutPlatformWithResponse call +func ParsePutPlatformResponse(rsp *http.Response) (*PutPlatformResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PutPlatformResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Platform + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest N400 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest N401 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest N500 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// Base64 encoded, gzipped, json marshaled Swagger object +var swaggerSpec = []string{ + + "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", + "+QAA", +} + +// GetSwagger returns the content of the embedded swagger specification file +// or error if failed to decode +func decodeSpec() ([]byte, error) { + zipped, err := base64.StdEncoding.DecodeString(strings.Join(swaggerSpec, "")) + if err != nil { + return nil, fmt.Errorf("error base64 decoding spec: %w", err) + } + zr, err := gzip.NewReader(bytes.NewReader(zipped)) + if err != nil { + return nil, fmt.Errorf("error decompressing spec: %w", err) + } + var buf bytes.Buffer + _, err = buf.ReadFrom(zr) + if err != nil { + return nil, fmt.Errorf("error decompressing spec: %w", err) + } + + return buf.Bytes(), nil +} + +var rawSpec = decodeSpecCached() + +// a naive cached of a decoded swagger spec +func decodeSpecCached() func() ([]byte, error) { + data, err := decodeSpec() + return func() ([]byte, error) { + return data, err + } +} + +// Constructs a synthetic filesystem for resolving external references when loading openapi specifications. +func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error) { + res := make(map[string]func() ([]byte, error)) + if len(pathToFile) > 0 { + res[pathToFile] = rawSpec + } + + return res +} + +// GetSwagger returns the Swagger specification corresponding to the generated code +// in this file. The external references of Swagger specification are resolved. +// The logic of resolving external references is tightly connected to "import-mapping" feature. +// Externally referenced files must be embedded in the corresponding golang packages. +// Urls can be supported but this task was out of the scope. +func GetSwagger() (swagger *openapi3.T, err error) { + resolvePath := PathToRawSpec("") + + loader := openapi3.NewLoader() + loader.IsExternalRefsAllowed = true + loader.ReadFromURIFunc = func(loader *openapi3.Loader, url *url.URL) ([]byte, error) { + pathToFile := url.String() + pathToFile = path.Clean(pathToFile) + getSpec, ok := resolvePath[pathToFile] + if !ok { + err1 := fmt.Errorf("path not found: %s", pathToFile) + return nil, err1 + } + return getSpec() + } + var specData []byte + specData, err = rawSpec() + if err != nil { + return + } + swagger, err = loader.LoadFromData(specData) + if err != nil { + return + } + return +} diff --git a/internal/provider/account/data_source.go b/internal/provider/account/data_source.go deleted file mode 100644 index ae26131cd9b2a43a2e22be306fdc12bffd5f5845..0000000000000000000000000000000000000000 --- a/internal/provider/account/data_source.go +++ /dev/null @@ -1,279 +0,0 @@ -package account - -import ( - "context" - "encoding/json" - "fmt" - "net/http" - - "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" - "github.com/hashicorp/terraform-plugin-framework/datasource" - "github.com/hashicorp/terraform-plugin-framework/datasource/schema" - "github.com/hashicorp/terraform-plugin-framework/path" - "github.com/hashicorp/terraform-plugin-framework/schema/validator" - v20231101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20231101" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/utils" -) - -var _ datasource.DataSource = &DataSource{} - -type DataSource struct { - client *v20231101.Client -} - -func NewDataSource() datasource.DataSource { - return &DataSource{} -} - -func (d *DataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { - resp.TypeName = accountTypeName -} - -// Configure adds the Smallstep API client to the data source. -func (d *DataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { - // Prevent panic if the provider has not been configured. - if req.ProviderData == nil { - return - } - - client, ok := req.ProviderData.(*v20231101.Client) - - if !ok { - resp.Diagnostics.AddError( - "Get Smallstep API client from provider", - fmt.Sprintf("Expected *v20231101.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData), - ) - return - } - - d.client = client -} - -func (d *DataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - account, props, err := utils.Describe("account") - if err != nil { - resp.Diagnostics.AddError( - "Parse Smallstep OpenAPI Account Schema", - err.Error(), - ) - return - } - - wifi, wifiProps, err := utils.Describe("wifiAccount") - if err != nil { - resp.Diagnostics.AddError( - "Parse Smallstep OpenAPI WiFi Account Schema", - err.Error(), - ) - return - } - - vpn, vpnProps, err := utils.Describe("vpnAccount") - if err != nil { - resp.Diagnostics.AddError( - "Parse Smallstep OpenAPI VPN Account Schema", - err.Error(), - ) - return - } - - ike, ikeProps, err := utils.Describe("ikeV2Config") - if err != nil { - resp.Diagnostics.AddError( - "Parse Smallstep OpenAPI VPN IKEv2 Account Schema", - err.Error(), - ) - return - } - - browser, _, err := utils.Describe("browserAccount") - if err != nil { - resp.Diagnostics.AddError( - "Parse Smallstep OpenAPI Browser Account Schema", - err.Error(), - ) - return - } - - ethernet, ethernetProps, err := utils.Describe("ethernetAccount") - if err != nil { - resp.Diagnostics.AddError( - "Parse Smallstep OpenAPI Ethernet Account Schema", - err.Error(), - ) - return - } - - resp.Schema = schema.Schema{ - MarkdownDescription: account, - - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - MarkdownDescription: props["id"], - Required: true, - Validators: []validator.String{ - stringvalidator.RegexMatches( - utils.UUID, - "must be a valid UUID", - ), - }, - }, - "name": schema.StringAttribute{ - MarkdownDescription: props["name"], - Computed: true, - }, - "wifi": schema.SingleNestedAttribute{ - MarkdownDescription: wifi, - Computed: true, - Attributes: map[string]schema.Attribute{ - "autojoin": schema.BoolAttribute{ - MarkdownDescription: wifiProps["autojoin"], - Computed: true, - }, - "ca_chain": schema.StringAttribute{ - MarkdownDescription: wifiProps["caChain"], - Computed: true, - }, - "external_radius_server": schema.BoolAttribute{ - MarkdownDescription: wifiProps["externalRadiusServer"], - Computed: true, - }, - "hidden": schema.BoolAttribute{ - MarkdownDescription: wifiProps["hidden"], - Computed: true, - }, - "network_access_server_ip": schema.StringAttribute{ - MarkdownDescription: wifiProps["networkAccessServerIP"], - Computed: true, - }, - "ssid": schema.StringAttribute{ - MarkdownDescription: wifiProps["ssid"], - Computed: true, - }, - }, - }, - "vpn": schema.SingleNestedAttribute{ - MarkdownDescription: vpn, - Computed: true, - Attributes: map[string]schema.Attribute{ - "autojoin": schema.BoolAttribute{ - MarkdownDescription: vpnProps["autojoin"], - Computed: true, - }, - "connection_type": schema.StringAttribute{ - MarkdownDescription: vpnProps["connectionType"], - Computed: true, - }, - "remote_address": schema.StringAttribute{ - MarkdownDescription: vpnProps["remoteAddress"], - Computed: true, - }, - "vendor": schema.StringAttribute{ - MarkdownDescription: vpnProps["vendor"], - Computed: true, - }, - "ike": schema.SingleNestedAttribute{ - MarkdownDescription: ike, - Computed: true, - Attributes: map[string]schema.Attribute{ - "ca_chain": schema.StringAttribute{ - MarkdownDescription: ikeProps["caChain"], - Computed: true, - }, - "eap": schema.BoolAttribute{ - MarkdownDescription: ikeProps["eap"], - Computed: true, - }, - "remote_id": schema.StringAttribute{ - MarkdownDescription: ikeProps["remoteID"], - Computed: true, - }, - }, - }, - }, - }, - "ethernet": schema.SingleNestedAttribute{ - MarkdownDescription: ethernet, - Computed: true, - Attributes: map[string]schema.Attribute{ - "autojoin": schema.BoolAttribute{ - MarkdownDescription: ethernetProps["autojoin"], - Computed: true, - }, - "ca_chain": schema.StringAttribute{ - MarkdownDescription: ethernetProps["caChain"], - Computed: true, - }, - "external_radius_server": schema.BoolAttribute{ - MarkdownDescription: ethernetProps["externalRadiusServer"], - Computed: true, - }, - "network_access_server_ip": schema.StringAttribute{ - MarkdownDescription: ethernetProps["networkAccessServerIP"], - Computed: true, - }, - }, - }, - "browser": schema.SingleNestedAttribute{ - MarkdownDescription: browser, - Computed: true, - Attributes: map[string]schema.Attribute{}, - }, - }, - } -} - -func (d *DataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { - var id string - - ds := req.Config.GetAttribute(ctx, path.Root("id"), &id) - resp.Diagnostics.Append(ds...) - if resp.Diagnostics.HasError() { - return - } - - httpResp, err := d.client.GetAccount(ctx, id, &v20231101.GetAccountParams{}) - if err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to read account %q: %v", id, err), - ) - return - } - defer httpResp.Body.Close() - - switch httpResp.StatusCode { - case http.StatusOK: - break - case http.StatusNotFound: - resp.Diagnostics.AddError( - "Account Not Found", - fmt.Sprintf("Account %q data source not found", id), - ) - return - default: - reqID := httpResp.Header.Get("X-Request-Id") - resp.Diagnostics.AddError( - "Smallstep API Response Error", - fmt.Sprintf("Request %q received status %d reading account %q: %s", reqID, httpResp.StatusCode, id, utils.APIErrorMsg(httpResp.Body)), - ) - return - } - - account := &v20231101.Account{} - if err := json.NewDecoder(httpResp.Body).Decode(account); err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to unmarshal account %s: %v", id, err), - ) - return - } - - remote, ds := fromAPI(ctx, account, req.Config) - resp.Diagnostics.Append(ds...) - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(resp.State.Set(ctx, &remote)...) -} diff --git a/internal/provider/account/data_source_test.go b/internal/provider/account/data_source_test.go deleted file mode 100644 index 968b64b67180b564a27f688c983f0663b413696a..0000000000000000000000000000000000000000 --- a/internal/provider/account/data_source_test.go +++ /dev/null @@ -1,36 +0,0 @@ -package account - -import ( - "fmt" - "regexp" - "testing" - - "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/utils" -) - -func TestAccAccountDataSource(t *testing.T) { - t.Parallel() - account, wifi := utils.NewAccount(t) - config := fmt.Sprintf(` -data "smallstep_account" "wifi" { - id = %q -} -`, *account.Id) - - resource.Test(t, resource.TestCase{ - ProtoV6ProviderFactories: providerFactories, - Steps: []resource.TestStep{ - { - Config: config, - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("data.smallstep_account.wifi", "id", *account.Id), - resource.TestCheckResourceAttr("data.smallstep_account.wifi", "name", account.Name), - resource.TestCheckResourceAttr("data.smallstep_account.wifi", "wifi.ssid", wifi.Ssid), - resource.TestCheckResourceAttr("data.smallstep_account.wifi", "wifi.network_access_server_ip", *wifi.NetworkAccessServerIP), - resource.TestMatchResourceAttr("data.smallstep_account.wifi", "wifi.ca_chain", regexp.MustCompile("-----BEGIN CERTIFICATE-----")), - ), - }, - }, - }) -} diff --git a/internal/provider/account/model.go b/internal/provider/account/model.go deleted file mode 100644 index b5a9cfc30285cb787de8ba5eef8a1b4cdd3a91c1..0000000000000000000000000000000000000000 --- a/internal/provider/account/model.go +++ /dev/null @@ -1,339 +0,0 @@ -package account - -import ( - "context" - - "github.com/hashicorp/terraform-plugin-framework/attr" - "github.com/hashicorp/terraform-plugin-framework/diag" - "github.com/hashicorp/terraform-plugin-framework/path" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-plugin-framework/types/basetypes" - v20231101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20231101" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/utils" -) - -const accountTypeName = "smallstep_account" - -type Model struct { - ID types.String `tfsdk:"id"` - Name types.String `tfsdk:"name"` - WiFi types.Object `tfsdk:"wifi"` - VPN types.Object `tfsdk:"vpn"` - Browser types.Object `tfsdk:"browser"` - Ethernet types.Object `tfsdk:"ethernet"` -} - -type WiFiModel struct { - Autojoin types.Bool `tfsdk:"autojoin"` - CAChain types.String `tfsdk:"ca_chain"` - ExternalRadiusServer types.Bool `tfsdk:"external_radius_server"` - Hidden types.Bool `tfsdk:"hidden"` - NetworkAccessServerIP types.String `tfsdk:"network_access_server_ip"` - SSID types.String `tfsdk:"ssid"` -} - -var wifiAttrTypes = map[string]attr.Type{ - "autojoin": types.BoolType, - "ca_chain": types.StringType, - "external_radius_server": types.BoolType, - "hidden": types.BoolType, - "network_access_server_ip": types.StringType, - "ssid": types.StringType, -} - -type BrowserModel struct{} - -var browserAttrTypes = map[string]attr.Type{} - -type VPNModel struct { - Autojoin types.Bool `tfsdk:"autojoin"` - ConnectionType types.String `tfsdk:"connection_type"` - IKE types.Object `tfsdk:"ike"` - RemoteAddress types.String `tfsdk:"remote_address"` - Vendor types.String `tfsdk:"vendor"` -} - -var ikeAttrTypes = map[string]attr.Type{ - "ca_chain": types.StringType, - "eap": types.BoolType, - "remote_id": types.StringType, -} - -var vpnAttrTypes = map[string]attr.Type{ - "autojoin": types.BoolType, - "connection_type": types.StringType, - "remote_address": types.StringType, - "vendor": types.StringType, - "ike": types.ObjectType{ - AttrTypes: ikeAttrTypes, - }, -} - -type IKEModel struct { - CAChain types.String `tfsdk:"ca_chain"` - EAP types.Bool `tfsdk:"eap"` - RemoteID types.String `tfsdk:"remote_id"` -} - -type EthernetModel struct { - Autojoin types.Bool `tfsdk:"autojoin"` - CAChain types.String `tfsdk:"ca_chain"` - ExternalRadiusServer types.Bool `tfsdk:"external_radius_server"` - NetworkAccessServerIP types.String `tfsdk:"network_access_server_ip"` -} - -var ethernetAttrTypes = map[string]attr.Type{ - "autojoin": types.BoolType, - "ca_chain": types.StringType, - "external_radius_server": types.BoolType, - "network_access_server_ip": types.StringType, -} - -func toAPI(ctx context.Context, model *Model) (*v20231101.Account, diag.Diagnostics) { - var diags diag.Diagnostics - - account := &v20231101.Account{ - Id: model.ID.ValueStringPointer(), - Name: model.Name.ValueString(), - Type: v20231101.AccountType(model.Name.ValueString()), - } - - // TODO(areed) validate no more than one is set - switch { - case !model.WiFi.IsNull(): - account.Type = v20231101.Wifi - - wifi := &WiFiModel{} - ds := model.WiFi.As(ctx, wifi, basetypes.ObjectAsOptions{}) - diags.Append(ds...) - - err := account.FromWifiAccount(v20231101.WifiAccount{ - Autojoin: wifi.Autojoin.ValueBoolPointer(), - CaChain: wifi.CAChain.ValueStringPointer(), - ExternalRadiusServer: wifi.ExternalRadiusServer.ValueBoolPointer(), - Hidden: wifi.Hidden.ValueBoolPointer(), - NetworkAccessServerIP: wifi.NetworkAccessServerIP.ValueStringPointer(), - Ssid: wifi.SSID.ValueString(), - }) - if err != nil { - diags.AddError("Account WiFi Configuration Error", err.Error()) - } - - case !model.VPN.IsNull(): - account.Type = v20231101.Vpn - - vpn := &VPNModel{} - ds := model.VPN.As(ctx, vpn, basetypes.ObjectAsOptions{}) - diags.Append(ds...) - - vpnAccount := v20231101.VpnAccount{ - Autojoin: vpn.Autojoin.ValueBoolPointer(), - ConnectionType: v20231101.VpnAccountConnectionType(vpn.ConnectionType.ValueString()), - RemoteAddress: vpn.RemoteAddress.ValueString(), - Vendor: utils.ToStringPointer[v20231101.VpnAccountVendor](vpn.Vendor.ValueStringPointer()), - } - - if !vpn.IKE.IsNull() && !vpn.IKE.IsUnknown() { - ike := &IKEModel{} - ds := vpn.IKE.As(ctx, ike, basetypes.ObjectAsOptions{}) - diags.Append(ds...) - vpnAccount.Ike = &v20231101.IkeV2Config{ - CaChain: ike.CAChain.ValueStringPointer(), - Eap: ike.EAP.ValueBoolPointer(), - RemoteID: ike.RemoteID.ValueStringPointer(), - } - } - - err := account.FromVpnAccount(vpnAccount) - if err != nil { - diags.AddError("Account VPN Configuration Error", err.Error()) - } - - case !model.Browser.IsNull(): - account.Type = v20231101.Browser - - browser := &BrowserModel{} - ds := model.Browser.As(ctx, browser, basetypes.ObjectAsOptions{}) - diags.Append(ds...) - - err := account.FromBrowserAccount(v20231101.BrowserAccount{}) - if err != nil { - diags.AddError("Account Browser Configuration Error", err.Error()) - } - - case !model.Ethernet.IsNull(): - account.Type = v20231101.Ethernet - - ethernet := &EthernetModel{} - ds := model.Ethernet.As(ctx, ethernet, basetypes.ObjectAsOptions{}) - diags.Append(ds...) - - err := account.FromEthernetAccount(v20231101.EthernetAccount{ - Autojoin: ethernet.Autojoin.ValueBoolPointer(), - CaChain: ethernet.CAChain.ValueStringPointer(), - ExternalRadiusServer: ethernet.ExternalRadiusServer.ValueBoolPointer(), - NetworkAccessServerIP: ethernet.NetworkAccessServerIP.ValueStringPointer(), - }) - if err != nil { - diags.AddError("Account Ethernet Configuration Error", err.Error()) - } - } - - return account, diags -} - -func fromAPI(ctx context.Context, account *v20231101.Account, state utils.AttributeGetter) (*Model, diag.Diagnostics) { - var diags diag.Diagnostics - - id, ds := utils.ToOptionalString(ctx, account.Id, state, path.Root("id")) - diags.Append(ds...) - - model := &Model{ - ID: id, - Name: types.StringValue(account.Name), - } - - switch account.Type { - case v20231101.Wifi: - wifi, err := account.AsWifiAccount() - if err != nil { - diags.AddError("Account Wifi Parse Error", err.Error()) - break - } - - autojoin, ds := utils.ToOptionalBool(ctx, wifi.Autojoin, state, path.Root("wifi").AtName("autojoin")) - diags.Append(ds...) - - caChain, ds := utils.ToOptionalString(ctx, wifi.CaChain, state, path.Root("wifi").AtName("ca_chain")) - diags.Append(ds...) - - externalRadiusServer, ds := utils.ToOptionalBool(ctx, wifi.ExternalRadiusServer, state, path.Root("wifi").AtName("external_radius_server")) - diags.Append(ds...) - - hidden, ds := utils.ToOptionalBool(ctx, wifi.Hidden, state, path.Root("wifi").AtName("hidden")) - diags.Append(ds...) - - nasIP, ds := utils.ToOptionalString(ctx, wifi.NetworkAccessServerIP, state, path.Root("wifi").AtName("network_access_server_ip")) - diags.Append(ds...) - - obj, ds := basetypes.NewObjectValue(wifiAttrTypes, map[string]attr.Value{ - "autojoin": autojoin, - "ca_chain": caChain, - "external_radius_server": externalRadiusServer, - "hidden": hidden, - "network_access_server_ip": nasIP, - "ssid": types.StringValue(wifi.Ssid), - }) - diags.Append(ds...) - - model.WiFi = obj - model.VPN = basetypes.NewObjectNull(vpnAttrTypes) - model.Browser = basetypes.NewObjectNull(browserAttrTypes) - model.Ethernet = basetypes.NewObjectNull(ethernetAttrTypes) - - case v20231101.Vpn: - vpn, err := account.AsVpnAccount() - if err != nil { - diags.AddError("Account VPN Parse Error", err.Error()) - break - } - - autojoin, ds := utils.ToOptionalBool(ctx, vpn.Autojoin, state, path.Root("vpn").AtName("autojoin")) - diags.Append(ds...) - - vendor, ds := utils.ToOptionalString(ctx, vpn.Vendor, state, path.Root("vpn").AtName("vendor")) - diags.Append(ds...) - - ike, ds := ikeFromAPI(ctx, vpn.Ike, path.Root("vpn").AtName("ike"), state) - diags.Append(ds...) - - obj, ds := basetypes.NewObjectValue(vpnAttrTypes, map[string]attr.Value{ - "autojoin": autojoin, - "connection_type": types.StringValue(string(vpn.ConnectionType)), - "remote_address": types.StringValue(vpn.RemoteAddress), - "vendor": vendor, - "ike": ike, - }) - diags.Append(ds...) - - model.VPN = obj - model.WiFi = basetypes.NewObjectNull(wifiAttrTypes) - model.Browser = basetypes.NewObjectNull(browserAttrTypes) - model.Ethernet = basetypes.NewObjectNull(ethernetAttrTypes) - - case v20231101.Browser: - _, err := account.AsBrowserAccount() - if err != nil { - diags.AddError("Account Browser Parse Error", err.Error()) - break - } - - obj, ds := basetypes.NewObjectValue(browserAttrTypes, map[string]attr.Value{}) - diags.Append(ds...) - - model.Browser = obj - model.WiFi = basetypes.NewObjectNull(wifiAttrTypes) - model.VPN = basetypes.NewObjectNull(vpnAttrTypes) - model.Ethernet = basetypes.NewObjectNull(ethernetAttrTypes) - - case v20231101.Ethernet: - ethernet, err := account.AsEthernetAccount() - if err != nil { - diags.AddError("Account Ethernet Parse Error", err.Error()) - break - } - - autojoin, ds := utils.ToOptionalBool(ctx, ethernet.Autojoin, state, path.Root("ethernet").AtName("autojoin")) - diags.Append(ds...) - - caChain, ds := utils.ToOptionalString(ctx, ethernet.CaChain, state, path.Root("ethernet").AtName("ca_chain")) - diags.Append(ds...) - - externalRadiusServer, ds := utils.ToOptionalBool(ctx, ethernet.ExternalRadiusServer, state, path.Root("ethernet").AtName("external_radius_server")) - diags.Append(ds...) - - nasIP, ds := utils.ToOptionalString(ctx, ethernet.NetworkAccessServerIP, state, path.Root("ethernet").AtName("network_access_server_ip")) - diags.Append(ds...) - - obj, ds := basetypes.NewObjectValue(ethernetAttrTypes, map[string]attr.Value{ - "autojoin": autojoin, - "ca_chain": caChain, - "external_radius_server": externalRadiusServer, - "network_access_server_ip": nasIP, - }) - diags.Append(ds...) - - model.Ethernet = obj - model.WiFi = basetypes.NewObjectNull(wifiAttrTypes) - model.VPN = basetypes.NewObjectNull(vpnAttrTypes) - model.Browser = basetypes.NewObjectNull(browserAttrTypes) - } - - return model, diags -} - -func ikeFromAPI(ctx context.Context, ike *v20231101.IkeV2Config, ikePath path.Path, state utils.AttributeGetter) (types.Object, diag.Diagnostics) { - var diags diag.Diagnostics - - if ike == nil { - return basetypes.NewObjectNull(ikeAttrTypes), diags - } - - caChain, ds := utils.ToOptionalString(ctx, ike.CaChain, state, ikePath.AtName("ca_chain")) - diags.Append(ds...) - - eap, ds := utils.ToOptionalBool(ctx, ike.Eap, state, ikePath.AtName("eap")) - diags.Append(ds...) - - remoteID, ds := utils.ToOptionalString(ctx, ike.RemoteID, state, ikePath.AtName("remote_id")) - diags.Append(ds...) - - obj, ds := basetypes.NewObjectValue(ikeAttrTypes, map[string]attr.Value{ - "ca_chain": caChain, - "eap": eap, - "remote_id": remoteID, - }) - diags.Append(ds...) - - return obj, diags -} diff --git a/internal/provider/account/resource.go b/internal/provider/account/resource.go deleted file mode 100644 index 9caa47358810522c758d69abdabaa871b243ba01..0000000000000000000000000000000000000000 --- a/internal/provider/account/resource.go +++ /dev/null @@ -1,420 +0,0 @@ -package account - -import ( - "context" - "encoding/json" - "fmt" - "net/http" - - "github.com/hashicorp/terraform-plugin-framework/path" - "github.com/hashicorp/terraform-plugin-framework/resource" - "github.com/hashicorp/terraform-plugin-framework/resource/schema" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" - v20231101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20231101" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/utils" -) - -var _ resource.ResourceWithImportState = (*Resource)(nil) - -func NewResource() resource.Resource { - return &Resource{} -} - -// Resource defines the resource implementation. -type Resource struct { - client *v20231101.Client -} - -func (r *Resource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { - account, props, err := utils.Describe("account") - if err != nil { - resp.Diagnostics.AddError( - "Parse Smallstep OpenAPI Account Schema", - err.Error(), - ) - return - } - - wifi, wifiProps, err := utils.Describe("wifiAccount") - if err != nil { - resp.Diagnostics.AddError( - "Parse Smallstep OpenAPI WiFi Account Schema", - err.Error(), - ) - return - } - - vpn, vpnProps, err := utils.Describe("vpnAccount") - if err != nil { - resp.Diagnostics.AddError( - "Parse Smallstep OpenAPI VPN Account Schema", - err.Error(), - ) - return - } - - ike, ikeProps, err := utils.Describe("ikeV2Config") - if err != nil { - resp.Diagnostics.AddError( - "Parse Smallstep OpenAPI VPN IKEv2 Account Schema", - err.Error(), - ) - return - } - - browser, _, err := utils.Describe("browserAccount") - if err != nil { - resp.Diagnostics.AddError( - "Parse Smallstep OpenAPI Browser Account Schema", - err.Error(), - ) - return - } - - ethernet, ethernetProps, err := utils.Describe("ethernetAccount") - if err != nil { - resp.Diagnostics.AddError( - "Parse Smallstep OpenAPI Ethernet Account Schema", - err.Error(), - ) - return - } - - resp.Schema = schema.Schema{ - MarkdownDescription: account, - - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - MarkdownDescription: props["id"], - Computed: true, - }, - "name": schema.StringAttribute{ - MarkdownDescription: props["name"], - Required: true, - }, - "wifi": schema.SingleNestedAttribute{ - MarkdownDescription: wifi, - Optional: true, - Attributes: map[string]schema.Attribute{ - "autojoin": schema.BoolAttribute{ - MarkdownDescription: wifiProps["autojoin"], - Optional: true, - }, - "ca_chain": schema.StringAttribute{ - MarkdownDescription: wifiProps["caChain"], - Computed: true, - Optional: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.UseStateForUnknown(), - }, - }, - "external_radius_server": schema.BoolAttribute{ - MarkdownDescription: wifiProps["externalRadiusServer"], - Optional: true, - }, - "hidden": schema.BoolAttribute{ - MarkdownDescription: wifiProps["hidden"], - Optional: true, - }, - "network_access_server_ip": schema.StringAttribute{ - MarkdownDescription: wifiProps["networkAccessServerIP"], - Optional: true, - }, - "ssid": schema.StringAttribute{ - MarkdownDescription: wifiProps["ssid"], - Required: true, - }, - }, - }, - "vpn": schema.SingleNestedAttribute{ - MarkdownDescription: vpn, - Optional: true, - Attributes: map[string]schema.Attribute{ - "autojoin": schema.BoolAttribute{ - MarkdownDescription: vpnProps["autojoin"], - Optional: true, - }, - "connection_type": schema.StringAttribute{ - MarkdownDescription: vpnProps["connectionType"], - Required: true, - }, - "remote_address": schema.StringAttribute{ - MarkdownDescription: vpnProps["remoteAddress"], - Required: true, - }, - "vendor": schema.StringAttribute{ - MarkdownDescription: vpnProps["vendor"], - Optional: true, - }, - "ike": schema.SingleNestedAttribute{ - MarkdownDescription: ike, - Optional: true, - Attributes: map[string]schema.Attribute{ - "ca_chain": schema.StringAttribute{ - MarkdownDescription: ikeProps["caChain"], - Optional: true, - }, - "eap": schema.BoolAttribute{ - MarkdownDescription: ikeProps["eap"], - Optional: true, - }, - "remote_id": schema.StringAttribute{ - MarkdownDescription: ikeProps["remoteID"], - Optional: true, - }, - }, - }, - }, - }, - "ethernet": schema.SingleNestedAttribute{ - MarkdownDescription: ethernet, - Optional: true, - Attributes: map[string]schema.Attribute{ - "autojoin": schema.BoolAttribute{ - MarkdownDescription: ethernetProps["autojoin"], - Optional: true, - }, - "ca_chain": schema.StringAttribute{ - MarkdownDescription: ethernetProps["caChain"], - Optional: true, - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.UseStateForUnknown(), - }, - }, - "external_radius_server": schema.BoolAttribute{ - MarkdownDescription: ethernetProps["externalRadiusServer"], - Optional: true, - }, - "network_access_server_ip": schema.StringAttribute{ - MarkdownDescription: ethernetProps["networkAccessServerIP"], - Optional: true, - }, - }, - }, - "browser": schema.SingleNestedAttribute{ - MarkdownDescription: browser, - Optional: true, - Attributes: map[string]schema.Attribute{}, - }, - }, - } -} - -func (r *Resource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = accountTypeName -} - -// Configure adds the Smallstep API client to the resource. -func (r *Resource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { - // Prevent panic if the provider has not been configured. - if req.ProviderData == nil { - return - } - - client, ok := req.ProviderData.(*v20231101.Client) - - if !ok { - resp.Diagnostics.AddError( - "Get Smallstep API client from provider", - fmt.Sprintf("Expected *v20231101.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData), - ) - return - } - - r.client = client -} - -func (r *Resource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { - state := &Model{} - - resp.Diagnostics.Append(req.State.Get(ctx, state)...) - if resp.Diagnostics.HasError() { - return - } - - httpResp, err := r.client.GetAccount(ctx, state.ID.ValueString(), &v20231101.GetAccountParams{}) - if err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to read account %q: %v", state.ID.ValueString(), err), - ) - return - } - defer httpResp.Body.Close() - - if httpResp.StatusCode == http.StatusNotFound { - resp.State.RemoveResource(ctx) - return - } - if httpResp.StatusCode != http.StatusOK { - reqID := httpResp.Header.Get("X-Request-Id") - resp.Diagnostics.AddError( - "Smallstep API Response Error", - fmt.Sprintf("Request %q received status %d reading account %s: %s", reqID, httpResp.StatusCode, state.ID.String(), utils.APIErrorMsg(httpResp.Body)), - ) - return - } - - account := &v20231101.Account{} - if err := json.NewDecoder(httpResp.Body).Decode(account); err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to unmarshal account %s: %v", state.ID.String(), err), - ) - return - } - - remote, d := fromAPI(ctx, account, req.State) - resp.Diagnostics.Append(d...) - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(resp.State.Set(ctx, &remote)...) -} - -func (a *Resource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - plan := &Model{} - resp.Diagnostics.Append(req.Plan.Get(ctx, plan)...) - if resp.Diagnostics.HasError() { - return - } - - reqBody, diags := toAPI(ctx, plan) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - - httpResp, err := a.client.PostAccounts(ctx, &v20231101.PostAccountsParams{}, *reqBody) - if err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to create account: %v", err), - ) - return - } - defer httpResp.Body.Close() - - if httpResp.StatusCode != http.StatusCreated { - reqID := httpResp.Header.Get("X-Request-Id") - resp.Diagnostics.AddError( - "Smallstep API Response Error", - fmt.Sprintf("Request %q received status %d creating account: %s", reqID, httpResp.StatusCode, utils.APIErrorMsg(httpResp.Body)), - ) - return - } - - account := &v20231101.Account{} - if err := json.NewDecoder(httpResp.Body).Decode(account); err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to unmarshal account: %v", err), - ) - return - } - - model, diags := fromAPI(ctx, account, req.Plan) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - - diags = resp.State.Set(ctx, model) - resp.Diagnostics.Append(diags...) -} - -func (r *Resource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { - plan := &Model{} - diags := req.Plan.Get(ctx, plan) - if diags.HasError() { - resp.Diagnostics.Append(diags...) - return - } - var accountID string - req.State.GetAttribute(ctx, path.Root("id"), &accountID) - - account, diags := toAPI(ctx, plan) - if diags.HasError() { - resp.Diagnostics.Append(diags...) - return - } - account.Id = &accountID - - httpResp, err := r.client.PutAccount(ctx, accountID, &v20231101.PutAccountParams{}, *account) - if err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - err.Error(), - ) - return - } - defer httpResp.Body.Close() - - if httpResp.StatusCode != http.StatusOK { - reqID := httpResp.Header.Get("X-Request-Id") - resp.Diagnostics.AddError( - "Smallstep API Response Error", - fmt.Sprintf("Request %q received status %d updating account: %s", reqID, httpResp.StatusCode, utils.APIErrorMsg(httpResp.Body)), - ) - return - } - - account = &v20231101.Account{} - if err := json.NewDecoder(httpResp.Body).Decode(account); err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to parse account update response: %v", err), - ) - return - } - - model, diags := fromAPI(ctx, account, req.Plan) - resp.Diagnostics.Append(diags...) - - diags = resp.State.Set(ctx, model) - resp.Diagnostics.Append(diags...) -} - -func (r *Resource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { - state := &Model{} - diags := req.State.Get(ctx, state) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - - accountID := state.ID.ValueString() - if accountID == "" { - resp.Diagnostics.AddError( - "Invalid Delete Account Request", - "Account ID is required", - ) - return - } - - httpResp, err := r.client.DeleteAccount(ctx, accountID, &v20231101.DeleteAccountParams{}) - if err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to delete account: %v", err), - ) - return - } - defer httpResp.Body.Close() - - if httpResp.StatusCode != http.StatusNoContent { - reqID := httpResp.Header.Get("X-Request-Id") - resp.Diagnostics.AddError( - "Smallstep API Response Error", - fmt.Sprintf("Request %q received status %d updating account: %s", reqID, httpResp.StatusCode, utils.APIErrorMsg(httpResp.Body)), - ) - return - } -} - -func (r *Resource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { - resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) -} diff --git a/internal/provider/account/resource_test.go b/internal/provider/account/resource_test.go deleted file mode 100644 index 3555cbce123a5823f7fa6049d64084a22ed88a5f..0000000000000000000000000000000000000000 --- a/internal/provider/account/resource_test.go +++ /dev/null @@ -1,358 +0,0 @@ -package account - -import ( - "fmt" - "regexp" - "testing" - - "github.com/hashicorp/terraform-plugin-framework/datasource" - "github.com/hashicorp/terraform-plugin-framework/providerserver" - "github.com/hashicorp/terraform-plugin-framework/resource" - "github.com/hashicorp/terraform-plugin-go/tfprotov6" - helper "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/hashicorp/terraform-plugin-testing/plancheck" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/utils" - "github.com/smallstep/terraform-provider-smallstep/internal/testprovider" -) - -func TestMain(m *testing.M) { - helper.TestMain(m) -} - -var provider = &testprovider.SmallstepTestProvider{ - ResourceFactories: []func() resource.Resource{ - NewResource, - }, - DataSourceFactories: []func() datasource.DataSource{ - NewDataSource, - }, -} - -var providerFactories = map[string]func() (tfprotov6.ProviderServer, error){ - "smallstep": providerserver.NewProtocol6WithError(provider), -} - -func TestAccAccountResource(t *testing.T) { - t.Parallel() - const browsers = ` -resource "smallstep_account" "browsers" { - name = "Browsers" - browser = {} -} -` - const browsers2 = ` -resource "smallstep_account" "browsers" { - name = "Browsers2" - browser = {} -} -` - - helper.Test(t, helper.TestCase{ - ProtoV6ProviderFactories: providerFactories, - Steps: []helper.TestStep{ - { - Config: browsers, - ConfigPlanChecks: helper.ConfigPlanChecks{ - PreApply: []plancheck.PlanCheck{ - plancheck.ExpectResourceAction("smallstep_account.browsers", plancheck.ResourceActionCreate), - }, - }, - Check: helper.ComposeAggregateTestCheckFunc( - helper.TestMatchResourceAttr("smallstep_account.browsers", "id", utils.UUID), - helper.TestCheckResourceAttr("smallstep_account.browsers", "name", "Browsers"), - ), - }, - { - Config: browsers2, - ConfigPlanChecks: helper.ConfigPlanChecks{ - PreApply: []plancheck.PlanCheck{ - plancheck.ExpectResourceAction("smallstep_account.browsers", plancheck.ResourceActionUpdate), - }, - }, - Check: helper.ComposeAggregateTestCheckFunc( - helper.TestMatchResourceAttr("smallstep_account.browsers", "id", utils.UUID), - helper.TestCheckResourceAttr("smallstep_account.browsers", "name", "Browsers2"), - ), - }, - { - ResourceName: "smallstep_account.browsers", - ImportState: true, - ImportStateVerify: true, - }, - }, - }) - - const wifiHostedRadius = ` -resource "smallstep_account" "wifi_hosted_radius" { - name = "WiFi Hosted Radius" - wifi = { - autojoin = true - external_radius_server = false - hidden = true - network_access_server_ip = "1.2.3.4" - ssid = "corpnet" - } -} -` - const wifiHostedRadius2 = ` -resource "smallstep_account" "wifi_hosted_radius" { - name = "WiFi Hosted Radius" - wifi = { - autojoin = false - external_radius_server = false - network_access_server_ip = "5.6.7.8" - ssid = "Corp Net" - } -} -` - helper.Test(t, helper.TestCase{ - ProtoV6ProviderFactories: providerFactories, - Steps: []helper.TestStep{ - { - Config: wifiHostedRadius, - ConfigPlanChecks: helper.ConfigPlanChecks{ - PreApply: []plancheck.PlanCheck{ - plancheck.ExpectResourceAction("smallstep_account.wifi_hosted_radius", plancheck.ResourceActionCreate), - }, - }, - Check: helper.ComposeAggregateTestCheckFunc( - helper.TestMatchResourceAttr("smallstep_account.wifi_hosted_radius", "id", utils.UUID), - helper.TestCheckResourceAttr("smallstep_account.wifi_hosted_radius", "name", "WiFi Hosted Radius"), - helper.TestCheckResourceAttr("smallstep_account.wifi_hosted_radius", "wifi.autojoin", "true"), - helper.TestCheckResourceAttr("smallstep_account.wifi_hosted_radius", "wifi.external_radius_server", "false"), - helper.TestCheckResourceAttr("smallstep_account.wifi_hosted_radius", "wifi.hidden", "true"), - helper.TestCheckResourceAttr("smallstep_account.wifi_hosted_radius", "wifi.network_access_server_ip", "1.2.3.4"), - helper.TestCheckResourceAttr("smallstep_account.wifi_hosted_radius", "wifi.ssid", "corpnet"), - helper.TestMatchResourceAttr("smallstep_account.wifi_hosted_radius", "wifi.ca_chain", regexp.MustCompile("-----BEGIN CERTIFICATE-----")), - ), - }, - { - Config: wifiHostedRadius2, - ConfigPlanChecks: helper.ConfigPlanChecks{ - PreApply: []plancheck.PlanCheck{ - plancheck.ExpectResourceAction("smallstep_account.wifi_hosted_radius", plancheck.ResourceActionUpdate), - }, - }, - Check: helper.ComposeAggregateTestCheckFunc( - helper.TestCheckResourceAttr("smallstep_account.wifi_hosted_radius", "wifi.autojoin", "false"), - helper.TestCheckNoResourceAttr("smallstep_account.wifi_hosted_radius", "wifi.hidden"), - helper.TestCheckResourceAttr("smallstep_account.wifi_hosted_radius", "wifi.network_access_server_ip", "5.6.7.8"), - helper.TestCheckResourceAttr("smallstep_account.wifi_hosted_radius", "wifi.ssid", "Corp Net"), - helper.TestMatchResourceAttr("smallstep_account.wifi_hosted_radius", "wifi.ca_chain", regexp.MustCompile("-----BEGIN CERTIFICATE-----")), - ), - }, - }, - }) - - root, _ := utils.CACerts(t) - wifiExternalRadius := fmt.Sprintf(` -resource "smallstep_account" "wifi_byoradius" { - name = "WiFi Hosted Radius" - wifi = { - external_radius_server = true - ca_chain = %q - network_access_server_ip = "1.2.3.4" - ssid = "corpnet" - } -} -`, root) - root2, _ := utils.CACerts(t) - wifiExternalRadius2 := fmt.Sprintf(` -resource "smallstep_account" "wifi_byoradius" { - name = "WiFi Hosted Radius" - wifi = { - external_radius_server = true - ca_chain = %q - network_access_server_ip = "1.2.3.4" - ssid = "corpnet" - hidden = true - autojoin = true - } -} -`, root2) - - helper.Test(t, helper.TestCase{ - ProtoV6ProviderFactories: providerFactories, - Steps: []helper.TestStep{ - { - Config: wifiExternalRadius, - ConfigPlanChecks: helper.ConfigPlanChecks{ - PreApply: []plancheck.PlanCheck{ - plancheck.ExpectResourceAction("smallstep_account.wifi_byoradius", plancheck.ResourceActionCreate), - }, - }, - Check: helper.ComposeAggregateTestCheckFunc( - helper.TestMatchResourceAttr("smallstep_account.wifi_byoradius", "id", utils.UUID), - helper.TestCheckResourceAttr("smallstep_account.wifi_byoradius", "name", "WiFi Hosted Radius"), - helper.TestCheckResourceAttr("smallstep_account.wifi_byoradius", "wifi.external_radius_server", "true"), - helper.TestCheckResourceAttr("smallstep_account.wifi_byoradius", "wifi.network_access_server_ip", "1.2.3.4"), - helper.TestCheckResourceAttr("smallstep_account.wifi_byoradius", "wifi.ca_chain", root), - helper.TestCheckResourceAttr("smallstep_account.wifi_byoradius", "wifi.ssid", "corpnet"), - helper.TestCheckNoResourceAttr("smallstep_account.wifi_byoradius", "wifi.autojoin"), - helper.TestCheckNoResourceAttr("smallstep_account.wifi_byoradius", "wifi.hidden"), - ), - }, - { - Config: wifiExternalRadius2, - ConfigPlanChecks: helper.ConfigPlanChecks{ - PreApply: []plancheck.PlanCheck{ - plancheck.ExpectResourceAction("smallstep_account.wifi_byoradius", plancheck.ResourceActionUpdate), - }, - }, - Check: helper.ComposeAggregateTestCheckFunc( - helper.TestMatchResourceAttr("smallstep_account.wifi_byoradius", "id", utils.UUID), - helper.TestCheckResourceAttr("smallstep_account.wifi_byoradius", "wifi.ca_chain", root2), - helper.TestCheckResourceAttr("smallstep_account.wifi_byoradius", "wifi.hidden", "true"), - helper.TestCheckResourceAttr("smallstep_account.wifi_byoradius", "wifi.autojoin", "true"), - ), - }, - }, - }) - - const vpn = ` -resource "smallstep_account" "vpn" { - name = "VPN" - vpn = { - autojoin = true - connection_type = "IPSec" - remote_address = "vpn.example.com" - vendor = "F5" - } -} -` - vpn2 := fmt.Sprintf(` -resource "smallstep_account" "vpn" { - name = "VPN" - vpn = { - autojoin = false - connection_type = "IKEv2" - remote_address = "ike.example.com" - ike = { - ca_chain = %q - eap = true - remote_id = "foo" - } - } -} -`, root) - - const vpn3 = ` -resource "smallstep_account" "vpn" { - name = "VPN" - vpn = { - connection_type = "SSL" - remote_address = "ssl.example.com" - vendor = "Cisco" - } -} -` - - helper.Test(t, helper.TestCase{ - ProtoV6ProviderFactories: providerFactories, - Steps: []helper.TestStep{ - { - Config: vpn, - ConfigPlanChecks: helper.ConfigPlanChecks{ - PreApply: []plancheck.PlanCheck{ - plancheck.ExpectResourceAction("smallstep_account.vpn", plancheck.ResourceActionCreate), - }, - }, - Check: helper.ComposeAggregateTestCheckFunc( - helper.TestCheckResourceAttr("smallstep_account.vpn", "vpn.autojoin", "true"), - helper.TestCheckResourceAttr("smallstep_account.vpn", "vpn.connection_type", "IPSec"), - helper.TestCheckResourceAttr("smallstep_account.vpn", "vpn.remote_address", "vpn.example.com"), - helper.TestCheckResourceAttr("smallstep_account.vpn", "vpn.vendor", "F5"), - helper.TestCheckNoResourceAttr("smallstep_account.vpn", "vpn.ike"), - ), - }, - { - Config: vpn2, - ConfigPlanChecks: helper.ConfigPlanChecks{ - PreApply: []plancheck.PlanCheck{ - plancheck.ExpectResourceAction("smallstep_account.vpn", plancheck.ResourceActionUpdate), - }, - }, - Check: helper.ComposeAggregateTestCheckFunc( - helper.TestCheckResourceAttr("smallstep_account.vpn", "vpn.autojoin", "false"), - helper.TestCheckResourceAttr("smallstep_account.vpn", "vpn.connection_type", "IKEv2"), - helper.TestCheckResourceAttr("smallstep_account.vpn", "vpn.remote_address", "ike.example.com"), - helper.TestCheckResourceAttr("smallstep_account.vpn", "vpn.ike.ca_chain", root), - helper.TestCheckResourceAttr("smallstep_account.vpn", "vpn.ike.eap", "true"), - helper.TestCheckResourceAttr("smallstep_account.vpn", "vpn.ike.remote_id", "foo"), - ), - }, - { - Config: vpn3, - ConfigPlanChecks: helper.ConfigPlanChecks{ - PreApply: []plancheck.PlanCheck{ - plancheck.ExpectResourceAction("smallstep_account.vpn", plancheck.ResourceActionUpdate), - }, - }, - Check: helper.ComposeAggregateTestCheckFunc( - helper.TestCheckResourceAttr("smallstep_account.vpn", "vpn.connection_type", "SSL"), - helper.TestCheckResourceAttr("smallstep_account.vpn", "vpn.remote_address", "ssl.example.com"), - helper.TestCheckResourceAttr("smallstep_account.vpn", "vpn.vendor", "Cisco"), - helper.TestCheckNoResourceAttr("smallstep_account.vpn", "vpn.ike"), - helper.TestCheckNoResourceAttr("smallstep_account.vpn", "vpn.autojoin"), - ), - }, - }, - }) - - const ethernet1 = ` -resource "smallstep_account" "ethernet" { - name = "Ethernet Hosted Radius" - ethernet = { - autojoin = true - external_radius_server = false - network_access_server_ip = "1.2.3.4" - } -} -` - ethernet2 := fmt.Sprintf(` -resource "smallstep_account" "ethernet" { - name = "Ethernet BYORadius" - ethernet = { - autojoin = false - external_radius_server = true - ca_chain = %q - } -} -`, root) - - helper.Test(t, helper.TestCase{ - ProtoV6ProviderFactories: providerFactories, - Steps: []helper.TestStep{ - { - Config: ethernet1, - ConfigPlanChecks: helper.ConfigPlanChecks{ - PreApply: []plancheck.PlanCheck{ - plancheck.ExpectResourceAction("smallstep_account.ethernet", plancheck.ResourceActionCreate), - }, - }, - Check: helper.ComposeAggregateTestCheckFunc( - helper.TestMatchResourceAttr("smallstep_account.ethernet", "id", utils.UUID), - helper.TestCheckResourceAttr("smallstep_account.ethernet", "name", "Ethernet Hosted Radius"), - helper.TestCheckResourceAttr("smallstep_account.ethernet", "ethernet.autojoin", "true"), - helper.TestCheckResourceAttr("smallstep_account.ethernet", "ethernet.external_radius_server", "false"), - helper.TestCheckResourceAttr("smallstep_account.ethernet", "ethernet.network_access_server_ip", "1.2.3.4"), - helper.TestMatchResourceAttr("smallstep_account.ethernet", "ethernet.ca_chain", regexp.MustCompile("-----BEGIN CERTIFICATE-----")), - ), - }, - { - Config: ethernet2, - ConfigPlanChecks: helper.ConfigPlanChecks{ - PreApply: []plancheck.PlanCheck{ - plancheck.ExpectResourceAction("smallstep_account.ethernet", plancheck.ResourceActionUpdate), - }, - }, - Check: helper.ComposeAggregateTestCheckFunc( - helper.TestCheckResourceAttr("smallstep_account.ethernet", "ethernet.autojoin", "false"), - helper.TestCheckNoResourceAttr("smallstep_account.ethernet", "ethernet.network_access_server_ip"), - helper.TestCheckResourceAttr("smallstep_account.ethernet", "ethernet.ca_chain", root), - helper.TestCheckResourceAttr("smallstep_account.ethernet", "ethernet.external_radius_server", "true"), - ), - }, - }, - }) -} diff --git a/internal/provider/attestation_authority/data_source.go b/internal/provider/attestation_authority/data_source.go deleted file mode 100644 index fc651e8908aa3247e6f4b07ada85d205f9ac99af..0000000000000000000000000000000000000000 --- a/internal/provider/attestation_authority/data_source.go +++ /dev/null @@ -1,146 +0,0 @@ -package attestation_authority - -import ( - "context" - "encoding/json" - "fmt" - "net/http" - - "github.com/hashicorp/terraform-plugin-framework/datasource" - "github.com/hashicorp/terraform-plugin-framework/datasource/schema" - "github.com/hashicorp/terraform-plugin-log/tflog" - v20231101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20231101" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/utils" -) - -var _ datasource.DataSourceWithConfigure = (*DataSource)(nil) - -func NewDataSource() datasource.DataSource { - return &DataSource{} -} - -// DataSource implements data.smallstep_attestation_authority -type DataSource struct { - client *v20231101.Client -} - -func (a *DataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { - resp.TypeName = typeName -} - -// Configure adds the Smallstep API client to the data source. -func (a *DataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { - // Prevent panic if the provider has not been configured. - if req.ProviderData == nil { - return - } - - client, ok := req.ProviderData.(*v20231101.Client) - - if !ok { - resp.Diagnostics.AddError( - "Get Smallstep API client from provider", - fmt.Sprintf("Expected *v20231101.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData), - ) - return - } - - a.client = client -} - -func (a *DataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { - var config Model - - // Read Terraform configuration data into the model - resp.Diagnostics.Append(req.Config.Get(ctx, &config)...) - - if resp.Diagnostics.HasError() { - return - } - - id := config.ID.ValueString() - - httpResp, err := a.client.GetAttestationAuthority(ctx, id, &v20231101.GetAttestationAuthorityParams{}) - if err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to read attestation authority %q: %v", id, err), - ) - return - } - defer httpResp.Body.Close() - - if httpResp.StatusCode != http.StatusOK { - reqID := httpResp.Header.Get("X-Request-Id") - resp.Diagnostics.AddError( - "Smallstep API Response Error", - fmt.Sprintf("Request %q received status %d reading attestation authority %q: %s", reqID, httpResp.StatusCode, id, utils.APIErrorMsg(httpResp.Body)), - ) - return - } - - aa := &v20231101.AttestationAuthority{} - if err := json.NewDecoder(httpResp.Body).Decode(aa); err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to unmarshal attestation authority %q: %v", id, err), - ) - return - } - - remote, d := fromAPI(ctx, aa, req.Config) - resp.Diagnostics.Append(d...) - if resp.Diagnostics.HasError() { - return - } - - tflog.Trace(ctx, fmt.Sprintf("read attestation authority %q data source", id)) - - resp.Diagnostics.Append(resp.State.Set(ctx, &remote)...) -} - -func (d *DataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - component, props, err := utils.Describe("attestationAuthority") - if err != nil { - resp.Diagnostics.AddError( - "Parse Smallstep OpenAPI spec", - err.Error(), - ) - return - } - - resp.Schema = schema.Schema{ - MarkdownDescription: component, - - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - MarkdownDescription: props["id"], - Required: true, - }, - "slug": schema.StringAttribute{ - MarkdownDescription: props["slug"], - Computed: true, - }, - "name": schema.StringAttribute{ - MarkdownDescription: props["name"], - Computed: true, - }, - "root": schema.StringAttribute{ - MarkdownDescription: props["root"], - Computed: true, - }, - "attestor_roots": schema.StringAttribute{ - MarkdownDescription: props["attestorRoots"], - Computed: true, - }, - "attestor_intermediates": schema.StringAttribute{ - MarkdownDescription: props["attestorIntermediates"], - Computed: true, - }, - "created_at": schema.StringAttribute{ - MarkdownDescription: props["createdAt"], - Computed: true, - }, - }, - } -} diff --git a/internal/provider/attestation_authority/data_source_test.go b/internal/provider/attestation_authority/data_source_test.go deleted file mode 100644 index a6b7e13e898a16a34332840f506d5c41b605333c..0000000000000000000000000000000000000000 --- a/internal/provider/attestation_authority/data_source_test.go +++ /dev/null @@ -1,42 +0,0 @@ -package attestation_authority - -import ( - "fmt" - "regexp" - "testing" - - "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/utils" -) - -func TestAccAttestationAuthorityDataSource(t *testing.T) { - // Don't parallelize because of limit of 1 attestation authority per team - - collection := utils.NewCollection(t) - // Catalog may not be the slug passed in if the attestation authority already existed - aa := utils.FixAttestationAuthority(t, collection.Slug) - - config := fmt.Sprintf(` -data "smallstep_attestation_authority" "test" { - id = %q -} -`, *aa.Id) - - resource.Test(t, resource.TestCase{ - ProtoV6ProviderFactories: providerFactories, - Steps: []resource.TestStep{ - { - Config: config, - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("data.smallstep_attestation_authority.test", "id", *aa.Id), - resource.TestCheckResourceAttr("data.smallstep_attestation_authority.test", "name", aa.Name), - resource.TestCheckResourceAttr("data.smallstep_attestation_authority.test", "slug", *aa.Slug), - resource.TestCheckResourceAttr("data.smallstep_attestation_authority.test", "root", *aa.Root), - resource.TestCheckResourceAttr("data.smallstep_attestation_authority.test", "attestor_roots", aa.AttestorRoots), - resource.TestCheckResourceAttr("data.smallstep_attestation_authority.test", "attestor_intermediates", utils.Deref(aa.AttestorIntermediates)), - resource.TestMatchResourceAttr("data.smallstep_attestation_authority.test", "created_at", regexp.MustCompile(`^20\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ`)), - ), - }, - }, - }) -} diff --git a/internal/provider/attestation_authority/model.go b/internal/provider/attestation_authority/model.go deleted file mode 100644 index 42006c14c837dc1001f1889be3a2d89dd5c67cd4..0000000000000000000000000000000000000000 --- a/internal/provider/attestation_authority/model.go +++ /dev/null @@ -1,51 +0,0 @@ -package attestation_authority - -import ( - "context" - "time" - - "github.com/hashicorp/terraform-plugin-framework/diag" - "github.com/hashicorp/terraform-plugin-framework/path" - "github.com/hashicorp/terraform-plugin-framework/types" - v20231101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20231101" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/utils" -) - -const typeName = "smallstep_attestation_authority" - -type Model struct { - ID types.String `tfsdk:"id"` - Name types.String `tfsdk:"name"` - Root types.String `tfsdk:"root"` - Slug types.String `tfsdk:"slug"` - AttestorIntermediates types.String `tfsdk:"attestor_intermediates"` - AttestorRoots types.String `tfsdk:"attestor_roots"` - CreatedAt types.String `tfsdk:"created_at"` -} - -func fromAPI(ctx context.Context, aa *v20231101.AttestationAuthority, state utils.AttributeGetter) (*Model, diag.Diagnostics) { - var diags diag.Diagnostics - - model := &Model{ - ID: types.StringValue(utils.Deref(aa.Id)), - Name: types.StringValue(aa.Name), - Root: types.StringValue(utils.Deref(aa.Root)), - Slug: types.StringValue(utils.Deref(aa.Slug)), - AttestorRoots: types.StringValue(aa.AttestorRoots), - CreatedAt: types.StringValue(aa.CreatedAt.Format(time.RFC3339)), - } - - attestorIntermediates, d := utils.ToOptionalString(ctx, aa.AttestorIntermediates, state, path.Root("attestor_intermediates")) - diags = append(diags, d...) - model.AttestorIntermediates = attestorIntermediates - - return model, diags -} - -func toAPI(model *Model) *v20231101.AttestationAuthority { - return &v20231101.AttestationAuthority{ - Name: model.Name.ValueString(), - AttestorRoots: model.AttestorRoots.ValueString(), - AttestorIntermediates: model.AttestorIntermediates.ValueStringPointer(), - } -} diff --git a/internal/provider/attestation_authority/resource.go b/internal/provider/attestation_authority/resource.go deleted file mode 100644 index 13726bcef7d25f0bc0800a1ea28bf5052f02ccfc..0000000000000000000000000000000000000000 --- a/internal/provider/attestation_authority/resource.go +++ /dev/null @@ -1,264 +0,0 @@ -package attestation_authority - -import ( - "context" - "encoding/json" - "fmt" - "net/http" - - "github.com/hashicorp/terraform-plugin-framework/path" - "github.com/hashicorp/terraform-plugin-framework/resource" - "github.com/hashicorp/terraform-plugin-framework/resource/schema" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" - "github.com/hashicorp/terraform-plugin-log/tflog" - v20231101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20231101" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/utils" -) - -var _ resource.ResourceWithImportState = (*Resource)(nil) - -func NewResource() resource.Resource { - return &Resource{} -} - -// Resource defines the resource implementation. -type Resource struct { - client *v20231101.Client -} - -func (r *Resource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = typeName -} - -// Configure adds the Smallstep API client to the resource. -func (r *Resource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { - // Prevent panic if the provider has not been configured. - if req.ProviderData == nil { - return - } - - client, ok := req.ProviderData.(*v20231101.Client) - - if !ok { - resp.Diagnostics.AddError( - "Get Smallstep API client from provider", - fmt.Sprintf("Expected *v20231101.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData), - ) - return - } - - r.client = client -} - -func (r *Resource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { - state := &Model{} - - resp.Diagnostics.Append(req.State.Get(ctx, state)...) - - if resp.Diagnostics.HasError() { - return - } - - id := state.ID.ValueString() - - httpResp, err := r.client.GetAttestationAuthority(ctx, id, &v20231101.GetAttestationAuthorityParams{}) - if err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to read attestation authority %q: %v", id, err), - ) - return - } - defer httpResp.Body.Close() - - if httpResp.StatusCode == http.StatusNotFound { - resp.State.RemoveResource(ctx) - return - } - - if httpResp.StatusCode != http.StatusOK { - reqID := httpResp.Header.Get("X-Request-Id") - resp.Diagnostics.AddError( - "Smallstep API Response Error", - fmt.Sprintf("Request %q received status %d reading attestation authority %q: %s", reqID, httpResp.StatusCode, id, utils.APIErrorMsg(httpResp.Body)), - ) - return - } - - aa := &v20231101.AttestationAuthority{} - if err := json.NewDecoder(httpResp.Body).Decode(aa); err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to unmarshal attestation authority %q: %v", id, err), - ) - return - } - - remote, d := fromAPI(ctx, aa, req.State) - resp.Diagnostics.Append(d...) - if resp.Diagnostics.HasError() { - return - } - - tflog.Trace(ctx, fmt.Sprintf("read aa %q resource", id)) - - resp.Diagnostics.Append(resp.State.Set(ctx, &remote)...) -} - -func (r *Resource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { - component, props, err := utils.Describe("attestationAuthority") - if err != nil { - resp.Diagnostics.AddError( - "Parse Smallstep OpenAPI spec", - err.Error(), - ) - return - } - - resp.Schema = schema.Schema{ - MarkdownDescription: component, - - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - MarkdownDescription: props["id"], - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.UseStateForUnknown(), - }, - }, - "slug": schema.StringAttribute{ - MarkdownDescription: props["slug"], - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.UseStateForUnknown(), - }, - }, - "name": schema.StringAttribute{ - MarkdownDescription: props["name"], - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, - "root": schema.StringAttribute{ - MarkdownDescription: props["root"], - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.UseStateForUnknown(), - }, - }, - "attestor_roots": schema.StringAttribute{ - MarkdownDescription: props["attestorRoots"], - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, - "attestor_intermediates": schema.StringAttribute{ - MarkdownDescription: props["attestorIntermediates"], - Optional: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, - "created_at": schema.StringAttribute{ - MarkdownDescription: props["createdAt"], - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.UseStateForUnknown(), - }, - }, - }, - } -} - -func (a *Resource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan Model - - resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) - - if resp.Diagnostics.HasError() { - return - } - - reqBody := toAPI(&plan) - - b, _ := json.Marshal(reqBody) - tflog.Trace(ctx, string(b)) - - httpResp, err := a.client.PostAttestationAuthorities(ctx, &v20231101.PostAttestationAuthoritiesParams{}, *reqBody) - if err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to create attestation authority %q: %v", plan.Name.ValueString(), err), - ) - return - } - defer httpResp.Body.Close() - - if httpResp.StatusCode != http.StatusCreated { - resp.Diagnostics.AddError( - "Smallstep API Response Error", - fmt.Sprintf("Received status %d creating attestation authority %q: %s", httpResp.StatusCode, plan.Name.ValueString(), utils.APIErrorMsg(httpResp.Body)), - ) - return - } - - aa := &v20231101.AttestationAuthority{} - if err := json.NewDecoder(httpResp.Body).Decode(aa); err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to unmarshal collection %q: %v", plan.Name.ValueString(), err), - ) - return - } - - state, diags := fromAPI(ctx, aa, req.Plan) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - - tflog.Trace(ctx, fmt.Sprintf("create attestation authority %q resource", plan.Name.ValueString())) - - resp.Diagnostics.Append(resp.State.Set(ctx, state)...) -} - -func (r *Resource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { - // Update not supported. All changes require replacement. -} - -func (a *Resource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { - var state Model - - resp.Diagnostics.Append(req.State.Get(ctx, &state)...) - - if resp.Diagnostics.HasError() { - return - } - - id := state.ID.ValueString() - - httpResp, err := a.client.DeleteAttestationAuthority(ctx, id, &v20231101.DeleteAttestationAuthorityParams{}) - if err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to delete attestation authority %s: %v", id, err), - ) - return - } - defer httpResp.Body.Close() - - if httpResp.StatusCode != http.StatusNoContent { - resp.Diagnostics.AddError( - "Smallstep API Response Error", - fmt.Sprintf("Received status %d deleting attestation authority %s: %s", httpResp.StatusCode, id, utils.APIErrorMsg(httpResp.Body)), - ) - return - } -} - -func (r *Resource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { - resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) -} diff --git a/internal/provider/attestation_authority/resource_test.go b/internal/provider/attestation_authority/resource_test.go deleted file mode 100644 index 7ed0bd120e917165fac1cf37a0865fbbbe672ec4..0000000000000000000000000000000000000000 --- a/internal/provider/attestation_authority/resource_test.go +++ /dev/null @@ -1,134 +0,0 @@ -package attestation_authority - -import ( - "fmt" - "regexp" - "testing" - - "github.com/hashicorp/terraform-plugin-framework/datasource" - "github.com/hashicorp/terraform-plugin-framework/providerserver" - "github.com/hashicorp/terraform-plugin-framework/resource" - "github.com/hashicorp/terraform-plugin-go/tfprotov6" - helper "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/collection" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/utils" - "github.com/smallstep/terraform-provider-smallstep/internal/testprovider" - "github.com/stretchr/testify/require" -) - -var provider = &testprovider.SmallstepTestProvider{ - ResourceFactories: []func() resource.Resource{ - NewResource, - collection.NewResource, - }, - DataSourceFactories: []func() datasource.DataSource{ - NewDataSource, - }, -} - -var providerFactories = map[string]func() (tfprotov6.ProviderServer, error){ - "smallstep": providerserver.NewProtocol6WithError(provider), -} - -func TestAccAttestationAuthorityResource(t *testing.T) { - attestorRoot, attestorIntermediate := utils.CACerts(t) - slug := utils.Slug(t) - config := fmt.Sprintf(` -resource "smallstep_collection" "tpms" { - slug = %q -} - -resource "smallstep_attestation_authority" "aa" { - name = %q - attestor_roots = %q - attestor_intermediates = %q - depends_on = [smallstep_collection.tpms] -} -`, slug, slug, attestorRoot, attestorIntermediate) - - helper.Test(t, helper.TestCase{ - PreCheck: func() { - require.NoError(t, utils.SweepAttestationAuthorities()) - }, - ProtoV6ProviderFactories: providerFactories, - Steps: []helper.TestStep{ - { - Config: config, - Check: helper.ComposeAggregateTestCheckFunc( - helper.TestMatchResourceAttr("smallstep_attestation_authority.aa", "id", regexp.MustCompile(`^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$`)), - helper.TestCheckResourceAttr("smallstep_attestation_authority.aa", "name", slug), - helper.TestCheckResourceAttr("smallstep_attestation_authority.aa", "attestor_roots", attestorRoot), - helper.TestCheckResourceAttr("smallstep_attestation_authority.aa", "attestor_intermediates", attestorIntermediate), - helper.TestMatchResourceAttr("smallstep_attestation_authority.aa", "root", regexp.MustCompile(`^-----BEGIN CERTIFICATE-----`)), - helper.TestMatchResourceAttr("smallstep_attestation_authority.aa", "slug", regexp.MustCompile(`^[a-z1-9-]+$`)), - helper.TestMatchResourceAttr("smallstep_attestation_authority.aa", "created_at", regexp.MustCompile(`^20\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ`)), - ), - }, - { - ResourceName: "smallstep_attestation_authority.aa", - ImportState: true, - ImportStateVerify: true, - }, - }, - }) - - nullIntermediate := fmt.Sprintf(` -resource "smallstep_collection" "tpms" { - slug = %q -} - -resource "smallstep_attestation_authority" "aa" { - name = %q - attestor_roots = %q - depends_on = [smallstep_collection.tpms] -} -`, slug, slug, attestorRoot) - - helper.Test(t, helper.TestCase{ - PreCheck: func() { - require.NoError(t, utils.SweepAttestationAuthorities()) - }, - ProtoV6ProviderFactories: providerFactories, - Steps: []helper.TestStep{ - { - Config: nullIntermediate, - Check: helper.ComposeAggregateTestCheckFunc( - helper.TestMatchResourceAttr("smallstep_attestation_authority.aa", "id", regexp.MustCompile(`^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$`)), - helper.TestCheckResourceAttr("smallstep_attestation_authority.aa", "attestor_roots", attestorRoot), - helper.TestMatchResourceAttr("smallstep_attestation_authority.aa", "root", regexp.MustCompile(`^-----BEGIN CERTIFICATE-----`)), - ), - }, - }, - }) - - emptyIntermediate := fmt.Sprintf(` -resource "smallstep_collection" "tpms" { - slug = %q -} - -resource "smallstep_attestation_authority" "aa" { - name = %q - attestor_roots = %q - attestor_intermediates = "" - depends_on = [smallstep_collection.tpms] -} -`, slug, slug, attestorRoot) - - helper.Test(t, helper.TestCase{ - PreCheck: func() { - require.NoError(t, utils.SweepAttestationAuthorities()) - }, - ProtoV6ProviderFactories: providerFactories, - Steps: []helper.TestStep{ - { - Config: emptyIntermediate, - Check: helper.ComposeAggregateTestCheckFunc( - helper.TestMatchResourceAttr("smallstep_attestation_authority.aa", "id", regexp.MustCompile(`^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$`)), - helper.TestCheckResourceAttr("smallstep_attestation_authority.aa", "attestor_roots", attestorRoot), - helper.TestCheckResourceAttr("smallstep_attestation_authority.aa", "attestor_intermediates", ""), - helper.TestMatchResourceAttr("smallstep_attestation_authority.aa", "root", regexp.MustCompile(`^-----BEGIN CERTIFICATE-----`)), - ), - }, - }, - }) -} diff --git a/internal/provider/attestation_authority/sweep_test.go b/internal/provider/attestation_authority/sweep_test.go deleted file mode 100644 index 9bebe0882cf97b12ffcbb13caf5de51043a1dd35..0000000000000000000000000000000000000000 --- a/internal/provider/attestation_authority/sweep_test.go +++ /dev/null @@ -1,15 +0,0 @@ -package attestation_authority - -import ( - "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/utils" -) - -func init() { - resource.AddTestSweepers("smallstep_attestation_authority", &resource.Sweeper{ - Name: "smallstep_attestation_authority", - F: func(region string) error { - return utils.SweepAttestationAuthorities() - }, - }) -} diff --git a/internal/provider/authority/data_source.go b/internal/provider/authority/data_source.go index 3045e65fce063b0592d4c31231c3baf37a001e09..ec4920f400e848f8f2a35521a9e5f27f0a1b33e2 100644 --- a/internal/provider/authority/data_source.go +++ b/internal/provider/authority/data_source.go @@ -12,7 +12,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-log/tflog" - v20231101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20231101" + v20250101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20250101" "github.com/smallstep/terraform-provider-smallstep/internal/provider/utils" ) @@ -24,7 +24,7 @@ func NewDataSource() datasource.DataSource { // DataSource implements data.smallstep_authority type DataSource struct { - client *v20231101.Client + client *v20250101.Client } func (a *DataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { @@ -38,12 +38,12 @@ func (a *DataSource) Configure(ctx context.Context, req datasource.ConfigureRequ return } - client, ok := req.ProviderData.(*v20231101.Client) + client, ok := req.ProviderData.(*v20250101.Client) if !ok { resp.Diagnostics.AddError( "Get Smallstep API client from provider", - fmt.Sprintf("Expected *v20231101.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData), + fmt.Sprintf("Expected *v20250101.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData), ) return } @@ -65,7 +65,7 @@ func (a *DataSource) Read(ctx context.Context, req datasource.ReadRequest, resp id = data.Domain.ValueString() } - httpResp, err := a.client.GetAuthority(ctx, id, &v20231101.GetAuthorityParams{}) + httpResp, err := a.client.GetAuthority(ctx, id, &v20250101.GetAuthorityParams{}) if err != nil { resp.Diagnostics.AddError( "Smallstep API Client Error", @@ -84,7 +84,7 @@ func (a *DataSource) Read(ctx context.Context, req datasource.ReadRequest, resp return } - authority := &v20231101.Authority{} + authority := &v20250101.Authority{} if err := json.NewDecoder(httpResp.Body).Decode(authority); err != nil { resp.Diagnostics.AddError( "Smallstep API Client Error", diff --git a/internal/provider/authority/model.go b/internal/provider/authority/model.go index 5b263179a89cf04ace74c87b9a5de553bc2a8151..d3c5ecc31eb3ae12982951def146c1d1e2d09f38 100644 --- a/internal/provider/authority/model.go +++ b/internal/provider/authority/model.go @@ -5,7 +5,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/types" - v20231101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20231101" + v20250101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20250101" ) // type name for both resources and data sources @@ -47,7 +47,7 @@ type X509IssuerModel struct { Subject *DistinguishedNameModel `tfsdk:"subject"` } -func (issuer *X509IssuerModel) AsAPI(ctx context.Context) (*v20231101.X509Issuer, diag.Diagnostics) { +func (issuer *X509IssuerModel) AsAPI(ctx context.Context) (*v20250101.X509Issuer, diag.Diagnostics) { if issuer == nil { return nil, diag.Diagnostics{} } @@ -59,9 +59,9 @@ func (issuer *X509IssuerModel) AsAPI(ctx context.Context) (*v20231101.X509Issuer maxPathLength := int(issuer.MaxPathLength.ValueInt64()) - return &v20231101.X509Issuer{ + return &v20250101.X509Issuer{ Duration: issuer.Duration.ValueStringPointer(), - KeyVersion: v20231101.X509IssuerKeyVersion(issuer.KeyVersion.ValueString()), + KeyVersion: v20250101.X509IssuerKeyVersion(issuer.KeyVersion.ValueString()), MaxPathLength: &maxPathLength, Name: issuer.Name.ValueString(), NameConstraints: nameConstraints, @@ -81,7 +81,7 @@ type NameConstraintsModel struct { PermittedURIDomains types.Set `tfsdk:"permitted_uri_domains"` } -func (nc *NameConstraintsModel) AsAPI(ctx context.Context) (*v20231101.NameConstraints, diag.Diagnostics) { +func (nc *NameConstraintsModel) AsAPI(ctx context.Context) (*v20250101.NameConstraints, diag.Diagnostics) { var d diag.Diagnostics if nc == nil { @@ -109,7 +109,7 @@ func (nc *NameConstraintsModel) AsAPI(ctx context.Context) (*v20231101.NameConst return nil, d } - return &v20231101.NameConstraints{ + return &v20250101.NameConstraints{ Critical: nc.Critical.ValueBoolPointer(), ExcludedDNSDomains: excludedDNSDomains, ExcludedEmailAddresses: excludedEmailAddresses, @@ -135,12 +135,12 @@ type DistinguishedNameModel struct { StreetAddress types.String `tfsdk:"street_address"` } -func (dn *DistinguishedNameModel) AsAPI() *v20231101.DistinguishedName { +func (dn *DistinguishedNameModel) AsAPI() *v20250101.DistinguishedName { if dn == nil { return nil } - return &v20231101.DistinguishedName{ + return &v20250101.DistinguishedName{ CommonName: dn.CommonName.ValueStringPointer(), Country: dn.Country.ValueStringPointer(), EmailAddress: dn.EmailAddress.ValueStringPointer(), diff --git a/internal/provider/authority/resource.go b/internal/provider/authority/resource.go index 9847f9019ac74597fb9ef0d6227b3cb1fbcf26e2..6768bc1d85c0bb074beafa18e712da0863890b61 100644 --- a/internal/provider/authority/resource.go +++ b/internal/provider/authority/resource.go @@ -19,7 +19,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-log/tflog" - v20231101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20231101" + v20250101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20250101" "github.com/smallstep/terraform-provider-smallstep/internal/provider/utils" ) @@ -31,7 +31,7 @@ func NewResource() resource.Resource { // Resource defines the resource implementation. type Resource struct { - client *v20231101.Client + client *v20250101.Client } func (r *Resource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { @@ -280,12 +280,12 @@ func (r *Resource) Configure(ctx context.Context, req resource.ConfigureRequest, return } - client, ok := req.ProviderData.(*v20231101.Client) + client, ok := req.ProviderData.(*v20250101.Client) if !ok { resp.Diagnostics.AddError( "Unexpected Resource Configure Type", - fmt.Sprintf("Expected *v20231101.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData), + fmt.Sprintf("Expected *v20250101.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData), ) return } @@ -315,18 +315,18 @@ func (a *Resource) Create(ctx context.Context, req resource.CreateRequest, resp return } - reqBody := v20231101.PostAuthoritiesJSONRequestBody{ + reqBody := v20250101.PostAuthoritiesJSONRequestBody{ Name: data.Name.ValueString(), ActiveRevocation: data.ActiveRevocation.ValueBoolPointer(), AdminEmails: adminEmails, IntermediateIssuer: intermediate, RootIssuer: root, Subdomain: data.Subdomain.ValueString(), - Type: v20231101.NewAuthorityType(data.Type.ValueString()), + Type: v20250101.NewAuthorityType(data.Type.ValueString()), } b, _ := json.Marshal(reqBody) tflog.Debug(ctx, string(b)) - httpResp, err := a.client.PostAuthorities(ctx, &v20231101.PostAuthoritiesParams{}, reqBody) + httpResp, err := a.client.PostAuthorities(ctx, &v20250101.PostAuthoritiesParams{}, reqBody) if err != nil { resp.Diagnostics.AddError( "Smallstep API Client Error", @@ -345,7 +345,7 @@ func (a *Resource) Create(ctx context.Context, req resource.CreateRequest, resp return } - authority := &v20231101.Authority{} + authority := &v20250101.Authority{} if err := json.NewDecoder(httpResp.Body).Decode(authority); err != nil { resp.Diagnostics.AddError( "Smallstep API Client Error", @@ -380,7 +380,7 @@ func (a *Resource) Read(ctx context.Context, req resource.ReadRequest, resp *res id = data.Domain.ValueString() } - httpResp, err := a.client.GetAuthority(ctx, id, &v20231101.GetAuthorityParams{}) + httpResp, err := a.client.GetAuthority(ctx, id, &v20250101.GetAuthorityParams{}) if err != nil { resp.Diagnostics.AddError( "Smallstep API Client Error", @@ -404,7 +404,7 @@ func (a *Resource) Read(ctx context.Context, req resource.ReadRequest, resp *res return } - authority := &v20231101.Authority{} + authority := &v20250101.Authority{} if err := json.NewDecoder(httpResp.Body).Decode(authority); err != nil { resp.Diagnostics.AddError( "Smallstep API Client Error", @@ -462,7 +462,7 @@ func (a *Resource) Delete(ctx context.Context, req resource.DeleteRequest, resp return } - httpResp, err := a.client.DeleteAuthority(ctx, data.ID.ValueString(), &v20231101.DeleteAuthorityParams{}) + httpResp, err := a.client.DeleteAuthority(ctx, data.ID.ValueString(), &v20250101.DeleteAuthorityParams{}) if err != nil { resp.Diagnostics.AddError( "Smallstep API Client Error", diff --git a/internal/provider/authority/sweep_test.go b/internal/provider/authority/sweep_test.go index ae0e5f9cb1ffe24d7fdb081138c93f43efd7cdd3..a6485062fda4fd46decc9b8d8d90a5f1b335f4f1 100644 --- a/internal/provider/authority/sweep_test.go +++ b/internal/provider/authority/sweep_test.go @@ -12,7 +12,7 @@ import ( "time" "github.com/hashicorp/terraform-plugin-testing/helper/resource" - v20231101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20231101" + v20250101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20250101" "github.com/smallstep/terraform-provider-smallstep/internal/provider/utils" ) @@ -27,7 +27,7 @@ func init() { return err } - resp, err := client.GetAuthorities(ctx, &v20231101.GetAuthoritiesParams{}) + resp, err := client.GetAuthorities(ctx, &v20250101.GetAuthoritiesParams{}) if err != nil { return err } @@ -36,7 +36,7 @@ func init() { body, _ := io.ReadAll(resp.Body) return fmt.Errorf("failed to list authorities: %d: %s", resp.StatusCode, body) } - var list []*v20231101.Authority + var list []*v20250101.Authority if err := json.NewDecoder(resp.Body).Decode(&list); err != nil { return err } @@ -57,7 +57,7 @@ func init() { if authority.CreatedAt.After(time.Now().Add(age * -1)) { continue } - resp, err := client.DeleteAuthority(ctx, authority.Id, &v20231101.DeleteAuthorityParams{}) + resp, err := client.DeleteAuthority(ctx, authority.Id, &v20250101.DeleteAuthorityParams{}) if err != nil { return err } diff --git a/internal/provider/collection/data_source.go b/internal/provider/collection/data_source.go deleted file mode 100644 index 08ee4689a0f95284ccf3093e976f1a7aec766919..0000000000000000000000000000000000000000 --- a/internal/provider/collection/data_source.go +++ /dev/null @@ -1,140 +0,0 @@ -package collection - -import ( - "context" - "encoding/json" - "fmt" - "net/http" - - "github.com/hashicorp/terraform-plugin-framework/datasource" - "github.com/hashicorp/terraform-plugin-framework/datasource/schema" - "github.com/hashicorp/terraform-plugin-log/tflog" - v20231101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20231101" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/utils" -) - -var _ datasource.DataSourceWithConfigure = (*DataSource)(nil) - -func NewDataSource() datasource.DataSource { - return &DataSource{} -} - -// DataSource implements data.smallstep_collection -type DataSource struct { - client *v20231101.Client -} - -func (a *DataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { - resp.TypeName = collectionTypeName -} - -// Configure adds the Smallstep API client to the data source. -func (a *DataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { - // Prevent panic if the provider has not been configured. - if req.ProviderData == nil { - return - } - - client, ok := req.ProviderData.(*v20231101.Client) - - if !ok { - resp.Diagnostics.AddError( - "Get Smallstep API client from provider", - fmt.Sprintf("Expected *v20231101.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData), - ) - return - } - - a.client = client -} - -func (a *DataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { - var config Model - - // Read Terraform configuration data into the model - resp.Diagnostics.Append(req.Config.Get(ctx, &config)...) - - if resp.Diagnostics.HasError() { - return - } - - httpResp, err := a.client.GetCollection(ctx, config.Slug.ValueString(), &v20231101.GetCollectionParams{}) - if err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to read collection %s: %v", config.Slug.String(), err), - ) - return - } - defer httpResp.Body.Close() - - if httpResp.StatusCode != http.StatusOK { - reqID := httpResp.Header.Get("X-Request-Id") - resp.Diagnostics.AddError( - "Smallstep API Response Error", - fmt.Sprintf("Request %q received status %d reading collection %s: %s", reqID, httpResp.StatusCode, config.Slug.String(), utils.APIErrorMsg(httpResp.Body)), - ) - return - } - - collection := &v20231101.Collection{} - if err := json.NewDecoder(httpResp.Body).Decode(collection); err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to unmarshal collection %s: %v", config.Slug.String(), err), - ) - return - } - - remote, d := fromAPI(ctx, collection, req.Config) - resp.Diagnostics.Append(d...) - if resp.Diagnostics.HasError() { - return - } - - tflog.Trace(ctx, fmt.Sprintf("read collection %q data source", config.Slug.String())) - - resp.Diagnostics.Append(resp.State.Set(ctx, &remote)...) -} - -func (d *DataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - component, props, err := utils.Describe("collection") - if err != nil { - resp.Diagnostics.AddError( - "Parse Smallstep OpenAPI spec", - err.Error(), - ) - return - } - - resp.Schema = schema.Schema{ - MarkdownDescription: component, - - Attributes: map[string]schema.Attribute{ - "slug": schema.StringAttribute{ - MarkdownDescription: props["slug"], - Required: true, - }, - "display_name": schema.StringAttribute{ - MarkdownDescription: props["displayName"], - Computed: true, - }, - "schema_uri": schema.StringAttribute{ - MarkdownDescription: props["schemaURI"], - Optional: true, - }, - "instance_count": schema.Int64Attribute{ - MarkdownDescription: props["instanceCount"], - Computed: true, - }, - "created_at": schema.StringAttribute{ - MarkdownDescription: props["createdAt"], - Computed: true, - }, - "updated_at": schema.StringAttribute{ - MarkdownDescription: props["updatedAt"], - Computed: true, - }, - }, - } -} diff --git a/internal/provider/collection/data_source_test.go b/internal/provider/collection/data_source_test.go deleted file mode 100644 index 4d39695bba91b45fa3de676cd65ce5be1e8c5483..0000000000000000000000000000000000000000 --- a/internal/provider/collection/data_source_test.go +++ /dev/null @@ -1,36 +0,0 @@ -package collection - -import ( - "fmt" - "regexp" - "testing" - - "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/utils" -) - -func TestAccCollectionDataSource(t *testing.T) { - t.Parallel() - collection := utils.NewCollection(t) - config := fmt.Sprintf(` -data "smallstep_collection" "test" { - slug = %q -} -`, collection.Slug) - - resource.Test(t, resource.TestCase{ - ProtoV6ProviderFactories: providerFactories, - Steps: []resource.TestStep{ - { - Config: config, - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("data.smallstep_collection.test", "slug", collection.Slug), - resource.TestCheckResourceAttr("data.smallstep_collection.test", "instance_count", "0"), - resource.TestCheckResourceAttr("data.smallstep_collection.test", "display_name", collection.DisplayName), - resource.TestMatchResourceAttr("data.smallstep_collection.test", "created_at", regexp.MustCompile(`^20\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ`)), - resource.TestMatchResourceAttr("data.smallstep_collection.test", "updated_at", regexp.MustCompile(`^20\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ`)), - ), - }, - }, - }) -} diff --git a/internal/provider/collection/model.go b/internal/provider/collection/model.go deleted file mode 100644 index 6dc8188e0c117d7446ec95c221af20422bfbb8a1..0000000000000000000000000000000000000000 --- a/internal/provider/collection/model.go +++ /dev/null @@ -1,60 +0,0 @@ -package collection - -import ( - "context" - "time" - - "github.com/hashicorp/terraform-plugin-framework/diag" - "github.com/hashicorp/terraform-plugin-framework/path" - "github.com/hashicorp/terraform-plugin-framework/types" - v20231101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20231101" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/utils" -) - -const collectionTypeName = "smallstep_collection" - -type Model struct { - Slug types.String `tfsdk:"slug"` - DisplayName types.String `tfsdk:"display_name"` - InstanceCount types.Int64 `tfsdk:"instance_count"` - CreatedAt types.String `tfsdk:"created_at"` - UpdatedAt types.String `tfsdk:"updated_at"` - SchemaURI types.String `tfsdk:"schema_uri"` -} - -func fromAPI(ctx context.Context, collection *v20231101.Collection, state utils.AttributeGetter) (*Model, diag.Diagnostics) { - var diags diag.Diagnostics - - displayName, d := utils.ToOptionalString(ctx, &collection.DisplayName, state, path.Root("display_name")) - diags.Append(d...) - - schemaURI, d := utils.ToOptionalString(ctx, collection.SchemaURI, state, path.Root("schema_uri")) - diags.Append(d...) - - model := &Model{ - Slug: types.StringValue(collection.Slug), - InstanceCount: types.Int64Value(int64(collection.InstanceCount)), - DisplayName: displayName, - SchemaURI: schemaURI, - CreatedAt: types.StringValue(collection.CreatedAt.Format(time.RFC3339)), - UpdatedAt: types.StringValue(collection.UpdatedAt.Format(time.RFC3339)), - } - - return model, diags -} - -func toAPINew(model *Model) *v20231101.NewCollection { - return &v20231101.NewCollection{ - Slug: model.Slug.ValueString(), - DisplayName: model.DisplayName.ValueStringPointer(), - SchemaURI: model.SchemaURI.ValueStringPointer(), - } -} - -func toAPI(model *Model) *v20231101.Collection { - return &v20231101.Collection{ - Slug: model.Slug.ValueString(), - DisplayName: model.DisplayName.ValueString(), - SchemaURI: model.SchemaURI.ValueStringPointer(), - } -} diff --git a/internal/provider/collection/resource.go b/internal/provider/collection/resource.go deleted file mode 100644 index 3014bde65167aaa5cb4b5fdba37a39ec8558b2bc..0000000000000000000000000000000000000000 --- a/internal/provider/collection/resource.go +++ /dev/null @@ -1,318 +0,0 @@ -package collection - -import ( - "context" - "encoding/json" - "fmt" - "net/http" - - "github.com/hashicorp/terraform-plugin-framework/path" - "github.com/hashicorp/terraform-plugin-framework/resource" - "github.com/hashicorp/terraform-plugin-framework/resource/schema" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" - "github.com/hashicorp/terraform-plugin-log/tflog" - v20231101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20231101" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/utils" -) - -var _ resource.ResourceWithImportState = (*Resource)(nil) - -func NewResource() resource.Resource { - return &Resource{} -} - -// Resource defines the resource implementation. -type Resource struct { - client *v20231101.Client -} - -func (r *Resource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = collectionTypeName -} - -// Configure adds the Smallstep API client to the resource. -func (r *Resource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { - // Prevent panic if the provider has not been configured. - if req.ProviderData == nil { - return - } - - client, ok := req.ProviderData.(*v20231101.Client) - - if !ok { - resp.Diagnostics.AddError( - "Get Smallstep API client from provider", - fmt.Sprintf("Expected *v20231101.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData), - ) - return - } - - r.client = client -} - -func (r *Resource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { - state := &Model{} - - resp.Diagnostics.Append(req.State.Get(ctx, state)...) - - if resp.Diagnostics.HasError() { - return - } - - httpResp, err := r.client.GetCollection(ctx, state.Slug.ValueString(), &v20231101.GetCollectionParams{}) - if err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to read collection %s: %v", state.Slug.String(), err), - ) - return - } - defer httpResp.Body.Close() - - if httpResp.StatusCode == http.StatusNotFound { - resp.State.RemoveResource(ctx) - return - } - - if httpResp.StatusCode != http.StatusOK { - reqID := httpResp.Header.Get("X-Request-Id") - resp.Diagnostics.AddError( - "Smallstep API Response Error", - fmt.Sprintf("Request %q received status %d reading collection %s: %s", reqID, httpResp.StatusCode, state.Slug.String(), utils.APIErrorMsg(httpResp.Body)), - ) - return - } - - collection := &v20231101.Collection{} - if err := json.NewDecoder(httpResp.Body).Decode(collection); err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to unmarshal collection %s: %v", state.Slug.String(), err), - ) - return - } - - remote, d := fromAPI(ctx, collection, req.State) - resp.Diagnostics.Append(d...) - if resp.Diagnostics.HasError() { - return - } - - tflog.Trace(ctx, fmt.Sprintf("read collection %q resource", collection.Slug)) - - resp.Diagnostics.Append(resp.State.Set(ctx, &remote)...) -} - -func (r *Resource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { - component, props, err := utils.Describe("collection") - if err != nil { - resp.Diagnostics.AddError( - "Parse Smallstep OpenAPI spec", - err.Error(), - ) - return - } - - resp.Schema = schema.Schema{ - MarkdownDescription: component, - - Attributes: map[string]schema.Attribute{ - "slug": schema.StringAttribute{ - MarkdownDescription: props["slug"], - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, - "display_name": schema.StringAttribute{ - MarkdownDescription: props["displayName"], - Optional: true, - }, - "schema_uri": schema.StringAttribute{ - MarkdownDescription: props["schemaURI"], - Optional: true, - }, - "instance_count": schema.Int64Attribute{ - MarkdownDescription: props["instanceCount"], - Computed: true, - }, - "created_at": schema.StringAttribute{ - MarkdownDescription: props["createdAt"], - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.UseStateForUnknown(), - }, - }, - "updated_at": schema.StringAttribute{ - MarkdownDescription: props["updatedAt"], - Computed: true, - }, - }, - } -} - -func (a *Resource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan Model - - resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) - - if resp.Diagnostics.HasError() { - return - } - - reqBody := toAPINew(&plan) - - b, _ := json.Marshal(reqBody) - tflog.Trace(ctx, string(b)) - - httpResp, err := a.client.PostCollections(ctx, &v20231101.PostCollectionsParams{}, *reqBody) - if err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to create collection %q: %v", plan.Slug.String(), err), - ) - return - } - defer httpResp.Body.Close() - - if httpResp.StatusCode != http.StatusCreated { - reqID := httpResp.Header.Get("X-Request-Id") - resp.Diagnostics.AddError( - "Smallstep API Response Error", - fmt.Sprintf("Request %q received status %d creating collection %q: %s", reqID, httpResp.StatusCode, plan.Slug.String(), utils.APIErrorMsg(httpResp.Body)), - ) - return - } - - collection := &v20231101.Collection{} - if err := json.NewDecoder(httpResp.Body).Decode(collection); err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to unmarshal collection %q: %v", plan.Slug.ValueString(), err), - ) - return - } - - state, diags := fromAPI(ctx, collection, req.Plan) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - - tflog.Trace(ctx, fmt.Sprintf("create collection %q resource", plan.Slug.ValueString())) - - resp.Diagnostics.Append(resp.State.Set(ctx, state)...) -} - -func (r *Resource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { - plan := &Model{} - - resp.Diagnostics.Append(req.Plan.Get(ctx, plan)...) - if resp.Diagnostics.HasError() { - return - } - - reqBody := toAPI(plan) - - httpResp, err := r.client.PutCollection(ctx, plan.Slug.ValueString(), &v20231101.PutCollectionParams{}, *reqBody) - if err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to update collection %q: %v", plan.Slug.String(), err), - ) - return - } - defer httpResp.Body.Close() - - if httpResp.StatusCode != http.StatusOK { - reqID := httpResp.Header.Get("X-Request-Id") - resp.Diagnostics.AddError( - "Smallstep API Response Error", - fmt.Sprintf("Request %q received status %d updating collection %q: %s", reqID, httpResp.StatusCode, plan.Slug.String(), utils.APIErrorMsg(httpResp.Body)), - ) - return - } - - collection := &v20231101.Collection{} - if err := json.NewDecoder(httpResp.Body).Decode(collection); err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to unmarshal collection %q: %v", plan.Slug.ValueString(), err), - ) - return - } - - state, diags := fromAPI(ctx, collection, req.Plan) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - - tflog.Trace(ctx, fmt.Sprintf("update collection %q resource", plan.Slug.ValueString())) - - resp.Diagnostics.Append(resp.State.Set(ctx, state)...) -} - -func (a *Resource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { - var state Model - - resp.Diagnostics.Append(req.State.Get(ctx, &state)...) - - if resp.Diagnostics.HasError() { - return - } - - // Lookup the collection to ensure it's empty before deleting - getResp, err := a.client.GetCollection(ctx, state.Slug.ValueString(), &v20231101.GetCollectionParams{}) - if err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to read collection %s: %v", state.Slug.String(), err), - ) - return - } - defer getResp.Body.Close() - if getResp.StatusCode == http.StatusNotFound { - return - } - collection := &v20231101.Collection{} - if err := json.NewDecoder(getResp.Body).Decode(collection); err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to unmarshal collection %s: %v", state.Slug.String(), err), - ) - return - } - if collection.InstanceCount != 0 { - resp.Diagnostics.AddError( - "Delete Not Allowed", - fmt.Sprintf("The collection cannot be deleted because it is not empty"), - ) - return - - } - - httpResp, err := a.client.DeleteCollection(ctx, state.Slug.ValueString(), &v20231101.DeleteCollectionParams{}) - if err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to delete collection %s: %v", state.Slug.String(), err), - ) - return - } - defer httpResp.Body.Close() - - if httpResp.StatusCode != http.StatusNoContent { - reqID := httpResp.Header.Get("X-Request-Id") - resp.Diagnostics.AddError( - "Smallstep API Response Error", - fmt.Sprintf("Request %q received status %d deleting collection %s: %s", reqID, httpResp.StatusCode, state.Slug.String(), utils.APIErrorMsg(httpResp.Body)), - ) - return - } -} - -func (r *Resource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { - resource.ImportStatePassthroughID(ctx, path.Root("slug"), req, resp) -} diff --git a/internal/provider/collection/resource_test.go b/internal/provider/collection/resource_test.go deleted file mode 100644 index a6150babaffc5c991e92fffb90d29b6728c058f7..0000000000000000000000000000000000000000 --- a/internal/provider/collection/resource_test.go +++ /dev/null @@ -1,195 +0,0 @@ -package collection - -import ( - "context" - "encoding/json" - "fmt" - "io" - "log" - "net/http" - "os" - "regexp" - "strings" - "testing" - "time" - - "github.com/hashicorp/terraform-plugin-framework/datasource" - "github.com/hashicorp/terraform-plugin-framework/providerserver" - "github.com/hashicorp/terraform-plugin-framework/resource" - "github.com/hashicorp/terraform-plugin-go/tfprotov6" - helper "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/hashicorp/terraform-plugin-testing/plancheck" - v20231101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20231101" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/utils" - "github.com/smallstep/terraform-provider-smallstep/internal/testprovider" -) - -func TestMain(m *testing.M) { - helper.TestMain(m) -} - -var provider = &testprovider.SmallstepTestProvider{ - ResourceFactories: []func() resource.Resource{ - NewResource, - }, - DataSourceFactories: []func() datasource.DataSource{ - NewDataSource, - }, -} - -var providerFactories = map[string]func() (tfprotov6.ProviderServer, error){ - "smallstep": providerserver.NewProtocol6WithError(provider), -} - -func init() { - helper.AddTestSweepers("smallstep_collection", &helper.Sweeper{ - Name: "smallstep_collection", - F: func(region string) error { - ctx := context.Background() - - client, err := utils.SmallstepAPIClientFromEnv() - if err != nil { - return err - } - - resp, err := client.ListCollections(ctx, &v20231101.ListCollectionsParams{}) - if err != nil { - return err - } - defer resp.Body.Close() - if resp.StatusCode != http.StatusOK { - body, _ := io.ReadAll(resp.Body) - return fmt.Errorf("failed to list collections: %d: %s", resp.StatusCode, body) - } - var list []*v20231101.Collection - if err := json.NewDecoder(resp.Body).Decode(&list); err != nil { - return err - } - - for _, collection := range list { - if !strings.HasPrefix(collection.Slug, "tfprovider") { - continue - } - // Don't delete collections that may be used by running tests - age := time.Minute - if sweepAge := os.Getenv("SWEEP_AGE"); sweepAge != "" { - d, err := time.ParseDuration(sweepAge) - if err != nil { - return err - } - age = d - } - if collection.CreatedAt.After(time.Now().Add(age * -1)) { - continue - } - resp, err := client.DeleteCollection(ctx, collection.Slug, &v20231101.DeleteCollectionParams{}) - if err != nil { - return err - } - defer resp.Body.Close() - // special-purpose collections such as workloads won't delete successfully - if resp.StatusCode == http.StatusNoContent { - log.Printf("Successfully swept collection %s\n", collection.Slug) - } - } - - return nil - }, - }) -} - -func TestAccCollectionResource(t *testing.T) { - t.Parallel() - - slug := utils.Slug(t) - config := fmt.Sprintf(` -resource "smallstep_collection" "employees" { - slug = %q - display_name = "Current Employees" - schema_uri = "https://schema.infra.smallstep.com/manage-workloads/device/aws-vm" -}`, slug) - - updatedConfig := fmt.Sprintf(` -resource "smallstep_collection" "employees" { - slug = %q - display_name = "Employees" -}`, slug) - - helper.Test(t, helper.TestCase{ - ProtoV6ProviderFactories: providerFactories, - Steps: []helper.TestStep{ - { - Config: config, - Check: helper.ComposeAggregateTestCheckFunc( - helper.TestCheckResourceAttr("smallstep_collection.employees", "slug", slug), - helper.TestCheckResourceAttr("smallstep_collection.employees", "display_name", "Current Employees"), - helper.TestCheckResourceAttr("smallstep_collection.employees", "schema_uri", "https://schema.infra.smallstep.com/manage-workloads/device/aws-vm"), - helper.TestCheckResourceAttr("smallstep_collection.employees", "instance_count", "0"), - helper.TestMatchResourceAttr("smallstep_collection.employees", "created_at", regexp.MustCompile(`^20\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ`)), - helper.TestMatchResourceAttr("smallstep_collection.employees", "updated_at", regexp.MustCompile(`^20\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ`)), - ), - }, - { - Config: updatedConfig, - Check: helper.ComposeAggregateTestCheckFunc( - helper.TestCheckResourceAttr("smallstep_collection.employees", "display_name", "Employees"), - helper.TestCheckNoResourceAttr("smallstep_collection.employees", "schema_uri"), - ), - ConfigPlanChecks: helper.ConfigPlanChecks{ - PreApply: []plancheck.PlanCheck{ - plancheck.ExpectResourceAction("smallstep_collection.employees", plancheck.ResourceActionUpdate), - }, - }, - }, - { - ResourceName: "smallstep_collection.employees", - ImportState: true, - ImportStateId: slug, - ImportStateVerify: true, - ImportStateVerifyIdentifierAttribute: "slug", - }, - }, - }) - - slug2 := utils.Slug(t) - emptyConfig := fmt.Sprintf(` -resource "smallstep_collection" "employees" { - slug = %q - display_name = "" - schema_uri = "" -}`, slug2) - - helper.Test(t, helper.TestCase{ - ProtoV6ProviderFactories: providerFactories, - Steps: []helper.TestStep{ - { - Config: emptyConfig, - Check: helper.ComposeAggregateTestCheckFunc( - helper.TestCheckResourceAttr("smallstep_collection.employees", "slug", slug2), - helper.TestCheckResourceAttr("smallstep_collection.employees", "display_name", ""), - helper.TestCheckResourceAttr("smallstep_collection.employees", "schema_uri", ""), - ), - }, - }, - }) - - slug3 := utils.Slug(t) - nullConfig := fmt.Sprintf(` -resource "smallstep_collection" "employees" { - slug = %q -}`, slug3) - - helper.Test(t, helper.TestCase{ - ProtoV6ProviderFactories: providerFactories, - Steps: []helper.TestStep{ - { - Config: nullConfig, - Check: helper.ComposeAggregateTestCheckFunc( - helper.TestCheckResourceAttr("smallstep_collection.employees", "slug", slug3), - helper.TestCheckNoResourceAttr("smallstep_collection.employees", "display_name"), - helper.TestCheckNoResourceAttr("smallstep_collection.employees", "schema_uri"), - ), - }, - }, - }) -} diff --git a/internal/provider/collection_instance/data_source.go b/internal/provider/collection_instance/data_source.go deleted file mode 100644 index a6b7b9500feff44be3eb0dfe53e68fbeedee8e76..0000000000000000000000000000000000000000 --- a/internal/provider/collection_instance/data_source.go +++ /dev/null @@ -1,143 +0,0 @@ -package collection_instance - -import ( - "context" - "encoding/json" - "fmt" - "net/http" - - "github.com/hashicorp/terraform-plugin-framework/datasource" - "github.com/hashicorp/terraform-plugin-framework/datasource/schema" - "github.com/hashicorp/terraform-plugin-log/tflog" - v20231101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20231101" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/utils" -) - -var _ datasource.DataSourceWithConfigure = (*DataSource)(nil) - -func NewDataSource() datasource.DataSource { - return &DataSource{} -} - -// DataSource implements data.smallstep_collection -type DataSource struct { - client *v20231101.Client -} - -func (a *DataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { - resp.TypeName = instanceTypeName -} - -// Configure adds the Smallstep API client to the data source. -func (a *DataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { - // Prevent panic if the provider has not been configured. - if req.ProviderData == nil { - return - } - - client, ok := req.ProviderData.(*v20231101.Client) - - if !ok { - resp.Diagnostics.AddError( - "Get Smallstep API client from provider", - fmt.Sprintf("Expected *v20231101.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData), - ) - return - } - - a.client = client -} - -func (a *DataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { - var config Model - - // Read Terraform configuration data into the model - resp.Diagnostics.Append(req.Config.Get(ctx, &config)...) - - if resp.Diagnostics.HasError() { - return - } - - slug := config.CollectionSlug.ValueString() - id := config.ID.ValueString() - - httpResp, err := a.client.GetCollectionInstance(ctx, slug, id, &v20231101.GetCollectionInstanceParams{}) - if err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to read collection instance %s/%s: %v", slug, id, err), - ) - return - } - defer httpResp.Body.Close() - - if httpResp.StatusCode != http.StatusOK { - reqID := httpResp.Header.Get("X-Request-Id") - resp.Diagnostics.AddError( - "Smallstep API Response Error", - fmt.Sprintf("Request %q received status %d reading collection instance %s/%s: %s", reqID, httpResp.StatusCode, slug, id, utils.APIErrorMsg(httpResp.Body)), - ) - return - } - - instance := &v20231101.CollectionInstance{} - if err := json.NewDecoder(httpResp.Body).Decode(instance); err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to unmarshal collection instance %s/%s: %v", slug, id, err), - ) - return - } - - remote, d := fromAPI(ctx, slug, instance, req.Config) - resp.Diagnostics.Append(d...) - if resp.Diagnostics.HasError() { - return - } - - tflog.Trace(ctx, fmt.Sprintf("read collection instance %s/%s data source", slug, id)) - - resp.Diagnostics.Append(resp.State.Set(ctx, &remote)...) -} - -func (d *DataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - component, props, err := utils.Describe("collectionInstance") - if err != nil { - resp.Diagnostics.AddError( - "Parse Smallstep OpenAPI spec", - err.Error(), - ) - return - } - - resp.Schema = schema.Schema{ - MarkdownDescription: component, - - Attributes: map[string]schema.Attribute{ - "collection_slug": schema.StringAttribute{ - MarkdownDescription: "The slug of the collection this instance belongs to", - Required: true, - }, - "id": schema.StringAttribute{ - MarkdownDescription: props["id"], - Required: true, - }, - "data": schema.StringAttribute{ - MarkdownDescription: props["data"], - Computed: true, - }, - "out_data": schema.StringAttribute{ - MarkdownDescription: props["data"], - Computed: true, - }, - "created_at": schema.StringAttribute{ - MarkdownDescription: props["createdAt"], - Computed: true, - }, - "updated_at": schema.StringAttribute{ - MarkdownDescription: props["updatedAt"], - Computed: true, - }, - }, - } -} diff --git a/internal/provider/collection_instance/data_source_test.go b/internal/provider/collection_instance/data_source_test.go deleted file mode 100644 index 695bbe88a8eb6385a91b67038b4492c972cb402b..0000000000000000000000000000000000000000 --- a/internal/provider/collection_instance/data_source_test.go +++ /dev/null @@ -1,43 +0,0 @@ -package collection_instance - -import ( - "encoding/json" - "fmt" - "regexp" - "testing" - - helper "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/utils" - "github.com/stretchr/testify/require" -) - -func TestAccCollectionInstanceDataSource(t *testing.T) { - t.Parallel() - collection := utils.NewCollection(t) - instance := utils.NewCollectionInstance(t, collection.Slug) - config := fmt.Sprintf(` -data "smallstep_collection_instance" "test" { - collection_slug = %q - id = %q -} -`, collection.Slug, instance.Id) - - dataJSON, err := json.Marshal(instance.Data) - require.NoError(t, err) - - helper.Test(t, helper.TestCase{ - ProtoV6ProviderFactories: providerFactories, - Steps: []helper.TestStep{ - { - Config: config, - Check: helper.ComposeAggregateTestCheckFunc( - helper.TestCheckResourceAttr("data.smallstep_collection_instance.test", "collection_slug", collection.Slug), - helper.TestCheckResourceAttr("data.smallstep_collection_instance.test", "id", instance.Id), - helper.TestCheckResourceAttr("data.smallstep_collection_instance.test", "data", string(dataJSON)), - helper.TestMatchResourceAttr("data.smallstep_collection_instance.test", "created_at", regexp.MustCompile(`^20\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ`)), - helper.TestMatchResourceAttr("data.smallstep_collection_instance.test", "updated_at", regexp.MustCompile(`^20\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ`)), - ), - }, - }, - }) -} diff --git a/internal/provider/collection_instance/model.go b/internal/provider/collection_instance/model.go deleted file mode 100644 index c420bff38446dd66d718ecdb22a0e0046c0ce93c..0000000000000000000000000000000000000000 --- a/internal/provider/collection_instance/model.go +++ /dev/null @@ -1,64 +0,0 @@ -package collection_instance - -import ( - "context" - "encoding/json" - "time" - - "github.com/hashicorp/terraform-plugin-framework/diag" - "github.com/hashicorp/terraform-plugin-framework/path" - "github.com/hashicorp/terraform-plugin-framework/types" - v20231101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20231101" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/utils" -) - -const instanceTypeName = "smallstep_collection_instance" - -type Model struct { - CollectionSlug types.String `tfsdk:"collection_slug"` - ID types.String `tfsdk:"id"` - Data types.String `tfsdk:"data"` - OutData types.String `tfsdk:"out_data"` - CreatedAt types.String `tfsdk:"created_at"` - UpdatedAt types.String `tfsdk:"updated_at"` -} - -func fromAPI(ctx context.Context, slug string, instance *v20231101.CollectionInstance, state utils.AttributeGetter) (*Model, diag.Diagnostics) { - var diags diag.Diagnostics - - model := &Model{ - CollectionSlug: types.StringValue(slug), - ID: types.StringValue(instance.Id), - CreatedAt: types.StringValue(instance.CreatedAt.Format(time.RFC3339)), - UpdatedAt: types.StringValue(instance.UpdatedAt.Format(time.RFC3339)), - } - - apiDataJSON, err := json.Marshal(instance.Data) - if err != nil { - diags.AddError("Marshal Instance Data", err.Error()) - return nil, diags - } - model.OutData = types.StringValue(string(apiDataJSON)) - - dataFromState := types.String{} - d := state.GetAttribute(ctx, path.Root("data"), &dataFromState) - diags = append(diags, d...) - if dataFromState.IsNull() { - model.Data = model.OutData - } else { - model.Data = dataFromState - } - - return model, diags -} -func toAPI(model *Model) (*v20231101.PutCollectionInstanceJSONRequestBody, diag.Diagnostics) { - var diags diag.Diagnostics - - instance := &v20231101.PutCollectionInstanceJSONRequestBody{} - - if err := json.Unmarshal([]byte(model.Data.ValueString()), &instance.Data); err != nil { - diags.AddError("Parse Instance Data", err.Error()) - } - - return instance, diags -} diff --git a/internal/provider/collection_instance/resource.go b/internal/provider/collection_instance/resource.go deleted file mode 100644 index 2ce826617afc31b33d8a98b4657a0f25d43b2565..0000000000000000000000000000000000000000 --- a/internal/provider/collection_instance/resource.go +++ /dev/null @@ -1,325 +0,0 @@ -package collection_instance - -import ( - "context" - "encoding/json" - "fmt" - "net/http" - "strings" - - "github.com/hashicorp/terraform-plugin-framework/path" - "github.com/hashicorp/terraform-plugin-framework/resource" - "github.com/hashicorp/terraform-plugin-framework/resource/schema" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" - "github.com/hashicorp/terraform-plugin-log/tflog" - v20231101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20231101" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/utils" -) - -var _ resource.ResourceWithImportState = (*Resource)(nil) - -func NewResource() resource.Resource { - return &Resource{} -} - -// Resource defines the resource implementation. -type Resource struct { - client *v20231101.Client -} - -func (r *Resource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = instanceTypeName -} - -// Configure adds the Smallstep API client to the resource. -func (r *Resource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { - // Prevent panic if the provider has not been configured. - if req.ProviderData == nil { - return - } - - client, ok := req.ProviderData.(*v20231101.Client) - - if !ok { - resp.Diagnostics.AddError( - "Get Smallstep API client from provider", - fmt.Sprintf("Expected *v20231101.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData), - ) - return - } - - r.client = client -} - -func (r *Resource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { - state := &Model{} - - resp.Diagnostics.Append(req.State.Get(ctx, state)...) - - if resp.Diagnostics.HasError() { - return - } - - slug := state.CollectionSlug.ValueString() - id := state.ID.ValueString() - - httpResp, err := r.client.GetCollectionInstance(ctx, slug, id, &v20231101.GetCollectionInstanceParams{}) - if err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to read collection instance %s/%s: %v", slug, id, err), - ) - return - } - defer httpResp.Body.Close() - - if httpResp.StatusCode == http.StatusNotFound { - resp.State.RemoveResource(ctx) - return - } - - if httpResp.StatusCode != http.StatusOK { - reqID := httpResp.Header.Get("X-Request-Id") - resp.Diagnostics.AddError( - "Smallstep API Response Error", - fmt.Sprintf("Request %q received status %d reading collection instance %s/%s: %s", reqID, httpResp.StatusCode, slug, id, utils.APIErrorMsg(httpResp.Body)), - ) - return - } - - instance := &v20231101.CollectionInstance{} - if err := json.NewDecoder(httpResp.Body).Decode(instance); err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to unmarshal collection instance %s/%s: %v", slug, id, err), - ) - return - } - - remote, d := fromAPI(ctx, slug, instance, req.State) - if d.HasError() { - resp.Diagnostics.Append(d...) - return - } - - tflog.Trace(ctx, fmt.Sprintf("read collection resource %s/%s", slug, id)) - - resp.Diagnostics.Append(resp.State.Set(ctx, &remote)...) -} - -func (r *Resource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { - component, props, err := utils.Describe("collectionInstance") - if err != nil { - resp.Diagnostics.AddError( - "Parse Smallstep OpenAPI spec", - err.Error(), - ) - return - } - - collectionWarning := ` -The collection will be created implicitly if it does not exist. -If creating this collection with a smallstep_collection resource in the same config you MUST use depends_on to avoid race conditions.` - - resp.Schema = schema.Schema{ - MarkdownDescription: component, - - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - MarkdownDescription: props["id"], - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, - "collection_slug": schema.StringAttribute{ - MarkdownDescription: props["collectionSlug"] + collectionWarning, - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, - "data": schema.StringAttribute{ - MarkdownDescription: props["data"], - Required: true, - }, - "out_data": schema.StringAttribute{ - MarkdownDescription: "The instance data stored after any modifications made server-side. If the instance belongs to a device collection a host ID attribute will be added to the data.", - Computed: true, - }, - "created_at": schema.StringAttribute{ - MarkdownDescription: props["createdAt"], - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.UseStateForUnknown(), - }, - }, - "updated_at": schema.StringAttribute{ - MarkdownDescription: props["updatedAt"], - Computed: true, - }, - }, - } -} - -func (a *Resource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan Model - - resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) - - if resp.Diagnostics.HasError() { - return - } - - reqBody, diags := toAPI(&plan) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - - b, _ := json.Marshal(reqBody) - tflog.Trace(ctx, string(b)) - - id := plan.ID.ValueString() - slug := plan.CollectionSlug.ValueString() - - httpResp, err := a.client.PutCollectionInstance(ctx, slug, id, &v20231101.PutCollectionInstanceParams{}, *reqBody) - if err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to create collection instance %s/%s: %v", slug, id, err), - ) - return - } - defer httpResp.Body.Close() - - if httpResp.StatusCode != http.StatusOK { - reqID := httpResp.Header.Get("X-Request-Id") - resp.Diagnostics.AddError( - "Smallstep API Response Error", - fmt.Sprintf("Request %q received status %d: %s", reqID, httpResp.StatusCode, utils.APIErrorMsg(httpResp.Body)), - ) - return - } - - instance := &v20231101.CollectionInstance{} - if err := json.NewDecoder(httpResp.Body).Decode(instance); err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to unmarshal collection instance %s/%s: %v", slug, id, err), - ) - return - } - - state, diags := fromAPI(ctx, slug, instance, req.Plan) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - - tflog.Trace(ctx, fmt.Sprintf("create collection instance %s/%s resource", slug, id)) - - resp.Diagnostics.Append(resp.State.Set(ctx, state)...) -} - -func (r *Resource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { - plan := &Model{} - - resp.Diagnostics.Append(req.Plan.Get(ctx, plan)...) - if resp.Diagnostics.HasError() { - return - } - - reqBody, diags := toAPI(plan) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - - id := plan.ID.ValueString() - slug := plan.CollectionSlug.ValueString() - - httpResp, err := r.client.PutCollectionInstance(ctx, slug, id, &v20231101.PutCollectionInstanceParams{}, *reqBody) - if err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to update collection instance %s/%s: %v", slug, id, err), - ) - return - } - defer httpResp.Body.Close() - - if httpResp.StatusCode != http.StatusOK { - reqID := httpResp.Header.Get("X-Request-Id") - resp.Diagnostics.AddError( - "Smallstep API Response Error", - fmt.Sprintf("Request %q received status %d: %s", reqID, httpResp.StatusCode, utils.APIErrorMsg(httpResp.Body)), - ) - return - } - - instance := &v20231101.CollectionInstance{} - if err := json.NewDecoder(httpResp.Body).Decode(instance); err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to unmarshal collection instance %s/%s: %v", slug, id, err), - ) - return - } - - state, diags := fromAPI(ctx, slug, instance, req.Plan) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - - tflog.Trace(ctx, fmt.Sprintf("update collection instance %s/%s resource", slug, id)) - - resp.Diagnostics.Append(resp.State.Set(ctx, state)...) -} - -func (a *Resource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { - var state Model - - resp.Diagnostics.Append(req.State.Get(ctx, &state)...) - - if resp.Diagnostics.HasError() { - return - } - - slug := state.CollectionSlug.ValueString() - id := state.ID.ValueString() - - httpResp, err := a.client.DeleteCollectionInstance(ctx, slug, id, &v20231101.DeleteCollectionInstanceParams{}) - if err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to delete collection instance %s/%s: %v", slug, id, err), - ) - return - } - defer httpResp.Body.Close() - - if httpResp.StatusCode != http.StatusNoContent { - reqID := httpResp.Header.Get("X-Request-Id") - resp.Diagnostics.AddError( - "Smallstep API Response Error", - fmt.Sprintf("Request %q received status %d deleting collection instance %s/%s: %s", reqID, httpResp.StatusCode, slug, id, utils.APIErrorMsg(httpResp.Body)), - ) - return - } -} - -func (r *Resource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { - parts := strings.Split(req.ID, "/") - if len(parts) != 2 { - resp.Diagnostics.AddError( - "Invalid import ID", - `Import ID must be "<collection_slug>/<id>"`, - ) - return - } - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("collection_slug"), parts[0])...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("id"), parts[1])...) -} diff --git a/internal/provider/collection_instance/resource_test.go b/internal/provider/collection_instance/resource_test.go deleted file mode 100644 index e977021f3806b079dec4a700f26dfe2cb793577a..0000000000000000000000000000000000000000 --- a/internal/provider/collection_instance/resource_test.go +++ /dev/null @@ -1,149 +0,0 @@ -package collection_instance - -import ( - "fmt" - "os" - "regexp" - "testing" - - "github.com/hashicorp/terraform-plugin-framework/datasource" - "github.com/hashicorp/terraform-plugin-framework/providerserver" - "github.com/hashicorp/terraform-plugin-framework/resource" - "github.com/hashicorp/terraform-plugin-go/tfprotov6" - helper "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/hashicorp/terraform-plugin-testing/plancheck" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/authority" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/collection" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/device_collection" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/utils" - "github.com/smallstep/terraform-provider-smallstep/internal/testprovider" -) - -func TestMain(m *testing.M) { - helper.TestMain(m) -} - -var provider = &testprovider.SmallstepTestProvider{ - ResourceFactories: []func() resource.Resource{ - collection.NewResource, - device_collection.NewResource, - NewResource, - }, - DataSourceFactories: []func() datasource.DataSource{ - NewDataSource, - authority.NewDataSource, - }, -} - -var providerFactories = map[string]func() (tfprotov6.ProviderServer, error){ - "smallstep": providerserver.NewProtocol6WithError(provider), -} - -func TestAccDeviceInstance(t *testing.T) { - slug := utils.Slug(t) - caDomain := os.Getenv("SMALLSTEP_CA_DOMAIN") - if caDomain == "" { - caDomain = ".step-e2e.ca.smallstep.com" - } - agentsDomain := "agents" + caDomain - config1 := fmt.Sprintf(` -data "smallstep_authority" "agents" { - domain = %q -} - -resource "smallstep_device_collection" "ec2_east" { - slug = %q - display_name = "EC2 East" - authority_id = data.smallstep_authority.agents.id - device_type = "aws-vm" - aws_vm = { - accounts = ["0123456789"] - } -} - -resource "smallstep_collection_instance" "thing1" { - depends_on = [smallstep_device_collection.ec2_east] - collection_slug = smallstep_device_collection.ec2_east.slug - id = "i-%s" - data = "{\"name\":\"thing1\"}" -}`, agentsDomain, slug, slug) - - helper.Test(t, helper.TestCase{ - ProtoV6ProviderFactories: providerFactories, - Steps: []helper.TestStep{ - { - Config: config1, - Check: helper.ComposeAggregateTestCheckFunc( - helper.TestCheckResourceAttr("smallstep_collection_instance.thing1", "id", "i-"+slug), - ), - }, - }, - }) -} - -func TestAccCollectionInstanceResource(t *testing.T) { - t.Parallel() - - slug := utils.Slug(t) - config := fmt.Sprintf(` -resource "smallstep_collection" "things" { - slug = %q -} - -resource "smallstep_collection_instance" "thing1" { - collection_slug = %q - id = %q - data = "{\"name\":\"thing1\"}" - depends_on = [smallstep_collection.things] -}`, slug, slug, slug) - - updated := fmt.Sprintf(` -resource "smallstep_collection" "things" { - slug = %q -} - -resource "smallstep_collection_instance" "thing1" { - collection_slug = %q - id = %q - data = "{\"name\":\"thing2\"}" - depends_on = [smallstep_collection.things] -}`, slug, slug, slug) - - helper.Test(t, helper.TestCase{ - ProtoV6ProviderFactories: providerFactories, - Steps: []helper.TestStep{ - { - Config: config, - Check: helper.ComposeAggregateTestCheckFunc( - helper.TestCheckResourceAttr("smallstep_collection_instance.thing1", "collection_slug", slug), - helper.TestCheckResourceAttr("smallstep_collection_instance.thing1", "data", `{"name":"thing1"}`), - helper.TestMatchResourceAttr("smallstep_collection_instance.thing1", "created_at", regexp.MustCompile(`^20\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ`)), - helper.TestMatchResourceAttr("smallstep_collection_instance.thing1", "updated_at", regexp.MustCompile(`^20\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ`)), - ), - }, - { - Config: updated, - Check: helper.ComposeAggregateTestCheckFunc( - helper.TestCheckResourceAttr("smallstep_collection_instance.thing1", "collection_slug", slug), - helper.TestCheckResourceAttr("smallstep_collection_instance.thing1", "data", `{"name":"thing2"}`), - helper.TestMatchResourceAttr("smallstep_collection_instance.thing1", "created_at", regexp.MustCompile(`^20\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ`)), - helper.TestMatchResourceAttr("smallstep_collection_instance.thing1", "updated_at", regexp.MustCompile(`^20\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ`)), - ), - ConfigPlanChecks: helper.ConfigPlanChecks{ - PreApply: []plancheck.PlanCheck{ - plancheck.ExpectResourceAction("smallstep_collection_instance.thing1", plancheck.ResourceActionUpdate), - }, - }, - }, - { - ResourceName: "smallstep_collection_instance.thing1", - ImportState: true, - ImportStateId: fmt.Sprintf("%s/%s", slug, slug), - // This only succeeds because the data JSON is simple enough to - // have the same serialization every time. Change to `false` to - // test more complex JSON. - ImportStateVerify: true, - }, - }, - }) -} diff --git a/internal/provider/device_collection/model.go b/internal/provider/device_collection/model.go deleted file mode 100644 index b12809876c5fb4c0d45fc9e06c85e98f8555e491..0000000000000000000000000000000000000000 --- a/internal/provider/device_collection/model.go +++ /dev/null @@ -1,289 +0,0 @@ -package device_collection - -import ( - "context" - "fmt" - - "github.com/hashicorp/terraform-plugin-framework/attr" - "github.com/hashicorp/terraform-plugin-framework/diag" - "github.com/hashicorp/terraform-plugin-framework/path" - "github.com/hashicorp/terraform-plugin-framework/types" - v20231101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20231101" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/utils" -) - -const collectionTypeName = "smallstep_device_collection" - -type Model struct { - Slug types.String `tfsdk:"slug"` - AuthorityID types.String `tfsdk:"authority_id"` - DisplayName types.String `tfsdk:"display_name"` - DeviceType types.String `tfsdk:"device_type"` - AWSDevice *AWSDevice `tfsdk:"aws_vm"` - GCPDevice *GCPDevice `tfsdk:"gcp_vm"` - AzureDevice *AzureDevice `tfsdk:"azure_vm"` - TPMDevice *TPMDevice `tfsdk:"tpm"` -} - -type AWSDevice struct { - Accounts types.Set `tfsdk:"accounts"` - DisableCustomSANs types.Bool `tfsdk:"disable_custom_sans"` -} - -type GCPDevice struct { - ServiceAccounts types.Set `tfsdk:"service_accounts"` - ProjectIDs types.Set `tfsdk:"project_ids"` - DisableCustomSANs types.Bool `tfsdk:"disable_custom_sans"` -} - -type AzureDevice struct { - TenantID types.String `tfsdk:"tenant_id"` - ResourceGroups types.Set `tfsdk:"resource_groups"` - DisableCustomSANs types.Bool `tfsdk:"disable_custom_sans"` - Audience types.String `tfsdk:"audience"` -} - -type TPMDevice struct { - AttestorIntermediates types.String `tfsdk:"attestor_intermediates"` - AttestorRoots types.String `tfsdk:"attestor_roots"` - ForceCN types.Bool `tfsdk:"force_cn"` - RequireEAB types.Bool `tfsdk:"require_eab"` -} - -func fromAPI(ctx context.Context, collection *v20231101.DeviceCollection, state utils.AttributeGetter) (*Model, diag.Diagnostics) { - var diags diag.Diagnostics - - model := &Model{ - Slug: types.StringValue(collection.Slug), - DisplayName: types.StringValue(collection.DisplayName), - DeviceType: types.StringValue(string(collection.DeviceType)), - AuthorityID: types.StringValue(collection.AuthorityID), - } - - switch collection.DeviceType { - case v20231101.DeviceCollectionDeviceTypeAwsVm: - aws, err := collection.DeviceTypeConfiguration.AsAwsVM() - if err != nil { - diags.AddError("Read AWS Device Configuration", err.Error()) - return nil, diags - } - - disableCustomSANs, d := utils.ToOptionalBool(ctx, aws.DisableCustomSANs, state, path.Root("aws_vm").AtName("disable_custom_sans")) - diags.Append(d...) - if diags.HasError() { - return nil, diags - } - - var accounts []attr.Value - for _, account := range aws.Accounts { - accounts = append(accounts, types.StringValue(account)) - } - accountsSet, diags := types.SetValue(types.StringType, accounts) - if diags.HasError() { - return nil, diags - } - - model.AWSDevice = &AWSDevice{ - Accounts: accountsSet, - DisableCustomSANs: disableCustomSANs, - } - case v20231101.DeviceCollectionDeviceTypeAzureVm: - azure, err := collection.DeviceTypeConfiguration.AsAzureVM() - if err != nil { - diags.AddError("Read Azure Device Configuration", err.Error()) - return nil, diags - } - - disableCustomSANs, d := utils.ToOptionalBool(ctx, azure.DisableCustomSANs, state, path.Root("azure_vm").AtName("disable_custom_sans")) - diags.Append(d...) - if diags.HasError() { - return nil, diags - } - - var resourceGroups []attr.Value - for _, rg := range azure.ResourceGroups { - resourceGroups = append(resourceGroups, types.StringValue(rg)) - } - resourceGroupsSet, diags := types.SetValue(types.StringType, resourceGroups) - if diags.HasError() { - return nil, diags - } - - audience, d := utils.ToOptionalString(ctx, azure.Audience, state, path.Root("azure_vm").AtName("audience")) - diags.Append(d...) - if diags.HasError() { - return nil, diags - } - - model.AzureDevice = &AzureDevice{ - TenantID: types.StringValue(azure.TenantID), - ResourceGroups: resourceGroupsSet, - DisableCustomSANs: disableCustomSANs, - Audience: audience, - } - case v20231101.DeviceCollectionDeviceTypeGcpVm: - gcp, err := collection.DeviceTypeConfiguration.AsGcpVM() - if err != nil { - diags.AddError("Read GCP Device Configuration", err.Error()) - return nil, diags - } - - disableCustomSANs, d := utils.ToOptionalBool(ctx, gcp.DisableCustomSANs, state, path.Root("gcp_vm").AtName("disable_custom_sans")) - diags.Append(d...) - if diags.HasError() { - return nil, diags - } - - serviceAccounts, d := utils.ToOptionalSet(ctx, gcp.ServiceAccounts, state, path.Root("gcp_vm").AtName("service_accounts")) - diags.Append(d...) - if diags.HasError() { - return nil, diags - } - - projectIDs, d := utils.ToOptionalSet(ctx, gcp.ProjectIDs, state, path.Root("gcp_vm").AtName("project_ids")) - diags.Append(d...) - if diags.HasError() { - return nil, diags - } - - model.GCPDevice = &GCPDevice{ - DisableCustomSANs: disableCustomSANs, - ServiceAccounts: serviceAccounts, - ProjectIDs: projectIDs, - } - case v20231101.DeviceCollectionDeviceTypeTpm: - tpm, err := collection.DeviceTypeConfiguration.AsTpm() - if err != nil { - diags.AddError("Read TPM Device Configuration", err.Error()) - return nil, diags - } - - forceCN, d := utils.ToOptionalBool(ctx, tpm.ForceCN, state, path.Root("tpm").AtName("force_cn")) - diags.Append(d...) - if diags.HasError() { - return nil, diags - } - - requireEAB, d := utils.ToOptionalBool(ctx, tpm.RequireEAB, state, path.Root("tpm").AtName("require_eab")) - diags.Append(d...) - if diags.HasError() { - return nil, diags - } - - attestorRoots, d := utils.ToOptionalString(ctx, tpm.AttestorRoots, state, path.Root("tpm").AtName("attestor_roots")) - diags.Append(d...) - if diags.HasError() { - return nil, diags - } - - attestorIntermediates, d := utils.ToOptionalString(ctx, tpm.AttestorIntermediates, state, path.Root("tpm").AtName("attestor_intermediates")) - diags.Append(d...) - if diags.HasError() { - return nil, diags - } - - model.TPMDevice = &TPMDevice{ - AttestorRoots: attestorRoots, - AttestorIntermediates: attestorIntermediates, - RequireEAB: requireEAB, - ForceCN: forceCN, - } - } - - return model, diags -} - -func toAPI(ctx context.Context, model *Model) (*v20231101.DeviceCollection, diag.Diagnostics) { - var diags diag.Diagnostics - - dc := &v20231101.DeviceCollection{ - Slug: model.Slug.ValueString(), - DisplayName: model.DisplayName.ValueString(), - DeviceType: v20231101.DeviceCollectionDeviceType(model.DeviceType.ValueString()), - AuthorityID: model.AuthorityID.ValueString(), - } - - switch dc.DeviceType { - case v20231101.DeviceCollectionDeviceTypeAwsVm: - if model.AWSDevice == nil { - diags.AddError("AWS Device", "aws_vm is required with device type aws-vm") - return nil, diags - } - aws := v20231101.AwsVM{ - Accounts: []string{}, - DisableCustomSANs: model.AWSDevice.DisableCustomSANs.ValueBoolPointer(), - } - d := model.AWSDevice.Accounts.ElementsAs(ctx, &aws.Accounts, false) - diags.Append(d...) - - if err := dc.DeviceTypeConfiguration.FromAwsVM(aws); err != nil { - diags.AddError("AWS VM", err.Error()) - return nil, diags - } - case v20231101.DeviceCollectionDeviceTypeAzureVm: - if model.AzureDevice == nil { - diags.AddError("Azure Device", "azure_vm is required with device type azure-vm") - return nil, diags - } - azure := v20231101.AzureVM{ - TenantID: model.AzureDevice.TenantID.ValueString(), - ResourceGroups: []string{}, - DisableCustomSANs: model.AzureDevice.DisableCustomSANs.ValueBoolPointer(), - Audience: model.AzureDevice.Audience.ValueStringPointer(), - } - d := model.AzureDevice.ResourceGroups.ElementsAs(ctx, &azure.ResourceGroups, false) - diags.Append(d...) - - if err := dc.DeviceTypeConfiguration.FromAzureVM(azure); err != nil { - diags.AddError("Azure VM", err.Error()) - return nil, diags - } - case v20231101.DeviceCollectionDeviceTypeGcpVm: - if model.GCPDevice == nil { - diags.AddError("GCP Device", "gcp_vm is required with device type gcp-vm") - return nil, diags - } - gcp := v20231101.GcpVM{ - DisableCustomSANs: model.GCPDevice.DisableCustomSANs.ValueBoolPointer(), - ProjectIDs: nil, - ServiceAccounts: nil, - } - if !model.GCPDevice.ServiceAccounts.IsNull() { - d := model.GCPDevice.ServiceAccounts.ElementsAs(ctx, &gcp.ServiceAccounts, false) - diags.Append(d...) - if diags.HasError() { - return nil, diags - } - } - if !model.GCPDevice.ProjectIDs.IsNull() { - d := model.GCPDevice.ProjectIDs.ElementsAs(ctx, &gcp.ProjectIDs, false) - diags.Append(d...) - if diags.HasError() { - return nil, diags - } - } - if err := dc.DeviceTypeConfiguration.FromGcpVM(gcp); err != nil { - diags.AddError("GCP VM", err.Error()) - return nil, diags - } - case v20231101.DeviceCollectionDeviceTypeTpm: - if model.TPMDevice == nil { - diags.AddError("TPM Device", "tpm block is required with device type tpm") - } - tpm := v20231101.Tpm{ - AttestorRoots: model.TPMDevice.AttestorRoots.ValueStringPointer(), - AttestorIntermediates: model.TPMDevice.AttestorIntermediates.ValueStringPointer(), - ForceCN: model.TPMDevice.ForceCN.ValueBoolPointer(), - RequireEAB: model.TPMDevice.RequireEAB.ValueBoolPointer(), - } - if err := dc.DeviceTypeConfiguration.FromTpm(tpm); err != nil { - diags.AddError("TPM", err.Error()) - return nil, diags - } - default: - diags.AddError("Device Type", fmt.Sprintf("Unsupported device collection type %q", dc.DeviceType)) - return nil, diags - } - - return dc, diags -} diff --git a/internal/provider/device_collection/resource.go b/internal/provider/device_collection/resource.go deleted file mode 100644 index 1b74b3f8df15a395a7ee8a2986eaea12b69f00e1..0000000000000000000000000000000000000000 --- a/internal/provider/device_collection/resource.go +++ /dev/null @@ -1,420 +0,0 @@ -package device_collection - -import ( - "context" - "encoding/json" - "fmt" - "net/http" - - "github.com/hashicorp/terraform-plugin-framework/path" - "github.com/hashicorp/terraform-plugin-framework/resource" - "github.com/hashicorp/terraform-plugin-framework/resource/schema" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-plugin-log/tflog" - v20231101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20231101" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/utils" -) - -var _ resource.Resource = (*Resource)(nil) - -func NewResource() resource.Resource { - return &Resource{} -} - -// Resource defines the resource implementation. -type Resource struct { - client *v20231101.Client -} - -func (r *Resource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = collectionTypeName -} - -// Configure adds the Smallstep API client to the resource. -func (r *Resource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { - // Prevent panic if the provider has not been configured. - if req.ProviderData == nil { - return - } - - client, ok := req.ProviderData.(*v20231101.Client) - - if !ok { - resp.Diagnostics.AddError( - "Get Smallstep API client from provider", - fmt.Sprintf("Expected *v20231101.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData), - ) - return - } - - r.client = client -} - -func (r *Resource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { - state := &Model{} - - resp.Diagnostics.Append(req.State.Get(ctx, state)...) - - if resp.Diagnostics.HasError() { - return - } - - httpResp, err := r.client.GetDeviceCollection(ctx, state.Slug.ValueString(), &v20231101.GetDeviceCollectionParams{}) - if err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to read device-collection %s: %v", state.Slug.String(), err), - ) - return - } - defer httpResp.Body.Close() - - if httpResp.StatusCode == http.StatusNotFound { - resp.State.RemoveResource(ctx) - return - } - - if httpResp.StatusCode != http.StatusOK { - reqID := httpResp.Header.Get("X-Request-Id") - resp.Diagnostics.AddError( - "Smallstep API Response Error", - fmt.Sprintf("Request %q received status %d reading device-collection %s: %s", reqID, httpResp.StatusCode, state.Slug.String(), utils.APIErrorMsg(httpResp.Body)), - ) - return - } - - collection := &v20231101.DeviceCollection{} - if err := json.NewDecoder(httpResp.Body).Decode(collection); err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to unmarshal device-collection %s: %v", state.Slug.String(), err), - ) - return - } - - remote, d := fromAPI(ctx, collection, req.State) - resp.Diagnostics.Append(d...) - if resp.Diagnostics.HasError() { - return - } - - tflog.Trace(ctx, fmt.Sprintf("read device-collection %q resource", collection.Slug)) - - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("slug"), remote.Slug)...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("display_name"), remote.DisplayName)...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("authority_id"), remote.AuthorityID)...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("device_type"), remote.DeviceType)...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("aws_vm"), remote.AWSDevice)...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("azure_vm"), state.AzureDevice)...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("gcp_vm"), remote.GCPDevice)...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("tpm"), state.TPMDevice)...) -} - -func (r *Resource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { - component, props, err := utils.Describe("deviceCollection") - if err != nil { - resp.Diagnostics.AddError( - "Parse Smallstep OpenAPI spec", - err.Error(), - ) - return - } - - aws, awsProps, err := utils.Describe("awsVM") - if err != nil { - resp.Diagnostics.AddError( - "Parse Smallstep OpenAPI spec", - err.Error(), - ) - return - } - - gcp, gcpProps, err := utils.Describe("gcpVM") - if err != nil { - resp.Diagnostics.AddError( - "Parse Smallstep OpenAPI spec", - err.Error(), - ) - return - } - - azure, azureProps, err := utils.Describe("azureVM") - if err != nil { - resp.Diagnostics.AddError( - "Parse Smallstep OpenAPI spec", - err.Error(), - ) - return - } - - tpm, tpmProps, err := utils.Describe("tpm") - if err != nil { - resp.Diagnostics.AddError( - "Parse Smallstep OpenAPI spec", - err.Error(), - ) - return - } - - resp.Schema = schema.Schema{ - MarkdownDescription: component, - - Attributes: map[string]schema.Attribute{ - "slug": schema.StringAttribute{ - MarkdownDescription: props["slug"], - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, - "authority_id": schema.StringAttribute{ - MarkdownDescription: props["authorityID"], - Required: true, - }, - "display_name": schema.StringAttribute{ - MarkdownDescription: props["name"], - Required: true, - }, - "device_type": schema.StringAttribute{ - MarkdownDescription: props["deviceType"], - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, - "aws_vm": schema.SingleNestedAttribute{ - MarkdownDescription: aws, - Optional: true, - Attributes: map[string]schema.Attribute{ - "accounts": schema.SetAttribute{ - MarkdownDescription: awsProps["accounts"], - ElementType: types.StringType, - Required: true, - }, - "disable_custom_sans": schema.BoolAttribute{ - MarkdownDescription: awsProps["disableCustomSANs"], - Optional: true, - }, - }, - }, - "azure_vm": schema.SingleNestedAttribute{ - MarkdownDescription: azure, - Optional: true, - Attributes: map[string]schema.Attribute{ - "resource_groups": schema.SetAttribute{ - MarkdownDescription: azureProps["resourceGroups"], - ElementType: types.StringType, - Required: true, - }, - "disable_custom_sans": schema.BoolAttribute{ - MarkdownDescription: azureProps["disableCustomSANs"], - Optional: true, - }, - "tenant_id": schema.StringAttribute{ - MarkdownDescription: azureProps["tenantID"], - Required: true, - }, - "audience": schema.StringAttribute{ - MarkdownDescription: azureProps["audience"], - Optional: true, - }, - }, - }, - "gcp_vm": schema.SingleNestedAttribute{ - MarkdownDescription: gcp, - Optional: true, - Attributes: map[string]schema.Attribute{ - "service_accounts": schema.SetAttribute{ - MarkdownDescription: gcpProps["serviceAccounts"], - ElementType: types.StringType, - Optional: true, - }, - "project_ids": schema.SetAttribute{ - MarkdownDescription: gcpProps["projectIDs"], - ElementType: types.StringType, - Optional: true, - }, - "disable_custom_sans": schema.BoolAttribute{ - MarkdownDescription: gcpProps["disableCustomSANs"], - Optional: true, - }, - }, - }, - "tpm": schema.SingleNestedAttribute{ - MarkdownDescription: tpm, - Optional: true, - Attributes: map[string]schema.Attribute{ - "attestor_roots": schema.StringAttribute{ - MarkdownDescription: tpmProps["attestorRoots"], - Optional: true, - }, - "attestor_intermediates": schema.StringAttribute{ - MarkdownDescription: tpmProps["attestorIntermediates"], - Optional: true, - }, - "force_cn": schema.BoolAttribute{ - MarkdownDescription: tpmProps["forceCN"], - Optional: true, - }, - "require_eab": schema.BoolAttribute{ - MarkdownDescription: tpmProps["requireEAB"], - Optional: true, - }, - }, - }, - }, - } -} - -func (a *Resource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan Model - - resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) - - if resp.Diagnostics.HasError() { - return - } - - reqBody, d := toAPI(ctx, &plan) - resp.Diagnostics.Append(d...) - if resp.Diagnostics.HasError() { - return - } - - httpResp, err := a.client.PutDeviceCollection(ctx, reqBody.Slug, &v20231101.PutDeviceCollectionParams{}, *reqBody) - if err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to create device collection %q: %v", plan.Slug.String(), err), - ) - return - } - defer httpResp.Body.Close() - - if httpResp.StatusCode != http.StatusOK { - reqID := httpResp.Header.Get("X-Request-Id") - resp.Diagnostics.AddError( - "Smallstep API Response Error", - fmt.Sprintf("Request %q received status %d creating device collection %q: %s", reqID, httpResp.StatusCode, plan.Slug.String(), utils.APIErrorMsg(httpResp.Body)), - ) - return - } - - collection := &v20231101.DeviceCollection{} - if err := json.NewDecoder(httpResp.Body).Decode(collection); err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to unmarshal collection %q: %v", plan.Slug.ValueString(), err), - ) - return - } - - state, diags := fromAPI(ctx, collection, req.Plan) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - - tflog.Trace(ctx, fmt.Sprintf("create collection %q resource", plan.Slug.ValueString())) - - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("slug"), state.Slug)...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("display_name"), state.DisplayName)...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("authority_id"), state.AuthorityID)...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("device_type"), state.DeviceType)...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("aws_vm"), state.AWSDevice)...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("azure_vm"), state.AzureDevice)...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("gcp_vm"), state.GCPDevice)...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("tpm"), state.TPMDevice)...) -} - -func (r *Resource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { - var plan Model - - resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) - - if resp.Diagnostics.HasError() { - return - } - - reqBody, d := toAPI(ctx, &plan) - resp.Diagnostics.Append(d...) - if resp.Diagnostics.HasError() { - return - } - - httpResp, err := r.client.PutDeviceCollection(ctx, reqBody.Slug, &v20231101.PutDeviceCollectionParams{}, *reqBody) - if err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to create device collection %q: %v", plan.Slug.String(), err), - ) - return - } - defer httpResp.Body.Close() - - if httpResp.StatusCode != http.StatusOK { - reqID := httpResp.Header.Get("X-Request-Id") - resp.Diagnostics.AddError( - "Smallstep API Response Error", - fmt.Sprintf("Request %q received status %d creating device collection %q: %s", reqID, httpResp.StatusCode, plan.Slug.String(), utils.APIErrorMsg(httpResp.Body)), - ) - return - } - - collection := &v20231101.DeviceCollection{} - if err := json.NewDecoder(httpResp.Body).Decode(collection); err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to unmarshal collection %q: %v", plan.Slug.ValueString(), err), - ) - return - } - - state, diags := fromAPI(ctx, collection, req.Plan) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - - tflog.Trace(ctx, fmt.Sprintf("create collection %q resource", plan.Slug.ValueString())) - - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("slug"), state.Slug)...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("display_name"), state.DisplayName)...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("authority_id"), state.AuthorityID)...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("device_type"), state.DeviceType)...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("aws_vm"), state.AWSDevice)...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("azure_vm"), state.AzureDevice)...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("gcp_vm"), state.GCPDevice)...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("tpm"), state.TPMDevice)...) -} - -func (a *Resource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { - var plan Model - - resp.Diagnostics.Append(req.State.Get(ctx, &plan)...) - - if resp.Diagnostics.HasError() { - return - } - - httpResp, err := a.client.DeleteDeviceCollection(ctx, plan.Slug.ValueString(), &v20231101.DeleteDeviceCollectionParams{}) - if err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to delete device collection %q: %v", plan.Slug.String(), err), - ) - return - } - defer httpResp.Body.Close() - - if httpResp.StatusCode != http.StatusNoContent { - reqID := httpResp.Header.Get("X-Request-Id") - resp.Diagnostics.AddError( - "Smallstep API Response Error", - fmt.Sprintf("Request %q received status %d deleting device collection %q: %s", reqID, httpResp.StatusCode, plan.Slug.String(), utils.APIErrorMsg(httpResp.Body)), - ) - return - } -} diff --git a/internal/provider/device_collection/resource_test.go b/internal/provider/device_collection/resource_test.go deleted file mode 100644 index 08fe0732288c7fdfa9ed62250a8d53dc84fd0386..0000000000000000000000000000000000000000 --- a/internal/provider/device_collection/resource_test.go +++ /dev/null @@ -1,591 +0,0 @@ -package device_collection - -import ( - "fmt" - "testing" - - "github.com/hashicorp/terraform-plugin-framework/providerserver" - "github.com/hashicorp/terraform-plugin-framework/resource" - "github.com/hashicorp/terraform-plugin-go/tfprotov6" - helper "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/hashicorp/terraform-plugin-testing/plancheck" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/attestation_authority" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/authority" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/utils" - "github.com/smallstep/terraform-provider-smallstep/internal/testprovider" - "github.com/stretchr/testify/require" -) - -func TestMain(m *testing.M) { - helper.TestMain(m) -} - -var provider = &testprovider.SmallstepTestProvider{ - ResourceFactories: []func() resource.Resource{ - NewResource, - attestation_authority.NewResource, - authority.NewResource, - }, -} - -var providerFactories = map[string]func() (tfprotov6.ProviderServer, error){ - "smallstep": providerserver.NewProtocol6WithError(provider), -} - -func TestAccDeviceCollectionResource(t *testing.T) { - slug := utils.Slug(t) - awsRequired := fmt.Sprintf(` -resource "smallstep_authority" "agent" { - name = "Agent" - subdomain = "agent" - type = "devops" - admin_emails = ["andrew@smallstep.com"] -} - -resource "smallstep_device_collection" "aws_required_only" { - slug = %q - display_name = "EC2 West" - authority_id = smallstep_authority.agent.id - device_type = "aws-vm" - aws_vm = { - accounts = ["0123456789"] - } -}`, slug) - - updated := fmt.Sprintf(` -resource "smallstep_authority" "agent" { - name = "Agent" - subdomain = "agent" - type = "devops" - admin_emails = ["andrew@smallstep.com"] -} - -resource "smallstep_device_collection" "aws_required_only" { - slug = %q - display_name = "EC2 East" - authority_id = smallstep_authority.agent.id - device_type = "aws-vm" - aws_vm = { - accounts = ["0123456789"] - } -}`, slug) - - helper.Test(t, helper.TestCase{ - ProtoV6ProviderFactories: providerFactories, - Steps: []helper.TestStep{ - { - Config: awsRequired, - Check: helper.ComposeAggregateTestCheckFunc( - helper.TestCheckResourceAttr("smallstep_device_collection.aws_required_only", "slug", slug), - helper.TestCheckResourceAttr("smallstep_device_collection.aws_required_only", "display_name", "EC2 West"), - helper.TestCheckResourceAttr("smallstep_device_collection.aws_required_only", "aws_vm.accounts.0", "0123456789"), - helper.TestMatchResourceAttr("smallstep_device_collection.aws_required_only", "authority_id", utils.UUID), - ), - }, - { - Config: updated, - ConfigPlanChecks: helper.ConfigPlanChecks{ - PreApply: []plancheck.PlanCheck{ - plancheck.ExpectResourceAction("smallstep_device_collection.aws_required_only", plancheck.ResourceActionUpdate), - }, - }, - Check: helper.ComposeAggregateTestCheckFunc( - helper.TestCheckResourceAttr("smallstep_device_collection.aws_required_only", "slug", slug), - helper.TestCheckResourceAttr("smallstep_device_collection.aws_required_only", "display_name", "EC2 East"), - ), - }, - }, - }) - - slug = utils.Slug(t) - awsOptionalEmpty := fmt.Sprintf(` -resource "smallstep_authority" "aws" { - name = "AWS" - subdomain = "aws" - type = "devops" - admin_emails = ["andrew@smallstep.com"] -} - -resource "smallstep_device_collection" "aws_optional_empty" { - slug = %q - display_name = "EC2 West" - authority_id = smallstep_authority.aws.id - device_type = "aws-vm" - aws_vm = { - accounts = ["0123456789"] - disable_custom_sans = false - } -}`, slug) - - helper.Test(t, helper.TestCase{ - ProtoV6ProviderFactories: providerFactories, - Steps: []helper.TestStep{ - { - Config: awsOptionalEmpty, - Check: helper.ComposeAggregateTestCheckFunc( - helper.TestCheckResourceAttr("smallstep_device_collection.aws_optional_empty", "aws_vm.disable_custom_sans", "false"), - ), - }, - }, - }) - - slug = utils.Slug(t) - awsOptionalNonempty := fmt.Sprintf(` -resource "smallstep_authority" "aws" { - name = "AWS" - subdomain = "aws" - type = "devops" - admin_emails = ["andrew@smallstep.com"] -} - -resource "smallstep_device_collection" "aws_optional_nonempty" { - slug = %q - display_name = "EC2 West" - authority_id = smallstep_authority.aws.id - device_type = "aws-vm" - aws_vm = { - accounts = ["0123456789"] - disable_custom_sans = true - } -}`, slug) - - helper.Test(t, helper.TestCase{ - ProtoV6ProviderFactories: providerFactories, - Steps: []helper.TestStep{ - { - Config: awsOptionalNonempty, - Check: helper.ComposeAggregateTestCheckFunc( - helper.TestCheckResourceAttr("smallstep_device_collection.aws_optional_nonempty", "aws_vm.disable_custom_sans", "true"), - ), - }, - }, - }) - - slug = utils.Slug(t) - gcpRequired := fmt.Sprintf(` -resource "smallstep_authority" "gcp" { - name = "GCP" - subdomain = "gcp" - type = "devops" - admin_emails = ["andrew@smallstep.com"] -} - -resource "smallstep_device_collection" "gcp_required_only" { - slug = %q - display_name = "GCE" - authority_id = smallstep_authority.gcp.id - device_type = "gcp-vm" - gcp_vm = { - service_accounts = ["0123456789"] - project_ids = ["prod-1"] - } -}`, slug) - - updatedGCPRequired := fmt.Sprintf(` -resource "smallstep_authority" "gcp" { - name = "GCP" - subdomain = "gcp" - type = "devops" - admin_emails = ["andrew@smallstep.com"] -} - -resource "smallstep_device_collection" "gcp_required_only" { - slug = %q - display_name = "Google Compute Engine" - authority_id = smallstep_authority.gcp.id - device_type = "gcp-vm" - gcp_vm = { - service_accounts = ["0123456789"] - project_ids = ["prod-1"] - } -}`, slug) - - helper.Test(t, helper.TestCase{ - ProtoV6ProviderFactories: providerFactories, - Steps: []helper.TestStep{ - { - Config: gcpRequired, - Check: helper.ComposeAggregateTestCheckFunc( - helper.TestCheckResourceAttr("smallstep_device_collection.gcp_required_only", "slug", slug), - helper.TestCheckResourceAttr("smallstep_device_collection.gcp_required_only", "display_name", "GCE"), - helper.TestCheckResourceAttr("smallstep_device_collection.gcp_required_only", "gcp_vm.service_accounts.0", "0123456789"), - ), - }, - { - Config: updatedGCPRequired, - ConfigPlanChecks: helper.ConfigPlanChecks{ - PreApply: []plancheck.PlanCheck{ - plancheck.ExpectResourceAction("smallstep_device_collection.gcp_required_only", plancheck.ResourceActionUpdate), - }, - }, - Check: helper.ComposeAggregateTestCheckFunc( - helper.TestCheckResourceAttr("smallstep_device_collection.gcp_required_only", "slug", slug), - helper.TestCheckResourceAttr("smallstep_device_collection.gcp_required_only", "display_name", "Google Compute Engine"), - ), - }, - }, - }) - - slug = utils.Slug(t) - gcpOptionalEmpty := fmt.Sprintf(` -resource "smallstep_authority" "gcp" { - name = "GCP" - subdomain = "gcp2" - type = "devops" - admin_emails = ["andrew@smallstep.com"] -} - -resource "smallstep_device_collection" "gcp_optional_empty" { - slug = %q - display_name = "GCE" - authority_id = smallstep_authority.gcp.id - device_type = "gcp-vm" - gcp_vm = { - service_accounts = ["0123456789"] - disable_custom_sans = false - } -}`, slug) - - helper.Test(t, helper.TestCase{ - ProtoV6ProviderFactories: providerFactories, - Steps: []helper.TestStep{ - { - Config: gcpOptionalEmpty, - Check: helper.ComposeAggregateTestCheckFunc( - helper.TestCheckResourceAttr("smallstep_device_collection.gcp_optional_empty", "gcp_vm.disable_custom_sans", "false"), - ), - }, - }, - }) - - slug = utils.Slug(t) - gcpOptionalNonempty := fmt.Sprintf(` -resource "smallstep_authority" "gcp" { - name = "GCP" - subdomain = "gcp3" - type = "devops" - admin_emails = ["andrew@smallstep.com"] -} - -resource "smallstep_device_collection" "gcp_optional_nonempty" { - slug = %q - display_name = "GCE" - authority_id = smallstep_authority.gcp.id - device_type = "gcp-vm" - gcp_vm = { - project_ids = ["prod-123"] - disable_custom_sans = true - } -}`, slug) - - helper.Test(t, helper.TestCase{ - ProtoV6ProviderFactories: providerFactories, - Steps: []helper.TestStep{ - { - Config: gcpOptionalNonempty, - Check: helper.ComposeAggregateTestCheckFunc( - helper.TestCheckResourceAttr("smallstep_device_collection.gcp_optional_nonempty", "gcp_vm.disable_custom_sans", "true"), - ), - }, - }, - }) - - slug = utils.Slug(t) - azureRequired := fmt.Sprintf(` -resource "smallstep_authority" "azure" { - name = "Azure" - subdomain = "azure" - type = "devops" - admin_emails = ["andrew@smallstep.com"] -} - -resource "smallstep_device_collection" "azure_required_only" { - slug = %q - display_name = "Azure VMs" - authority_id = smallstep_authority.azure.id - device_type = "azure-vm" - azure_vm = { - resource_groups = ["0123456789"] - tenant_id = "7" - } -}`, slug) - - updatedAzureRequired := fmt.Sprintf(` -resource "smallstep_authority" "azure" { - name = "Azure" - subdomain = "azure" - type = "devops" - admin_emails = ["andrew@smallstep.com"] -} - -resource "smallstep_device_collection" "azure_required_only" { - slug = %q - display_name = "Azure Instances" - authority_id = smallstep_authority.azure.id - device_type = "azure-vm" - azure_vm = { - resource_groups = ["0123456789"] - tenant_id = "7" - } -}`, slug) - - helper.Test(t, helper.TestCase{ - ProtoV6ProviderFactories: providerFactories, - Steps: []helper.TestStep{ - { - Config: azureRequired, - Check: helper.ComposeAggregateTestCheckFunc( - helper.TestCheckResourceAttr("smallstep_device_collection.azure_required_only", "slug", slug), - helper.TestCheckResourceAttr("smallstep_device_collection.azure_required_only", "display_name", "Azure VMs"), - helper.TestCheckResourceAttr("smallstep_device_collection.azure_required_only", "azure_vm.tenant_id", "7"), - helper.TestCheckResourceAttr("smallstep_device_collection.azure_required_only", "azure_vm.resource_groups.0", "0123456789"), - ), - }, - { - Config: updatedAzureRequired, - ConfigPlanChecks: helper.ConfigPlanChecks{ - PreApply: []plancheck.PlanCheck{ - plancheck.ExpectResourceAction("smallstep_device_collection.azure_required_only", plancheck.ResourceActionUpdate), - }, - }, - Check: helper.ComposeAggregateTestCheckFunc( - helper.TestCheckResourceAttr("smallstep_device_collection.azure_required_only", "slug", slug), - helper.TestCheckResourceAttr("smallstep_device_collection.azure_required_only", "display_name", "Azure Instances"), - ), - }, - }, - }) - - slug = utils.Slug(t) - azureOptionalEmpty := fmt.Sprintf(` -resource "smallstep_authority" "azure" { - name = "Azure Agents" - subdomain = "azure" - type = "devops" - admin_emails = ["andrew@smallstep.com"] -} - -resource "smallstep_device_collection" "azure_optional_empty" { - slug = %q - display_name = "Azure VMs" - authority_id = smallstep_authority.azure.id - device_type = "azure-vm" - azure_vm = { - tenant_id = "7" - resource_groups = ["0123456789"] - disable_custom_sans = false - audience = "" - } -}`, slug) - - helper.Test(t, helper.TestCase{ - ProtoV6ProviderFactories: providerFactories, - Steps: []helper.TestStep{ - { - Config: azureOptionalEmpty, - Check: helper.ComposeAggregateTestCheckFunc( - helper.TestCheckResourceAttr("smallstep_device_collection.azure_optional_empty", "azure_vm.disable_custom_sans", "false"), - helper.TestCheckResourceAttr("smallstep_device_collection.azure_optional_empty", "azure_vm.audience", ""), - ), - }, - }, - }) - - slug = utils.Slug(t) - azureOptionalNonempty := fmt.Sprintf(` -resource "smallstep_authority" "azure" { - name = "Azure Agents" - subdomain = "azure2" - type = "devops" - admin_emails = ["andrew@smallstep.com"] -} - -resource "smallstep_device_collection" "azure_optional_nonempty" { - slug = %q - display_name = "Azure VMs" - authority_id = smallstep_authority.azure.id - device_type = "azure-vm" - azure_vm = { - tenant_id = "7" - resource_groups = ["0123456789"] - disable_custom_sans = true - audience = "example.com" - } -}`, slug) - - helper.Test(t, helper.TestCase{ - ProtoV6ProviderFactories: providerFactories, - Steps: []helper.TestStep{ - { - Config: azureOptionalNonempty, - Check: helper.ComposeAggregateTestCheckFunc( - helper.TestCheckResourceAttr("smallstep_device_collection.azure_optional_nonempty", "azure_vm.disable_custom_sans", "true"), - helper.TestCheckResourceAttr("smallstep_device_collection.azure_optional_nonempty", "azure_vm.audience", "example.com"), - ), - }, - }, - }) - - attestorRoot, attestorIntermediate := utils.CACerts(t) - slug = utils.Slug(t) - tpmRequired := fmt.Sprintf(` -resource "smallstep_attestation_authority" "attest_ca" { - name = %q - attestor_roots = %q -} - -resource "smallstep_authority" "linux_agents" { - name = "Linux Agents" - subdomain = "linux" - type = "devops" - admin_emails = ["andrew@smallstep.com"] -} - -resource "smallstep_device_collection" "tpm_required_only" { - slug = %q - display_name = "TPMs" - authority_id = smallstep_authority.linux_agents.id - device_type = "tpm" - tpm = {} - depends_on = [smallstep_attestation_authority.attest_ca] -}`, slug, attestorRoot, slug) - - tpmUpdated := fmt.Sprintf(` -resource "smallstep_attestation_authority" "attest_ca" { - name = %q - attestor_roots = %q -} - -resource "smallstep_authority" "linux_agents" { - name = "Linux Agents" - subdomain = "linux" - type = "devops" - admin_emails = ["andrew@smallstep.com"] -} - -resource "smallstep_device_collection" "tpm_required_only" { - slug = %q - display_name = "TPM Servers" - authority_id = smallstep_authority.linux_agents.id - device_type = "tpm" - tpm = { - require_eab = true - force_cn = true - } - depends_on = [smallstep_attestation_authority.attest_ca] -}`, slug, attestorRoot, slug) - - helper.Test(t, helper.TestCase{ - PreCheck: func() { - require.NoError(t, utils.SweepAttestationAuthorities()) - }, - ProtoV6ProviderFactories: providerFactories, - Steps: []helper.TestStep{ - { - Config: tpmRequired, - Check: helper.ComposeAggregateTestCheckFunc( - helper.TestCheckResourceAttr("smallstep_device_collection.tpm_required_only", "slug", slug), - helper.TestCheckResourceAttr("smallstep_device_collection.tpm_required_only", "display_name", "TPMs"), - ), - }, - { - Config: tpmUpdated, - ConfigPlanChecks: helper.ConfigPlanChecks{ - PreApply: []plancheck.PlanCheck{ - plancheck.ExpectResourceAction("smallstep_device_collection.tpm_required_only", plancheck.ResourceActionUpdate), - }, - }, - Check: helper.ComposeAggregateTestCheckFunc( - helper.TestCheckResourceAttr("smallstep_device_collection.tpm_required_only", "slug", slug), - helper.TestCheckResourceAttr("smallstep_device_collection.tpm_required_only", "display_name", "TPM Servers"), - ), - }, - }, - }) - - slug = utils.Slug(t) - tpmOptionalEmpty := fmt.Sprintf(` -resource "smallstep_attestation_authority" "attest_ca" { - name = %q - attestor_roots = %q -} - -resource "smallstep_authority" "linux_agents" { - name = "Linux Agents" - subdomain = "linux2" - type = "devops" - admin_emails = ["andrew@smallstep.com"] -} - -resource "smallstep_device_collection" "tpm_optional_empty" { - slug = %q - display_name = "TPM Servers" - authority_id = smallstep_authority.linux_agents.id - device_type = "tpm" - tpm = { - force_cn = false - require_eab = false - attestor_roots = "" - attestor_intermediates = "" - } - depends_on = [smallstep_attestation_authority.attest_ca] -}`, slug, attestorRoot, slug) - - helper.Test(t, helper.TestCase{ - PreCheck: func() { - require.NoError(t, utils.SweepAttestationAuthorities()) - }, - ProtoV6ProviderFactories: providerFactories, - Steps: []helper.TestStep{ - { - Config: tpmOptionalEmpty, - Check: helper.ComposeAggregateTestCheckFunc( - helper.TestCheckResourceAttr("smallstep_device_collection.tpm_optional_empty", "tpm.force_cn", "false"), - helper.TestCheckResourceAttr("smallstep_device_collection.tpm_optional_empty", "tpm.require_eab", "false"), - helper.TestCheckResourceAttr("smallstep_device_collection.tpm_optional_empty", "tpm.attestor_roots", ""), - helper.TestCheckResourceAttr("smallstep_device_collection.tpm_optional_empty", "tpm.attestor_intermediates", ""), - ), - }, - }, - }) - - slug = utils.Slug(t) - tpmOptionalNonempty := fmt.Sprintf(` -resource "smallstep_authority" "linux_agents" { - name = "Linux Agents" - subdomain = "linux3" - type = "devops" - admin_emails = ["andrew@smallstep.com"] -} - -resource "smallstep_device_collection" "tpm_optional_nonempty" { - slug = %q - display_name = "TPM Servers" - authority_id = smallstep_authority.linux_agents.id - device_type = "tpm" - tpm = { - attestor_roots = %q - attestor_intermediates = %q - force_cn = true - require_eab = true - } - }`, slug, attestorRoot, attestorIntermediate) - - helper.Test(t, helper.TestCase{ - PreCheck: func() { - require.NoError(t, utils.SweepAttestationAuthorities()) - }, - ProtoV6ProviderFactories: providerFactories, - Steps: []helper.TestStep{ - { - Config: tpmOptionalNonempty, - Check: helper.ComposeAggregateTestCheckFunc( - helper.TestCheckResourceAttr("smallstep_device_collection.tpm_optional_nonempty", "tpm.force_cn", "true"), - helper.TestCheckResourceAttr("smallstep_device_collection.tpm_optional_nonempty", "tpm.require_eab", "true"), - helper.TestCheckResourceAttr("smallstep_device_collection.tpm_optional_nonempty", "tpm.attestor_roots", attestorRoot), - helper.TestCheckResourceAttr("smallstep_device_collection.tpm_optional_nonempty", "tpm.attestor_intermediates", attestorIntermediate), - ), - }, - }, - }) -} diff --git a/internal/provider/device_collection_account/data_source.go b/internal/provider/device_collection_account/data_source.go deleted file mode 100644 index d424dc9b7250709607a8943ae72509e79b93cf9d..0000000000000000000000000000000000000000 --- a/internal/provider/device_collection_account/data_source.go +++ /dev/null @@ -1,184 +0,0 @@ -package device_collection_account - -import ( - "context" - "encoding/json" - "fmt" - "net/http" - - "github.com/hashicorp/terraform-plugin-framework/datasource" - "github.com/hashicorp/terraform-plugin-framework/datasource/schema" - "github.com/hashicorp/terraform-plugin-framework/path" - v20231101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20231101" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/utils" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/workload" -) - -var _ datasource.DataSource = &DataSource{} - -type DataSource struct { - client *v20231101.Client -} - -func NewDataSource() datasource.DataSource { - return &DataSource{} -} - -func (d *DataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { - resp.TypeName = name -} - -// Configure adds the Smallstep API client to the data source. -func (d *DataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { - // Prevent panic if the provider has not been configured. - if req.ProviderData == nil { - return - } - - client, ok := req.ProviderData.(*v20231101.Client) - - if !ok { - resp.Diagnostics.AddError( - "Get Smallstep API client from provider", - fmt.Sprintf("Expected *v20231101.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData), - ) - return - } - - d.client = client -} - -func (d *DataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - dca, props, err := utils.Describe("deviceCollectionAccount") - if err != nil { - resp.Diagnostics.AddError( - "Parse Smallstep OpenAPI Schema", - err.Error(), - ) - return - } - - certInfo, err := workload.NewCertificateInfoDataSourceSchema() - if err != nil { - resp.Diagnostics.AddError( - "Parse Smallstep OpenAPI spec", - err.Error(), - ) - return - } - - certData, err := workload.NewCertificateDataDataSourceSchema() - if err != nil { - resp.Diagnostics.AddError( - "Parse Smallstep OpenAPI spec", - err.Error(), - ) - } - - keyInfo, err := workload.NewKeyInfoDataSourceSchema() - if err != nil { - resp.Diagnostics.AddError( - "Parse Smallstep OpenAPI spec", - err.Error(), - ) - return - } - - reloadInfo, err := workload.NewReloadInfoDataSourceSchema() - if err != nil { - resp.Diagnostics.AddError( - "Parse Smallstep OpenAPI spec", - err.Error(), - ) - return - } - - resp.Schema = schema.Schema{ - MarkdownDescription: dca, - - Attributes: map[string]schema.Attribute{ - "device_collection_slug": schema.StringAttribute{ - MarkdownDescription: props["deviceCollectionSlug"], - Required: true, - }, - "slug": schema.StringAttribute{ - MarkdownDescription: props["slug"], - Required: true, - }, - "account_id": schema.StringAttribute{ - MarkdownDescription: props["accountID"], - Optional: true, - }, - "authority_id": schema.StringAttribute{ - MarkdownDescription: props["authorityID"], - Optional: true, - }, - "display_name": schema.StringAttribute{ - MarkdownDescription: props["displayName"], - Optional: true, - }, - "certificate_info": certInfo, - "reload_info": reloadInfo, - "certificate_data": certData, - "key_info": keyInfo, - }, - } -} - -func (d *DataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { - var slug string - var dcSlug string - - ds := req.Config.GetAttribute(ctx, path.Root("slug"), &slug) - resp.Diagnostics.Append(ds...) - ds = req.Config.GetAttribute(ctx, path.Root("device_collection_slug"), &dcSlug) - resp.Diagnostics.Append(ds...) - if resp.Diagnostics.HasError() { - return - } - - httpResp, err := d.client.GetDeviceCollectionAccount(ctx, dcSlug, slug, &v20231101.GetDeviceCollectionAccountParams{}) - if err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to read device collection account %q: %v", slug, err), - ) - return - } - defer httpResp.Body.Close() - - switch httpResp.StatusCode { - case http.StatusOK: - break - case http.StatusNotFound: - resp.Diagnostics.AddError( - "Device Collection Account Not Found", - fmt.Sprintf("Device collection account %q data source not found", slug), - ) - return - default: - reqID := httpResp.Header.Get("X-Request-Id") - resp.Diagnostics.AddError( - "Smallstep API Response Error", - fmt.Sprintf("Request %q received status %d reading device collection account %q: %s", reqID, httpResp.StatusCode, slug, utils.APIErrorMsg(httpResp.Body)), - ) - return - } - - dca := &v20231101.DeviceCollectionAccount{} - if err := json.NewDecoder(httpResp.Body).Decode(dca); err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to unmarshal device collection account %s: %v", slug, err), - ) - return - } - - remote, ds := fromAPI(ctx, dca, dcSlug, req.Config) - resp.Diagnostics.Append(ds...) - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(resp.State.Set(ctx, &remote)...) -} diff --git a/internal/provider/device_collection_account/data_source_test.go b/internal/provider/device_collection_account/data_source_test.go deleted file mode 100644 index c61e5e54d1c9094a4cef7296101d2cbaf768a19b..0000000000000000000000000000000000000000 --- a/internal/provider/device_collection_account/data_source_test.go +++ /dev/null @@ -1,36 +0,0 @@ -package device_collection_account - -import ( - "fmt" - "testing" - - helper "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/utils" -) - -func TestAccDeviceCollectionAccountDataSource(t *testing.T) { - dca, dcSlug := utils.NewDeviceCollectionAccount(t) - - config := fmt.Sprintf(` -data "smallstep_device_collection_account" "tester" { - slug = %q - device_collection_slug = %q -} -`, dca.Slug, dcSlug) - - helper.Test(t, helper.TestCase{ - ProtoV6ProviderFactories: providerFactories, - Steps: []helper.TestStep{ - { - Config: config, - Check: helper.ComposeAggregateTestCheckFunc( - helper.TestCheckResourceAttr("data.smallstep_device_collection_account.tester", "slug", dca.Slug), - helper.TestCheckResourceAttr("data.smallstep_device_collection_account.tester", "account_id", dca.AccountID), - helper.TestCheckResourceAttr("data.smallstep_device_collection_account.tester", "device_collection_slug", dcSlug), - helper.TestCheckResourceAttr("data.smallstep_device_collection_account.tester", "display_name", dca.DisplayName), - helper.TestCheckResourceAttr("data.smallstep_device_collection_account.tester", "authority_id", dca.AuthorityID), - ), - }, - }, - }) -} diff --git a/internal/provider/device_collection_account/model.go b/internal/provider/device_collection_account/model.go deleted file mode 100644 index 8b290c904e3862a1eb7d6cd9412242ff7b3f65a8..0000000000000000000000000000000000000000 --- a/internal/provider/device_collection_account/model.go +++ /dev/null @@ -1,104 +0,0 @@ -package device_collection_account - -import ( - "context" - - "github.com/hashicorp/terraform-plugin-framework/diag" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-plugin-framework/types/basetypes" - v20231101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20231101" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/utils" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/workload" -) - -const name = "smallstep_device_collection_account" - -type Model struct { - Slug types.String `tfsdk:"slug"` - AccountID types.String `tfsdk:"account_id"` - DeviceCollectionSlug types.String `tfsdk:"device_collection_slug"` - AuthorityID types.String `tfsdk:"authority_id"` - DisplayName types.String `tfsdk:"display_name"` - CertificateInfo types.Object `tfsdk:"certificate_info"` - KeyInfo types.Object `tfsdk:"key_info"` - ReloadInfo types.Object `tfsdk:"reload_info"` - CertificateData types.Object `tfsdk:"certificate_data"` -} - -func toAPI(ctx context.Context, model *Model) (*v20231101.DeviceCollectionAccount, diag.Diagnostics) { - var diags diag.Diagnostics - - reloadInfo := &workload.ReloadInfoModel{} - ds := model.ReloadInfo.As(ctx, &reloadInfo, basetypes.ObjectAsOptions{ - UnhandledUnknownAsEmpty: true, - }) - diags.Append(ds...) - - certInfo := &workload.CertificateInfoModel{} - ds = model.CertificateInfo.As(ctx, &certInfo, basetypes.ObjectAsOptions{}) - diags.Append(ds...) - - keyInfo := &workload.KeyInfoModel{} - ds = model.KeyInfo.As(ctx, &keyInfo, basetypes.ObjectAsOptions{}) - diags.Append(ds...) - - dca := &v20231101.DeviceCollectionAccount{ - Slug: model.Slug.ValueString(), - AccountID: model.AccountID.ValueString(), - AuthorityID: model.AuthorityID.ValueString(), - DisplayName: model.DisplayName.ValueString(), - CertificateInfo: certInfo.ToAPI(), - KeyInfo: keyInfo.ToAPI(), - ReloadInfo: reloadInfo.ToAPI(), - } - - certDataModel := &workload.CertificateDataModel{} - diags = model.CertificateData.As(ctx, &certDataModel, basetypes.ObjectAsOptions{ - UnhandledUnknownAsEmpty: true, - }) - x509Fields, ds := certDataModel.ToAPI(ctx) - diags.Append(ds...) - err := dca.FromX509Fields(x509Fields) - if err != nil { - diags.AddError("Device Collection Account Certificate Data", err.Error()) - return nil, diags - } - - return dca, diags -} - -func fromAPI(ctx context.Context, dca *v20231101.DeviceCollectionAccount, dcSlug string, state utils.AttributeGetter) (*Model, diag.Diagnostics) { - var diags diag.Diagnostics - - model := &Model{ - Slug: types.StringValue(dca.Slug), - AccountID: types.StringValue(dca.AccountID), - DeviceCollectionSlug: types.StringValue(dcSlug), - DisplayName: types.StringValue(dca.DisplayName), - AuthorityID: types.StringValue(dca.AuthorityID), - } - - x509Fields, err := dca.AsX509Fields() - if err != nil { - diags.AddError("parse device collection account response", err.Error()) - return nil, diags - } - - certInfo, ds := workload.CertInfoFromAPI(ctx, dca.CertificateInfo, state) - diags.Append(ds...) - model.CertificateInfo = certInfo - - certData, ds := workload.CertDataFromAPI(ctx, x509Fields, state) - diags.Append(ds...) - model.CertificateData = certData - - keyInfo, ds := workload.KeyInfoFromAPI(ctx, dca.KeyInfo, state) - diags.Append(ds...) - model.KeyInfo = keyInfo - - reloadInfo, ds := workload.ReloadInfoFromAPI(ctx, dca.ReloadInfo, state) - diags.Append(ds...) - model.ReloadInfo = reloadInfo - - return model, diags -} diff --git a/internal/provider/device_collection_account/resource.go b/internal/provider/device_collection_account/resource.go deleted file mode 100644 index d2e7f0f2e9a514dc6bab6cdd747f7e7a1d6c15d1..0000000000000000000000000000000000000000 --- a/internal/provider/device_collection_account/resource.go +++ /dev/null @@ -1,332 +0,0 @@ -package device_collection_account - -import ( - "context" - "encoding/json" - "fmt" - "net/http" - "strings" - - "github.com/hashicorp/terraform-plugin-framework/path" - "github.com/hashicorp/terraform-plugin-framework/resource" - "github.com/hashicorp/terraform-plugin-framework/resource/schema" - v20231101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20231101" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/utils" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/workload" -) - -var _ resource.ResourceWithImportState = (*Resource)(nil) - -func NewResource() resource.Resource { - return &Resource{} -} - -// Resource defines the resource implementation. -type Resource struct { - client *v20231101.Client -} - -func (r *Resource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { - dca, props, err := utils.Describe("deviceCollectionAccount") - if err != nil { - resp.Diagnostics.AddError( - "Parse Smallstep OpenAPI Schema", - err.Error(), - ) - return - } - - certInfo, err := workload.NewCertificateInfoResourceSchema() - if err != nil { - resp.Diagnostics.AddError( - "Parse Smallstep OpenAPI spec", - err.Error(), - ) - return - } - - certData, err := workload.NewCertificateDataResourceSchema() - if err != nil { - resp.Diagnostics.AddError( - "Parse Smallstep OpenAPI spec", - err.Error(), - ) - } - - keyInfo, err := workload.NewKeyInfoResourceSchema() - if err != nil { - resp.Diagnostics.AddError( - "Parse Smallstep OpenAPI spec", - err.Error(), - ) - return - } - - reloadInfo, err := workload.NewReloadInfoResourceSchema() - if err != nil { - resp.Diagnostics.AddError( - "Parse Smallstep OpenAPI spec", - err.Error(), - ) - return - } - - resp.Schema = schema.Schema{ - MarkdownDescription: dca, - - Attributes: map[string]schema.Attribute{ - "account_id": schema.StringAttribute{ - MarkdownDescription: props["accountID"], - Required: true, - }, - "authority_id": schema.StringAttribute{ - MarkdownDescription: props["authorityID"], - Required: true, - }, - "display_name": schema.StringAttribute{ - MarkdownDescription: props["displayName"], - Required: true, - }, - "slug": schema.StringAttribute{ - MarkdownDescription: props["slug"], - Required: true, - }, - "device_collection_slug": schema.StringAttribute{ - MarkdownDescription: props["deviceCollectionSlug"], - Required: true, - }, - "certificate_info": certInfo, - "reload_info": reloadInfo, - "certificate_data": certData, - "key_info": keyInfo, - }, - } -} - -func (r *Resource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = name -} - -// Configure adds the Smallstep API client to the resource. -func (r *Resource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { - // Prevent panic if the provider has not been configured. - if req.ProviderData == nil { - return - } - - client, ok := req.ProviderData.(*v20231101.Client) - - if !ok { - resp.Diagnostics.AddError( - "Get Smallstep API client from provider", - fmt.Sprintf("Expected *v20231101.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData), - ) - return - } - - r.client = client -} - -func (r *Resource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { - state := &Model{} - - resp.Diagnostics.Append(req.State.Get(ctx, state)...) - if resp.Diagnostics.HasError() { - return - } - - dcSlug := state.DeviceCollectionSlug.ValueString() - slug := state.Slug.ValueString() - - httpResp, err := r.client.GetDeviceCollectionAccount(ctx, dcSlug, slug, &v20231101.GetDeviceCollectionAccountParams{}) - if err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to read device collection account %q: %v", slug, err), - ) - return - } - defer httpResp.Body.Close() - - if httpResp.StatusCode == http.StatusNotFound { - resp.State.RemoveResource(ctx) - return - } - if httpResp.StatusCode != http.StatusOK { - reqID := httpResp.Header.Get("X-Request-Id") - resp.Diagnostics.AddError( - "Smallstep API Response Error", - fmt.Sprintf("Request %q received status %d reading device collection account %s: %s", reqID, httpResp.StatusCode, slug, utils.APIErrorMsg(httpResp.Body)), - ) - return - } - - dca := &v20231101.DeviceCollectionAccount{} - if err := json.NewDecoder(httpResp.Body).Decode(dca); err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to unmarshal device collection account %s: %v", slug, err), - ) - return - } - - remote, d := fromAPI(ctx, dca, dcSlug, req.State) - resp.Diagnostics.Append(d...) - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(resp.State.Set(ctx, &remote)...) -} - -func (a *Resource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - plan := &Model{} - resp.Diagnostics.Append(req.Plan.Get(ctx, plan)...) - if resp.Diagnostics.HasError() { - return - } - - reqBody, diags := toAPI(ctx, plan) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - - dcSlug := plan.DeviceCollectionSlug.ValueString() - slug := plan.Slug.ValueString() - - httpResp, err := a.client.PutDeviceCollectionAccount(ctx, dcSlug, slug, &v20231101.PutDeviceCollectionAccountParams{}, *reqBody) - if err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to create device collection account: %v", err), - ) - return - } - defer httpResp.Body.Close() - - if httpResp.StatusCode != http.StatusOK { - reqID := httpResp.Header.Get("X-Request-Id") - resp.Diagnostics.AddError( - "Smallstep API Response Error", - fmt.Sprintf("Request %q received status %d creating device collection account: %s", reqID, httpResp.StatusCode, utils.APIErrorMsg(httpResp.Body)), - ) - return - } - - dca := &v20231101.DeviceCollectionAccount{} - if err := json.NewDecoder(httpResp.Body).Decode(dca); err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to unmarshal device collection account: %v", err), - ) - return - } - - model, diags := fromAPI(ctx, dca, dcSlug, req.Plan) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - - diags = resp.State.Set(ctx, model) - resp.Diagnostics.Append(diags...) -} - -func (r *Resource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { - plan := &Model{} - resp.Diagnostics.Append(req.Plan.Get(ctx, plan)...) - if resp.Diagnostics.HasError() { - return - } - - reqBody, diags := toAPI(ctx, plan) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - - dcSlug := plan.DeviceCollectionSlug.ValueString() - slug := plan.Slug.ValueString() - - httpResp, err := r.client.PutDeviceCollectionAccount(ctx, dcSlug, slug, &v20231101.PutDeviceCollectionAccountParams{}, *reqBody) - if err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to update device collection account: %v", err), - ) - return - } - defer httpResp.Body.Close() - - if httpResp.StatusCode != http.StatusOK { - reqID := httpResp.Header.Get("X-Request-Id") - resp.Diagnostics.AddError( - "Smallstep API Response Error", - fmt.Sprintf("Request %q received status %d creating device collection account: %s", reqID, httpResp.StatusCode, utils.APIErrorMsg(httpResp.Body)), - ) - return - } - - dca := &v20231101.DeviceCollectionAccount{} - if err := json.NewDecoder(httpResp.Body).Decode(dca); err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to unmarshal device collection account: %v", err), - ) - return - } - - model, diags := fromAPI(ctx, dca, dcSlug, req.Plan) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - - diags = resp.State.Set(ctx, model) - resp.Diagnostics.Append(diags...) -} - -func (r *Resource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { - state := &Model{} - diags := req.State.Get(ctx, state) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - - dcSlug := state.DeviceCollectionSlug.ValueString() - slug := state.Slug.ValueString() - - httpResp, err := r.client.DeleteDeviceCollectionAccount(ctx, dcSlug, slug, &v20231101.DeleteDeviceCollectionAccountParams{}) - if err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to delete device collection account: %v", err), - ) - return - } - defer httpResp.Body.Close() - - if httpResp.StatusCode != http.StatusNoContent { - reqID := httpResp.Header.Get("X-Request-Id") - resp.Diagnostics.AddError( - "Smallstep API Response Error", - fmt.Sprintf("Request %q received status %d deleting device collection account: %s", reqID, httpResp.StatusCode, utils.APIErrorMsg(httpResp.Body)), - ) - return - } -} - -func (r *Resource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { - parts := strings.Split(req.ID, "/") - if len(parts) != 2 { - resp.Diagnostics.AddError( - "Invalid import ID", - `Import ID must be "<device collection slug>/<slug>"`, - ) - return - } - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("device_collection_slug"), parts[0])...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("slug"), parts[1])...) -} diff --git a/internal/provider/device_collection_account/resource_test.go b/internal/provider/device_collection_account/resource_test.go deleted file mode 100644 index 090aecbc09907ac0da855e8ba86aa6c9d75e7077..0000000000000000000000000000000000000000 --- a/internal/provider/device_collection_account/resource_test.go +++ /dev/null @@ -1,125 +0,0 @@ -package device_collection_account - -import ( - "fmt" - "testing" - - "github.com/hashicorp/terraform-plugin-framework/datasource" - "github.com/hashicorp/terraform-plugin-framework/providerserver" - "github.com/hashicorp/terraform-plugin-framework/resource" - "github.com/hashicorp/terraform-plugin-go/tfprotov6" - helper "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/hashicorp/terraform-plugin-testing/plancheck" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/utils" - "github.com/smallstep/terraform-provider-smallstep/internal/testprovider" -) - -func TestMain(m *testing.M) { - helper.TestMain(m) -} - -var provider = &testprovider.SmallstepTestProvider{ - ResourceFactories: []func() resource.Resource{ - NewResource, - }, - DataSourceFactories: []func() datasource.DataSource{ - NewDataSource, - }, -} - -var providerFactories = map[string]func() (tfprotov6.ProviderServer, error){ - "smallstep": providerserver.NewProtocol6WithError(provider), -} - -func TestAccDeviceCollectionAccountResource(t *testing.T) { - authority := utils.NewAuthority(t) - dc := utils.NewTPMDeviceCollection(t, authority.Id) - account, _ := utils.NewAccount(t) - slug := utils.Slug(t) - - config := fmt.Sprintf(` -resource "smallstep_device_collection_account" "test" { - slug = %q - device_collection_slug = %q - account_id = %q - authority_id = %q - display_name = "Tester" - certificate_info = { - type = "X509" - } - key_info = { - type = "ECDSA_P256" - protection = "HARDWARE" - format = "DEFAULT" - } - certificate_data = { - common_name = { - device_metadata = "email" - } - sans = { - device_metadata = ["email"] - } - } -}`, slug, dc.Slug, *account.Id, authority.Id) - - config2 := fmt.Sprintf(` -resource "smallstep_device_collection_account" "test" { - slug = %q - device_collection_slug = %q - account_id = %q - authority_id = %q - display_name = "Tester 2" - certificate_info = { - type = "X509" - } - key_info = { - type = "ECDSA_P256" - protection = "HARDWARE" - format = "DEFAULT" - } - certificate_data = { - common_name = { - device_metadata = "email" - } - sans = { - device_metadata = ["email"] - } - } -}`, slug, dc.Slug, *account.Id, authority.Id) - - helper.Test(t, helper.TestCase{ - ProtoV6ProviderFactories: providerFactories, - Steps: []helper.TestStep{ - { - Config: config, - ConfigPlanChecks: helper.ConfigPlanChecks{ - PreApply: []plancheck.PlanCheck{ - plancheck.ExpectResourceAction("smallstep_device_collection_account.test", plancheck.ResourceActionCreate), - }, - }, - Check: helper.ComposeAggregateTestCheckFunc( - helper.TestCheckResourceAttr("smallstep_device_collection_account.test", "slug", slug), - helper.TestCheckResourceAttr("smallstep_device_collection_account.test", "display_name", "Tester"), - ), - }, - { - Config: config2, - ConfigPlanChecks: helper.ConfigPlanChecks{ - PreApply: []plancheck.PlanCheck{ - plancheck.ExpectResourceAction("smallstep_device_collection_account.test", plancheck.ResourceActionUpdate), - }, - }, - Check: helper.ComposeAggregateTestCheckFunc( - helper.TestCheckResourceAttr("smallstep_device_collection_account.test", "display_name", "Tester 2"), - ), - }, - { - ResourceName: "smallstep_device_collection_account.test", - ImportState: true, - ImportStateId: fmt.Sprintf("%s/%s", dc.Slug, slug), - ImportStateVerify: true, - ImportStateVerifyIdentifierAttribute: "slug", - }, - }, - }) -} diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 3b39ef298b89812da2d5a3486aa928c231c7f4dc..30a7e59deb8d5139fcb6c91ef3e92f2be322dc28 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -12,17 +12,10 @@ import ( "github.com/hashicorp/terraform-plugin-framework/provider/schema" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/types" - v20231101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20231101" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/account" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/attestation_authority" + v20250101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20250101" "github.com/smallstep/terraform-provider-smallstep/internal/provider/authority" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/collection" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/collection_instance" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/device_collection" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/device_collection_account" "github.com/smallstep/terraform-provider-smallstep/internal/provider/provisioner" "github.com/smallstep/terraform-provider-smallstep/internal/provider/webhook" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/workload" ) // Ensure SmallstepProvider satisfies various provider interfaces. @@ -155,7 +148,7 @@ func (p *SmallstepProvider) Configure(ctx context.Context, req provider.Configur token = data.BearerToken.ValueString() } - client, err := v20231101.NewClient(server, v20231101.WithRequestEditorFn(v20231101.RequestEditorFn(func(ctx context.Context, r *http.Request) error { + client, err := v20250101.NewClient(server, v20250101.WithRequestEditorFn(v20250101.RequestEditorFn(func(ctx context.Context, r *http.Request) error { r.Header.Set("X-Smallstep-Api-Version", "2023-11-01") r.Header.Set("Authorization", fmt.Sprintf("Bearer %s", token)) return nil @@ -173,14 +166,7 @@ func (p *SmallstepProvider) Resources(ctx context.Context) []func() resource.Res return []func() resource.Resource{ authority.NewResource, provisioner.NewResource, - collection.NewResource, - collection_instance.NewResource, - attestation_authority.NewResource, webhook.NewResource, - device_collection.NewResource, - workload.NewResource, - account.NewResource, - device_collection_account.NewResource, } } @@ -188,12 +174,7 @@ func (p *SmallstepProvider) DataSources(ctx context.Context) []func() datasource return []func() datasource.DataSource{ authority.NewDataSource, provisioner.NewDataSource, - collection.NewDataSource, - collection_instance.NewDataSource, - attestation_authority.NewDataSource, webhook.NewDataSource, - account.NewDataSource, - device_collection_account.NewDataSource, } } diff --git a/internal/provider/utils/testutils.go b/internal/provider/utils/testutils.go index 81ece0303975aa396dfd31fa3dd55657ffed10aa..8b4c035dc55e762a10e81b36b9ead756d53b8b32 100644 --- a/internal/provider/utils/testutils.go +++ b/internal/provider/utils/testutils.go @@ -7,14 +7,13 @@ import ( "errors" "fmt" "io" - "log" "net/http" "os" "regexp" "testing" "github.com/hashicorp/terraform-plugin-testing/helper/acctest" - v20231101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20231101" + v20250101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20250101" "github.com/stretchr/testify/require" "go.step.sm/crypto/jose" "go.step.sm/crypto/minica" @@ -24,7 +23,7 @@ import ( var UUID = regexp.MustCompile(`^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$`) -func SmallstepAPIClientFromEnv() (*v20231101.Client, error) { +func SmallstepAPIClientFromEnv() (*v20250101.Client, error) { token := os.Getenv("SMALLSTEP_API_TOKEN") if token == "" { return nil, errors.New("missing environment variable SMALLSTEP_API_TOKEN") @@ -34,7 +33,7 @@ func SmallstepAPIClientFromEnv() (*v20231101.Client, error) { return nil, errors.New("missing environment variable SMALLSTEP_API_URL") } - client, err := v20231101.NewClient(server, v20231101.WithRequestEditorFn(v20231101.RequestEditorFn(func(ctx context.Context, r *http.Request) error { + client, err := v20250101.NewClient(server, v20250101.WithRequestEditorFn(v20250101.RequestEditorFn(func(ctx context.Context, r *http.Request) error { r.Header.Set("X-Smallstep-Api-Version", "2023-11-01") r.Header.Set("Authorization", fmt.Sprintf("Bearer %s", token)) return nil @@ -45,19 +44,19 @@ func SmallstepAPIClientFromEnv() (*v20231101.Client, error) { return client, nil } -func NewAuthority(t *testing.T) *v20231101.Authority { +func NewAuthority(t *testing.T) *v20250101.Authority { client, err := SmallstepAPIClientFromEnv() if err != nil { t.Fatal(err) } slug := "tfprovider-" + acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum) - reqBody := v20231101.PostAuthoritiesJSONRequestBody{ + reqBody := v20250101.PostAuthoritiesJSONRequestBody{ Name: slug + " Authority", AdminEmails: []string{"eng@smallstep.com"}, Subdomain: slug, Type: "devops", } - resp, err := client.PostAuthorities(context.Background(), &v20231101.PostAuthoritiesParams{}, reqBody) + resp, err := client.PostAuthorities(context.Background(), &v20250101.PostAuthoritiesParams{}, reqBody) if err != nil { t.Fatal(err) } @@ -67,7 +66,7 @@ func NewAuthority(t *testing.T) *v20231101.Authority { t.Fatalf("Failed to create authority: %d: %s", resp.StatusCode, body) } - authority := &v20231101.Authority{} + authority := &v20250101.Authority{} err = json.NewDecoder(resp.Body).Decode(authority) if err != nil { t.Fatal(err) @@ -76,16 +75,16 @@ func NewAuthority(t *testing.T) *v20231101.Authority { return authority } -func NewOIDCProvisioner(t *testing.T, authorityID string) (*v20231101.Provisioner, *v20231101.OidcProvisioner) { +func NewOIDCProvisioner(t *testing.T, authorityID string) (*v20250101.Provisioner, *v20250101.OidcProvisioner) { client, err := SmallstepAPIClientFromEnv() if err != nil { t.Fatal(err) } - req := v20231101.Provisioner{ + req := v20250101.Provisioner{ Name: acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum), Type: "OIDC", } - oidc := v20231101.OidcProvisioner{ + oidc := v20250101.OidcProvisioner{ ClientID: acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum), ClientSecret: acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum), ConfigurationEndpoint: "https://accounts.google.com/.well-known/openid-configuration", @@ -93,7 +92,7 @@ func NewOIDCProvisioner(t *testing.T, authorityID string) (*v20231101.Provisione if err := req.FromOidcProvisioner(oidc); err != nil { t.Fatal(err) } - resp, err := client.PostAuthorityProvisioners(context.Background(), authorityID, &v20231101.PostAuthorityProvisionersParams{}, req) + resp, err := client.PostAuthorityProvisioners(context.Background(), authorityID, &v20250101.PostAuthorityProvisionersParams{}, req) if err != nil { t.Fatal(err) } @@ -103,7 +102,7 @@ func NewOIDCProvisioner(t *testing.T, authorityID string) (*v20231101.Provisione t.Fatalf("Failed to create provisioner: %d: %s", resp.StatusCode, body) } - provisioner := &v20231101.Provisioner{} + provisioner := &v20250101.Provisioner{} if err := json.NewDecoder(resp.Body).Decode(&provisioner); err != nil { t.Fatal(err) } @@ -138,7 +137,7 @@ func CACerts(t *testing.T) (string, string) { return string(pem.EncodeToMemory(root)), string(pem.EncodeToMemory(intermediate)) } -func NewWebhook(t *testing.T, provisionerID, authorityID string) *v20231101.ProvisionerWebhook { +func NewWebhook(t *testing.T, provisionerID, authorityID string) *v20250101.ProvisionerWebhook { client, err := SmallstepAPIClientFromEnv() if err != nil { t.Fatal(err) @@ -147,7 +146,7 @@ func NewWebhook(t *testing.T, provisionerID, authorityID string) *v20231101.Prov name, err := randutil.Alphanumeric(8) require.NoError(t, err) - req := v20231101.ProvisionerWebhook{ + req := v20250101.ProvisionerWebhook{ Name: name, Url: &url, Kind: "ENRICHING", @@ -155,7 +154,7 @@ func NewWebhook(t *testing.T, provisionerID, authorityID string) *v20231101.Prov ServerType: "EXTERNAL", } - resp, err := client.PostWebhooks(context.Background(), authorityID, provisionerID, &v20231101.PostWebhooksParams{}, req) + resp, err := client.PostWebhooks(context.Background(), authorityID, provisionerID, &v20250101.PostWebhooksParams{}, req) require.NoError(t, err) defer resp.Body.Close() body, err := io.ReadAll(resp.Body) @@ -163,257 +162,15 @@ func NewWebhook(t *testing.T, provisionerID, authorityID string) *v20231101.Prov require.Equal(t, http.StatusCreated, resp.StatusCode, "got %d: %s", resp.StatusCode, body) - wh := &v20231101.ProvisionerWebhook{} + wh := &v20250101.ProvisionerWebhook{} require.NoError(t, json.Unmarshal(body, wh)) wh.Secret = nil return wh } -func NewAccount(t *testing.T) (*v20231101.Account, *v20231101.WifiAccount) { - client, err := SmallstepAPIClientFromEnv() - require.NoError(t, err) - - req := v20231101.Account{ - Name: "WiFi", - Type: v20231101.Wifi, - } - ip := "1.2.3.4" - err = req.FromWifiAccount(v20231101.WifiAccount{ - Ssid: "CorpNet", - NetworkAccessServerIP: &ip, - }) - require.NoError(t, err) - - resp, err := client.PostAccounts(context.Background(), &v20231101.PostAccountsParams{}, req) - require.NoError(t, err) - defer resp.Body.Close() - body, err := io.ReadAll(resp.Body) - require.NoError(t, err) - - require.Equal(t, http.StatusCreated, resp.StatusCode, "got %d: %s", resp.StatusCode, body) - - account := &v20231101.Account{} - err = json.Unmarshal(body, account) - require.NoError(t, err) - - wifi, err := account.AsWifiAccount() - require.NoError(t, err) - - return account, &wifi -} - -func NewCollection(t *testing.T) *v20231101.Collection { - client, err := SmallstepAPIClientFromEnv() - require.NoError(t, err) - - slug := Slug(t) - displayName := "Collection " + slug - - req := v20231101.NewCollection{ - Slug: slug, - DisplayName: &displayName, - } - - resp, err := client.PostCollections(context.Background(), &v20231101.PostCollectionsParams{}, req) - require.NoError(t, err) - defer resp.Body.Close() - body, err := io.ReadAll(resp.Body) - require.NoError(t, err) - - require.Equal(t, http.StatusCreated, resp.StatusCode, "got %d: %s", resp.StatusCode, body) - - collection := &v20231101.Collection{} - err = json.Unmarshal(body, collection) - require.NoError(t, err) - - return collection -} - -func NewCollectionInstance(t *testing.T, slug string) *v20231101.CollectionInstance { - client, err := SmallstepAPIClientFromEnv() - require.NoError(t, err) - - id, err := randutil.Alphanumeric(8) - require.NoError(t, err) - - req := v20231101.PutCollectionInstanceJSONRequestBody{ - Data: map[string]string{"id": id}, - } - resp, err := client.PutCollectionInstance(context.Background(), slug, id, &v20231101.PutCollectionInstanceParams{}, req) - require.NoError(t, err) - defer resp.Body.Close() - body, err := io.ReadAll(resp.Body) - require.NoError(t, err) - - require.Equal(t, http.StatusOK, resp.StatusCode, "got %d: %s", resp.StatusCode, body) - - instance := &v20231101.CollectionInstance{} - err = json.Unmarshal(body, instance) - require.NoError(t, err) - - return instance -} - -func NewTPMDeviceCollection(t *testing.T, authorityID string) *v20231101.DeviceCollection { - client, err := SmallstepAPIClientFromEnv() - require.NoError(t, err) - - slug := Slug(t) - displayName := "Collection " + slug - - req := v20231101.DeviceCollection{ - Slug: slug, - DisplayName: displayName, - DeviceType: v20231101.DeviceCollectionDeviceTypeTpm, - AuthorityID: authorityID, - } - root, intermediate := CACerts(t) - req.DeviceTypeConfiguration.FromTpm(v20231101.Tpm{ - AttestorRoots: &root, - AttestorIntermediates: &intermediate, - }) - - resp, err := client.PutDeviceCollection(context.Background(), slug, &v20231101.PutDeviceCollectionParams{}, req) - require.NoError(t, err) - defer resp.Body.Close() - body, err := io.ReadAll(resp.Body) - require.NoError(t, err) - - require.Equal(t, http.StatusOK, resp.StatusCode, "got %d: %s", resp.StatusCode, body) - - dc := &v20231101.DeviceCollection{} - err = json.Unmarshal(body, dc) - require.NoError(t, err) - - return dc -} - -func NewDeviceCollectionAccount(t *testing.T) (*v20231101.DeviceCollectionAccount, string) { - client, err := SmallstepAPIClientFromEnv() - require.NoError(t, err) - - authority := NewAuthority(t) - dc := NewTPMDeviceCollection(t, authority.Id) - account, _ := NewAccount(t) - slug := Slug(t) - - req := v20231101.DeviceCollectionAccount{ - AuthorityID: authority.Id, - AccountID: *account.Id, - Slug: slug, - DisplayName: "tcacc " + slug, - CertificateInfo: &v20231101.EndpointCertificateInfo{ - Type: "X509", - }, - } - cn := &v20231101.CertificateField{} - cn.FromCertificateFieldStatic(v20231101.CertificateFieldStatic{Static: "testacc"}) - err = req.FromX509Fields(v20231101.X509Fields{ - CommonName: cn, - }) - require.NoError(t, err) - - resp, err := client.PutDeviceCollectionAccount(context.Background(), dc.Slug, slug, &v20231101.PutDeviceCollectionAccountParams{}, req) - require.NoError(t, err) - defer resp.Body.Close() - body, err := io.ReadAll(resp.Body) - require.NoError(t, err) - - require.Equal(t, http.StatusOK, resp.StatusCode, "got %d: %s", resp.StatusCode, body) - - dca := &v20231101.DeviceCollectionAccount{} - err = json.Unmarshal(body, dca) - require.NoError(t, err) - - return dca, dc.Slug -} - func Slug(t *testing.T) string { slug, err := randutil.String(10, "abcdefghijklmnopqrstuvwxyz0123456789") require.NoError(t, err) return "tfprovider" + slug } - -// There can only be 1 per team - don't try to create a new one if one exists -func FixAttestationAuthority(t *testing.T, catalog string) *v20231101.AttestationAuthority { - client, err := SmallstepAPIClientFromEnv() - require.NoError(t, err) - - resp, err := client.GetAttestationAuthorities(context.Background(), &v20231101.GetAttestationAuthoritiesParams{}) - require.NoError(t, err) - body, err := io.ReadAll(resp.Body) - require.NoError(t, err) - - require.Equal(t, http.StatusOK, resp.StatusCode, "list attestation authorities got %d: %s", resp.StatusCode, body) - - list := []*v20231101.AttestationAuthority{} - err = json.Unmarshal(body, &list) - require.NoError(t, err) - - if len(list) > 0 { - return list[0] - } - - root, intermediate := CACerts(t) - - req := v20231101.AttestationAuthority{ - Name: "tfprovider", - AttestorRoots: root, - AttestorIntermediates: &intermediate, - } - - resp, err = client.PostAttestationAuthorities(context.Background(), &v20231101.PostAttestationAuthoritiesParams{}, req) - require.NoError(t, err) - body, err = io.ReadAll(resp.Body) - require.NoError(t, err) - - require.Equal(t, http.StatusCreated, resp.StatusCode, "create attestation authority got %d: %s", resp.StatusCode, body) - - aa := &v20231101.AttestationAuthority{} - err = json.Unmarshal(body, aa) - require.NoError(t, err) - - return aa -} - -func SweepAttestationAuthorities() error { - client, err := SmallstepAPIClientFromEnv() - if err != nil { - return err - } - - resp, err := client.GetAttestationAuthorities(context.Background(), &v20231101.GetAttestationAuthoritiesParams{}) - if err != nil { - return err - } - body, err := io.ReadAll(resp.Body) - if err != nil { - return err - } - - if resp.StatusCode != http.StatusOK { - return fmt.Errorf("list attestation authorities got %d: %s", resp.StatusCode, body) - } - - list := []*v20231101.AttestationAuthority{} - if err := json.Unmarshal(body, &list); err != nil { - return err - } - - for _, aa := range list { - resp, err := client.DeleteAttestationAuthority(context.Background(), *aa.Id, &v20231101.DeleteAttestationAuthorityParams{}) - if err != nil { - return err - } - defer resp.Body.Close() - body, _ := io.ReadAll(resp.Body) - - if resp.StatusCode != http.StatusNoContent { - return fmt.Errorf("delete attestation authority %q got %d: %s", *aa.Id, resp.StatusCode, body) - } - log.Printf("Successfully swept attestation authority %s\n", *aa.Id) - } - - return nil -} diff --git a/internal/provider/utils/utils.go b/internal/provider/utils/utils.go index 4c29218f66a4806a0a5a98309fb149b386a2a8b0..12770aeb9ef57d75ec0029afb011a1e882ba80f1 100644 --- a/internal/provider/utils/utils.go +++ b/internal/provider/utils/utils.go @@ -5,7 +5,7 @@ import ( "fmt" "io" - v20231101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20231101" + v20250101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20250101" ) // APIErrorMsg attempts to parse .Message from the API JSON response. @@ -15,7 +15,7 @@ func APIErrorMsg(r io.Reader) string { if err != nil { return "Failed to read Smallstep API response" } - e := &v20231101.Error{} + e := &v20250101.Error{} if err := json.Unmarshal(body, e); err != nil { return string(body) } @@ -26,9 +26,7 @@ type dereferencable interface { string | bool | int | - []string | - v20231101.EndpointKeyInfoType | - v20231101.EndpointKeyInfoFormat + []string } // Deref gets the default value for a pointer type. This makes it easier to work @@ -60,8 +58,7 @@ func ToStringPointer[Out ~string](str *string) *Out { // OpenAPI spec. This ensures the terraform attribute documentation is kept in // sync with the API spec. func Describe(component string) (string, map[string]string, error) { - spec, err := v20231101.GetSwagger() - + spec, err := v20250101.GetSwagger() if err != nil { return "", nil, err } diff --git a/internal/provider/workload/data_source.go b/internal/provider/workload/data_source.go deleted file mode 100644 index be8952da5b26957dbae2cbf5736b9825ad5ea807..0000000000000000000000000000000000000000 --- a/internal/provider/workload/data_source.go +++ /dev/null @@ -1,249 +0,0 @@ -package workload - -import ( - "github.com/hashicorp/terraform-plugin-framework/datasource/schema" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/utils" -) - -func NewCertificateInfoDataSourceSchema() (schema.SingleNestedAttribute, error) { - certInfo, certInfoProps, err := utils.Describe("endpointCertificateInfo") - if err != nil { - return schema.SingleNestedAttribute{}, err - } - - out := schema.SingleNestedAttribute{ - Optional: true, - MarkdownDescription: certInfo, - Attributes: map[string]schema.Attribute{ - "type": schema.StringAttribute{ - MarkdownDescription: certInfoProps["type"], - Optional: true, - }, - "duration": schema.StringAttribute{ - MarkdownDescription: certInfoProps["duration"], - Optional: true, - }, - "crt_file": schema.StringAttribute{ - MarkdownDescription: certInfoProps["crtFile"], - Optional: true, - }, - "key_file": schema.StringAttribute{ - MarkdownDescription: certInfoProps["keyFile"], - Optional: true, - }, - "root_file": schema.StringAttribute{ - MarkdownDescription: certInfoProps["rootFile"], - Optional: true, - }, - "uid": schema.Int64Attribute{ - MarkdownDescription: certInfoProps["uid"], - Optional: true, - }, - "gid": schema.Int64Attribute{ - MarkdownDescription: certInfoProps["gid"], - Optional: true, - }, - "mode": schema.Int64Attribute{ - MarkdownDescription: certInfoProps["mode"], - Optional: true, - }, - }, - } - - return out, nil -} - -func NewCertificateDataDataSourceSchema() (schema.SingleNestedAttribute, error) { - certData, _, err := utils.Describe("x509Fields") - if err != nil { - return schema.SingleNestedAttribute{}, err - } - - out := schema.SingleNestedAttribute{ - Optional: true, - MarkdownDescription: certData, - Attributes: map[string]schema.Attribute{ - "common_name": schema.SingleNestedAttribute{ - Optional: true, - Attributes: map[string]schema.Attribute{ - "static": schema.StringAttribute{ - Optional: true, - }, - "device_metadata": schema.StringAttribute{ - Optional: true, - }, - }, - }, - "sans": schema.SingleNestedAttribute{ - Optional: true, - Attributes: map[string]schema.Attribute{ - "static": schema.ListAttribute{ - ElementType: types.StringType, - Optional: true, - }, - "device_metadata": schema.ListAttribute{ - ElementType: types.StringType, - Optional: true, - }, - }, - }, - "organization": schema.SingleNestedAttribute{ - Optional: true, - Attributes: map[string]schema.Attribute{ - "static": schema.ListAttribute{ - ElementType: types.StringType, - Optional: true, - }, - "device_metadata": schema.ListAttribute{ - ElementType: types.StringType, - Optional: true, - }, - }, - }, - "organizational_unit": schema.SingleNestedAttribute{ - Optional: true, - Attributes: map[string]schema.Attribute{ - "static": schema.ListAttribute{ - ElementType: types.StringType, - Optional: true, - }, - "device_metadata": schema.ListAttribute{ - ElementType: types.StringType, - Optional: true, - }, - }, - }, - "locality": schema.SingleNestedAttribute{ - Optional: true, - Attributes: map[string]schema.Attribute{ - "static": schema.ListAttribute{ - ElementType: types.StringType, - Optional: true, - }, - "device_metadata": schema.ListAttribute{ - ElementType: types.StringType, - Optional: true, - }, - }, - }, - "country": schema.SingleNestedAttribute{ - Optional: true, - Attributes: map[string]schema.Attribute{ - "static": schema.ListAttribute{ - ElementType: types.StringType, - Optional: true, - }, - "device_metadata": schema.ListAttribute{ - ElementType: types.StringType, - Optional: true, - }, - }, - }, - "province": schema.SingleNestedAttribute{ - Optional: true, - Attributes: map[string]schema.Attribute{ - "static": schema.ListAttribute{ - ElementType: types.StringType, - Optional: true, - }, - "device_metadata": schema.ListAttribute{ - ElementType: types.StringType, - Optional: true, - }, - }, - }, - "street_address": schema.SingleNestedAttribute{ - Optional: true, - Attributes: map[string]schema.Attribute{ - "static": schema.ListAttribute{ - ElementType: types.StringType, - Optional: true, - }, - "device_metadata": schema.ListAttribute{ - ElementType: types.StringType, - Optional: true, - }, - }, - }, - "postal_code": schema.SingleNestedAttribute{ - Optional: true, - Attributes: map[string]schema.Attribute{ - "static": schema.ListAttribute{ - ElementType: types.StringType, - Optional: true, - }, - "device_metadata": schema.ListAttribute{ - ElementType: types.StringType, - Optional: true, - }, - }, - }, - }, - } - return out, nil -} - -func NewKeyInfoDataSourceSchema() (schema.SingleNestedAttribute, error) { - keyInfo, keyInfoProps, err := utils.Describe("endpointKeyInfo") - if err != nil { - return schema.SingleNestedAttribute{}, err - } - - out := schema.SingleNestedAttribute{ - Optional: true, - MarkdownDescription: keyInfo, - Attributes: map[string]schema.Attribute{ - "type": schema.StringAttribute{ - Optional: true, - MarkdownDescription: keyInfoProps["type"], - }, - "format": schema.StringAttribute{ - Optional: true, - MarkdownDescription: keyInfoProps["format"], - }, - "pub_file": schema.StringAttribute{ - Optional: true, - MarkdownDescription: keyInfoProps["pubFile"], - }, - "protection": schema.StringAttribute{ - Optional: true, - MarkdownDescription: keyInfoProps["protection"], - }, - }, - } - - return out, nil -} - -func NewReloadInfoDataSourceSchema() (schema.SingleNestedAttribute, error) { - reloadInfo, reloadInfoProps, err := utils.Describe("endpointReloadInfo") - if err != nil { - return schema.SingleNestedAttribute{}, err - } - - out := schema.SingleNestedAttribute{ - Optional: true, - MarkdownDescription: reloadInfo, - Attributes: map[string]schema.Attribute{ - "method": schema.StringAttribute{ - Optional: true, - MarkdownDescription: reloadInfoProps["method"], - }, - "pid_file": schema.StringAttribute{ - Optional: true, - MarkdownDescription: reloadInfoProps["pidFile"], - }, - "signal": schema.Int64Attribute{ - Optional: true, - MarkdownDescription: reloadInfoProps["signal"], - }, - "unit_name": schema.StringAttribute{ - Optional: true, - MarkdownDescription: reloadInfoProps["unitName"], - }, - }, - } - - return out, nil -} diff --git a/internal/provider/workload/model.go b/internal/provider/workload/model.go deleted file mode 100644 index bc46a79a592aa627b2fd9b4eb23333478e946199..0000000000000000000000000000000000000000 --- a/internal/provider/workload/model.go +++ /dev/null @@ -1,491 +0,0 @@ -package workload - -import ( - "context" - - "github.com/hashicorp/terraform-plugin-framework/attr" - "github.com/hashicorp/terraform-plugin-framework/diag" - "github.com/hashicorp/terraform-plugin-framework/path" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-plugin-framework/types/basetypes" - v20231101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20231101" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/utils" -) - -const typeName = "smallstep_workload" - -type Model struct { - WorkloadType types.String `tfsdk:"workload_type"` - DisplayName types.String `tfsdk:"display_name"` - Slug types.String `tfsdk:"slug"` - DeviceCollectionSlug types.String `tfsdk:"device_collection_slug"` - AuthorityID types.String `tfsdk:"authority_id"` - CertificateInfo types.Object `tfsdk:"certificate_info"` - KeyInfo types.Object `tfsdk:"key_info"` - ReloadInfo types.Object `tfsdk:"reload_info"` - Hooks types.Object `tfsdk:"hooks"` - CertificateData types.Object `tfsdk:"certificate_data"` -} - -type CertificateField struct { - Static types.String `tfsdk:"static"` - DeviceMetadata types.String `tfsdk:"device_metadata"` -} - -var certificateFieldType = types.ObjectType{ - AttrTypes: map[string]attr.Type{ - "static": types.StringType, - "device_metadata": types.StringType, - }, -} - -type CertificateFieldList struct { - Static types.List `tfsdk:"static"` - DeviceMetadata types.List `tfsdk:"device_metadata"` -} - -var certificateFieldListType = types.ObjectType{ - AttrTypes: map[string]attr.Type{ - "static": types.ListType{ - ElemType: types.StringType, - }, - "device_metadata": types.ListType{ - ElemType: types.StringType, - }, - }, -} - -type CertificateDataModel struct { - CommonName types.Object `tfsdk:"common_name"` - SANs types.Object `tfsdk:"sans"` - Organization types.Object `tfsdk:"organization"` - OrganizationalUnit types.Object `tfsdk:"organizational_unit"` - Locality types.Object `tfsdk:"locality"` - Province types.Object `tfsdk:"province"` - StreetAddress types.Object `tfsdk:"street_address"` - PostalCode types.Object `tfsdk:"postal_code"` - Country types.Object `tfsdk:"country"` -} - -var certificateDataType = types.ObjectType{ - AttrTypes: map[string]attr.Type{ - "common_name": certificateFieldType, - "sans": certificateFieldListType, - "organization": certificateFieldListType, - "organizational_unit": certificateFieldListType, - "locality": certificateFieldListType, - "province": certificateFieldListType, - "street_address": certificateFieldListType, - "postal_code": certificateFieldListType, - "country": certificateFieldListType, - }, -} - -func (certDataModel CertificateDataModel) ToAPI(ctx context.Context) (v20231101.X509Fields, diag.Diagnostics) { - var diags diag.Diagnostics - - cn := &CertificateField{} - diags = certDataModel.CommonName.As(ctx, &cn, basetypes.ObjectAsOptions{ - UnhandledUnknownAsEmpty: true, - }) - sans := &CertificateFieldList{} - diags = certDataModel.SANs.As(ctx, &sans, basetypes.ObjectAsOptions{ - UnhandledUnknownAsEmpty: true, - }) - org := &CertificateFieldList{} - diags = certDataModel.Organization.As(ctx, &org, basetypes.ObjectAsOptions{ - UnhandledUnknownAsEmpty: true, - }) - ou := &CertificateFieldList{} - diags = certDataModel.OrganizationalUnit.As(ctx, &ou, basetypes.ObjectAsOptions{ - UnhandledUnknownAsEmpty: true, - }) - locality := &CertificateFieldList{} - diags = certDataModel.Locality.As(ctx, &locality, basetypes.ObjectAsOptions{ - UnhandledUnknownAsEmpty: true, - }) - province := &CertificateFieldList{} - diags = certDataModel.Province.As(ctx, &province, basetypes.ObjectAsOptions{ - UnhandledUnknownAsEmpty: true, - }) - street := &CertificateFieldList{} - diags = certDataModel.StreetAddress.As(ctx, &street, basetypes.ObjectAsOptions{ - UnhandledUnknownAsEmpty: true, - }) - postal := &CertificateFieldList{} - diags = certDataModel.PostalCode.As(ctx, &postal, basetypes.ObjectAsOptions{ - UnhandledUnknownAsEmpty: true, - }) - country := &CertificateFieldList{} - diags = certDataModel.Country.As(ctx, &country, basetypes.ObjectAsOptions{ - UnhandledUnknownAsEmpty: true, - }) - - cnField := &v20231101.CertificateField{} - if cn != nil { - if cn.Static.ValueString() != "" { - err := cnField.FromCertificateFieldStatic(v20231101.CertificateFieldStatic{ - Static: cn.Static.ValueString(), - }) - if err != nil { - diags.AddError("workload static common name", err.Error()) - return v20231101.X509Fields{}, diags - } - } else if cn.DeviceMetadata.ValueString() != "" { - err := cnField.FromCertificateFieldDeviceMetadata(v20231101.CertificateFieldDeviceMetadata{ - DeviceMetadata: cn.DeviceMetadata.ValueString(), - }) - if err != nil { - diags.AddError("workload device metadata common name", err.Error()) - return v20231101.X509Fields{}, diags - } - } - } - - countryCFL, d := toCertificateFieldList(ctx, country) - diags.Append(d...) - - localityCFL, d := toCertificateFieldList(ctx, locality) - diags.Append(d...) - - orgCFL, d := toCertificateFieldList(ctx, org) - diags.Append(d...) - - ouCFL, d := toCertificateFieldList(ctx, ou) - diags.Append(d...) - - postalCFL, d := toCertificateFieldList(ctx, postal) - diags.Append(d...) - - provinceCFL, d := toCertificateFieldList(ctx, province) - diags.Append(d...) - - sansCFL, d := toCertificateFieldList(ctx, sans) - diags.Append(d...) - - streetCFL, d := toCertificateFieldList(ctx, street) - diags.Append(d...) - - return v20231101.X509Fields{ - CommonName: cnField, - Sans: sansCFL, - Country: countryCFL, - Locality: localityCFL, - Organization: orgCFL, - OrganizationalUnit: ouCFL, - PostalCode: postalCFL, - Province: provinceCFL, - StreetAddress: streetCFL, - }, diags -} - -func fromAPI(ctx context.Context, workload *v20231101.Workload, state utils.AttributeGetter) (*Model, diag.Diagnostics) { - var diags diag.Diagnostics - - certInfo, ds := CertInfoFromAPI(ctx, workload.CertificateInfo, state) - diags.Append(ds...) - - keyInfo, ds := KeyInfoFromAPI(ctx, workload.KeyInfo, state) - diags.Append(ds...) - - reloadInfo, ds := ReloadInfoFromAPI(ctx, workload.ReloadInfo, state) - diags.Append(ds...) - - workloadType, d := utils.ToOptionalString(ctx, workload.WorkloadType, state, path.Root("workload_type")) - diags.Append(d...) - - model := &Model{ - Slug: types.StringValue(workload.Slug), - WorkloadType: workloadType, - DisplayName: types.StringValue(workload.DisplayName), - AuthorityID: types.StringValue(workload.AuthorityID), - CertificateInfo: certInfo, - KeyInfo: keyInfo, - ReloadInfo: reloadInfo, - } - - if workload.Hooks != nil { - sign, d := HookFromAPI(ctx, workload.Hooks.Sign, path.Root("hooks").AtName("sign"), state) - diags.Append(d...) - - renew, d := HookFromAPI(ctx, workload.Hooks.Renew, path.Root("hooks").AtName("renew"), state) - diags.Append(d...) - - hooksObj, d := basetypes.NewObjectValue(HooksObjectType, map[string]attr.Value{ - "sign": sign, - "renew": renew, - }) - diags.Append(d...) - - model.Hooks = hooksObj - } else { - model.Hooks = basetypes.NewObjectNull(HooksObjectType) - } - - x509Fields, err := workload.AsX509Fields() - if err != nil { - diags.AddError("parse workload response", err.Error()) - return nil, diags - } - - certData, ds := CertDataFromAPI(ctx, x509Fields, state) - diags.Append(ds...) - - model.CertificateData = certData - - return model, diags -} - -func ReloadInfoFromAPI(ctx context.Context, reloadInfo *v20231101.EndpointReloadInfo, state utils.AttributeGetter) (types.Object, diag.Diagnostics) { - var diags diag.Diagnostics - - pidFile, d := utils.ToOptionalString(ctx, reloadInfo.PidFile, state, path.Root("reload_info").AtName("method")) - diags.Append(d...) - - signal, d := utils.ToOptionalInt(ctx, reloadInfo.Signal, state, path.Root("reload_info").AtName("signal")) - diags.Append(d...) - - unitName, d := utils.ToOptionalString(ctx, reloadInfo.UnitName, state, path.Root("reload_info").AtName("unit_name")) - diags.Append(d...) - - out, d := basetypes.NewObjectValue(reloadInfoAttrTypes, map[string]attr.Value{ - "method": types.StringValue(string(reloadInfo.Method)), - "pid_file": pidFile, - "signal": signal, - "unit_name": unitName, - }) - diags.Append(d...) - - return out, diags -} - -func KeyInfoFromAPI(ctx context.Context, keyInfo *v20231101.EndpointKeyInfo, state utils.AttributeGetter) (types.Object, diag.Diagnostics) { - var diags diag.Diagnostics - - if keyInfo == nil { - return basetypes.NewObjectNull(keyInfoAttrTypes), diags - } - - format, ds := utils.ToOptionalString(ctx, keyInfo.Format, state, path.Root("key_info").AtName("format")) - diags.Append(ds...) - - pubFile, ds := utils.ToOptionalString(ctx, keyInfo.PubFile, state, path.Root("key_info").AtName("pub_file")) - diags.Append(ds...) - - typ, ds := utils.ToOptionalString(ctx, keyInfo.Type, state, path.Root("key_info").AtName("type")) - diags.Append(ds...) - - protection, ds := utils.ToOptionalString(ctx, keyInfo.Protection, state, path.Root("key_info").AtName("protection")) - diags.Append(ds...) - - out, ds := basetypes.NewObjectValue(keyInfoAttrTypes, map[string]attr.Value{ - "format": format, - "pub_file": pubFile, - "type": typ, - "protection": protection, - }) - diags.Append(ds...) - - return out, diags -} - -func CertInfoFromAPI(ctx context.Context, certInfo *v20231101.EndpointCertificateInfo, state utils.AttributeGetter) (types.Object, diag.Diagnostics) { - var diags diag.Diagnostics - - dur, d := utils.ToEqualString(ctx, certInfo.Duration, state, path.Root("certificate_info").AtName("duration"), utils.IsDurationEqual) - diags = append(diags, d...) - - crtFile, d := utils.ToOptionalString(ctx, certInfo.CrtFile, state, path.Root("certificate_info").AtName("crt_file")) - diags = append(diags, d...) - - keyFile, d := utils.ToOptionalString(ctx, certInfo.KeyFile, state, path.Root("certificate_info").AtName("key_file")) - diags = append(diags, d...) - - rootFile, d := utils.ToOptionalString(ctx, certInfo.RootFile, state, path.Root("certificate_info").AtName("root_file")) - diags = append(diags, d...) - - uid, d := utils.ToOptionalInt(ctx, certInfo.Uid, state, path.Root("certificate_info").AtName("uid")) - diags = append(diags, d...) - - gid, d := utils.ToOptionalInt(ctx, certInfo.Gid, state, path.Root("certificate_info").AtName("gid")) - diags = append(diags, d...) - - mode, d := utils.ToOptionalInt(ctx, certInfo.Mode, state, path.Root("certificate_info").AtName("mode")) - diags = append(diags, d...) - - out, d := basetypes.NewObjectValue(certInfoAttrTypes, map[string]attr.Value{ - "type": types.StringValue(string(certInfo.Type)), - "crt_file": crtFile, - "key_file": keyFile, - "root_file": rootFile, - "duration": dur, - "gid": gid, - "uid": uid, - "mode": mode, - }) - diags.Append(d...) - - return out, diags -} - -func CertDataFromAPI(ctx context.Context, x509Fields v20231101.X509Fields, state utils.AttributeGetter) (types.Object, diag.Diagnostics) { - var diags diag.Diagnostics - - cn := basetypes.NewObjectNull(certificateFieldType.AttrTypes) - if x509Fields.CommonName != nil { - cfStatic, err := x509Fields.CommonName.AsCertificateFieldStatic() - if err != nil { - diags.AddError("parse static common name", err.Error()) - return types.Object{}, diags - } - cfDeviceMetadata, err := x509Fields.CommonName.AsCertificateFieldDeviceMetadata() - if err != nil { - diags.AddError("parse device metadata common name", err.Error()) - return types.Object{}, diags - } - static, d := utils.ToOptionalString(ctx, &cfStatic.Static, state, path.Root("certificate_data").AtName("common_name").AtName("static")) - diags.Append(d...) - dm, d := utils.ToOptionalString(ctx, &cfDeviceMetadata.DeviceMetadata, state, path.Root("certificate_data").AtName("common_name").AtName("device_metadata")) - diags.Append(d...) - cn, d = basetypes.NewObjectValue(certificateFieldType.AttrTypes, map[string]attr.Value{ - "static": static, - "device_metadata": dm, - }) - diags.Append(d...) - if diags.HasError() { - return types.Object{}, diags - } - } - - sans, d := CertificateFieldListFromAPI(ctx, x509Fields.Sans, state, path.Root("certificate_data").AtName("sans")) - diags.Append(d...) - - org, d := CertificateFieldListFromAPI(ctx, x509Fields.Organization, state, path.Root("certificate_data").AtName("organization")) - diags.Append(d...) - - ou, d := CertificateFieldListFromAPI(ctx, x509Fields.OrganizationalUnit, state, path.Root("certificate_data").AtName("organizational_unit")) - diags.Append(d...) - - locality, d := CertificateFieldListFromAPI(ctx, x509Fields.Locality, state, path.Root("certificate_data").AtName("locality")) - diags.Append(d...) - - province, d := CertificateFieldListFromAPI(ctx, x509Fields.Province, state, path.Root("certificate_data").AtName("province")) - diags.Append(d...) - - street, d := CertificateFieldListFromAPI(ctx, x509Fields.StreetAddress, state, path.Root("certificate_data").AtName("street_address")) - diags.Append(d...) - - postal, d := CertificateFieldListFromAPI(ctx, x509Fields.PostalCode, state, path.Root("certificate_data").AtName("postal_code")) - diags.Append(d...) - - country, d := CertificateFieldListFromAPI(ctx, x509Fields.Country, state, path.Root("certificate_data").AtName("country")) - diags.Append(d...) - - certData, d := basetypes.NewObjectValue(certificateDataType.AttrTypes, map[string]attr.Value{ - "common_name": cn, - "sans": sans, - "organization": org, - "organizational_unit": ou, - "locality": locality, - "province": province, - "street_address": street, - "postal_code": postal, - "country": country, - }) - diags.Append(d...) - - return certData, diags -} - -func toAPI(ctx context.Context, model *Model) (*v20231101.Workload, diag.Diagnostics) { - hooksModel := &HooksModel{} - diags := model.Hooks.As(ctx, &hooksModel, basetypes.ObjectAsOptions{ - UnhandledUnknownAsEmpty: true, - }) - hooks, d := hooksModel.ToAPI(ctx) - diags.Append(d...) - - reloadInfo := &ReloadInfoModel{} - d = model.ReloadInfo.As(ctx, &reloadInfo, basetypes.ObjectAsOptions{ - UnhandledUnknownAsEmpty: true, - }) - diags.Append(d...) - - ci := &CertificateInfoModel{} - d = model.CertificateInfo.As(ctx, &ci, basetypes.ObjectAsOptions{}) - diags.Append(d...) - - keyInfo := &KeyInfoModel{} - d = model.KeyInfo.As(ctx, &keyInfo, basetypes.ObjectAsOptions{}) - diags.Append(d...) - - workload := &v20231101.Workload{ - DisplayName: model.DisplayName.ValueString(), - WorkloadType: model.WorkloadType.ValueStringPointer(), - Slug: model.Slug.ValueString(), - AuthorityID: model.AuthorityID.ValueString(), - CertificateInfo: ci.ToAPI(), - KeyInfo: keyInfo.ToAPI(), - Hooks: hooks, - ReloadInfo: reloadInfo.ToAPI(), - } - - certDataModel := &CertificateDataModel{} - diags = model.CertificateData.As(ctx, &certDataModel, basetypes.ObjectAsOptions{ - UnhandledUnknownAsEmpty: true, - }) - x509Fields, ds := certDataModel.ToAPI(ctx) - diags.Append(ds...) - - err := workload.FromX509Fields(x509Fields) - if err != nil { - diags.AddError("workload certificate data", err.Error()) - return nil, diags - } - - return workload, diags -} - -func toCertificateFieldList(ctx context.Context, cfl *CertificateFieldList) (*v20231101.CertificateFieldList, diag.Diagnostics) { - var diags diag.Diagnostics - if cfl == nil { - return nil, diags - } - - var static *[]string - var deviceMetadata *[]string - - if !cfl.Static.IsNull() { - diags.Append(cfl.Static.ElementsAs(ctx, &static, false)...) - } - if !cfl.DeviceMetadata.IsNull() { - diags.Append(cfl.DeviceMetadata.ElementsAs(ctx, &deviceMetadata, false)...) - } - - return &v20231101.CertificateFieldList{ - Static: static, - DeviceMetadata: deviceMetadata, - }, diags -} - -func CertificateFieldListFromAPI(ctx context.Context, cfl *v20231101.CertificateFieldList, state utils.AttributeGetter, p path.Path) (types.Object, diag.Diagnostics) { - var diags diag.Diagnostics - - if cfl == nil { - return basetypes.NewObjectNull(certificateFieldListType.AttrTypes), diags - } - - static, d := utils.ToOptionalList(ctx, cfl.Static, state, p.AtName("static")) - diags.Append(d...) - - deviceMetadata, d := utils.ToOptionalList(ctx, cfl.DeviceMetadata, state, p.AtName("device_metadata")) - diags.Append(d...) - - obj, d := basetypes.NewObjectValue(certificateFieldListType.AttrTypes, map[string]attr.Value{ - "static": static, - "device_metadata": deviceMetadata, - }) - diags.Append(d...) - - return obj, diags -} diff --git a/internal/provider/workload/models.go b/internal/provider/workload/models.go deleted file mode 100644 index 92abdceb608aed3e2b8835224971dd12dc8dc9bb..0000000000000000000000000000000000000000 --- a/internal/provider/workload/models.go +++ /dev/null @@ -1,486 +0,0 @@ -package workload - -import ( - "context" - - "github.com/hashicorp/terraform-plugin-framework/attr" - "github.com/hashicorp/terraform-plugin-framework/diag" - "github.com/hashicorp/terraform-plugin-framework/path" - "github.com/hashicorp/terraform-plugin-framework/resource/schema" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-plugin-framework/types/basetypes" - v20231101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20231101" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/utils" -) - -type CertificateInfoModel struct { - Type types.String `tfsdk:"type"` - CrtFile types.String `tfsdk:"crt_file"` - KeyFile types.String `tfsdk:"key_file"` - RootFile types.String `tfsdk:"root_file"` - Duration types.String `tfsdk:"duration"` - GID types.Int64 `tfsdk:"gid"` - UID types.Int64 `tfsdk:"uid"` - Mode types.Int64 `tfsdk:"mode"` -} - -var certInfoAttrTypes = map[string]attr.Type{ - "type": types.StringType, - "crt_file": types.StringType, - "key_file": types.StringType, - "root_file": types.StringType, - "duration": types.StringType, - "gid": types.Int64Type, - "uid": types.Int64Type, - "mode": types.Int64Type, -} - -func (ci CertificateInfoModel) ToAPI() *v20231101.EndpointCertificateInfo { - d := ci.Duration.ValueStringPointer() - // duration defaults to 24h if not set, which means the schema must - // mark it as both computed and optional. With the computed flag it - // will be uknown rather than null if not set. The ValueStringPointer() - // method returns the empty string for unknown values, but passing an - // empty string to the API results in a 400 since it's not a valid - // duration. - if ci.Duration.IsUnknown() { - d = nil - } - return &v20231101.EndpointCertificateInfo{ - Type: v20231101.EndpointCertificateInfoType(ci.Type.ValueString()), - Duration: d, - CrtFile: ci.CrtFile.ValueStringPointer(), - KeyFile: ci.KeyFile.ValueStringPointer(), - RootFile: ci.RootFile.ValueStringPointer(), - Uid: utils.ToIntPointer(ci.UID.ValueInt64Pointer()), - Gid: utils.ToIntPointer(ci.GID.ValueInt64Pointer()), - Mode: utils.ToIntPointer(ci.Mode.ValueInt64Pointer()), - } -} - -type HookModel struct { - Shell types.String `tfsdk:"shell"` - Before types.List `tfsdk:"before"` - After types.List `tfsdk:"after"` - OnError types.List `tfsdk:"on_error"` -} - -var HookObjectType = types.ObjectType{ - AttrTypes: map[string]attr.Type{ - "shell": types.StringType, - "before": types.ListType{ - ElemType: types.StringType, - }, - "after": types.ListType{ - ElemType: types.StringType, - }, - "on_error": types.ListType{ - ElemType: types.StringType, - }, - }, -} - -func (h *HookModel) ToAPI(ctx context.Context) (*v20231101.EndpointHook, diag.Diagnostics) { - var diags diag.Diagnostics - - if h == nil { - return nil, diags - } - - var before *[]string - var after *[]string - var onError *[]string - - if !h.Before.IsNull() { - diags.Append(h.Before.ElementsAs(ctx, &before, false)...) - } - if !h.After.IsNull() { - diags.Append(h.After.ElementsAs(ctx, &after, false)...) - } - if !h.OnError.IsNull() { - diags.Append(h.OnError.ElementsAs(ctx, &onError, false)...) - } - - return &v20231101.EndpointHook{ - Shell: h.Shell.ValueStringPointer(), - Before: before, - After: after, - OnError: onError, - }, diags -} - -type HooksModel struct { - Sign types.Object `tfsdk:"sign"` - Renew types.Object `tfsdk:"renew"` -} - -var HooksObjectType = map[string]attr.Type{ - "sign": HookObjectType, - "renew": HookObjectType, -} - -func HookToAPI(ctx context.Context, hook types.Object) (*v20231101.EndpointHook, diag.Diagnostics) { - hookModel := &HookModel{} - diags := hook.As(ctx, &hookModel, basetypes.ObjectAsOptions{ - UnhandledUnknownAsEmpty: true, - }) - - h, d := hookModel.ToAPI(ctx) - diags.Append(d...) - - return h, diags -} - -func (h *HooksModel) ToAPI(ctx context.Context) (*v20231101.EndpointHooks, diag.Diagnostics) { - var diags diag.Diagnostics - - if h == nil { - return nil, diags - } - - sign, d := HookToAPI(ctx, h.Sign) - diags.Append(d...) - - renew, d := HookToAPI(ctx, h.Renew) - diags.Append(d...) - - return &v20231101.EndpointHooks{ - Sign: sign, - Renew: renew, - }, diags -} - -type KeyInfoModel struct { - Format types.String `tfsdk:"format"` - PubFile types.String `tfsdk:"pub_file"` - Type types.String `tfsdk:"type"` - Protection types.String `tfsdk:"protection"` -} - -var keyInfoAttrTypes = map[string]attr.Type{ - "format": types.StringType, - "pub_file": types.StringType, - "type": types.StringType, - "protection": types.StringType, -} - -func (ki *KeyInfoModel) ToAPI() *v20231101.EndpointKeyInfo { - if ki == nil { - return nil - } - - return &v20231101.EndpointKeyInfo{ - Format: utils.ToStringPointer[v20231101.EndpointKeyInfoFormat](ki.Format.ValueStringPointer()), - PubFile: ki.PubFile.ValueStringPointer(), - Type: utils.ToStringPointer[v20231101.EndpointKeyInfoType](ki.Type.ValueStringPointer()), - Protection: utils.ToStringPointer[v20231101.EndpointKeyInfoProtection](ki.Protection.ValueStringPointer()), - } -} - -func NewKeyInfoResourceSchema() (schema.SingleNestedAttribute, error) { - keyInfo, keyInfoProps, err := utils.Describe("endpointKeyInfo") - if err != nil { - return schema.SingleNestedAttribute{}, err - } - - out := schema.SingleNestedAttribute{ - // This object is not required by the API but a default object - // will always be returned with format, type and protection set to - // "DEFAULT". To avoid "inconsistent result after apply" errors - // require these fields to be set explicitly in terraform. - Required: true, - MarkdownDescription: keyInfo, - Attributes: map[string]schema.Attribute{ - "type": schema.StringAttribute{ - Required: true, - MarkdownDescription: keyInfoProps["type"], - }, - "format": schema.StringAttribute{ - Required: true, - MarkdownDescription: keyInfoProps["format"], - }, - "pub_file": schema.StringAttribute{ - Optional: true, - MarkdownDescription: keyInfoProps["pubFile"], - }, - "protection": schema.StringAttribute{ - Optional: true, - MarkdownDescription: keyInfoProps["protection"], - }, - }, - } - - return out, nil -} - -type ReloadInfoModel struct { - Method types.String `tfsdk:"method"` - PIDFile types.String `tfsdk:"pid_file"` - Signal types.Int64 `tfsdk:"signal"` - UnitName types.String `tfsdk:"unit_name"` -} - -var reloadInfoAttrTypes = map[string]attr.Type{ - "method": types.StringType, - "pid_file": types.StringType, - "signal": types.Int64Type, - "unit_name": types.StringType, -} - -func (ri *ReloadInfoModel) ToAPI() *v20231101.EndpointReloadInfo { - if ri == nil { - return nil - } - - return &v20231101.EndpointReloadInfo{ - Method: v20231101.EndpointReloadInfoMethod(ri.Method.ValueString()), - PidFile: ri.PIDFile.ValueStringPointer(), - Signal: utils.ToIntPointer(ri.Signal.ValueInt64Pointer()), - UnitName: ri.UnitName.ValueStringPointer(), - } -} - -func NewReloadInfoResourceSchema() (schema.SingleNestedAttribute, error) { - reloadInfo, reloadInfoProps, err := utils.Describe("endpointReloadInfo") - if err != nil { - return schema.SingleNestedAttribute{}, err - } - - out := schema.SingleNestedAttribute{ - Optional: true, - Computed: true, - MarkdownDescription: reloadInfo, - Attributes: map[string]schema.Attribute{ - "method": schema.StringAttribute{ - Required: true, - MarkdownDescription: reloadInfoProps["method"], - }, - "pid_file": schema.StringAttribute{ - Optional: true, - MarkdownDescription: reloadInfoProps["pidFile"], - }, - "signal": schema.Int64Attribute{ - Optional: true, - MarkdownDescription: reloadInfoProps["signal"], - }, - "unit_name": schema.StringAttribute{ - Optional: true, - MarkdownDescription: reloadInfoProps["unitName"], - }, - }, - } - - return out, nil -} - -func NewCertificateInfoResourceSchema() (schema.SingleNestedAttribute, error) { - certInfo, certInfoProps, err := utils.Describe("endpointCertificateInfo") - if err != nil { - return schema.SingleNestedAttribute{}, err - } - - out := schema.SingleNestedAttribute{ - Required: true, - MarkdownDescription: certInfo, - Attributes: map[string]schema.Attribute{ - "type": schema.StringAttribute{ - MarkdownDescription: certInfoProps["type"], - Required: true, - }, - "duration": schema.StringAttribute{ - MarkdownDescription: certInfoProps["duration"], - Optional: true, - Computed: true, - }, - "crt_file": schema.StringAttribute{ - MarkdownDescription: certInfoProps["crtFile"], - Optional: true, - }, - "key_file": schema.StringAttribute{ - MarkdownDescription: certInfoProps["keyFile"], - Optional: true, - }, - "root_file": schema.StringAttribute{ - MarkdownDescription: certInfoProps["rootFile"], - Optional: true, - }, - "uid": schema.Int64Attribute{ - MarkdownDescription: certInfoProps["uid"], - Optional: true, - }, - "gid": schema.Int64Attribute{ - MarkdownDescription: certInfoProps["gid"], - Optional: true, - }, - "mode": schema.Int64Attribute{ - MarkdownDescription: certInfoProps["mode"], - Optional: true, - }, - }, - } - - return out, nil -} - -func NewCertificateDataResourceSchema() (schema.SingleNestedAttribute, error) { - certData, _, err := utils.Describe("x509Fields") - if err != nil { - return schema.SingleNestedAttribute{}, err - } - - out := schema.SingleNestedAttribute{ - Optional: false, - Computed: false, - Required: true, - MarkdownDescription: certData, - Attributes: map[string]schema.Attribute{ - "common_name": schema.SingleNestedAttribute{ - Optional: false, - Required: true, - Attributes: map[string]schema.Attribute{ - "static": schema.StringAttribute{ - Optional: true, - }, - "device_metadata": schema.StringAttribute{ - Optional: true, - }, - }, - }, - "sans": schema.SingleNestedAttribute{ - Optional: true, - Attributes: map[string]schema.Attribute{ - "static": schema.ListAttribute{ - ElementType: types.StringType, - Optional: true, - }, - "device_metadata": schema.ListAttribute{ - ElementType: types.StringType, - Optional: true, - }, - }, - }, - "organization": schema.SingleNestedAttribute{ - Optional: true, - Attributes: map[string]schema.Attribute{ - "static": schema.ListAttribute{ - ElementType: types.StringType, - Optional: true, - }, - "device_metadata": schema.ListAttribute{ - ElementType: types.StringType, - Optional: true, - }, - }, - }, - "organizational_unit": schema.SingleNestedAttribute{ - Optional: true, - Attributes: map[string]schema.Attribute{ - "static": schema.ListAttribute{ - ElementType: types.StringType, - Optional: true, - }, - "device_metadata": schema.ListAttribute{ - ElementType: types.StringType, - Optional: true, - }, - }, - }, - "locality": schema.SingleNestedAttribute{ - Optional: true, - Attributes: map[string]schema.Attribute{ - "static": schema.ListAttribute{ - ElementType: types.StringType, - Optional: true, - }, - "device_metadata": schema.ListAttribute{ - ElementType: types.StringType, - Optional: true, - }, - }, - }, - "country": schema.SingleNestedAttribute{ - Optional: true, - Attributes: map[string]schema.Attribute{ - "static": schema.ListAttribute{ - ElementType: types.StringType, - Optional: true, - }, - "device_metadata": schema.ListAttribute{ - ElementType: types.StringType, - Optional: true, - }, - }, - }, - "province": schema.SingleNestedAttribute{ - Optional: true, - Attributes: map[string]schema.Attribute{ - "static": schema.ListAttribute{ - ElementType: types.StringType, - Optional: true, - }, - "device_metadata": schema.ListAttribute{ - ElementType: types.StringType, - Optional: true, - }, - }, - }, - "street_address": schema.SingleNestedAttribute{ - Optional: true, - Attributes: map[string]schema.Attribute{ - "static": schema.ListAttribute{ - ElementType: types.StringType, - Optional: true, - }, - "device_metadata": schema.ListAttribute{ - ElementType: types.StringType, - Optional: true, - }, - }, - }, - "postal_code": schema.SingleNestedAttribute{ - Optional: true, - Attributes: map[string]schema.Attribute{ - "static": schema.ListAttribute{ - ElementType: types.StringType, - Optional: true, - }, - "device_metadata": schema.ListAttribute{ - ElementType: types.StringType, - Optional: true, - }, - }, - }, - }, - } - return out, nil -} - -func HookFromAPI(ctx context.Context, hook *v20231101.EndpointHook, hookPath path.Path, state utils.AttributeGetter) (types.Object, diag.Diagnostics) { - var diags diag.Diagnostics - - if hook == nil { - return basetypes.NewObjectNull(HookObjectType.AttrTypes), diags - } - - shell, d := utils.ToOptionalString(ctx, hook.Shell, state, hookPath.AtName("shell")) - diags = append(diags, d...) - - before, d := utils.ToOptionalList(ctx, hook.Before, state, hookPath.AtName("before")) - diags = append(diags, d...) - - after, d := utils.ToOptionalList(ctx, hook.After, state, hookPath.AtName("after")) - diags = append(diags, d...) - - onError, d := utils.ToOptionalList(ctx, hook.OnError, state, hookPath.AtName("on_error")) - diags = append(diags, d...) - - obj, d := basetypes.NewObjectValue(HookObjectType.AttrTypes, map[string]attr.Value{ - "shell": shell, - "before": before, - "after": after, - "on_error": onError, - }) - diags.Append(d...) - - return obj, diags -} diff --git a/internal/provider/workload/resource.go b/internal/provider/workload/resource.go deleted file mode 100644 index 978b27ac31bb0244d72c69916c7d34b7f9ac5cf6..0000000000000000000000000000000000000000 --- a/internal/provider/workload/resource.go +++ /dev/null @@ -1,445 +0,0 @@ -package workload - -import ( - "context" - "encoding/json" - "fmt" - "net/http" - - "github.com/hashicorp/terraform-plugin-framework/path" - "github.com/hashicorp/terraform-plugin-framework/resource" - "github.com/hashicorp/terraform-plugin-framework/resource/schema" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-plugin-log/tflog" - v20231101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20231101" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/utils" -) - -var _ resource.Resource = (*Resource)(nil) - -func NewResource() resource.Resource { - return &Resource{} -} - -// Resource defines the resource implementation. -type Resource struct { - client *v20231101.Client -} - -func (r *Resource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = typeName -} - -// Configure adds the Smallstep API client to the resource. -func (r *Resource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { - // Prevent panic if the provider has not been configured. - if req.ProviderData == nil { - return - } - - client, ok := req.ProviderData.(*v20231101.Client) - - if !ok { - resp.Diagnostics.AddError( - "Get Smallstep API client from provider", - fmt.Sprintf("Expected *v20231101.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData), - ) - return - } - - r.client = client -} - -func (r *Resource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { - state := &Model{} - resp.Diagnostics.Append(req.State.Get(ctx, state)...) - - if resp.Diagnostics.HasError() { - return - } - - dcSlug := state.DeviceCollectionSlug.ValueString() - workloadSlug := state.Slug.ValueString() - - httpResp, err := r.client.GetWorkload(ctx, dcSlug, workloadSlug, &v20231101.GetWorkloadParams{}) - if err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to read workload %q: %v", workloadSlug, err), - ) - return - } - defer httpResp.Body.Close() - - if httpResp.StatusCode == http.StatusNotFound { - resp.State.RemoveResource(ctx) - return - } - - if httpResp.StatusCode != http.StatusOK { - reqID := httpResp.Header.Get("X-Request-Id") - resp.Diagnostics.AddError( - "Smallstep API Response Error", - fmt.Sprintf("Request %q received status %d reading workload %q: %s", reqID, httpResp.StatusCode, workloadSlug, utils.APIErrorMsg(httpResp.Body)), - ) - return - } - - workload := &v20231101.Workload{} - if err := json.NewDecoder(httpResp.Body).Decode(workload); err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to unmarshal workload %q: %v", workloadSlug, err), - ) - return - } - - remote, d := fromAPI(ctx, workload, req.State) - resp.Diagnostics.Append(d...) - if resp.Diagnostics.HasError() { - return - } - - tflog.Trace(ctx, fmt.Sprintf("read workload %q resource", workloadSlug)) - - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("certificate_info"), remote.CertificateInfo)...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("key_info"), remote.KeyInfo)...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("hooks"), remote.Hooks)...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("reload_info"), remote.ReloadInfo)...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("display_name"), remote.DisplayName)...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("workload_type"), remote.WorkloadType)...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("slug"), remote.Slug)...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("certificate_data"), remote.CertificateData)...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("authority_id"), remote.AuthorityID)...) - // Not returned from API. Use state. - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("device_collection_slug"), state.DeviceCollectionSlug)...) -} - -func (r *Resource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { - workload, props, err := utils.Describe("workload") - if err != nil { - resp.Diagnostics.AddError( - "Parse Smallstep OpenAPI spec", - err.Error(), - ) - return - } - - certInfo, err := NewCertificateInfoResourceSchema() - if err != nil { - resp.Diagnostics.AddError( - "Parse Smallstep OpenAPI spec", - err.Error(), - ) - return - } - - certData, err := NewCertificateDataResourceSchema() - if err != nil { - resp.Diagnostics.AddError( - "Parse Smallstep OpenAPI spec", - err.Error(), - ) - } - - _, hookProps, err := utils.Describe("endpointHook") - if err != nil { - resp.Diagnostics.AddError( - "Parse Smallstep OpenAPI spec", - err.Error(), - ) - return - } - - hooks, hooksProps, err := utils.Describe("endpointHooks") - if err != nil { - resp.Diagnostics.AddError( - "Parse Smallstep OpenAPI spec", - err.Error(), - ) - return - } - - keyInfo, err := NewKeyInfoResourceSchema() - if err != nil { - resp.Diagnostics.AddError( - "Parse Smallstep OpenAPI spec", - err.Error(), - ) - return - } - - reloadInfo, err := NewReloadInfoResourceSchema() - if err != nil { - resp.Diagnostics.AddError( - "Parse Smallstep OpenAPI spec", - err.Error(), - ) - return - } - - resp.Schema = schema.Schema{ - MarkdownDescription: workload, - - Attributes: map[string]schema.Attribute{ - "display_name": schema.StringAttribute{ - MarkdownDescription: props["displayName"], - Required: true, - }, - "workload_type": schema.StringAttribute{ - MarkdownDescription: props["workloadType"], - Optional: true, - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - stringplanmodifier.UseStateForUnknown(), - }, - }, - "slug": schema.StringAttribute{ - MarkdownDescription: props["slug"], - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, - "device_collection_slug": schema.StringAttribute{ - MarkdownDescription: "Slug of the device collection the workload will be added to.", - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, - "authority_id": schema.StringAttribute{ - MarkdownDescription: props["authorityID"], - Required: true, - }, - "key_info": keyInfo, - "reload_info": reloadInfo, - "certificate_data": certData, - "certificate_info": certInfo, - "hooks": schema.SingleNestedAttribute{ - Optional: true, - Computed: true, - MarkdownDescription: hooks, - Attributes: map[string]schema.Attribute{ - "sign": schema.SingleNestedAttribute{ - Optional: true, - MarkdownDescription: hooksProps["sign"], - Attributes: map[string]schema.Attribute{ - "shell": schema.StringAttribute{ - Optional: true, - MarkdownDescription: hookProps["shell"], - }, - "before": schema.ListAttribute{ - ElementType: types.StringType, - Optional: true, - MarkdownDescription: hookProps["before"], - }, - "after": schema.ListAttribute{ - ElementType: types.StringType, - Optional: true, - MarkdownDescription: hookProps["after"], - }, - "on_error": schema.ListAttribute{ - ElementType: types.StringType, - Optional: true, - MarkdownDescription: hookProps["onError"], - }, - }, - }, - "renew": schema.SingleNestedAttribute{ - Optional: true, - MarkdownDescription: hooksProps["renew"], - Attributes: map[string]schema.Attribute{ - "shell": schema.StringAttribute{ - Optional: true, - MarkdownDescription: hookProps["shell"], - }, - "before": schema.ListAttribute{ - ElementType: types.StringType, - Optional: true, - MarkdownDescription: hookProps["before"], - }, - "after": schema.ListAttribute{ - ElementType: types.StringType, - Optional: true, - MarkdownDescription: hookProps["after"], - }, - "on_error": schema.ListAttribute{ - ElementType: types.StringType, - Optional: true, - MarkdownDescription: hookProps["onError"], - }, - }, - }, - }, - }, - }, - } -} - -func (a *Resource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - plan := &Model{} - resp.Diagnostics.Append(req.Plan.Get(ctx, plan)...) - if resp.Diagnostics.HasError() { - return - } - - reqBody, diags := toAPI(ctx, plan) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - dcSlug := plan.DeviceCollectionSlug.ValueString() - slug := plan.Slug.ValueString() - - httpResp, err := a.client.PutWorkload(ctx, dcSlug, slug, &v20231101.PutWorkloadParams{}, *reqBody) - if err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to create workload %q: %v", plan.DisplayName.ValueString(), err), - ) - return - } - defer httpResp.Body.Close() - if httpResp.StatusCode != http.StatusOK { - reqID := httpResp.Header.Get("X-Request-Id") - resp.Diagnostics.AddError( - "Smallstep API Response Error", - fmt.Sprintf("Request %q received status %d creating workload %q: %s", reqID, httpResp.StatusCode, plan.DisplayName.ValueString(), utils.APIErrorMsg(httpResp.Body)), - ) - return - } - - workload := &v20231101.Workload{} - if err := json.NewDecoder(httpResp.Body).Decode(workload); err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to unmarshal workload %q: %v", plan.DisplayName.ValueString(), err), - ) - return - } - - state, diags := fromAPI(ctx, workload, req.Plan) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - - tflog.Trace(ctx, fmt.Sprintf("create workload %q resource", plan.DisplayName.ValueString())) - - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("certificate_info"), state.CertificateInfo)...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("key_info"), state.KeyInfo)...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("hooks"), state.Hooks)...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("reload_info"), state.ReloadInfo)...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("display_name"), state.DisplayName)...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("workload_type"), state.WorkloadType)...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("slug"), state.Slug)...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("certificate_data"), state.CertificateData)...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("authority_id"), state.AuthorityID)...) - // Not returned by the API. Use plan. - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("device_collection_slug"), plan.DeviceCollectionSlug)...) -} - -func (r *Resource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { - plan := &Model{} - resp.Diagnostics.Append(req.Plan.Get(ctx, plan)...) - - if resp.Diagnostics.HasError() { - return - } - - reqBody, diags := toAPI(ctx, plan) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - dcSlug := plan.DeviceCollectionSlug.ValueString() - slug := plan.Slug.ValueString() - - httpResp, err := r.client.PutWorkload(ctx, dcSlug, slug, &v20231101.PutWorkloadParams{}, *reqBody) - if err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to update workload %q: %v", plan.DisplayName.ValueString(), err), - ) - return - } - defer httpResp.Body.Close() - - if httpResp.StatusCode != http.StatusOK { - reqID := httpResp.Header.Get("X-Request-Id") - resp.Diagnostics.AddError( - "Smallstep API Response Error", - fmt.Sprintf("Request %q received status %d updating workload %q: %s", reqID, httpResp.StatusCode, plan.DisplayName.ValueString(), utils.APIErrorMsg(httpResp.Body)), - ) - return - } - - workload := &v20231101.Workload{} - if err := json.NewDecoder(httpResp.Body).Decode(workload); err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to unmarshal workload %q: %v", plan.DisplayName.ValueString(), err), - ) - return - } - - state, diags := fromAPI(ctx, workload, req.Plan) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - - tflog.Trace(ctx, fmt.Sprintf("update workload %q resource", plan.DisplayName.ValueString())) - - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("certificate_info"), state.CertificateInfo)...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("key_info"), state.KeyInfo)...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("hooks"), state.Hooks)...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("reload_info"), state.ReloadInfo)...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("display_name"), state.DisplayName)...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("workload_type"), state.WorkloadType)...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("slug"), state.Slug)...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("certificate_data"), state.CertificateData)...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("authority_id"), state.AuthorityID)...) - // Not returned by the API. Use plan. - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("device_collection_slug"), plan.DeviceCollectionSlug)...) -} - -func (a *Resource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { - state := &Model{} - resp.Diagnostics.Append(req.State.Get(ctx, state)...) - - if resp.Diagnostics.HasError() { - return - } - - dcSlug := state.DeviceCollectionSlug.ValueString() - workloadSlug := state.Slug.ValueString() - - httpResp, err := a.client.DeleteWorkload(ctx, dcSlug, workloadSlug, &v20231101.DeleteWorkloadParams{}) - if err != nil { - resp.Diagnostics.AddError( - "Smallstep API Client Error", - fmt.Sprintf("Failed to delete workload %q: %v", workloadSlug, err), - ) - return - } - defer httpResp.Body.Close() - - if httpResp.StatusCode == http.StatusNoContent { - resp.State.RemoveResource(ctx) - return - } - - if httpResp.StatusCode != http.StatusOK { - reqID := httpResp.Header.Get("X-Request-Id") - resp.Diagnostics.AddError( - "Smallstep API Response Error", - fmt.Sprintf("Request %q received status %d deleting workload %q: %s", reqID, httpResp.StatusCode, workloadSlug, utils.APIErrorMsg(httpResp.Body)), - ) - return - } -} diff --git a/internal/provider/workload/resource_test.go b/internal/provider/workload/resource_test.go deleted file mode 100644 index 4e5c2a29bd28245a91ef9ba2c4f7f3bf07b3b5c1..0000000000000000000000000000000000000000 --- a/internal/provider/workload/resource_test.go +++ /dev/null @@ -1,449 +0,0 @@ -package workload - -import ( - "fmt" - "os" - "testing" - - "github.com/hashicorp/terraform-plugin-framework/datasource" - "github.com/hashicorp/terraform-plugin-framework/providerserver" - "github.com/hashicorp/terraform-plugin-framework/resource" - "github.com/hashicorp/terraform-plugin-go/tfprotov6" - helper "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/hashicorp/terraform-plugin-testing/plancheck" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/authority" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/device_collection" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/utils" - "github.com/smallstep/terraform-provider-smallstep/internal/testprovider" -) - -func TestMain(m *testing.M) { - helper.TestMain(m) -} - -var provider = &testprovider.SmallstepTestProvider{ - ResourceFactories: []func() resource.Resource{ - NewResource, - device_collection.NewResource, - authority.NewResource, - }, - DataSourceFactories: []func() datasource.DataSource{ - authority.NewDataSource, - }, -} - -var providerFactories = map[string]func() (tfprotov6.ProviderServer, error){ - "smallstep": providerserver.NewProtocol6WithError(provider), -} - -func TestAccWorkloadResource(t *testing.T) { - dcSlug := utils.Slug(t) - genericSlug := utils.Slug(t) - nginxSlug := utils.Slug(t) - caDomain := os.Getenv("SMALLSTEP_CA_DOMAIN") - if caDomain == "" { - caDomain = ".step-e2e.ca.smallstep.com" - } - workloadsDomain := "workloads" + caDomain - config1 := fmt.Sprintf(` -resource "smallstep_authority" "agent" { - name = "Agent" - subdomain = "agent" - type = "devops" - admin_emails = ["andrew@smallstep.com"] -} - -resource "smallstep_device_collection" "ec2_east" { - slug = %q - display_name = "EC2 East" - device_type = "aws-vm" - authority_id = smallstep_authority.agent.id - aws_vm = { - accounts = ["0123456789"] - } -} - -data "smallstep_authority" "workloads" { - domain = %q -} - -resource "smallstep_workload" "generic" { - depends_on = [smallstep_device_collection.ec2_east] - device_collection_slug = resource.smallstep_device_collection.ec2_east.slug - slug = %q - display_name = "tfprovider generic" - authority_id = data.smallstep_authority.workloads.id - - certificate_info = { - type = "X509" - } - key_info = { - format = "DER" - type = "ECDSA_P256" - protection = "NONE" - } - certificate_data = { - common_name = { - static = "host.internal" - } - sans = { - static = ["host.internal"] - } - organization = { - static = ["generic static org"] - } - organizational_unit = { - static = ["generic static ou"] - } - locality = { - static = ["generic static locality"] - } - postal_code = { - static = ["generic static postal"] - } - country = { - static = ["generic static country"] - } - street_address = { - static = ["generic static street"] - } - province = { - static = ["generic static province"] - } - } -} - -resource "smallstep_workload" "nginx" { - depends_on = [smallstep_device_collection.ec2_east] - workload_type = "nginx" - device_collection_slug = resource.smallstep_device_collection.ec2_east.slug - slug = %q - display_name = "tfprovider Nginx" - authority_id = data.smallstep_authority.workloads.id - - certificate_info = { - type = "X509" - duration = "168h" - crt_file = "db.crt" - key_file = "db.key" - root_file = "ca.crt" - uid = 1001 - gid = 999 - mode = 256 - } - - hooks = { - renew = { - shell = "/bin/sh" - before = [ - "echo renewing 1", - "echo renewing 2", - "echo renewing 3", - ] - after = [ - "echo renewed 1", - "echo renewew 2", - "echo renewed 3", - ] - on_error = [ - "echo failed renew 1", - "echo failed renew 2", - "echo failed renew 3", - ] - } - sign = { - shell = "/bin/bash" - before = [ - "echo signing 1", - "echo signing 2", - "echo signing 3", - ] - after = [ - "echo signed 1", - "echo signed 2", - "echo signed 3", - ] - on_error = [ - "echo failed sign 1", - "echo failed sign 2", - "echo failed sign 3", - ] - } - } - - key_info = { - format = "DER" - type = "ECDSA_P256" - pub_file = "file.csr" - protection = "HARDWARE" - } - - reload_info = { - method = "SIGNAL" - pid_file = "db.pid" - signal = 1 - } - - certificate_data = { - common_name = { - static = "nginx.internal" - } - } -} -`, dcSlug, workloadsDomain, genericSlug, nginxSlug) - - config2 := fmt.Sprintf(` -resource "smallstep_authority" "agent" { - name = "Agent" - subdomain = "agent" - type = "devops" - admin_emails = ["andrew@smallstep.com"] -} - -resource "smallstep_device_collection" "ec2_east" { - slug = %q - display_name = "EC2 East" - authority_id = smallstep_authority.agent.id - device_type = "aws-vm" - aws_vm = { - accounts = ["0123456789"] - } -} - -data "smallstep_authority" "workloads" { - domain = %q -} - -resource "smallstep_workload" "generic" { - depends_on = [smallstep_device_collection.ec2_east] - device_collection_slug = resource.smallstep_device_collection.ec2_east.slug - slug = %q - display_name = "tfprovider generic" - authority_id = data.smallstep_authority.workloads.id - - certificate_info = { - type = "X509" - } - key_info = { - format = "DER" - type = "ECDSA_P256" - protection = "NONE" - } - - certificate_data = { - common_name = { - device_metadata = "host" - } - sans = { - device_metadata = ["sans"] - } - organization = { - device_metadata = ["org"] - } - organizational_unit = { - device_metadata = ["ou"] - } - locality = { - device_metadata = ["locality"] - } - postal_code = { - device_metadata = ["postal"] - } - country = { - device_metadata = ["country"] - } - street_address = { - device_metadata = ["street"] - } - province = { - device_metadata = ["province"] - } - } -} - -resource "smallstep_workload" "nginx" { - depends_on = [smallstep_device_collection.ec2_east] - workload_type = "nginx" - device_collection_slug = resource.smallstep_device_collection.ec2_east.slug - slug = %q - display_name = "tfprovider Nginx" - authority_id = data.smallstep_authority.workloads.id - - certificate_info = { - type = "X509" - duration = "167h" - crt_file = "pg.crt" - key_file = "pg.key" - root_file = "pg_ca.crt" - uid = 1002 - gid = 998 - mode = 7 - } - - hooks = { - renew = { - shell = "/bin/zsh" - before = [ - "echo renewing 4", - ] - after = [ - "echo renewed 4", - ] - on_error = [ - "echo failed renew 4", - ] - } - sign = { - shell = "/bin/fish" - before = [ - "echo signing 4", - ] - after = [ - "echo signed 4", - ] - on_error = [ - "echo failed sign 4", - ] - } - } - - key_info = { - format = "DEFAULT" - type = "ECDSA_P384" - pub_file = "" - } - - reload_info = { - method = "DBUS" - unit_name = "postgres.service" - } - - certificate_data = { - common_name = { - static = "nginx" - } - } -}`, dcSlug, workloadsDomain, genericSlug, nginxSlug) - - helper.Test(t, helper.TestCase{ - ProtoV6ProviderFactories: providerFactories, - Steps: []helper.TestStep{ - { - Config: config1, - Check: helper.ComposeAggregateTestCheckFunc( - helper.TestCheckResourceAttr("smallstep_workload.nginx", "display_name", "tfprovider Nginx"), - helper.TestMatchResourceAttr("smallstep_workload.nginx", "authority_id", utils.UUID), - helper.TestCheckResourceAttr("smallstep_workload.nginx", "certificate_info.type", "X509"), - helper.TestCheckResourceAttr("smallstep_workload.nginx", "certificate_info.duration", "168h"), - helper.TestCheckResourceAttr("smallstep_workload.nginx", "certificate_info.crt_file", "db.crt"), - helper.TestCheckResourceAttr("smallstep_workload.nginx", "certificate_info.key_file", "db.key"), - helper.TestCheckResourceAttr("smallstep_workload.nginx", "certificate_info.root_file", "ca.crt"), - helper.TestCheckResourceAttr("smallstep_workload.nginx", "certificate_info.uid", "1001"), - helper.TestCheckResourceAttr("smallstep_workload.nginx", "certificate_info.gid", "999"), - helper.TestCheckResourceAttr("smallstep_workload.nginx", "certificate_info.mode", "256"), - helper.TestCheckResourceAttr("smallstep_workload.nginx", "hooks.renew.shell", "/bin/sh"), - helper.TestCheckResourceAttr("smallstep_workload.nginx", "hooks.renew.before.#", "3"), - helper.TestCheckResourceAttr("smallstep_workload.nginx", "hooks.renew.after.#", "3"), - helper.TestCheckResourceAttr("smallstep_workload.nginx", "hooks.renew.on_error.#", "3"), - helper.TestCheckResourceAttr("smallstep_workload.nginx", "hooks.sign.shell", "/bin/bash"), - helper.TestCheckResourceAttr("smallstep_workload.nginx", "hooks.sign.before.#", "3"), - helper.TestCheckResourceAttr("smallstep_workload.nginx", "hooks.sign.after.#", "3"), - helper.TestCheckResourceAttr("smallstep_workload.nginx", "hooks.sign.on_error.#", "3"), - helper.TestCheckResourceAttr("smallstep_workload.nginx", "key_info.type", "ECDSA_P256"), - helper.TestCheckResourceAttr("smallstep_workload.nginx", "key_info.format", "DER"), - helper.TestCheckResourceAttr("smallstep_workload.nginx", "key_info.pub_file", "file.csr"), - helper.TestCheckResourceAttr("smallstep_workload.nginx", "reload_info.method", "SIGNAL"), - helper.TestCheckResourceAttr("smallstep_workload.nginx", "reload_info.pid_file", "db.pid"), - helper.TestCheckResourceAttr("smallstep_workload.nginx", "reload_info.signal", "1"), - helper.TestCheckResourceAttr("smallstep_workload.nginx", "certificate_data.common_name.static", "nginx.internal"), - - helper.TestCheckResourceAttr("smallstep_workload.generic", "workload_type", "generic"), - helper.TestCheckResourceAttr("smallstep_workload.generic", "certificate_data.sans.static.#", "1"), - helper.TestCheckResourceAttr("smallstep_workload.generic", "certificate_data.sans.static.0", "host.internal"), - - helper.TestCheckResourceAttr("smallstep_workload.generic", "certificate_data.organization.static.#", "1"), - helper.TestCheckResourceAttr("smallstep_workload.generic", "certificate_data.organization.static.0", "generic static org"), - - helper.TestCheckResourceAttr("smallstep_workload.generic", "certificate_data.organizational_unit.static.#", "1"), - helper.TestCheckResourceAttr("smallstep_workload.generic", "certificate_data.organizational_unit.static.0", "generic static ou"), - - helper.TestCheckResourceAttr("smallstep_workload.generic", "certificate_data.locality.static.#", "1"), - helper.TestCheckResourceAttr("smallstep_workload.generic", "certificate_data.locality.static.0", "generic static locality"), - - helper.TestCheckResourceAttr("smallstep_workload.generic", "certificate_data.postal_code.static.#", "1"), - helper.TestCheckResourceAttr("smallstep_workload.generic", "certificate_data.postal_code.static.0", "generic static postal"), - - helper.TestCheckResourceAttr("smallstep_workload.generic", "certificate_data.country.static.#", "1"), - helper.TestCheckResourceAttr("smallstep_workload.generic", "certificate_data.country.static.0", "generic static country"), - - helper.TestCheckResourceAttr("smallstep_workload.generic", "certificate_data.street_address.static.#", "1"), - helper.TestCheckResourceAttr("smallstep_workload.generic", "certificate_data.street_address.static.0", "generic static street"), - - helper.TestCheckResourceAttr("smallstep_workload.generic", "certificate_data.province.static.#", "1"), - helper.TestCheckResourceAttr("smallstep_workload.generic", "certificate_data.province.static.0", "generic static province"), - ), - }, - { - Config: config2, - ConfigPlanChecks: helper.ConfigPlanChecks{ - PreApply: []plancheck.PlanCheck{ - plancheck.ExpectResourceAction("smallstep_workload.nginx", plancheck.ResourceActionUpdate), - plancheck.ExpectResourceAction("smallstep_workload.generic", plancheck.ResourceActionUpdate), - }, - }, - Check: helper.ComposeAggregateTestCheckFunc( - helper.TestCheckResourceAttr("smallstep_workload.nginx", "display_name", "tfprovider Nginx"), - helper.TestMatchResourceAttr("smallstep_workload.nginx", "authority_id", utils.UUID), - helper.TestCheckResourceAttr("smallstep_workload.nginx", "certificate_info.type", "X509"), - helper.TestCheckResourceAttr("smallstep_workload.nginx", "certificate_info.duration", "167h"), - helper.TestCheckResourceAttr("smallstep_workload.nginx", "certificate_info.crt_file", "pg.crt"), - helper.TestCheckResourceAttr("smallstep_workload.nginx", "certificate_info.key_file", "pg.key"), - helper.TestCheckResourceAttr("smallstep_workload.nginx", "certificate_info.root_file", "pg_ca.crt"), - helper.TestCheckResourceAttr("smallstep_workload.nginx", "certificate_info.uid", "1002"), - helper.TestCheckResourceAttr("smallstep_workload.nginx", "certificate_info.gid", "998"), - helper.TestCheckResourceAttr("smallstep_workload.nginx", "certificate_info.mode", "7"), - helper.TestCheckResourceAttr("smallstep_workload.nginx", "hooks.renew.shell", "/bin/zsh"), - helper.TestCheckResourceAttr("smallstep_workload.nginx", "hooks.renew.before.#", "1"), - helper.TestCheckResourceAttr("smallstep_workload.nginx", "hooks.renew.after.#", "1"), - helper.TestCheckResourceAttr("smallstep_workload.nginx", "hooks.renew.on_error.#", "1"), - helper.TestCheckResourceAttr("smallstep_workload.nginx", "hooks.sign.shell", "/bin/fish"), - helper.TestCheckResourceAttr("smallstep_workload.nginx", "hooks.sign.before.#", "1"), - helper.TestCheckResourceAttr("smallstep_workload.nginx", "hooks.sign.after.#", "1"), - helper.TestCheckResourceAttr("smallstep_workload.nginx", "hooks.sign.on_error.#", "1"), - helper.TestCheckResourceAttr("smallstep_workload.nginx", "key_info.type", "ECDSA_P384"), - helper.TestCheckResourceAttr("smallstep_workload.nginx", "key_info.format", "DEFAULT"), - helper.TestCheckResourceAttr("smallstep_workload.nginx", "key_info.pub_file", ""), - helper.TestCheckResourceAttr("smallstep_workload.nginx", "reload_info.method", "DBUS"), - helper.TestCheckResourceAttr("smallstep_workload.nginx", "reload_info.unit_name", "postgres.service"), - helper.TestCheckResourceAttr("smallstep_workload.nginx", "certificate_data.common_name.static", "nginx"), - - helper.TestCheckNoResourceAttr("smallstep_workload.generic", "certificate_data.sans.static"), - - helper.TestCheckResourceAttr("smallstep_workload.generic", "certificate_data.sans.device_metadata.#", "1"), - helper.TestCheckResourceAttr("smallstep_workload.generic", "certificate_data.sans.device_metadata.0", "sans"), - - helper.TestCheckResourceAttr("smallstep_workload.generic", "certificate_data.organization.device_metadata.#", "1"), - helper.TestCheckResourceAttr("smallstep_workload.generic", "certificate_data.organization.device_metadata.0", "org"), - - helper.TestCheckResourceAttr("smallstep_workload.generic", "certificate_data.organizational_unit.device_metadata.#", "1"), - helper.TestCheckResourceAttr("smallstep_workload.generic", "certificate_data.organizational_unit.device_metadata.0", "ou"), - - helper.TestCheckResourceAttr("smallstep_workload.generic", "certificate_data.locality.device_metadata.#", "1"), - helper.TestCheckResourceAttr("smallstep_workload.generic", "certificate_data.locality.device_metadata.0", "locality"), - - helper.TestCheckResourceAttr("smallstep_workload.generic", "certificate_data.postal_code.device_metadata.#", "1"), - helper.TestCheckResourceAttr("smallstep_workload.generic", "certificate_data.postal_code.device_metadata.0", "postal"), - - helper.TestCheckResourceAttr("smallstep_workload.generic", "certificate_data.country.device_metadata.#", "1"), - helper.TestCheckResourceAttr("smallstep_workload.generic", "certificate_data.country.device_metadata.0", "country"), - - helper.TestCheckResourceAttr("smallstep_workload.generic", "certificate_data.street_address.device_metadata.#", "1"), - helper.TestCheckResourceAttr("smallstep_workload.generic", "certificate_data.street_address.device_metadata.0", "street"), - - helper.TestCheckResourceAttr("smallstep_workload.generic", "certificate_data.province.device_metadata.#", "1"), - helper.TestCheckResourceAttr("smallstep_workload.generic", "certificate_data.province.device_metadata.0", "province"), - ), - }, - }, - }) -}