/**
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */ import { KubernetesObject } from 'kpt-functions' ; import * as apisMetaV1 from './io.k8s.apimachinery.pkg.apis.meta.v1' ; import * as pkgUtilIntstr from './io.k8s.apimachinery.pkg.util.intstr' ; export class IPBlock { public cidr : string ; public except ? : string [ ] ; constructor ( desc ) { this . cidr = desc . cidr ; this . except = desc . except ; } } export class NetworkPolicy implements KubernetesObject { public apiVersion : string ; public kind : string ; public metadata : apisMetaV1 . ObjectMeta ; public spec ? : NetworkPolicySpec ; constructor ( desc ) { this . apiVersion = NetworkPolicy . apiVersion ; this . kind = NetworkPolicy . kind ; this . metadata = desc . metadata ; this . spec = desc . spec ; } } export function isNetworkPolicy ( o ) { return ( o && o . apiVersion === NetworkPolicy . apiVersion && o . kind === NetworkPolicy . kind ) ; } export namespace NetworkPolicy { export const apiVersion = 'networking.k8s.io/v1' ; export const group = 'networking.k8s.io' ; export const version = 'v1' ; export const kind = 'NetworkPolicy' ; export function named ( name ) { return new NetworkPolicy ( { metadata : { name } } ) ; } export interface Interface { metadata : apisMetaV1 . ObjectMeta ; spec ? : NetworkPolicySpec ; } } export class NetworkPolicyEgressRule { public ports ? : NetworkPolicyPort [ ] ; public to ? : NetworkPolicyPeer [ ] ; } export class NetworkPolicyIngressRule { public from ? : NetworkPolicyPeer [ ] ; public ports ? : NetworkPolicyPort [ ] ; } export class NetworkPolicyList { public apiVersion : string ; public items : NetworkPolicy [ ] ; public kind : string ; public metadata ? : apisMetaV1 . ListMeta ; constructor ( desc ) { this . apiVersion = NetworkPolicyList . apiVersion ; this . items = desc . items . map ( ( i ) => new NetworkPolicy ( i ) ) ; this . kind = NetworkPolicyList . kind ; this . metadata = desc . metadata ; } } export function isNetworkPolicyList ( o ) { return ( o && o . apiVersion === NetworkPolicyList . apiVersion && o . kind === NetworkPolicyList . kind ) ; } export namespace NetworkPolicyList { export const apiVersion = 'networking.k8s.io/v1' ; export const group = 'networking.k8s.io' ; export const version = 'v1' ; export const kind = 'NetworkPolicyList' ; export interface Interface { items : NetworkPolicy [ ] ; metadata ? : apisMetaV1 . ListMeta ; } } export class NetworkPolicyPeer { public ipBlock ? : IPBlock ; public namespaceSelector ? : apisMetaV1 . LabelSelector ; public podSelector ? : apisMetaV1 . LabelSelector ; } export class NetworkPolicyPort { public port ? : pkgUtilIntstr . IntOrString ; public protocol ? : string ; } export class NetworkPolicySpec { public egress ? : NetworkPolicyEgressRule [ ] ; public ingress ? : NetworkPolicyIngressRule [ ] ; public podSelector : apisMetaV1 . LabelSelector ; public policyTypes ? : string [ ] ; constructor ( desc ) { this . egress = desc . egress ; this . ingress = desc . ingress ; this . podSelector = desc . podSelector ; this . policyTypes = desc . policyTypes ; } }