text:
package com.squareup.moshi;

import android.util.Pair;
import java.io.File;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.annotation.Retention;
import java.lang.reflect.Field;
import java.lang.reflect.Type;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import javax.annotation.Nullable;
import javax.crypto.KeyGenerator;
import okio.Buffer;
import org.junit.Test;

import static com.squareup.moshi.TestUtil.newReader;
import static com.squareup.moshi.TestUtil.repeat;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;

public final class MoshiTest {
  @Test public void booleanAdapter() throws Exception {
    Moshi moshi = new Moshi.Builder().build();
    JsonAdapter<Boolean> adapter = moshi.adapter(boolean.class).lenient();
    assertThat(adapter.fromJson("true")).isTrue();
    assertThat(adapter.fromJson("TRUE")).isTrue();
    assertThat(adapter.toJson(true)).isEqualTo("true");
    assertThat(adapter.fromJson("false")).isFalse();
    assertThat(adapter.fromJson("FALSE")).isFalse();
    assertThat(adapter.toJson(false)).isEqualTo("false");

    // Nulls not allowed for boolean.class
    try {
      adapter.fromJson("null");
      fail();
    } catch (JsonDataException expected) {
      assertThat(expected).hasMessage("Expected a boolean but was NULL at path $");
    }

    try {
      adapter.toJson(null);
      fail();
    } catch (NullPointerException expected) {
    }
  }

  @Test public void BooleanAdapter() throws Exception {
    Moshi moshi = new Moshi.Builder().build();
    JsonAdapter<Boolean> adapter = moshi.adapter(Boolean.class).lenient();
    assertThat(adapter.fromJson("true")).isTrue();
    assertThat(adapter.toJson(true)).isEqualTo("true");
    assertThat(adapter.fromJson("false")).isFalse();
    assertThat(adapter.toJson(false)).isEqualTo("false");
    // Allow nulls for Boolean.class
    assertThat(adapter.fromJson("null")).isEqualTo(null);
    assertThat(adapter.toJson(null)).isEqualTo("null");
  }

  @Test public void byteAdapter() throws Exception {
    Moshi moshi = new Moshi.Builder().build();
    JsonAdapter<Byte> adapter = moshi.adapter(byte.class).lenient();
    assertThat(adapter.fromJson("1")).isEqualTo((byte) 1);
    assertThat(adapter.toJson((byte) -2)).isEqualTo("254");

    // Canonical byte representation is unsigned, but parse the whole range -128..255
    assertThat(adapter.fromJson("-128")).isEqualTo((byte) -128);
    assertThat(adapter.fromJson("128")).isEqualTo((byte) -128);
    assertThat(adapter.toJson((byte) -128)).isEqualTo("128");

    assertThat(adapter.fromJson("255")).isEqualTo((byte) -1);
    assertThat(adapter.toJson((byte) -1)).isEqualTo("255");

    assertThat(adapter.fromJson("127")).isEqualTo((byte) 127);
    assertThat(adapter.toJson((byte) 127)).isEqualTo("127");

    try {
      adapter.fromJson("256");
      fail();
    } catch (JsonDataException expected) {
      assertThat(expected).hasMessage("Expected a byte but was 256 at path $");
    }

    try {
      adapter.fromJson("-129");
      fail();
    } catch (JsonDataException expected) {
      assertThat(expected).hasMessage("Expected a byte but was -129 at path $");
    }

    // Nulls not allowed for byte.class
    try {
      adapter.fromJson("null");
      fail();
    } catch (JsonDataException expected) {
      assertThat(expected).hasMessage("Expected an int but was NULL at path $");
    }

    try {
      adapter.toJson(null);
      fail();
    } catch (NullPointerException expected) {
    }
  }

  @Test public void ByteAdapter() throws Exception {
    Moshi moshi = new Moshi.Builder().build();
    JsonAdapter<Byte> adapter = moshi.adapter(Byte.class).lenient();
    assertThat(adapter.fromJson("1")).isEqualTo((byte) 1);
    assertThat(adapter.toJson((byte) -2)).isEqualTo("254");
    // Allow nulls for Byte.class
    assertThat(adapter.fromJson("null")).isEqualTo(null);
    assertThat(adapter.toJson(null)).isEqualTo("null");
  }

  @Test public void charAdapter() throws Exception {
    Moshi moshi = new Moshi.Builder().build();
    JsonAdapter<Character> adapter = moshi.adapter(char.class).lenient();
    assertThat(adapter.fromJson("\"a\"")).isEqualTo('a');
    assertThat(adapter.fromJson("'a'")).isEqualTo('a');
    assertThat(adapter.toJson('b')).isEqualTo("\"b\"");

    // Exhaustively test all valid characters.  Use an int to loop so we can check termination.
    for (int i = 0; i <= Character.MAX_VALUE; ++i) {
      final char c = (char) i;
      String s;
      switch (c) {
        // TODO: make JsonWriter.REPLACEMENT_CHARS visible for testing?
        case '\"':
          s = "\\\"";
          break;
        case '\\':
          s = "\\\\";
          break;
        case '\t':
          s = "\\t";
          break;
        case '\b':
          s = "\\b";
          break;
        case '\n':
          s = "\\n";
          break;
        case '\r':
          s = "\\r";
          break;
        case '\f':
          s = "\\f";
          break;
        case '\u2028':
          s = "\\u2028";
          break;
        case '\u2029':
          s = "\\u2029";
          break;
        default:
          if (c <= 0x1f) {
            s = String.format("\\u%04x", (int) c);
          } else if (c >= Character.MIN_SURROGATE && c <= Character.MAX_SURROGATE) {
            // TODO: not handled properly; do we need to?
            continue;
          } else {
            s = String.valueOf(c);
          }
          break;
      }
      s = '"' + s + '"';
      assertThat(adapter.toJson(c)).isEqualTo(s);
      assertThat(adapter.fromJson(s)).isEqualTo(c);
    }

    try {
      // Only a single character is allowed.
      adapter.fromJson("'ab'");
      fail();
    } catch (JsonDataException expected) {
      assertThat(expected).hasMessage("Expected a char but was \"ab\" at path $");
    }

    // Nulls not allowed for char.class
    try {
      adapter.fromJson("null");
      fail();
    } catch (JsonDataException expected) {
      assertThat(expected).hasMessage("Expected a string but was NULL at path $");
    }

    try {
      adapter.toJson(null);
      fail();
    } catch (NullPointerException expected) {
    }
  }

  @Test public void CharacterAdapter() throws Exception {
    Moshi moshi = new Moshi.Builder().build();
    JsonAdapter<Character> adapter = moshi.adapter(Character.class).lenient();
    assertThat(adapter.fromJson("\"a\"")).isEqualTo('a');
    assertThat(adapter.fromJson("'a'")).isEqualTo('a');
    assertThat(adapter.toJson('b')).isEqualTo("\"b\"");

    try {
      // Only a single character is allowed.
      adapter.fromJson("'ab'");
      fail();
    } catch (JsonDataException expected) {
      assertThat(expected).hasMessage("Expected a char but was \"ab\" at path $");
    }

    // Allow nulls for Character.class
    assertThat(adapter.fromJson("null")).isEqualTo(null);
    assertThat(adapter.toJson(null)).isEqualTo("null");
  }

  @Test public void doubleAdapter() throws Exception {
    Moshi moshi = new Moshi.Builder().build();
    JsonAdapter<Double> adapter = moshi.adapter(double.class).lenient();
    assertThat(adapter.fromJson("1.0")).isEqualTo(1.0);
    assertThat(adapter.fromJson("1")).isEqualTo(1.0);
    assertThat(adapter.fromJson("1e0")).isEqualTo(1.0);
    assertThat(adapter.toJson(-2.0)).isEqualTo("-2.0");

    // Test min/max values.
    assertThat(adapter.fromJson("-1.7976931348623157E308")).isEqualTo(-Double.MAX_VALUE);
    assertThat(adapter.toJson(-Double.MAX_VALUE)).isEqualTo("-1.7976931348623157E308");
    assertThat(adapter.fromJson("1.7976931348623157E308")).isEqualTo(Double.MAX_VALUE);
    assertThat(adapter.toJson(Double.MAX_VALUE)).isEqualTo("1.7976931348623157E308");

    // Lenient reader converts too large values to infinities.
    assertThat(adapter.fromJson("1E309")).isEqualTo(Double.POSITIVE_INFINITY);
    assertThat(adapter.fromJson("-1E309")).isEqualTo(Double.NEGATIVE_INFINITY);
    assertThat(adapter.fromJson("+Infinity")).isEqualTo(Double.POSITIVE_INFINITY);
    assertThat(adapter.fromJson("Infinity")).isEqualTo(Double.POSITIVE_INFINITY);
    assertThat(adapter.fromJson("-Infinity")).isEqualTo(Double.NEGATIVE_INFINITY);

    // Nulls not allowed for double.class
    try {
      adapter.fromJson("null");
      fail();
    } catch (JsonDataException expected) {
      assertThat(expected).hasMessage("Expected a double but was NULL at path $");
    }

    try {
      adapter.toJson(null);
      fail();
    } catch (NullPointerException expected) {
    }

    // Non-lenient adapter won't allow values outside of range.
    adapter = moshi.adapter(double.class);
    JsonReader reader = newReader("[1E309]");
    reader.beginArray();
    try {
      adapter.fromJson(reader);
      fail();
    } catch (IOException expected) {
      assertThat(expected).hasMessage("JSON forbids NaN and infinities: Infinity at path $[0]");
    }

    reader = newReader("[-1E309]");
    reader.beginArray();
    try {
      adapter.fromJson(reader);
      fail();
    } catch (IOException expected) {
      assertThat(expected).hasMessage("JSON forbids NaN and infinities: -Infinity at path $[0]");
    }
  }

  @Test public void DoubleAdapter() throws Exception {
    Moshi moshi = new Moshi.Builder().build();
    JsonAdapter<Double> adapter = moshi.adapter(Double.class).lenient();
    assertThat(adapter.fromJson("1.0")).isEqualTo(1.0);
    assertThat(adapter.fromJson("1")).isEqualTo(1.0);
    assertThat(adapter.fromJson("1e0")).isEqualTo(1.0);
    assertThat(adapter.toJson(-2.0)).isEqualTo("-2.0");
    // Allow nulls for Double.class
    assertThat(adapter.fromJson("null")).isEqualTo(null);
    assertThat(adapter.toJson(null)).isEqualTo("null");
  }

  @Test public void floatAdapter() throws Exception {
    Moshi moshi = new Moshi.Builder().build();
    JsonAdapter<Float> adapter = moshi.adapter(float.class).lenient();
    assertThat(adapter.fromJson("1.0")).isEqualTo(1.0f);
    assertThat(adapter.fromJson("1")).isEqualTo(1.0f);
    assertThat(adapter.fromJson("1e0")).isEqualTo(1.0f);
    assertThat(adapter.toJson(-2.0f)).isEqualTo("-2.0");

    // Test min/max values.
    assertThat(adapter.fromJson("-3.4028235E38")).isEqualTo(-Float.MAX_VALUE);
    assertThat(adapter.toJson(-Float.MAX_VALUE)).isEqualTo("-3.4028235E38");
    assertThat(adapter.fromJson("3.4028235E38")).isEqualTo(Float.MAX_VALUE);
    assertThat(adapter.toJson(Float.MAX_VALUE)).isEqualTo("3.4028235E38");

    // Lenient reader converts too large values to infinities.
    assertThat(adapter.fromJson("1E39")).isEqualTo(Float.POSITIVE_INFINITY);
    assertThat(adapter.fromJson("-1E39")).isEqualTo(Float.NEGATIVE_INFINITY);
    assertThat(adapter.fromJson("+Infinity")).isEqualTo(Float.POSITIVE_INFINITY);
    assertThat(adapter.fromJson("Infinity")).isEqualTo(Float.POSITIVE_INFINITY);
    assertThat(adapter.fromJson("-Infinity")).isEqualTo(Float.NEGATIVE_INFINITY);

    // Nulls not allowed for float.class
    try {
      adapter.fromJson("null");
      fail();
    } catch (JsonDataException expected) {
      assertThat(expected).hasMessage("Expected a double but was NULL at path $");
    }

    try {
      adapter.toJson(null);
      fail();
    } catch (NullPointerException expected) {
    }

    // Non-lenient adapter won't allow values outside of range.
    adapter = moshi.adapter(float.class);
    JsonReader reader = newReader("[1E39]");
    reader.beginArray();
    try {
      adapter.fromJson(reader);
      fail();
    } catch (JsonDataException expected) {
      assertThat(expected).hasMessage("JSON forbids NaN and infinities: Infinity at path $[1]");
    }

    reader = newReader("[-1E39]");
    reader.beginArray();
    try {
      adapter.fromJson(reader);
      fail();
    } catch (JsonDataException expected) {
      assertThat(expected).hasMessage("JSON forbids NaN and infinities: -Infinity at path $[1]");
    }
  }

  @Test public void FloatAdapter() throws Exception {
    Moshi moshi = new Moshi.Builder().build();
    JsonAdapter<Float> adapter = moshi.adapter(Float.class).lenient();
    assertThat(adapter.fromJson("1.0")).isEqualTo(1.0f);
    assertThat(adapter.fromJson("1")).isEqualTo(1.0f);
    assertThat(adapter.fromJson("1e0")).isEqualTo(1.0f);
    assertThat(adapter.toJson(-2.0f)).isEqualTo("-2.0");
    // Allow nulls for Float.class
    assertThat(adapter.fromJson("null")).isEqualTo(null);
    assertThat(adapter.toJson(null)).isEqualTo("null");
  }

  @Test public void intAdapter() throws Exception {
    Moshi moshi = new Moshi.Builder().build();
    JsonAdapter<Integer> adapter = moshi.adapter(int.class).lenient();
    assertThat(adapter.fromJson("1")).isEqualTo(1);
    assertThat(adapter.toJson(-2)).isEqualTo("-2");

    // Test min/max values
    assertThat(adapter.fromJson("-2147483648")).isEqualTo(Integer.MIN_VALUE);
    assertThat(adapter.toJson(Integer.MIN_VALUE)).isEqualTo("-2147483648");
    assertThat(adapter.fromJson("2147483647")).isEqualTo(Integer.MAX_VALUE);
    assertThat(adapter.toJson(Integer.MAX_VALUE)).isEqualTo("2147483647");

    try {
      adapter.fromJson("2147483648");
      fail();
    } catch (JsonDataException expected) {
      assertThat(expected).hasMessage("Expected an int but was 2147483648 at path $");
    }

    try {
      adapter.fromJson("-2147483649");
      fail();
    } catch (JsonDataException expected) {
      assertThat(expected).hasMessage("Expected an int but was -2147483649 at path $");
    }

    // Nulls not allowed for int.class
    try {
      adapter.fromJson("null");
      fail();
    } catch (JsonDataException expected) {
      assertThat(expected).hasMessage("Expected an int but was NULL at path $");
    }

    try {
      adapter.toJson(null);
      fail();
    } catch (NullPointerException expected) {
    }
  }

  @Test public void IntegerAdapter() throws Exception {
    Moshi moshi = new Moshi.Builder().build();
    JsonAdapter<Integer> adapter = moshi.adapter(Integer.class).lenient();
    assertThat(adapter.fromJson("1")).isEqualTo(1);
    assertThat(adapter.toJson(-2)).isEqualTo("-2");
    // Allow nulls for Integer.class
    assertThat(adapter.fromJson("null")).isEqualTo(null);
    assertThat(adapter.toJson(null)).isEqualTo("null");
  }

  @Test public void longAdapter() throws Exception {
    Moshi moshi = new Moshi.Builder().build();
    JsonAdapter<Long> adapter = moshi.adapter(long.class).lenient();
    assertThat(adapter.fromJson("1")).isEqualTo(1L);
    assertThat(adapter.toJson(-2L)).isEqualTo("-2");

    // Test min/max values
    assertThat(adapter.fromJson("-9223372036854775808")).isEqualTo(Long.MIN_VALUE);
    assertThat(adapter.toJson(Long.MIN_VALUE)).isEqualTo("-9223372036854775808");
    assertThat(adapter.fromJson("9223372036854775807")).isEqualTo(Long.MAX_VALUE);
    assertThat(adapter.toJson(Long.MAX_VALUE)).isEqualTo("9223372036854775807");

    try {
      adapter.fromJson("9223372036854775808");
      fail();
    } catch (JsonDataException expected) {
      assertThat(expected).hasMessage("Expected a long but was 9223372036854775808 at path $");
    }

    try {
      adapter.fromJson("-9223372036854775809");
      fail();
    } catch (JsonDataException expected) {
      assertThat(expected).hasMessage("Expected a long but was -9223372036854775809 at path $");
    }

    // Nulls not allowed for long.class
    try {
      adapter.fromJson("null");
      fail();
    } catch (JsonDataException expected) {
      assertThat(expected).hasMessage("Expected a long but was NULL at path $");
    }

    try {
      adapter.toJson(null);
      fail();
    } catch (NullPointerException expected) {
    }
  }

  @Test public void LongAdapter() throws Exception {
    Moshi moshi = new Moshi.Builder().build();
    JsonAdapter<Long> adapter = moshi.adapter(Long.class).lenient();
    assertThat(adapter.fromJson("1")).isEqualTo(1L);
    assertThat(adapter.toJson(-2L)).isEqualTo("-2");
    // Allow nulls for Integer.class
    assertThat(adapter.fromJson("null")).isEqualTo(null);
    assertThat(adapter.toJson(null)).isEqualTo("null");
  }

  @Test public void shortAdapter() throws Exception {
    Moshi moshi = new Moshi.Builder().build();
    JsonAdapter<Short> adapter = moshi.adapter(short.class).lenient();
    assertThat(adapter.fromJson("1")).isEqualTo((short) 1);
    assertThat(adapter.toJson((short) -2)).isEqualTo("-2");

    // Test min/max values.
    assertThat(adapter.fromJson("-32768")).isEqualTo(Short.MIN_VALUE);
    assertThat(adapter.toJson(Short.MIN_VALUE)).isEqualTo("-32768");
    assertThat(adapter.fromJson("32767")).isEqualTo(Short.MAX_VALUE);
    assertThat(adapter.toJson(Short.MAX_VALUE)).isEqualTo("32767");

    try {
      adapter.fromJson("32768");
      fail();
    } catch (JsonDataException expected) {
      assertThat(expected).hasMessage("Expected a short but was 32768 at path $");
    }

    try {
      adapter.fromJson("-32769");
      fail();
    } catch (JsonDataException expected) {
      assertThat(expected).hasMessage("Expected a short but was -32769 at path $");
    }

    // Nulls not allowed for short.class
    try {
      adapter.fromJson("null");
      fail();
    } catch (JsonDataException expected) {
      assertThat(expected).hasMessage("Expected an int but was NULL at path $");
    }

    try {
      adapter.toJson(null);
      fail();
    } catch (NullPointerException expected) {
    }
  }

  @Test public void ShortAdapter() throws Exception {
    Moshi moshi = new Moshi.Builder().build();
    JsonAdapter<Short> adapter = moshi.adapter(Short.class).lenient();
    assertThat(adapter.fromJson("1")).isEqualTo((short) 1);
    assertThat(adapter.toJson((short) -2)).isEqualTo("-2");
    // Allow nulls for Byte.class
    assertThat(adapter.fromJson("null")).isEqualTo(null);
    assertThat(adapter.toJson(null)).isEqualTo("null");
  }

  @Test public void stringAdapter() throws Exception {
    Moshi moshi = new Moshi.Builder().build();
    JsonAdapter<String> adapter = moshi.adapter(String.class).lenient();
    assertThat(adapter.fromJson("\"a\"")).isEqualTo("a");
    assertThat(adapter.toJson("b")).isEqualTo("\"b\"");
    assertThat(adapter.fromJson("null")).isEqualTo(null);
    assertThat(adapter.toJson(null)).isEqualTo("null");
  }

  @Test public void upperBoundedWildcardsAreNotHandled() {
    Moshi moshi = new Moshi.Builder().build();
    try {
      moshi.adapter(Types.subtypeOf(String.class));
      fail();
    } catch (IllegalArgumentException e) {
      assertThat(e).hasMessage("No JsonAdapter for ? extends java.lang.String annotated []");
    }
  }

  @Test public void lowerBoundedWildcardsAreNotHandled() {
    Moshi moshi = new Moshi.Builder().build();
    try {
      moshi.adapter(Types.supertypeOf(String.class));
      fail();
    } catch (IllegalArgumentException e) {
      assertThat(e).hasMessage("No JsonAdapter for ? super java.lang.String annotated []");
    }
  }

  @Test public void addNullFails() throws Exception {
    Type type = Object.class;
    Class<? extends Annotation> annotation = Annotation.class;
    Moshi.Builder builder = new Moshi.Builder();
    try {
      builder.add((null));
      fail();
    } catch (IllegalArgumentException expected) {
      assertThat(expected).hasMessage("factory == null");
    }
    try {
      builder.add((Object) null);
      fail();
    } catch (IllegalArgumentException expected) {
      assertThat(expected).hasMessage("adapter == null");
    }
    try {
      builder.add(null, null);
      fail();
    } catch (IllegalArgumentException expected) {
      assertThat(expected).hasMessage("type == null");
    }
    try {
      builder.add(type, null);
      fail();
    } catch (IllegalArgumentException expected) {
      assertThat(expected).hasMessage("jsonAdapter == null");
    }
    try {
      builder.add(null, null, null);
      fail();
    } catch (IllegalArgumentException expected) {
      assertThat(expected).hasMessage("type == null");
    }
    try {
      builder.add(type, null, null);
      fail();
    } catch (IllegalArgumentException expected) {
      assertThat(expected).hasMessage("annotation == null");
    }
    try {
      builder.add(type, annotation, null);
      fail();
    } catch (IllegalArgumentException expected) {
      assertThat(expected).hasMessage("jsonAdapter == null");
    }
  }

  @Test public void customJsonAdapter() throws Exception {
    Moshi moshi = new Moshi.Builder()
        .add(Pizza.class, new PizzaAdapter())
        .build();

    JsonAdapter<Pizza> jsonAdapter = moshi.adapter(Pizza.class);
    assertThat(jsonAdapter.toJson(new Pizza(15, true)))
        .isEqualTo("{\"size\":15,\"extra cheese\":true}");
    assertThat(jsonAdapter.fromJson("{\"extra cheese\":true,\"size\":18}"))
        .isEqualTo(new Pizza(18, true));
  }

  @Test public void classAdapterToObjectAndFromObject() throws Exception {
    Moshi moshi = new Moshi.Builder().build();

    Pizza pizza = new Pizza(15, true);

    Map<String, Object> pizzaObject = new LinkedHashMap<>();
    pizzaObject.put("diameter", 15L);
    pizzaObject.put("extraCheese", true);

    JsonAdapter<Pizza> jsonAdapter = moshi.adapter(Pizza.class);
    assertThat(jsonAdapter.toJsonValue(pizza)).isEqualTo(pizzaObject);
    assertThat(jsonAdapter.fromJsonValue(pizzaObject)).isEqualTo(pizza);
  }

  @Test public void customJsonAdapterToObjectAndFromObject() throws Exception {
    Moshi moshi = new Moshi.Builder()
        .add(Pizza.class, new PizzaAdapter())
        .build();

    Pizza pizza = new Pizza(15, true);

    Map<String, Object> pizzaObject = new LinkedHashMap<>();
    pizzaObject.put("size", 15L);
    pizzaObject.put("extra cheese", true);

    JsonAdapter<Pizza> jsonAdapter = moshi.adapter(Pizza.class);
    assertThat(jsonAdapter.toJsonValue(pizza)).isEqualTo(pizzaObject);
    assertThat(jsonAdapter.fromJsonValue(pizzaObject)).isEqualTo(pizza);
  }

  @Test public void indent() throws Exception {
    Moshi moshi = new Moshi.Builder().add(Pizza.class, new PizzaAdapter()).build();
    JsonAdapter<Pizza> jsonAdapter = moshi.adapter(Pizza.class);

    Pizza pizza = new Pizza(15, true);
    assertThat(jsonAdapter.indent("  ").toJson(pizza)).isEqualTo(""
        + "{\n"
        + "  \"size\": 15,\n"
        + "  \"extra cheese\": true\n"
        + "}");
  }

  @Test public void unindent() throws Exception {
    Moshi moshi = new Moshi.Builder().add(Pizza.class, new PizzaAdapter()).build();
    JsonAdapter<Pizza> jsonAdapter = moshi.adapter(Pizza.class);

    Buffer buffer = new Buffer();
    JsonWriter writer = JsonWriter.of(buffer);
    writer.setLenient(true);
    writer.setIndent("  ");

    Pizza pizza = new Pizza(15, true);

    // Calling JsonAdapter.indent("") can remove indentation.
    jsonAdapter.indent("").toJson(writer, pizza);
    assertThat(buffer.readUtf8()).isEqualTo("{\"size\":15,\"extra cheese\":true}");

    // Indentation changes only apply to their use.
    jsonAdapter.toJson(writer, pizza);
    assertThat(buffer.readUtf8()).isEqualTo(""
        + "{\n"
        + "  \"size\": 15,\n"
        + "  \"extra cheese\": true\n"
        + "}");
  }

  @Test public void composingJsonAdapterFactory() throws Exception {
    Moshi moshi = new Moshi.Builder()
        .add(new MealDealAdapterFactory())
        .add(Pizza.class, new PizzaAdapter())
        .build();

    JsonAdapter<MealDeal> jsonAdapter = moshi.adapter(MealDeal.class);
    assertThat(jsonAdapter.toJson(new MealDeal(new Pizza(15, true), "Pepsi")))
        .isEqualTo("[{\"size\":15,\"extra cheese\":true},\"Pepsi\"]");
    assertThat(jsonAdapter.fromJson("[{\"extra cheese\":true,\"size\":18},\"Coke\"]"))
        .isEqualTo(new MealDeal(new Pizza(18, true), "Coke"));
  }

  static class Message {
    String speak;
    @Uppercase String shout;
  }

  @Test public void registerJsonAdapterForAnnotatedType() throws Exception {
    JsonAdapter<String> uppercaseAdapter = new JsonAdapter<String>() {
      @Override public String fromJson(JsonReader reader) throws IOException {
        throw new AssertionError();
      }

      @Override public void toJson(JsonWriter writer, String value) throws IOException {
        writer.value(value.toUpperCase(Locale.US));
      }
    };

    Moshi moshi = new Moshi.Builder()
        .add(String.class, Uppercase.class, uppercaseAdapter)
        .build();

    JsonAdapter<Message> messageAdapter = moshi.adapter(Message.class);

    Message message = new Message();
    message.speak = "Yo dog";
    message.shout = "What's up";

    assertThat(messageAdapter.toJson(message))
        .isEqualTo("{\"shout\":\"WHAT'S UP\",\"speak\":\"Yo dog\"}");
  }

  @Uppercase
  static String uppercaseString;

  @Test public void nextJsonAdapterDisallowsNullAnnotations() throws Exception {
    JsonAdapter.Factory badFactory = new JsonAdapter.Factory() {
      @Nullable @Override
      public JsonAdapter<?> create(Type type, Set<? extends Annotation> annotations,
          Moshi moshi) {
        return moshi.nextAdapter(this, type, null);
      }
    };
    Moshi moshi = new Moshi.Builder().add(badFactory).build();
    try {
      moshi.adapter(Object.class);
      fail();
    } catch (NullPointerException expected) {
      assertThat(expected).hasMessage("annotations == null");
    }
  }

  @Test public void delegatingJsonAdapterFactory() throws Exception {
    Moshi moshi = new Moshi.Builder()
        .add(new UppercaseAdapterFactory())
        .build();

    Field uppercaseString = MoshiTest.class.getDeclaredField("uppercaseString");
    Set<? extends Annotation> annotations = Util.jsonAnnotations(uppercaseString);
    JsonAdapter<String> adapter = moshi.<String>adapter(String.class, annotations).lenient();
    assertThat(adapter.toJson("a")).isEqualTo("\"A\"");
    assertThat(adapter.fromJson("\"b\"")).isEqualTo("B");
  }

  @Test public void listJsonAdapter() throws Exception {
    Moshi moshi = new Moshi.Builder().build();
    JsonAdapter<List<String>> adapter =
        moshi.adapter(Types.newParameterizedType(List.class, String.class));
    assertThat(adapter.toJson(Arrays.asList("a", "b"))).isEqualTo("[\"a\",\"b\"]");
    assertThat(adapter.fromJson("[\"a\",\"b\"]")).isEqualTo(Arrays.asList("a", "b"));
  }

  @Test public void setJsonAdapter() throws Exception {
    Set<String> set = new LinkedHashSet<>();
    set.add("a");
    set.add("b");

    Moshi moshi = new Moshi.Builder().build();
    JsonAdapter<Set<String>> adapter =
        moshi.adapter(Types.newParameterizedType(Set.class, String.class));
    assertThat(adapter.toJson(set)).isEqualTo("[\"a\",\"b\"]");
    assertThat(adapter.fromJson("[\"a\",\"b\"]")).isEqualTo(set);
  }

  @Test public void collectionJsonAdapter() throws Exception {
    Collection<String> collection = new ArrayDeque<>();
    collection.add("a");
    collection.add("b");

    Moshi moshi = new Moshi.Builder().build();
    JsonAdapter<Collection<String>> adapter =
        moshi.adapter(Types.newParameterizedType(Collection.class, String.class));
    assertThat(adapter.toJson(collection)).isEqualTo("[\"a\",\"b\"]");
    assertThat(adapter.fromJson("[\"a\",\"b\"]")).containsExactly("a", "b");
  }

  @Uppercase
  static List<String> uppercaseStrings;

  @Test public void collectionsDoNotKeepAnnotations() throws Exception {
    Moshi moshi = new Moshi.Builder()
        .add(new UppercaseAdapterFactory())
        .build();

    Field uppercaseStringsField = MoshiTest.class.getDeclaredField("uppercaseStrings");
    try {
      moshi.adapter(uppercaseStringsField.getGenericType(),
          Util.jsonAnnotations(uppercaseStringsField));
      fail();
    } catch (IllegalArgumentException expected) {
      assertThat(expected).hasMessage("No JsonAdapter for java.util.List<java.lang.String> "
          + "annotated [@com.squareup.moshi.MoshiTest$Uppercase()]");
    }
  }

  @Test public void noTypeAdapterForQualifiedPlatformType() throws Exception {
    Moshi moshi = new Moshi.Builder().build();
    Field uppercaseStringField = MoshiTest.class.getDeclaredField("uppercaseString");
    try {
      moshi.adapter(uppercaseStringField.getGenericType(),
          Util.jsonAnnotations(uppercaseStringField));
      fail();
    } catch (IllegalArgumentException expected) {
      assertThat(expected).hasMessage("No JsonAdapter for class java.lang.String "
          + "annotated [@com.squareup.moshi.MoshiTest$Uppercase()]");
    }
  }

  @Test public void objectArray() throws Exception {
    Moshi moshi = new Moshi.Builder().build();
    JsonAdapter<String[]> adapter = moshi.adapter(String[].class);
    assertThat(adapter.toJson(new String[] {"a", "b"})).isEqualTo("[\"a\",\"b\"]");
    assertThat(adapter.fromJson("[\"a\",\"b\"]")).containsExactly("a", "b");
  }

  @Test public void primitiveArray() throws Exception {
    Moshi moshi = new Moshi.Builder().build();
    JsonAdapter<int[]> adapter = moshi.adapter(int[].class);
    assertThat(adapter.toJson(new int[] { 1, 2 })).isEqualTo("[1,2]");
    assertThat(adapter.fromJson("[2,3]")).containsExactly(2, 3);
  }

  @Test public void enumAdapter() throws Exception {
    Moshi moshi = new Moshi.Builder().build();
    JsonAdapter<Roshambo> adapter = moshi.adapter(Roshambo.class).lenient();
    assertThat(adapter.fromJson("\"ROCK\"")).isEqualTo(Roshambo.ROCK);
    assertThat(adapter.toJson(Roshambo.PAPER)).isEqualTo("\"PAPER\"");
  }

  @Test public void annotatedEnum() throws Exception {
    Moshi moshi = new Moshi.Builder().build();
    JsonAdapter<Roshambo> adapter = moshi.adapter(Roshambo.class).lenient();
    assertThat(adapter.fromJson("\"scr\"")).isEqualTo(Roshambo.SCISSORS);
    assertThat(adapter.toJson(Roshambo.SCISSORS)).isEqualTo("\"scr\"");
  }

  @Test public void invalidEnum() throws Exception {
    Moshi moshi = new Moshi.Builder().build();
    JsonAdapter<Roshambo> adapter = moshi.adapter(Roshambo.class).lenient();
    try {
      adapter.fromJson("\"SPOCK\"");
      fail();
    } catch (JsonDataException expected) {
      assertThat(expected).hasMessage(
          "Expected one of [ROCK, PAPER, scr] but was SPOCK at path $");
    }
  }

  @Test public void nullEnum() throws Exception {
    Moshi moshi = new Moshi.Builder().build();
    JsonAdapter<Roshambo> adapter = moshi.adapter(Roshambo.class).lenient();
    assertThat(adapter.fromJson("null")).isNull();
    assertThat(adapter.toJson(null)).isEqualTo("null");
  }

  @Test public void byDefaultUnknownFieldsAreIgnored() throws Exception {
    Moshi moshi = new Moshi.Builder().build();
    JsonAdapter<Pizza> adapter = moshi.adapter(Pizza.class);
    Pizza pizza = adapter.fromJson("{\"diameter\":5,\"crust\":\"thick\",\"extraCheese\":true}");
    assertThat(pizza.diameter).isEqualTo(5);
    assertThat(pizza.extraCheese).isEqualTo(true);
  }

  @Test public void failOnUnknownThrowsOnUnknownFields() throws Exception {
    Moshi moshi = new Moshi.Builder().build();
    JsonAdapter<Pizza> adapter = moshi.adapter(Pizza.class).failOnUnknown();
    try {
      adapter.fromJson("{\"diameter\":5,\"crust\":\"thick\",\"extraCheese\":true}");
      fail();
    } catch (JsonDataException expected) {
      assertThat(expected).hasMessage("Cannot skip unexpected STRING at $.crust");
    }
  }

  @Test public void platformTypeThrows() throws IOException {
    Moshi moshi = new Moshi.Builder().build();
    try {
      moshi.adapter(File.class);
      fail();
    } catch (IllegalArgumentException e) {
      assertThat(e).hasMessage(
          "Platform class java.io.File annotated [] requires explicit JsonAdapter to be registered");
    }
    try {
      moshi.adapter(KeyGenerator.class);
      fail();
    } catch (IllegalArgumentException e) {
      assertThat(e).hasMessage(
          "Platform class javax.crypto.KeyGenerator annotated [] requires explicit JsonAdapter to be registered");
    }
    try {
      moshi.adapter(Pair.class);
      fail();
    } catch (IllegalArgumentException e) {
      assertThat(e).hasMessage(
          "Platform class android.util.Pair annotated [] requires explicit JsonAdapter to be registered");
    }
  }

  @Test public void qualifierWithElementsMayNotBeDirectlyRegistered() throws IOException {
    try {
      new Moshi.Builder()
          .add(Boolean.class, Localized.class, StandardJsonAdapters.BOOLEAN_JSON_ADAPTER);
      fail();
    } catch (IllegalArgumentException expected) {
      assertThat(expected).hasMessage("Use JsonAdapter.Factory for annotations with elements");
    }
  }

  @Test public void qualifierWithElements() throws IOException {
    Moshi moshi = new Moshi.Builder()
        .add(LocalizedBooleanAdapter.FACTORY)
        .build();

    Baguette baguette = new Baguette();
    baguette.avecBeurre = true;
    baguette.withButter = true;

    JsonAdapter<Baguette> adapter = moshi.adapter(Baguette.class);
    assertThat(adapter.toJson(baguette))
        .isEqualTo("{\"avecBeurre\":\"oui\",\"withButter\":\"yes\"}");

    Baguette decoded = adapter.fromJson("{\"avecBeurre\":\"oui\",\"withButter\":\"yes\"}");
    assertThat(decoded.avecBeurre).isTrue();
    assertThat(decoded.withButter).isTrue();
  }

  /** Note that this is the opposite of Gson's behavior, where later adapters are preferred. */
  @Test public void adaptersRegisteredInOrderOfPrecedence() throws Exception {
    JsonAdapter<String> adapter1 = new JsonAdapter<String>() {
      @Override public String fromJson(JsonReader reader) throws IOException {
        throw new AssertionError();
      }
      @Override public void toJson(JsonWriter writer, String value) throws IOException {
        writer.value("one!");
      }
    };

    JsonAdapter<String> adapter2 = new JsonAdapter<String>() {
      @Override public String fromJson(JsonReader reader) throws IOException {
        throw new AssertionError();
      }
      @Override public void toJson(JsonWriter writer, String value) throws IOException {
        writer.value("two!");
      }
    };

    Moshi moshi = new Moshi.Builder()
        .add(String.class, adapter1)
        .add(String.class, adapter2)
        .build();
    JsonAdapter<String> adapter = moshi.adapter(String.class).lenient();
    assertThat(adapter.toJson("a")).isEqualTo("\"one!\"");
  }

  @Test public void cachingJsonAdapters() throws Exception {
    Moshi moshi = new Moshi.Builder().build();

    JsonAdapter<MealDeal> adapter1 = moshi.adapter(MealDeal.class);
    JsonAdapter<MealDeal> adapter2 = moshi.adapter(MealDeal.class);
    assertThat(adapter1).isSameAs(adapter2);
  }

  @Test public void newBuilder() throws Exception {
    Moshi moshi = new Moshi.Builder()
        .add(Pizza.class, new PizzaAdapter())
        .build();
    Moshi.Builder newBuilder = moshi.newBuilder();
    for (JsonAdapter.Factory factory : Moshi.BUILT_IN_FACTORIES) {
      assertThat(factory).isNotIn(newBuilder.factories);
    }
  }

  @Test public void referenceCyclesOnArrays() throws Exception {
    Moshi moshi = new Moshi.Builder().build();
    Map<String, Object> map = new LinkedHashMap<>();
    map.put("a", map);
    try {
      moshi.adapter(Object.class).toJson(map);
      fail();
    } catch (JsonDataException expected) {
      assertThat(expected).hasMessage("Nesting too deep at $"
          + repeat(".a", 255) + ": circular reference?");
    }
  }

  @Test public void referenceCyclesOnObjects() throws Exception {
    Moshi moshi = new Moshi.Builder().build();
    List<Object> list = new ArrayList<>();
    list.add(list);
    try {
      moshi.adapter(Object.class).toJson(list);
      fail();
    } catch (JsonDataException expected) {
      assertThat(expected).hasMessage("Nesting too deep at $"
          + repeat("[0]", 255) + ": circular reference?");
    }
  }

  @Test public void referenceCyclesOnMixedTypes() throws Exception {
    Moshi moshi = new Moshi.Builder().build();
    List<Object> list = new ArrayList<>();
    Map<String, Object> map = new LinkedHashMap<>();
    list.add(map);
    map.put("a", list);
    try {
      moshi.adapter(Object.class).toJson(list);
      fail();
    } catch (JsonDataException expected) {
      assertThat(expected).hasMessage("Nesting too deep at $[0]"
          + repeat(".a[0]", 127) + ": circular reference?");
    }
  }

  @Test public void duplicateKeyDisallowedInObjectType() throws Exception {
    Moshi moshi = new Moshi.Builder().build();
    JsonAdapter<Object> adapter = moshi.adapter(Object.class);
    String json = "{\"diameter\":5,\"diameter\":5,\"extraCheese\":true}";
    try {
      adapter.fromJson(json);
      fail();
    } catch (JsonDataException expected) {
      assertThat(expected).hasMessage(
          "Map key 'diameter' has multiple values at path $.diameter: 5.0 and 5.0");
    }
  }

  @Test public void duplicateKeysAllowedInCustomType() throws Exception {
    Moshi moshi = new Moshi.Builder().build();
    JsonAdapter<Pizza> adapter = moshi.adapter(Pizza.class);
    String json = "{\"diameter\":5,\"diameter\":5,\"extraCheese\":true}";
    assertThat(adapter.fromJson(json)).isEqualTo(new Pizza(5, true));
  }

  static class Pizza {
    final int diameter;
    final boolean extraCheese;

    Pizza(int diameter, boolean extraCheese) {
      this.diameter = diameter;
      this.extraCheese = extraCheese;
    }

    @Override public boolean equals(Object o) {
      return o instanceof Pizza
          && ((Pizza) o).diameter == diameter
          && ((Pizza) o).extraCheese == extraCheese;
    }

    @Override public int hashCode() {
      return diameter * (extraCheese ? 31 : 1);
    }
  }

  static class MealDeal {
    final Pizza pizza;
    final String drink;

    MealDeal(Pizza pizza, String drink) {
      this.pizza = pizza;
      this.drink = drink;
    }

    @Override public boolean equals(Object o) {
      return o instanceof MealDeal
          && ((MealDeal) o).pizza.equals(pizza)
          && ((MealDeal) o).drink.equals(drink);
    }

    @Override public int hashCode() {
      return pizza.hashCode() + (31 * drink.hashCode());
    }
  }

  static class PizzaAdapter extends JsonAdapter<Pizza> {
    @Override public Pizza fromJson(JsonReader reader) throws IOException {
      int diameter = 13;
      boolean extraCheese = false;
      reader.beginObject();
      while (reader.hasNext()) {
        String name = reader.nextName();
        if (name.equals("size")) {
          diameter = reader.nextInt();
        } else if (name.equals("extra cheese")) {
          extraCheese = reader.nextBoolean();
        } else {
          reader.skipValue();
        }
      }
      reader.endObject();
      return new Pizza(diameter, extraCheese);
    }

    @Override public void toJson(JsonWriter writer, Pizza value) throws IOException {
      writer.beginObject();
      writer.name("size").value(value.diameter);
      writer.name("extra cheese").value(value.extraCheese);
      writer.endObject();
    }
  }

  static class MealDealAdapterFactory implements JsonAdapter.Factory {
    @Override public JsonAdapter<?> create(
        Type type, Set<? extends Annotation> annotations, Moshi moshi) {
      if (!type.equals(MealDeal.class)) return null;
      final JsonAdapter<Pizza> pizzaAdapter = moshi.adapter(Pizza.class);
      final JsonAdapter<String> drinkAdapter = moshi.adapter(String.class);
      return new JsonAdapter<MealDeal>() {
        @Override public MealDeal fromJson(JsonReader reader) throws IOException {
          reader.beginArray();
          Pizza pizza = pizzaAdapter.fromJson(reader);
          String drink = drinkAdapter.fromJson(reader);
          reader.endArray();
          return new MealDeal(pizza, drink);
        }

        @Override public void toJson(JsonWriter writer, MealDeal value) throws IOException {
          writer.beginArray();
          pizzaAdapter.toJson(writer, value.pizza);
          drinkAdapter.toJson(writer, value.drink);
          writer.endArray();
        }
      };
    }
  }

  @Retention(RUNTIME)
  @JsonQualifier
  public @interface Uppercase {
  }

  static class UppercaseAdapterFactory implements JsonAdapter.Factory {
    @Override public JsonAdapter<?> create(
        Type type, Set<? extends Annotation> annotations, Moshi moshi) {
      if (!type.equals(String.class)) return null;
      if (!Util.isAnnotationPresent(annotations, Uppercase.class)) return null;

      final JsonAdapter<String> stringAdapter
          = moshi.nextAdapter(this, String.class, Util.NO_ANNOTATIONS);
      return new JsonAdapter<String>() {
        @Override public String fromJson(JsonReader reader) throws IOException {
          String s = stringAdapter.fromJson(reader);
          return s.toUpperCase(Locale.US);
        }

        @Override public void toJson(JsonWriter writer, String value) throws IOException {
          stringAdapter.toJson(writer, value.toUpperCase());
        }
      };
    }
  }

  enum Roshambo {
    ROCK,
    PAPER,
    @Json(name = "scr") SCISSORS
  }

  @Retention(RUNTIME)
  @JsonQualifier
  @interface Localized {
    String value();
  }

  static class Baguette {
    @Localized("en") boolean withButter;
    @Localized("fr") boolean avecBeurre;
  }

  static class LocalizedBooleanAdapter extends JsonAdapter<Boolean> {
    private static final JsonAdapter.Factory FACTORY = new JsonAdapter.Factory() {
      @Override public JsonAdapter<?> create(
          Type type, Set<? extends Annotation> annotations, Moshi moshi) {
        if (type == boolean.class) {
          for (Annotation annotation : annotations) {
            if (annotation instanceof Localized) {
              return new LocalizedBooleanAdapter(((Localized) annotation).value());
            }
          }
        }
        return null;
      }
    };

    private final String trueString;
    private final String falseString;

    public LocalizedBooleanAdapter(String language) {
      if (language.equals("fr")) {
        trueString = "oui";
        falseString = "non";
      } else {
        trueString = "yes";
        falseString = "no";
      }
    }

    @Override public Boolean fromJson(JsonReader reader) throws IOException {
      return reader.nextString().equals(trueString);
    }

    @Override public void toJson(JsonWriter writer, Boolean value) throws IOException {
      writer.value(value ? trueString : falseString);
    }
  }
}


text:
module Google
  module Apis
    module ConnectorsV2
      # Version of the google-apis-connectors_v2 gem
      GEM_VERSION = "0.3.0"

      # Version of the code generator used to generate this client
      GENERATOR_VERSION = "0.11.0"

      # Revision of the discovery document this client was generated from
      REVISION = "20220808"
    end
  end
end

redpajama_set_name: RedPajamaGithub


text:
from ..broker import Broker

class IfGroupDefnBroker(Broker):
    controller = "if_group_defns"

    def show(self, **kwargs):
        """Shows the details for the specified if group defn.

            **Inputs**

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` True
            |  ``default:`` None

             :param GroupID: The internal NetMRI identifier of an interface group.
             :type GroupID: Integer

            **Outputs**

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :return if_group_defn: The if group defn identified by the specified GroupID.
             :rtype if_group_defn: IfGroupDefn

            """

        return self.api_request(self._get_method_fullname("show"), kwargs)

    def index(self, **kwargs):
        """Lists the available if group defns. Any of the inputs listed may be be used to narrow the list; other inputs will be ignored. Of the various ways to query lists, using this method is most efficient.

            **Inputs**

            |  ``api version min:`` 2.4
            |  ``api version max:`` 2.4
            |  ``required:`` False
            |  ``default:`` None

             :param GroupID: The internal NetMRI identifier of an interface group.
             :type GroupID: Integer

            |  ``api version min:`` 2.5
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param GroupID: The internal NetMRI identifier of an interface group.
             :type GroupID: Array of Integer

            |  ``api version min:`` 2.4
            |  ``api version max:`` 2.4
            |  ``required:`` False
            |  ``default:`` None

             :param GroupName: The name of the group in the Interface.
             :type GroupName: String

            |  ``api version min:`` 2.5
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param GroupName: The name of the group in the Interface.
             :type GroupName: Array of String

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` 0

             :param start: The record number to return in the selected page of data. It will always appear, although it may not be the first record. See the :limit for more information.
             :type start: Integer

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` 1000

             :param limit: The size of the page of data, that is, the maximum number of records returned. The limit size will be used to break the data up into pages and the first page with the start record will be returned. So if you have 100 records and use a :limit of 10 and a :start of 10, you will get records 10-19. The maximum limit is 10000.
             :type limit: Integer

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` GroupID

             :param sort: The data field(s) to use for sorting the output. Default is GroupID. Valid values are GroupID, GroupName, Criteria, Rank, SNMPPolling, FlowCollection, PerfFrequency, Timestamp, MemberCount, UpdatedAt.
             :type sort: Array of String

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` asc

             :param dir: The direction(s) in which to sort the data. Default is 'asc'. Valid values are 'asc' and 'desc'.
             :type dir: Array of String

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param select: The list of attributes to return for each IfGroupDefn. Valid values are GroupID, GroupName, Criteria, Rank, SNMPPolling, FlowCollection, PerfFrequency, Timestamp, MemberCount, UpdatedAt. If empty or omitted, all attributes will be returned.
             :type select: Array

            |  ``api version min:`` 2.8
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param goto_field: The field name for NIOS GOTO that is used for locating a row position of records.
             :type goto_field: String

            |  ``api version min:`` 2.8
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param goto_value: The value of goto_field for NIOS GOTO that is used for locating a row position of records.
             :type goto_value: String

            **Outputs**

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :return if_group_defns: An array of the IfGroupDefn objects that match the specified input criteria.
             :rtype if_group_defns: Array of IfGroupDefn

            """

        return self.api_list_request(self._get_method_fullname("index"), kwargs)

    def search(self, **kwargs):
        """Lists the available if group defns matching the input criteria. This method provides a more flexible search interface than the index method, but searching using this method is more demanding on the system and will not perform to the same level as the index method. The input fields listed below will be used as in the index method, to filter the result, along with the optional query string and XML filter described below.

            **Inputs**

            |  ``api version min:`` 2.4
            |  ``api version max:`` 2.4
            |  ``required:`` False
            |  ``default:`` None

             :param Criteria: The group belongs to defined criteria in an interface group.
             :type Criteria: String

            |  ``api version min:`` 2.5
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param Criteria: The group belongs to defined criteria in an interface group.
             :type Criteria: Array of String

            |  ``api version min:`` 2.4
            |  ``api version max:`` 2.4
            |  ``required:`` False
            |  ``default:`` None

             :param FlowCollection: The level of flow collection in an interface group.
             :type FlowCollection: Integer

            |  ``api version min:`` 2.5
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param FlowCollection: The level of flow collection in an interface group.
             :type FlowCollection: Array of Integer

            |  ``api version min:`` 2.4
            |  ``api version max:`` 2.4
            |  ``required:`` False
            |  ``default:`` None

             :param GroupID: The internal NetMRI identifier of an interface group.
             :type GroupID: Integer

            |  ``api version min:`` 2.5
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param GroupID: The internal NetMRI identifier of an interface group.
             :type GroupID: Array of Integer

            |  ``api version min:`` 2.4
            |  ``api version max:`` 2.4
            |  ``required:`` False
            |  ``default:`` None

             :param GroupName: The name of the group in the Interface.
             :type GroupName: String

            |  ``api version min:`` 2.5
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param GroupName: The name of the group in the Interface.
             :type GroupName: Array of String

            |  ``api version min:`` 2.4
            |  ``api version max:`` 2.4
            |  ``required:`` False
            |  ``default:`` None

             :param MemberCount: The total number of members in an interface group.
             :type MemberCount: Integer

            |  ``api version min:`` 2.5
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param MemberCount: The total number of members in an interface group.
             :type MemberCount: Array of Integer

            |  ``api version min:`` 2.4
            |  ``api version max:`` 2.4
            |  ``required:`` False
            |  ``default:`` None

             :param PerfFrequency: The performance frequency level in an interface group.
             :type PerfFrequency: Integer

            |  ``api version min:`` 2.5
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param PerfFrequency: The performance frequency level in an interface group.
             :type PerfFrequency: Array of Integer

            |  ``api version min:`` 2.4
            |  ``api version max:`` 2.4
            |  ``required:`` False
            |  ``default:`` None

             :param Rank: The rank specified for the group in an interface.
             :type Rank: Integer

            |  ``api version min:`` 2.5
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param Rank: The rank specified for the group in an interface.
             :type Rank: Array of Integer

            |  ``api version min:`` 2.4
            |  ``api version max:`` 2.4
            |  ``required:`` False
            |  ``default:`` None

             :param SNMPPolling: The SNMP polling state in an interface group definition.
             :type SNMPPolling: Integer

            |  ``api version min:`` 2.5
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param SNMPPolling: The SNMP polling state in an interface group definition.
             :type SNMPPolling: Array of Integer

            |  ``api version min:`` 2.4
            |  ``api version max:`` 2.4
            |  ``required:`` False
            |  ``default:`` None

             :param Timestamp: The date and time this record was collected.
             :type Timestamp: DateTime

            |  ``api version min:`` 2.5
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param Timestamp: The date and time this record was collected.
             :type Timestamp: Array of DateTime

            |  ``api version min:`` 2.4
            |  ``api version max:`` 2.4
            |  ``required:`` False
            |  ``default:`` None

             :param UpdatedAt: The date and time this record was last modified.
             :type UpdatedAt: DateTime

            |  ``api version min:`` 2.5
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param UpdatedAt: The date and time this record was last modified.
             :type UpdatedAt: Array of DateTime

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` 0

             :param start: The record number to return in the selected page of data. It will always appear, although it may not be the first record. See the :limit for more information.
             :type start: Integer

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` 1000

             :param limit: The size of the page of data, that is, the maximum number of records returned. The limit size will be used to break the data up into pages and the first page with the start record will be returned. So if you have 100 records and use a :limit of 10 and a :start of 10, you will get records 10-19. The maximum limit is 10000.
             :type limit: Integer

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` GroupID

             :param sort: The data field(s) to use for sorting the output. Default is GroupID. Valid values are GroupID, GroupName, Criteria, Rank, SNMPPolling, FlowCollection, PerfFrequency, Timestamp, MemberCount, UpdatedAt.
             :type sort: Array of String

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` asc

             :param dir: The direction(s) in which to sort the data. Default is 'asc'. Valid values are 'asc' and 'desc'.
             :type dir: Array of String

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param select: The list of attributes to return for each IfGroupDefn. Valid values are GroupID, GroupName, Criteria, Rank, SNMPPolling, FlowCollection, PerfFrequency, Timestamp, MemberCount, UpdatedAt. If empty or omitted, all attributes will be returned.
             :type select: Array

            |  ``api version min:`` 2.8
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param goto_field: The field name for NIOS GOTO that is used for locating a row position of records.
             :type goto_field: String

            |  ``api version min:`` 2.8
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param goto_value: The value of goto_field for NIOS GOTO that is used for locating a row position of records.
             :type goto_value: String

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param query: This value will be matched against if group defns, looking to see if one or more of the listed attributes contain the passed value. You may also surround the value with '/' and '/' to perform a regular expression search rather than a containment operation. Any record that matches will be returned. The attributes searched are: Criteria, FlowCollection, GroupID, GroupName, MemberCount, PerfFrequency, Rank, SNMPPolling, Timestamp, UpdatedAt.
             :type query: String

            |  ``api version min:`` 2.3
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param xml_filter: A SetFilter XML structure to further refine the search. The SetFilter will be applied AFTER any search query or field values, but before any limit options. The limit and pagination will be enforced after the filter. Remind that this kind of filter may be costly and inefficient if not associated with a database filtering.
             :type xml_filter: String

            **Outputs**

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :return if_group_defns: An array of the IfGroupDefn objects that match the specified input criteria.
             :rtype if_group_defns: Array of IfGroupDefn

            """

        return self.api_list_request(self._get_method_fullname("search"), kwargs)

    def find(self, **kwargs):
        """Lists the available if group defns matching the input specification. This provides the most flexible search specification of all the query mechanisms, enabling searching using comparison operations other than equality. However, it is more complex to use and will not perform as efficiently as the index or search methods. In the input descriptions below, 'field names' refers to the following fields: Criteria, FlowCollection, GroupID, GroupName, MemberCount, PerfFrequency, Rank, SNMPPolling, Timestamp, UpdatedAt.

            **Inputs**

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param op_Criteria: The operator to apply to the field Criteria. Valid values are: =, <>, rlike, not rlike, >, >=, <, <=, like, not like, is null, is not null, between. Criteria: The group belongs to defined criteria in an interface group. For the between operator the value will be treated as an Array if comma delimited string is passed, and it must contain an even number of values.
             :type op_Criteria: String

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param val_f_Criteria: If op_Criteria is specified, the field named in this input will be compared to the value in Criteria using the specified operator. That is, the value in this input will be treated as another field name, rather than a constant value. Either this field or val_c_Criteria must be specified if op_Criteria is specified.
             :type val_f_Criteria: String

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param val_c_Criteria: If op_Criteria is specified, this value will be compared to the value in Criteria using the specified operator. The value in this input will be treated as an explicit constant value. Either this field or val_f_Criteria must be specified if op_Criteria is specified.
             :type val_c_Criteria: String

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param op_FlowCollection: The operator to apply to the field FlowCollection. Valid values are: =, <>, rlike, not rlike, >, >=, <, <=, like, not like, is null, is not null, between. FlowCollection: The level of flow collection in an interface group. For the between operator the value will be treated as an Array if comma delimited string is passed, and it must contain an even number of values.
             :type op_FlowCollection: String

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param val_f_FlowCollection: If op_FlowCollection is specified, the field named in this input will be compared to the value in FlowCollection using the specified operator. That is, the value in this input will be treated as another field name, rather than a constant value. Either this field or val_c_FlowCollection must be specified if op_FlowCollection is specified.
             :type val_f_FlowCollection: String

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param val_c_FlowCollection: If op_FlowCollection is specified, this value will be compared to the value in FlowCollection using the specified operator. The value in this input will be treated as an explicit constant value. Either this field or val_f_FlowCollection must be specified if op_FlowCollection is specified.
             :type val_c_FlowCollection: String

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param op_GroupID: The operator to apply to the field GroupID. Valid values are: =, <>, rlike, not rlike, >, >=, <, <=, like, not like, is null, is not null, between. GroupID: The internal NetMRI identifier of an interface group. For the between operator the value will be treated as an Array if comma delimited string is passed, and it must contain an even number of values.
             :type op_GroupID: String

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param val_f_GroupID: If op_GroupID is specified, the field named in this input will be compared to the value in GroupID using the specified operator. That is, the value in this input will be treated as another field name, rather than a constant value. Either this field or val_c_GroupID must be specified if op_GroupID is specified.
             :type val_f_GroupID: String

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param val_c_GroupID: If op_GroupID is specified, this value will be compared to the value in GroupID using the specified operator. The value in this input will be treated as an explicit constant value. Either this field or val_f_GroupID must be specified if op_GroupID is specified.
             :type val_c_GroupID: String

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param op_GroupName: The operator to apply to the field GroupName. Valid values are: =, <>, rlike, not rlike, >, >=, <, <=, like, not like, is null, is not null, between. GroupName: The name of the group in the Interface. For the between operator the value will be treated as an Array if comma delimited string is passed, and it must contain an even number of values.
             :type op_GroupName: String

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param val_f_GroupName: If op_GroupName is specified, the field named in this input will be compared to the value in GroupName using the specified operator. That is, the value in this input will be treated as another field name, rather than a constant value. Either this field or val_c_GroupName must be specified if op_GroupName is specified.
             :type val_f_GroupName: String

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param val_c_GroupName: If op_GroupName is specified, this value will be compared to the value in GroupName using the specified operator. The value in this input will be treated as an explicit constant value. Either this field or val_f_GroupName must be specified if op_GroupName is specified.
             :type val_c_GroupName: String

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param op_MemberCount: The operator to apply to the field MemberCount. Valid values are: =, <>, rlike, not rlike, >, >=, <, <=, like, not like, is null, is not null, between. MemberCount: The total number of members in an interface group. For the between operator the value will be treated as an Array if comma delimited string is passed, and it must contain an even number of values.
             :type op_MemberCount: String

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param val_f_MemberCount: If op_MemberCount is specified, the field named in this input will be compared to the value in MemberCount using the specified operator. That is, the value in this input will be treated as another field name, rather than a constant value. Either this field or val_c_MemberCount must be specified if op_MemberCount is specified.
             :type val_f_MemberCount: String

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param val_c_MemberCount: If op_MemberCount is specified, this value will be compared to the value in MemberCount using the specified operator. The value in this input will be treated as an explicit constant value. Either this field or val_f_MemberCount must be specified if op_MemberCount is specified.
             :type val_c_MemberCount: String

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param op_PerfFrequency: The operator to apply to the field PerfFrequency. Valid values are: =, <>, rlike, not rlike, >, >=, <, <=, like, not like, is null, is not null, between. PerfFrequency: The performance frequency level in an interface group. For the between operator the value will be treated as an Array if comma delimited string is passed, and it must contain an even number of values.
             :type op_PerfFrequency: String

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param val_f_PerfFrequency: If op_PerfFrequency is specified, the field named in this input will be compared to the value in PerfFrequency using the specified operator. That is, the value in this input will be treated as another field name, rather than a constant value. Either this field or val_c_PerfFrequency must be specified if op_PerfFrequency is specified.
             :type val_f_PerfFrequency: String

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param val_c_PerfFrequency: If op_PerfFrequency is specified, this value will be compared to the value in PerfFrequency using the specified operator. The value in this input will be treated as an explicit constant value. Either this field or val_f_PerfFrequency must be specified if op_PerfFrequency is specified.
             :type val_c_PerfFrequency: String

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param op_Rank: The operator to apply to the field Rank. Valid values are: =, <>, rlike, not rlike, >, >=, <, <=, like, not like, is null, is not null, between. Rank: The rank specified for the group in an interface. For the between operator the value will be treated as an Array if comma delimited string is passed, and it must contain an even number of values.
             :type op_Rank: String

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param val_f_Rank: If op_Rank is specified, the field named in this input will be compared to the value in Rank using the specified operator. That is, the value in this input will be treated as another field name, rather than a constant value. Either this field or val_c_Rank must be specified if op_Rank is specified.
             :type val_f_Rank: String

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param val_c_Rank: If op_Rank is specified, this value will be compared to the value in Rank using the specified operator. The value in this input will be treated as an explicit constant value. Either this field or val_f_Rank must be specified if op_Rank is specified.
             :type val_c_Rank: String

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param op_SNMPPolling: The operator to apply to the field SNMPPolling. Valid values are: =, <>, rlike, not rlike, >, >=, <, <=, like, not like, is null, is not null, between. SNMPPolling: The SNMP polling state in an interface group definition. For the between operator the value will be treated as an Array if comma delimited string is passed, and it must contain an even number of values.
             :type op_SNMPPolling: String

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param val_f_SNMPPolling: If op_SNMPPolling is specified, the field named in this input will be compared to the value in SNMPPolling using the specified operator. That is, the value in this input will be treated as another field name, rather than a constant value. Either this field or val_c_SNMPPolling must be specified if op_SNMPPolling is specified.
             :type val_f_SNMPPolling: String

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param val_c_SNMPPolling: If op_SNMPPolling is specified, this value will be compared to the value in SNMPPolling using the specified operator. The value in this input will be treated as an explicit constant value. Either this field or val_f_SNMPPolling must be specified if op_SNMPPolling is specified.
             :type val_c_SNMPPolling: String

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param op_Timestamp: The operator to apply to the field Timestamp. Valid values are: =, <>, rlike, not rlike, >, >=, <, <=, like, not like, is null, is not null, between. Timestamp: The date and time this record was collected. For the between operator the value will be treated as an Array if comma delimited string is passed, and it must contain an even number of values.
             :type op_Timestamp: String

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param val_f_Timestamp: If op_Timestamp is specified, the field named in this input will be compared to the value in Timestamp using the specified operator. That is, the value in this input will be treated as another field name, rather than a constant value. Either this field or val_c_Timestamp must be specified if op_Timestamp is specified.
             :type val_f_Timestamp: String

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param val_c_Timestamp: If op_Timestamp is specified, this value will be compared to the value in Timestamp using the specified operator. The value in this input will be treated as an explicit constant value. Either this field or val_f_Timestamp must be specified if op_Timestamp is specified.
             :type val_c_Timestamp: String

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param op_UpdatedAt: The operator to apply to the field UpdatedAt. Valid values are: =, <>, rlike, not rlike, >, >=, <, <=, like, not like, is null, is not null, between. UpdatedAt: The date and time this record was last modified. For the between operator the value will be treated as an Array if comma delimited string is passed, and it must contain an even number of values.
             :type op_UpdatedAt: String

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param val_f_UpdatedAt: If op_UpdatedAt is specified, the field named in this input will be compared to the value in UpdatedAt using the specified operator. That is, the value in this input will be treated as another field name, rather than a constant value. Either this field or val_c_UpdatedAt must be specified if op_UpdatedAt is specified.
             :type val_f_UpdatedAt: String

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param val_c_UpdatedAt: If op_UpdatedAt is specified, this value will be compared to the value in UpdatedAt using the specified operator. The value in this input will be treated as an explicit constant value. Either this field or val_f_UpdatedAt must be specified if op_UpdatedAt is specified.
             :type val_c_UpdatedAt: String

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` 0

             :param start: The record number to return in the selected page of data. It will always appear, although it may not be the first record. See the :limit for more information.
             :type start: Integer

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` 1000

             :param limit: The size of the page of data, that is, the maximum number of records returned. The limit size will be used to break the data up into pages and the first page with the start record will be returned. So if you have 100 records and use a :limit of 10 and a :start of 10, you will get records 10-19. The maximum limit is 10000.
             :type limit: Integer

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` GroupID

             :param sort: The data field(s) to use for sorting the output. Default is GroupID. Valid values are GroupID, GroupName, Criteria, Rank, SNMPPolling, FlowCollection, PerfFrequency, Timestamp, MemberCount, UpdatedAt.
             :type sort: Array of String

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` asc

             :param dir: The direction(s) in which to sort the data. Default is 'asc'. Valid values are 'asc' and 'desc'.
             :type dir: Array of String

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param select: The list of attributes to return for each IfGroupDefn. Valid values are GroupID, GroupName, Criteria, Rank, SNMPPolling, FlowCollection, PerfFrequency, Timestamp, MemberCount, UpdatedAt. If empty or omitted, all attributes will be returned.
             :type select: Array

            |  ``api version min:`` 2.8
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param goto_field: The field name for NIOS GOTO that is used for locating a row position of records.
             :type goto_field: String

            |  ``api version min:`` 2.8
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param goto_value: The value of goto_field for NIOS GOTO that is used for locating a row position of records.
             :type goto_value: String

            |  ``api version min:`` 2.3
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param xml_filter: A SetFilter XML structure to further refine the search. The SetFilter will be applied AFTER any search query or field values, but before any limit options. The limit and pagination will be enforced after the filter. Remind that this kind of filter may be costly and inefficient if not associated with a database filtering.
             :type xml_filter: String

            **Outputs**

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :return if_group_defns: An array of the IfGroupDefn objects that match the specified input criteria.
             :rtype if_group_defns: Array of IfGroupDefn

            """

        return self.api_list_request(self._get_method_fullname("find"), kwargs)

    def create(self, **kwargs):
        """Creates a new if group defn.

            **Inputs**

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` True
            |  ``default:`` None

             :param Criteria: The group belongs to defined criteria in an interface group.
             :type Criteria: String

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param FlowCollection: The level of flow collection in an interface group.
             :type FlowCollection: Integer

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` True
            |  ``default:`` None

             :param GroupName: The name of the group in the Interface.
             :type GroupName: String

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param MemberCount: The total number of members in an interface group.
             :type MemberCount: Integer

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param PerfFrequency: The performance frequency level in an interface group.
             :type PerfFrequency: Integer

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` True
            |  ``default:`` None

             :param Rank: The rank specified for the group in an interface.
             :type Rank: Integer

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param SNMPPolling: The SNMP polling state in an interface group definition.
             :type SNMPPolling: Integer

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param Timestamp: The date and time this record was collected.
             :type Timestamp: DateTime

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param UpdatedAt: The date and time this record was last modified.
             :type UpdatedAt: DateTime

            **Outputs**

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :return id: The id of the newly created if group defn.
             :rtype id: Integer

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :return model: The class name of the newly created if group defn.
             :rtype model: String

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :return uri: A URI that may be used to retrieve the newly created if group defn.
             :rtype uri: String

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :return if_group_defn: The newly created if group defn.
             :rtype if_group_defn: IfGroupDefn

            """

        return self.api_request(self._get_method_fullname("create"), kwargs)

    def destroy(self, **kwargs):
        """Deletes the specified if group defn from NetMRI.

            **Inputs**

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` True
            |  ``default:`` None

             :param GroupID: The internal NetMRI identifier of an interface group.
             :type GroupID: Integer

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` True
            |  ``default:`` None

             :param id: Interface group identity which identifies each definition.
             :type id: Integer

            **Outputs**

            """

        return self.api_request(self._get_method_fullname("destroy"), kwargs)

    def update(self, **kwargs):
        """Updates an existing if group defn.

            **Inputs**

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` True
            |  ``default:`` None

             :param GroupID: The internal NetMRI identifier of an interface group.
             :type GroupID: Integer

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param Criteria: The group belongs to defined criteria in an interface group. If omitted, this field will not be updated.
             :type Criteria: String

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param FlowCollection: The level of flow collection in an interface group. If omitted, this field will not be updated.
             :type FlowCollection: Integer

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param GroupName: The name of the group in the Interface. If omitted, this field will not be updated.
             :type GroupName: String

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param MemberCount: The total number of members in an interface group. If omitted, this field will not be updated.
             :type MemberCount: Integer

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param PerfFrequency: The performance frequency level in an interface group. If omitted, this field will not be updated.
             :type PerfFrequency: Integer

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param Rank: The rank specified for the group in an interface. If omitted, this field will not be updated.
             :type Rank: Integer

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param SNMPPolling: The SNMP polling state in an interface group definition. If omitted, this field will not be updated.
             :type SNMPPolling: Integer

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param Timestamp: The date and time this record was collected. If omitted, this field will not be updated.
             :type Timestamp: DateTime

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :param UpdatedAt: The date and time this record was last modified. If omitted, this field will not be updated.
             :type UpdatedAt: DateTime

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` True
            |  ``default:`` None

             :param id: Interface group identity which identifies each definition.
             :type id: Integer

            **Outputs**

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :return id: The id of the updated if group defn.
             :rtype id: Integer

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :return model: The class name of the updated if group defn.
             :rtype model: String

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :return uri: A URI that may be used to retrieve the updated if group defn.
             :rtype uri: String

            |  ``api version min:`` None
            |  ``api version max:`` None
            |  ``required:`` False
            |  ``default:`` None

             :return if_group_defn: The updated if group defn.
             :rtype if_group_defn: IfGroupDefn

            """

        return self.api_request(self._get_method_fullname("update"), kwargs)


text:
StartTest(function (t) {

    //==================================================================================================================================================================================
    t.diag("`Class` in module's body")

    Module("Base", function (module) {

        // Create the Base.App class
        Class("App", {
            has: {
                engine  : null
            },

            after: {
                initialize: function () {
                    this.engine = new Base.App.Engine({ app : this })
                }
            }
        })
    })

    t.ok(Base, 'Namespace `Base` has been created')
    t.ok(Base.meta.constructor == Joose.Namespace.Keeper, '.. and its a "module"')

    t.ok(Base.App, 'Namespace `Base.App` has been created')
    t.ok(Base.App.meta.constructor == Joose.Meta.Class, '.. and its a "class"')

    //==================================================================================================================================================================================
    t.diag("`Module` over the `Class` ")

    Module("Base.App", function (module) {

        t.ok(this == module && module == Base.App, 'Correct argument and scope for module body')

        // Create the "Base.App.Engine" class
        Class("Engine", {
           has: {
               app  : null
           }
        })
    })

    t.ok(Base.App.Engine, 'Namespace `Base.App.Engine` has been created')
    t.ok(Base.App.Engine.meta.constructor == Joose.Meta.Class, '.. and its a "class"')

    var app = new Base.App()

    t.ok(app, '`Base.App` has been successfully instantiated')

    //==================================================================================================================================================================================
    t.diag("`Class` re-declaration ")

    Class('Test')

    t.throws_ok(function () {

        Class('Test')

    }, Joose.is_IE ? "" : "Double declaration of [Test]", "Double class declaration is detected")

    t.expectGlobals('Test', 'Base')

    t.done()
})


text:
module.exports = (function() {
  'use strict';

  return {
    drain: function(stream) {
      return new Promise(function(resolve, reject) {
        var chunks = [];
        stream.on('data', function(chunk) {
          chunks.push(chunk);
        });
        stream.on('end', function() {
          resolve(Buffer.concat(chunks));
        });
      });
    }
  };
})();


text:
name             'barricade'
maintainer       'Barricade Security Systems Limited'
maintainer_email 'engineering@barricade.io'
license          'Simplified 2-Clause BSD License'
description      'Installs/Configures the barricade agent'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version          '0.1.0'
supports         'ubuntu'


text:
package org.apache.flink.runtime.operators.lifecycle.event;

import org.apache.flink.annotation.Internal;
import org.apache.flink.streaming.api.operators.BoundedMultiInput;

import java.util.Objects;

/**
 * An event of calling {@link BoundedMultiInput#endInput(int) endInput} method or the like on an
 * operator.
 */
@Internal
public class InputEndedEvent extends TestEvent {
    public final int inputId;

    public InputEndedEvent(String operatorId, int subtaskIndex, int attemptNumber, int inputId) {
        super(operatorId, subtaskIndex, attemptNumber);
        this.inputId = inputId;
    }

    @Override
    public boolean equals(Object o) {

        if (this == o) {
            return true;
        }
        if (!(o instanceof InputEndedEvent)) {
            return false;
        }
        if (!super.equals(o)) {
            return false;
        }
        InputEndedEvent that = (InputEndedEvent) o;
        return inputId == that.inputId;
    }

    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), inputId);
    }

    @Override
    public String toString() {
        return super.toString() + "(" + inputId + ")";
    }
}


text:
"use strict";

var test = require('tape');
var hasClassNameProperty = require('./');

test('exist', function(t) {
    t.equal(typeof hasClassNameProperty, 'function');
    t.end();
});

test('to be falsy', function(t) {
    t.equal(hasClassNameProperty(), false);
    t.equal(hasClassNameProperty({}), false);
    t.equal(hasClassNameProperty({
        className: 123
    }), false);
    t.equal(hasClassNameProperty(null), false);
    t.end();
});

test('to be truthly', function(t) {
    t.equal(hasClassNameProperty({
        className: ""
    }), true);
    t.end();
});


text:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity">

    <TextView android:text="@string/hello_world" android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/textView" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Send Broadcast"
        android:id="@+id/btnSendBroadcast"/>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Reg BCR"
        android:id="@+id/btnRegBCR"/>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Unreg BCR"
        android:id="@+id/btnUnregBCR"/>

</LinearLayout>